mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into unrewrite
Conflicts: src/compiler/emitter.ts tests/baselines/reference/ES5SymbolProperty1.js tests/baselines/reference/FunctionDeclaration8_es6.js tests/baselines/reference/FunctionDeclaration9_es6.js tests/baselines/reference/FunctionPropertyAssignments5_es6.js tests/baselines/reference/computedPropertyNames10_ES5.js tests/baselines/reference/computedPropertyNames11_ES5.js tests/baselines/reference/computedPropertyNames18_ES5.js tests/baselines/reference/computedPropertyNames19_ES5.js tests/baselines/reference/computedPropertyNames1_ES5.js tests/baselines/reference/computedPropertyNames20_ES5.js tests/baselines/reference/computedPropertyNames22_ES5.js tests/baselines/reference/computedPropertyNames23_ES5.js tests/baselines/reference/computedPropertyNames25_ES5.js tests/baselines/reference/computedPropertyNames26_ES5.js tests/baselines/reference/computedPropertyNames28_ES5.js tests/baselines/reference/computedPropertyNames29_ES5.js tests/baselines/reference/computedPropertyNames30_ES5.js tests/baselines/reference/computedPropertyNames31_ES5.js tests/baselines/reference/computedPropertyNames33_ES5.js tests/baselines/reference/computedPropertyNames34_ES5.js tests/baselines/reference/computedPropertyNames46_ES5.js tests/baselines/reference/computedPropertyNames47_ES5.js tests/baselines/reference/computedPropertyNames48_ES5.js tests/baselines/reference/computedPropertyNames49_ES5.js tests/baselines/reference/computedPropertyNames4_ES5.js tests/baselines/reference/computedPropertyNames50_ES5.js tests/baselines/reference/computedPropertyNames5_ES5.js tests/baselines/reference/computedPropertyNames6_ES5.js tests/baselines/reference/computedPropertyNames7_ES5.js tests/baselines/reference/computedPropertyNames8_ES5.js tests/baselines/reference/computedPropertyNames9_ES5.js tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt tests/baselines/reference/parserES5ComputedPropertyName2.js tests/baselines/reference/parserES5ComputedPropertyName3.js tests/baselines/reference/parserES5ComputedPropertyName4.js tests/baselines/reference/privateIndexer2.js
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
|
||||
root = true
|
||||
|
||||
[{src,scripts}/**.{ts,json,js}]
|
||||
end_of_line = crlf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
@@ -0,0 +1 @@
|
||||
*.js linguist-language=TypeScript
|
||||
@@ -21,6 +21,7 @@ tests/services/baselines/local/*
|
||||
tests/baselines/prototyping/local/*
|
||||
tests/baselines/rwc/*
|
||||
tests/baselines/test262/*
|
||||
tests/baselines/local/projectOutput/*
|
||||
tests/services/baselines/prototyping/local/*
|
||||
tests/services/browser/typescriptServices.js
|
||||
scripts/processDiagnosticMessages.d.ts
|
||||
|
||||
+1
-10
@@ -3,13 +3,4 @@ language: node_js
|
||||
node_js:
|
||||
- '0.10'
|
||||
|
||||
sudo: false
|
||||
|
||||
before_script: npm install -g codeclimate-test-reporter
|
||||
|
||||
after_script:
|
||||
- cat coverage/lcov.info | codeclimate
|
||||
|
||||
addons:
|
||||
code_climate:
|
||||
repo_token: 9852ac5362c8cc38c07ca5adc0f94c20c6c79bd78e17933dc284598a65338656
|
||||
sudo: false
|
||||
+1
-1
@@ -9,7 +9,7 @@ Design changes will not be accepted at this time. If you have a design change pr
|
||||
## Legal
|
||||
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright.
|
||||
|
||||
Please submit a Contributor License Agreement (CLA) before submitting a pull request. Download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. Please note that we're currently only accepting pull requests of bug fixes rather than new features.
|
||||
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request. Please note that we're currently only accepting pull requests of bug fixes rather than new features.
|
||||
|
||||
## Housekeeping
|
||||
Your pull request should:
|
||||
|
||||
@@ -39,6 +39,7 @@ var compilerSources = [
|
||||
"utilities.ts",
|
||||
"binder.ts",
|
||||
"checker.ts",
|
||||
"declarationEmitter.ts",
|
||||
"emitter.ts",
|
||||
"program.ts",
|
||||
"commandLineParser.ts",
|
||||
@@ -57,6 +58,7 @@ var servicesSources = [
|
||||
"utilities.ts",
|
||||
"binder.ts",
|
||||
"checker.ts",
|
||||
"declarationEmitter.ts",
|
||||
"emitter.ts",
|
||||
"program.ts",
|
||||
"commandLineParser.ts",
|
||||
@@ -65,7 +67,7 @@ var servicesSources = [
|
||||
return path.join(compilerDirectory, f);
|
||||
}).concat([
|
||||
"breakpoints.ts",
|
||||
"navigateTo.ts",
|
||||
"navigateTo.ts",
|
||||
"navigationBar.ts",
|
||||
"outliningElementsCollector.ts",
|
||||
"patternMatcher.ts",
|
||||
@@ -109,6 +111,7 @@ var definitionsRoots = [
|
||||
"compiler/parser.d.ts",
|
||||
"compiler/checker.d.ts",
|
||||
"compiler/program.d.ts",
|
||||
"compiler/commandLineParser.d.ts",
|
||||
"services/services.d.ts",
|
||||
];
|
||||
|
||||
@@ -141,7 +144,8 @@ var harnessSources = [
|
||||
"services/colorization.ts",
|
||||
"services/documentRegistry.ts",
|
||||
"services/preProcessFile.ts",
|
||||
"services/patternMatcher.ts"
|
||||
"services/patternMatcher.ts",
|
||||
"versionCache.ts"
|
||||
].map(function (f) {
|
||||
return path.join(unittestsDirectory, f);
|
||||
})).concat([
|
||||
@@ -220,15 +224,17 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
|
||||
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
|
||||
var options = "--module commonjs -noImplicitAny";
|
||||
|
||||
if (!keepComments) {
|
||||
options += " -removeComments";
|
||||
// Keep comments when specifically requested
|
||||
// or when in debug mode.
|
||||
if (!(keepComments || useDebugMode)) {
|
||||
options += " --removeComments";
|
||||
}
|
||||
|
||||
if (generateDeclarations) {
|
||||
options += " --declaration";
|
||||
}
|
||||
|
||||
if (useDebugMode || preserveConstEnums) {
|
||||
if (preserveConstEnums || useDebugMode) {
|
||||
options += " --preserveConstEnums";
|
||||
}
|
||||
|
||||
@@ -463,7 +469,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, nodePackageFile, 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);
|
||||
});
|
||||
@@ -537,7 +543,7 @@ function cleanTestDirs() {
|
||||
}
|
||||
|
||||
jake.mkdirP(localRwcBaseline);
|
||||
jake.mkdirP(localTest262Baseline);
|
||||
jake.mkdirP(localTest262Baseline);
|
||||
jake.mkdirP(localBaseline);
|
||||
}
|
||||
|
||||
@@ -574,7 +580,7 @@ task("runtests", ["tests", builtLocalDirectory], function() {
|
||||
}
|
||||
|
||||
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
|
||||
@@ -716,7 +722,7 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() {
|
||||
|
||||
var instrumenterPath = harnessDirectory + 'instrumenter.ts';
|
||||
var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js';
|
||||
compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath], [], /*useBuiltCompiler*/ true);
|
||||
compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true);
|
||||
|
||||
desc("Builds an instrumented tsc.js");
|
||||
task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function() {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
[](https://travis-ci.org/Microsoft/TypeScript)
|
||||
[](http://issuestats.com/github/microsoft/typescript)
|
||||
[](http://issuestats.com/github/microsoft/typescript)
|
||||
[](http://badge.fury.io/js/typescript)
|
||||
[](https://npmjs.org/package/typescript)
|
||||
|
||||
# TypeScript
|
||||
|
||||
|
||||
Vendored
+23
-3
@@ -179,19 +179,19 @@ interface ObjectConstructor {
|
||||
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
seal(o: any): any;
|
||||
seal<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
freeze(o: any): any;
|
||||
freeze<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the addition of new properties to an object.
|
||||
* @param o Object to make non-extensible.
|
||||
*/
|
||||
preventExtensions(o: any): any;
|
||||
preventExtensions<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
|
||||
@@ -425,6 +425,9 @@ interface String {
|
||||
*/
|
||||
substr(from: number, length?: number): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): string;
|
||||
|
||||
[index: number]: string;
|
||||
}
|
||||
|
||||
@@ -477,6 +480,9 @@ interface Number {
|
||||
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
|
||||
*/
|
||||
toPrecision(precision?: number): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): number;
|
||||
}
|
||||
|
||||
interface NumberConstructor {
|
||||
@@ -1164,3 +1170,17 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
declare var Array: ArrayConstructor;
|
||||
|
||||
interface TypedPropertyDescriptor<T> {
|
||||
enumerable?: boolean;
|
||||
configurable?: boolean;
|
||||
writable?: boolean;
|
||||
value?: T;
|
||||
get?: () => T;
|
||||
set?: (value: T) => void;
|
||||
}
|
||||
|
||||
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
|
||||
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
|
||||
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
||||
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
|
||||
|
||||
Vendored
+83
-57
@@ -179,19 +179,19 @@ interface ObjectConstructor {
|
||||
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
seal(o: any): any;
|
||||
seal<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
freeze(o: any): any;
|
||||
freeze<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the addition of new properties to an object.
|
||||
* @param o Object to make non-extensible.
|
||||
*/
|
||||
preventExtensions(o: any): any;
|
||||
preventExtensions<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
|
||||
@@ -425,6 +425,9 @@ interface String {
|
||||
*/
|
||||
substr(from: number, length?: number): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): string;
|
||||
|
||||
[index: number]: string;
|
||||
}
|
||||
|
||||
@@ -477,6 +480,9 @@ interface Number {
|
||||
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
|
||||
*/
|
||||
toPrecision(precision?: number): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): number;
|
||||
}
|
||||
|
||||
interface NumberConstructor {
|
||||
@@ -1164,6 +1170,20 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
declare var Array: ArrayConstructor;
|
||||
|
||||
interface TypedPropertyDescriptor<T> {
|
||||
enumerable?: boolean;
|
||||
configurable?: boolean;
|
||||
writable?: boolean;
|
||||
value?: T;
|
||||
get?: () => T;
|
||||
set?: (value: T) => void;
|
||||
}
|
||||
|
||||
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
|
||||
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
|
||||
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
||||
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Symbol {
|
||||
@@ -1396,22 +1416,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 +1515,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,14 +1633,19 @@ 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>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface GeneratorFunction extends Function {
|
||||
|
||||
}
|
||||
@@ -1636,10 +1661,11 @@ 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>;
|
||||
throw(exception: any): IteratorResult<T>;
|
||||
return(value: T): IteratorResult<T>;
|
||||
[Symbol.iterator](): Generator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
@@ -1807,15 +1833,15 @@ 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]>;
|
||||
values(): IterableIterator<V>;
|
||||
[Symbol.iterator]():IterableIterator<[K,V]>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
@@ -1846,13 +1872,13 @@ 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>;
|
||||
values(): IterableIterator<T>;
|
||||
[Symbol.iterator]():IterableIterator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
@@ -2083,7 +2109,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 +2189,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 +2326,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 +2399,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 +2479,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 +2616,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 +2689,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 +2769,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 +2906,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 +2979,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 +3059,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 +3196,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 +3269,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 +3349,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 +3486,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 +3559,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 +3639,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 +3776,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 +3849,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 +3929,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 +4066,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 +4139,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 +4219,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 +4356,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 +4429,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 +4509,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 +4646,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,7 +4708,7 @@ 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;
|
||||
|
||||
Vendored
+181
-11
@@ -179,19 +179,19 @@ interface ObjectConstructor {
|
||||
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
seal(o: any): any;
|
||||
seal<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
freeze(o: any): any;
|
||||
freeze<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the addition of new properties to an object.
|
||||
* @param o Object to make non-extensible.
|
||||
*/
|
||||
preventExtensions(o: any): any;
|
||||
preventExtensions<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
|
||||
@@ -425,6 +425,9 @@ interface String {
|
||||
*/
|
||||
substr(from: number, length?: number): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): string;
|
||||
|
||||
[index: number]: string;
|
||||
}
|
||||
|
||||
@@ -477,6 +480,9 @@ interface Number {
|
||||
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
|
||||
*/
|
||||
toPrecision(precision?: number): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): number;
|
||||
}
|
||||
|
||||
interface NumberConstructor {
|
||||
@@ -1165,6 +1171,20 @@ interface ArrayConstructor {
|
||||
|
||||
declare var Array: ArrayConstructor;
|
||||
|
||||
interface TypedPropertyDescriptor<T> {
|
||||
enumerable?: boolean;
|
||||
configurable?: boolean;
|
||||
writable?: boolean;
|
||||
value?: T;
|
||||
get?: () => T;
|
||||
set?: (value: T) => void;
|
||||
}
|
||||
|
||||
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
|
||||
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
|
||||
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
||||
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
|
||||
|
||||
/////////////////////////////
|
||||
/// IE10 ECMAScript Extensions
|
||||
/////////////////////////////
|
||||
@@ -14203,7 +14223,11 @@ declare function importScripts(...urls: string[]): void;
|
||||
/// Windows Script Host APIS
|
||||
/////////////////////////////
|
||||
|
||||
declare var ActiveXObject: { new (s: string): any; };
|
||||
|
||||
interface ActiveXObject {
|
||||
new (s: string): any;
|
||||
}
|
||||
declare var ActiveXObject: ActiveXObject;
|
||||
|
||||
interface ITextWriter {
|
||||
Write(s: string): void;
|
||||
@@ -14211,11 +14235,157 @@ interface ITextWriter {
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
declare var WScript: {
|
||||
Echo(s: any): void;
|
||||
StdErr: ITextWriter;
|
||||
StdOut: ITextWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
ScriptFullName: string;
|
||||
Quit(exitCode?: number): number;
|
||||
interface TextStreamBase {
|
||||
/**
|
||||
* The column number of the current character position in an input stream.
|
||||
*/
|
||||
Column: number;
|
||||
/**
|
||||
* The current line number in an input stream.
|
||||
*/
|
||||
Line: number;
|
||||
/**
|
||||
* Closes a text stream.
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
||||
*/
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
interface TextStreamWriter extends TextStreamBase {
|
||||
/**
|
||||
* Sends a string to an output stream.
|
||||
*/
|
||||
Write(s: string): void;
|
||||
/**
|
||||
* Sends a specified number of blank lines (newline characters) to an output stream.
|
||||
*/
|
||||
WriteBlankLines(intLines: number): void;
|
||||
/**
|
||||
* Sends a string followed by a newline character to an output stream.
|
||||
*/
|
||||
WriteLine(s: string): void;
|
||||
}
|
||||
|
||||
interface TextStreamReader extends TextStreamBase {
|
||||
/**
|
||||
* Returns a specified number of characters from an input stream, beginning at the current pointer position.
|
||||
* Does not return until the ENTER key is pressed.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
Read(characters: number): string;
|
||||
/**
|
||||
* Returns all characters from an input stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadAll(): string;
|
||||
/**
|
||||
* Returns an entire line from an input stream.
|
||||
* Although this method extracts the newline character, it does not add it to the returned string.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadLine(): string;
|
||||
/**
|
||||
* Skips a specified number of characters when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
|
||||
*/
|
||||
Skip(characters: number): void;
|
||||
/**
|
||||
* Skips the next line when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode, not writing or appending mode.
|
||||
*/
|
||||
SkipLine(): void;
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a line.
|
||||
*/
|
||||
AtEndOfLine: boolean;
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a stream.
|
||||
*/
|
||||
AtEndOfStream: boolean;
|
||||
}
|
||||
|
||||
declare var WScript: {
|
||||
/**
|
||||
* Outputs text to either a message box (under WScript.exe) or the command console window followed by a newline (under CScript.ext).
|
||||
*/
|
||||
Echo(s: any): void;
|
||||
/**
|
||||
* Exposes the write-only error output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdErr: TextStreamWriter;
|
||||
/**
|
||||
* Exposes the write-only output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdOut: TextStreamWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
/**
|
||||
* The full path of the currently running script.
|
||||
*/
|
||||
ScriptFullName: string;
|
||||
/**
|
||||
* Forces the script to stop immediately, with an optional exit code.
|
||||
*/
|
||||
Quit(exitCode?: number): number;
|
||||
/**
|
||||
* The Windows Script Host build version number.
|
||||
*/
|
||||
BuildVersion: number;
|
||||
/**
|
||||
* Fully qualified path of the host executable.
|
||||
*/
|
||||
FullName: string;
|
||||
/**
|
||||
* Gets/sets the script mode - interactive(true) or batch(false).
|
||||
*/
|
||||
Interactive: boolean;
|
||||
/**
|
||||
* The name of the host executable (WScript.exe or CScript.exe).
|
||||
*/
|
||||
Name: string;
|
||||
/**
|
||||
* Path of the directory containing the host executable.
|
||||
*/
|
||||
Path: string;
|
||||
/**
|
||||
* The filename of the currently running script.
|
||||
*/
|
||||
ScriptName: string;
|
||||
/**
|
||||
* Exposes the read-only input stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdIn: TextStreamReader;
|
||||
/**
|
||||
* Windows Script Host version
|
||||
*/
|
||||
Version: string;
|
||||
/**
|
||||
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
|
||||
*/
|
||||
ConnectObject(objEventSource: any, strPrefix: string): void;
|
||||
/**
|
||||
* Creates a COM object.
|
||||
* @param strProgiID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
CreateObject(strProgID: string, strPrefix?: string): any;
|
||||
/**
|
||||
* Disconnects a COM object from its event sources.
|
||||
*/
|
||||
DisconnectObject(obj: any): void;
|
||||
/**
|
||||
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
|
||||
* @param strPathname Fully qualified path to the file containing the object persisted to disk. For objects in memory, pass a zero-length string.
|
||||
* @param strProgID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
|
||||
/**
|
||||
* Suspends script execution for a specified length of time, then continues execution.
|
||||
* @param intTime Interval (in milliseconds) to suspend script execution.
|
||||
*/
|
||||
Sleep(intTime: number): void;
|
||||
};
|
||||
|
||||
Vendored
+241
-65
@@ -179,19 +179,19 @@ interface ObjectConstructor {
|
||||
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
seal(o: any): any;
|
||||
seal<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
freeze(o: any): any;
|
||||
freeze<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the addition of new properties to an object.
|
||||
* @param o Object to make non-extensible.
|
||||
*/
|
||||
preventExtensions(o: any): any;
|
||||
preventExtensions<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
|
||||
@@ -425,6 +425,9 @@ interface String {
|
||||
*/
|
||||
substr(from: number, length?: number): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): string;
|
||||
|
||||
[index: number]: string;
|
||||
}
|
||||
|
||||
@@ -477,6 +480,9 @@ interface Number {
|
||||
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
|
||||
*/
|
||||
toPrecision(precision?: number): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): number;
|
||||
}
|
||||
|
||||
interface NumberConstructor {
|
||||
@@ -1164,6 +1170,20 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
declare var Array: ArrayConstructor;
|
||||
|
||||
interface TypedPropertyDescriptor<T> {
|
||||
enumerable?: boolean;
|
||||
configurable?: boolean;
|
||||
writable?: boolean;
|
||||
value?: T;
|
||||
get?: () => T;
|
||||
set?: (value: T) => void;
|
||||
}
|
||||
|
||||
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
|
||||
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
|
||||
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
||||
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Symbol {
|
||||
@@ -1396,22 +1416,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 +1515,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,14 +1633,19 @@ 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>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface GeneratorFunction extends Function {
|
||||
|
||||
}
|
||||
@@ -1636,10 +1661,11 @@ 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>;
|
||||
throw(exception: any): IteratorResult<T>;
|
||||
return(value: T): IteratorResult<T>;
|
||||
[Symbol.iterator](): Generator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
@@ -1807,15 +1833,15 @@ 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]>;
|
||||
values(): IterableIterator<V>;
|
||||
[Symbol.iterator]():IterableIterator<[K,V]>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
@@ -1846,13 +1872,13 @@ 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>;
|
||||
values(): IterableIterator<T>;
|
||||
[Symbol.iterator]():IterableIterator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
@@ -2083,7 +2109,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 +2189,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 +2326,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 +2399,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 +2479,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 +2616,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 +2689,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 +2769,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 +2906,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 +2979,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 +3059,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 +3196,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 +3269,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 +3349,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 +3486,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 +3559,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 +3639,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 +3776,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 +3849,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 +3929,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 +4066,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 +4139,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 +4219,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 +4356,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 +4429,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 +4509,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 +4646,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,7 +4708,7 @@ 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;
|
||||
@@ -17179,7 +17205,11 @@ declare function importScripts(...urls: string[]): void;
|
||||
/// Windows Script Host APIS
|
||||
/////////////////////////////
|
||||
|
||||
declare var ActiveXObject: { new (s: string): any; };
|
||||
|
||||
interface ActiveXObject {
|
||||
new (s: string): any;
|
||||
}
|
||||
declare var ActiveXObject: ActiveXObject;
|
||||
|
||||
interface ITextWriter {
|
||||
Write(s: string): void;
|
||||
@@ -17187,11 +17217,157 @@ interface ITextWriter {
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
declare var WScript: {
|
||||
Echo(s: any): void;
|
||||
StdErr: ITextWriter;
|
||||
StdOut: ITextWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
ScriptFullName: string;
|
||||
Quit(exitCode?: number): number;
|
||||
interface TextStreamBase {
|
||||
/**
|
||||
* The column number of the current character position in an input stream.
|
||||
*/
|
||||
Column: number;
|
||||
/**
|
||||
* The current line number in an input stream.
|
||||
*/
|
||||
Line: number;
|
||||
/**
|
||||
* Closes a text stream.
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
||||
*/
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
interface TextStreamWriter extends TextStreamBase {
|
||||
/**
|
||||
* Sends a string to an output stream.
|
||||
*/
|
||||
Write(s: string): void;
|
||||
/**
|
||||
* Sends a specified number of blank lines (newline characters) to an output stream.
|
||||
*/
|
||||
WriteBlankLines(intLines: number): void;
|
||||
/**
|
||||
* Sends a string followed by a newline character to an output stream.
|
||||
*/
|
||||
WriteLine(s: string): void;
|
||||
}
|
||||
|
||||
interface TextStreamReader extends TextStreamBase {
|
||||
/**
|
||||
* Returns a specified number of characters from an input stream, beginning at the current pointer position.
|
||||
* Does not return until the ENTER key is pressed.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
Read(characters: number): string;
|
||||
/**
|
||||
* Returns all characters from an input stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadAll(): string;
|
||||
/**
|
||||
* Returns an entire line from an input stream.
|
||||
* Although this method extracts the newline character, it does not add it to the returned string.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadLine(): string;
|
||||
/**
|
||||
* Skips a specified number of characters when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
|
||||
*/
|
||||
Skip(characters: number): void;
|
||||
/**
|
||||
* Skips the next line when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode, not writing or appending mode.
|
||||
*/
|
||||
SkipLine(): void;
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a line.
|
||||
*/
|
||||
AtEndOfLine: boolean;
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a stream.
|
||||
*/
|
||||
AtEndOfStream: boolean;
|
||||
}
|
||||
|
||||
declare var WScript: {
|
||||
/**
|
||||
* Outputs text to either a message box (under WScript.exe) or the command console window followed by a newline (under CScript.ext).
|
||||
*/
|
||||
Echo(s: any): void;
|
||||
/**
|
||||
* Exposes the write-only error output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdErr: TextStreamWriter;
|
||||
/**
|
||||
* Exposes the write-only output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdOut: TextStreamWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
/**
|
||||
* The full path of the currently running script.
|
||||
*/
|
||||
ScriptFullName: string;
|
||||
/**
|
||||
* Forces the script to stop immediately, with an optional exit code.
|
||||
*/
|
||||
Quit(exitCode?: number): number;
|
||||
/**
|
||||
* The Windows Script Host build version number.
|
||||
*/
|
||||
BuildVersion: number;
|
||||
/**
|
||||
* Fully qualified path of the host executable.
|
||||
*/
|
||||
FullName: string;
|
||||
/**
|
||||
* Gets/sets the script mode - interactive(true) or batch(false).
|
||||
*/
|
||||
Interactive: boolean;
|
||||
/**
|
||||
* The name of the host executable (WScript.exe or CScript.exe).
|
||||
*/
|
||||
Name: string;
|
||||
/**
|
||||
* Path of the directory containing the host executable.
|
||||
*/
|
||||
Path: string;
|
||||
/**
|
||||
* The filename of the currently running script.
|
||||
*/
|
||||
ScriptName: string;
|
||||
/**
|
||||
* Exposes the read-only input stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdIn: TextStreamReader;
|
||||
/**
|
||||
* Windows Script Host version
|
||||
*/
|
||||
Version: string;
|
||||
/**
|
||||
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
|
||||
*/
|
||||
ConnectObject(objEventSource: any, strPrefix: string): void;
|
||||
/**
|
||||
* Creates a COM object.
|
||||
* @param strProgiID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
CreateObject(strProgID: string, strPrefix?: string): any;
|
||||
/**
|
||||
* Disconnects a COM object from its event sources.
|
||||
*/
|
||||
DisconnectObject(obj: any): void;
|
||||
/**
|
||||
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
|
||||
* @param strPathname Fully qualified path to the file containing the object persisted to disk. For objects in memory, pass a zero-length string.
|
||||
* @param strProgID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
|
||||
/**
|
||||
* Suspends script execution for a specified length of time, then continues execution.
|
||||
* @param intTime Interval (in milliseconds) to suspend script execution.
|
||||
*/
|
||||
Sleep(intTime: number): void;
|
||||
};
|
||||
|
||||
Vendored
+158
-8
@@ -20,7 +20,11 @@ and limitations under the License.
|
||||
/// Windows Script Host APIS
|
||||
/////////////////////////////
|
||||
|
||||
declare var ActiveXObject: { new (s: string): any; };
|
||||
|
||||
interface ActiveXObject {
|
||||
new (s: string): any;
|
||||
}
|
||||
declare var ActiveXObject: ActiveXObject;
|
||||
|
||||
interface ITextWriter {
|
||||
Write(s: string): void;
|
||||
@@ -28,11 +32,157 @@ interface ITextWriter {
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
declare var WScript: {
|
||||
Echo(s: any): void;
|
||||
StdErr: ITextWriter;
|
||||
StdOut: ITextWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
ScriptFullName: string;
|
||||
Quit(exitCode?: number): number;
|
||||
interface TextStreamBase {
|
||||
/**
|
||||
* The column number of the current character position in an input stream.
|
||||
*/
|
||||
Column: number;
|
||||
/**
|
||||
* The current line number in an input stream.
|
||||
*/
|
||||
Line: number;
|
||||
/**
|
||||
* Closes a text stream.
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
||||
*/
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
interface TextStreamWriter extends TextStreamBase {
|
||||
/**
|
||||
* Sends a string to an output stream.
|
||||
*/
|
||||
Write(s: string): void;
|
||||
/**
|
||||
* Sends a specified number of blank lines (newline characters) to an output stream.
|
||||
*/
|
||||
WriteBlankLines(intLines: number): void;
|
||||
/**
|
||||
* Sends a string followed by a newline character to an output stream.
|
||||
*/
|
||||
WriteLine(s: string): void;
|
||||
}
|
||||
|
||||
interface TextStreamReader extends TextStreamBase {
|
||||
/**
|
||||
* Returns a specified number of characters from an input stream, beginning at the current pointer position.
|
||||
* Does not return until the ENTER key is pressed.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
Read(characters: number): string;
|
||||
/**
|
||||
* Returns all characters from an input stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadAll(): string;
|
||||
/**
|
||||
* Returns an entire line from an input stream.
|
||||
* Although this method extracts the newline character, it does not add it to the returned string.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadLine(): string;
|
||||
/**
|
||||
* Skips a specified number of characters when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
|
||||
*/
|
||||
Skip(characters: number): void;
|
||||
/**
|
||||
* Skips the next line when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode, not writing or appending mode.
|
||||
*/
|
||||
SkipLine(): void;
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a line.
|
||||
*/
|
||||
AtEndOfLine: boolean;
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a stream.
|
||||
*/
|
||||
AtEndOfStream: boolean;
|
||||
}
|
||||
|
||||
declare var WScript: {
|
||||
/**
|
||||
* Outputs text to either a message box (under WScript.exe) or the command console window followed by a newline (under CScript.ext).
|
||||
*/
|
||||
Echo(s: any): void;
|
||||
/**
|
||||
* Exposes the write-only error output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdErr: TextStreamWriter;
|
||||
/**
|
||||
* Exposes the write-only output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdOut: TextStreamWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
/**
|
||||
* The full path of the currently running script.
|
||||
*/
|
||||
ScriptFullName: string;
|
||||
/**
|
||||
* Forces the script to stop immediately, with an optional exit code.
|
||||
*/
|
||||
Quit(exitCode?: number): number;
|
||||
/**
|
||||
* The Windows Script Host build version number.
|
||||
*/
|
||||
BuildVersion: number;
|
||||
/**
|
||||
* Fully qualified path of the host executable.
|
||||
*/
|
||||
FullName: string;
|
||||
/**
|
||||
* Gets/sets the script mode - interactive(true) or batch(false).
|
||||
*/
|
||||
Interactive: boolean;
|
||||
/**
|
||||
* The name of the host executable (WScript.exe or CScript.exe).
|
||||
*/
|
||||
Name: string;
|
||||
/**
|
||||
* Path of the directory containing the host executable.
|
||||
*/
|
||||
Path: string;
|
||||
/**
|
||||
* The filename of the currently running script.
|
||||
*/
|
||||
ScriptName: string;
|
||||
/**
|
||||
* Exposes the read-only input stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdIn: TextStreamReader;
|
||||
/**
|
||||
* Windows Script Host version
|
||||
*/
|
||||
Version: string;
|
||||
/**
|
||||
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
|
||||
*/
|
||||
ConnectObject(objEventSource: any, strPrefix: string): void;
|
||||
/**
|
||||
* Creates a COM object.
|
||||
* @param strProgiID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
CreateObject(strProgID: string, strPrefix?: string): any;
|
||||
/**
|
||||
* Disconnects a COM object from its event sources.
|
||||
*/
|
||||
DisconnectObject(obj: any): void;
|
||||
/**
|
||||
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
|
||||
* @param strPathname Fully qualified path to the file containing the object persisted to disk. For objects in memory, pass a zero-length string.
|
||||
* @param strProgID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
|
||||
/**
|
||||
* Suspends script execution for a specified length of time, then continues execution.
|
||||
* @param intTime Interval (in milliseconds) to suspend script execution.
|
||||
*/
|
||||
Sleep(intTime: number): void;
|
||||
};
|
||||
|
||||
+13392
-5295
File diff suppressed because one or more lines are too long
+36037
File diff suppressed because one or more lines are too long
Vendored
+331
-247
@@ -74,181 +74,198 @@ declare module "typescript" {
|
||||
BarBarToken = 49,
|
||||
QuestionToken = 50,
|
||||
ColonToken = 51,
|
||||
EqualsToken = 52,
|
||||
PlusEqualsToken = 53,
|
||||
MinusEqualsToken = 54,
|
||||
AsteriskEqualsToken = 55,
|
||||
SlashEqualsToken = 56,
|
||||
PercentEqualsToken = 57,
|
||||
LessThanLessThanEqualsToken = 58,
|
||||
GreaterThanGreaterThanEqualsToken = 59,
|
||||
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
|
||||
AmpersandEqualsToken = 61,
|
||||
BarEqualsToken = 62,
|
||||
CaretEqualsToken = 63,
|
||||
Identifier = 64,
|
||||
BreakKeyword = 65,
|
||||
CaseKeyword = 66,
|
||||
CatchKeyword = 67,
|
||||
ClassKeyword = 68,
|
||||
ConstKeyword = 69,
|
||||
ContinueKeyword = 70,
|
||||
DebuggerKeyword = 71,
|
||||
DefaultKeyword = 72,
|
||||
DeleteKeyword = 73,
|
||||
DoKeyword = 74,
|
||||
ElseKeyword = 75,
|
||||
EnumKeyword = 76,
|
||||
ExportKeyword = 77,
|
||||
ExtendsKeyword = 78,
|
||||
FalseKeyword = 79,
|
||||
FinallyKeyword = 80,
|
||||
ForKeyword = 81,
|
||||
FunctionKeyword = 82,
|
||||
IfKeyword = 83,
|
||||
ImportKeyword = 84,
|
||||
InKeyword = 85,
|
||||
InstanceOfKeyword = 86,
|
||||
NewKeyword = 87,
|
||||
NullKeyword = 88,
|
||||
ReturnKeyword = 89,
|
||||
SuperKeyword = 90,
|
||||
SwitchKeyword = 91,
|
||||
ThisKeyword = 92,
|
||||
ThrowKeyword = 93,
|
||||
TrueKeyword = 94,
|
||||
TryKeyword = 95,
|
||||
TypeOfKeyword = 96,
|
||||
VarKeyword = 97,
|
||||
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,
|
||||
SymbolKeyword = 120,
|
||||
TypeKeyword = 121,
|
||||
OfKeyword = 122,
|
||||
QualifiedName = 123,
|
||||
ComputedPropertyName = 124,
|
||||
TypeParameter = 125,
|
||||
Parameter = 126,
|
||||
PropertySignature = 127,
|
||||
PropertyDeclaration = 128,
|
||||
MethodSignature = 129,
|
||||
MethodDeclaration = 130,
|
||||
Constructor = 131,
|
||||
GetAccessor = 132,
|
||||
SetAccessor = 133,
|
||||
CallSignature = 134,
|
||||
ConstructSignature = 135,
|
||||
IndexSignature = 136,
|
||||
TypeReference = 137,
|
||||
FunctionType = 138,
|
||||
ConstructorType = 139,
|
||||
TypeQuery = 140,
|
||||
TypeLiteral = 141,
|
||||
ArrayType = 142,
|
||||
TupleType = 143,
|
||||
UnionType = 144,
|
||||
ParenthesizedType = 145,
|
||||
ObjectBindingPattern = 146,
|
||||
ArrayBindingPattern = 147,
|
||||
BindingElement = 148,
|
||||
ArrayLiteralExpression = 149,
|
||||
ObjectLiteralExpression = 150,
|
||||
PropertyAccessExpression = 151,
|
||||
ElementAccessExpression = 152,
|
||||
CallExpression = 153,
|
||||
NewExpression = 154,
|
||||
TaggedTemplateExpression = 155,
|
||||
TypeAssertionExpression = 156,
|
||||
ParenthesizedExpression = 157,
|
||||
FunctionExpression = 158,
|
||||
ArrowFunction = 159,
|
||||
DeleteExpression = 160,
|
||||
TypeOfExpression = 161,
|
||||
VoidExpression = 162,
|
||||
PrefixUnaryExpression = 163,
|
||||
PostfixUnaryExpression = 164,
|
||||
BinaryExpression = 165,
|
||||
ConditionalExpression = 166,
|
||||
TemplateExpression = 167,
|
||||
YieldExpression = 168,
|
||||
SpreadElementExpression = 169,
|
||||
OmittedExpression = 170,
|
||||
TemplateSpan = 171,
|
||||
Block = 172,
|
||||
VariableStatement = 173,
|
||||
EmptyStatement = 174,
|
||||
ExpressionStatement = 175,
|
||||
IfStatement = 176,
|
||||
DoStatement = 177,
|
||||
WhileStatement = 178,
|
||||
ForStatement = 179,
|
||||
ForInStatement = 180,
|
||||
ForOfStatement = 181,
|
||||
ContinueStatement = 182,
|
||||
BreakStatement = 183,
|
||||
ReturnStatement = 184,
|
||||
WithStatement = 185,
|
||||
SwitchStatement = 186,
|
||||
LabeledStatement = 187,
|
||||
ThrowStatement = 188,
|
||||
TryStatement = 189,
|
||||
DebuggerStatement = 190,
|
||||
VariableDeclaration = 191,
|
||||
VariableDeclarationList = 192,
|
||||
FunctionDeclaration = 193,
|
||||
ClassDeclaration = 194,
|
||||
InterfaceDeclaration = 195,
|
||||
TypeAliasDeclaration = 196,
|
||||
EnumDeclaration = 197,
|
||||
ModuleDeclaration = 198,
|
||||
ModuleBlock = 199,
|
||||
ImportDeclaration = 200,
|
||||
ExportAssignment = 201,
|
||||
ExternalModuleReference = 202,
|
||||
CaseClause = 203,
|
||||
DefaultClause = 204,
|
||||
HeritageClause = 205,
|
||||
CatchClause = 206,
|
||||
PropertyAssignment = 207,
|
||||
ShorthandPropertyAssignment = 208,
|
||||
EnumMember = 209,
|
||||
SourceFile = 210,
|
||||
SyntaxList = 211,
|
||||
Count = 212,
|
||||
FirstAssignment = 52,
|
||||
LastAssignment = 63,
|
||||
FirstReservedWord = 65,
|
||||
LastReservedWord = 100,
|
||||
FirstKeyword = 65,
|
||||
LastKeyword = 122,
|
||||
FirstFutureReservedWord = 101,
|
||||
LastFutureReservedWord = 109,
|
||||
FirstTypeNode = 137,
|
||||
LastTypeNode = 145,
|
||||
AtToken = 52,
|
||||
EqualsToken = 53,
|
||||
PlusEqualsToken = 54,
|
||||
MinusEqualsToken = 55,
|
||||
AsteriskEqualsToken = 56,
|
||||
SlashEqualsToken = 57,
|
||||
PercentEqualsToken = 58,
|
||||
LessThanLessThanEqualsToken = 59,
|
||||
GreaterThanGreaterThanEqualsToken = 60,
|
||||
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
|
||||
AmpersandEqualsToken = 62,
|
||||
BarEqualsToken = 63,
|
||||
CaretEqualsToken = 64,
|
||||
Identifier = 65,
|
||||
BreakKeyword = 66,
|
||||
CaseKeyword = 67,
|
||||
CatchKeyword = 68,
|
||||
ClassKeyword = 69,
|
||||
ConstKeyword = 70,
|
||||
ContinueKeyword = 71,
|
||||
DebuggerKeyword = 72,
|
||||
DefaultKeyword = 73,
|
||||
DeleteKeyword = 74,
|
||||
DoKeyword = 75,
|
||||
ElseKeyword = 76,
|
||||
EnumKeyword = 77,
|
||||
ExportKeyword = 78,
|
||||
ExtendsKeyword = 79,
|
||||
FalseKeyword = 80,
|
||||
FinallyKeyword = 81,
|
||||
ForKeyword = 82,
|
||||
FunctionKeyword = 83,
|
||||
IfKeyword = 84,
|
||||
ImportKeyword = 85,
|
||||
InKeyword = 86,
|
||||
InstanceOfKeyword = 87,
|
||||
NewKeyword = 88,
|
||||
NullKeyword = 89,
|
||||
ReturnKeyword = 90,
|
||||
SuperKeyword = 91,
|
||||
SwitchKeyword = 92,
|
||||
ThisKeyword = 93,
|
||||
ThrowKeyword = 94,
|
||||
TrueKeyword = 95,
|
||||
TryKeyword = 96,
|
||||
TypeOfKeyword = 97,
|
||||
VarKeyword = 98,
|
||||
VoidKeyword = 99,
|
||||
WhileKeyword = 100,
|
||||
WithKeyword = 101,
|
||||
AsKeyword = 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,
|
||||
FromKeyword = 124,
|
||||
OfKeyword = 125,
|
||||
QualifiedName = 126,
|
||||
ComputedPropertyName = 127,
|
||||
TypeParameter = 128,
|
||||
Parameter = 129,
|
||||
Decorator = 130,
|
||||
PropertySignature = 131,
|
||||
PropertyDeclaration = 132,
|
||||
MethodSignature = 133,
|
||||
MethodDeclaration = 134,
|
||||
Constructor = 135,
|
||||
GetAccessor = 136,
|
||||
SetAccessor = 137,
|
||||
CallSignature = 138,
|
||||
ConstructSignature = 139,
|
||||
IndexSignature = 140,
|
||||
TypeReference = 141,
|
||||
FunctionType = 142,
|
||||
ConstructorType = 143,
|
||||
TypeQuery = 144,
|
||||
TypeLiteral = 145,
|
||||
ArrayType = 146,
|
||||
TupleType = 147,
|
||||
UnionType = 148,
|
||||
ParenthesizedType = 149,
|
||||
ObjectBindingPattern = 150,
|
||||
ArrayBindingPattern = 151,
|
||||
BindingElement = 152,
|
||||
ArrayLiteralExpression = 153,
|
||||
ObjectLiteralExpression = 154,
|
||||
PropertyAccessExpression = 155,
|
||||
ElementAccessExpression = 156,
|
||||
CallExpression = 157,
|
||||
NewExpression = 158,
|
||||
TaggedTemplateExpression = 159,
|
||||
TypeAssertionExpression = 160,
|
||||
ParenthesizedExpression = 161,
|
||||
FunctionExpression = 162,
|
||||
ArrowFunction = 163,
|
||||
DeleteExpression = 164,
|
||||
TypeOfExpression = 165,
|
||||
VoidExpression = 166,
|
||||
PrefixUnaryExpression = 167,
|
||||
PostfixUnaryExpression = 168,
|
||||
BinaryExpression = 169,
|
||||
ConditionalExpression = 170,
|
||||
TemplateExpression = 171,
|
||||
YieldExpression = 172,
|
||||
SpreadElementExpression = 173,
|
||||
ClassExpression = 174,
|
||||
OmittedExpression = 175,
|
||||
TemplateSpan = 176,
|
||||
HeritageClauseElement = 177,
|
||||
SemicolonClassElement = 178,
|
||||
Block = 179,
|
||||
VariableStatement = 180,
|
||||
EmptyStatement = 181,
|
||||
ExpressionStatement = 182,
|
||||
IfStatement = 183,
|
||||
DoStatement = 184,
|
||||
WhileStatement = 185,
|
||||
ForStatement = 186,
|
||||
ForInStatement = 187,
|
||||
ForOfStatement = 188,
|
||||
ContinueStatement = 189,
|
||||
BreakStatement = 190,
|
||||
ReturnStatement = 191,
|
||||
WithStatement = 192,
|
||||
SwitchStatement = 193,
|
||||
LabeledStatement = 194,
|
||||
ThrowStatement = 195,
|
||||
TryStatement = 196,
|
||||
DebuggerStatement = 197,
|
||||
VariableDeclaration = 198,
|
||||
VariableDeclarationList = 199,
|
||||
FunctionDeclaration = 200,
|
||||
ClassDeclaration = 201,
|
||||
InterfaceDeclaration = 202,
|
||||
TypeAliasDeclaration = 203,
|
||||
EnumDeclaration = 204,
|
||||
ModuleDeclaration = 205,
|
||||
ModuleBlock = 206,
|
||||
CaseBlock = 207,
|
||||
ImportEqualsDeclaration = 208,
|
||||
ImportDeclaration = 209,
|
||||
ImportClause = 210,
|
||||
NamespaceImport = 211,
|
||||
NamedImports = 212,
|
||||
ImportSpecifier = 213,
|
||||
ExportAssignment = 214,
|
||||
ExportDeclaration = 215,
|
||||
NamedExports = 216,
|
||||
ExportSpecifier = 217,
|
||||
MissingDeclaration = 218,
|
||||
ExternalModuleReference = 219,
|
||||
CaseClause = 220,
|
||||
DefaultClause = 221,
|
||||
HeritageClause = 222,
|
||||
CatchClause = 223,
|
||||
PropertyAssignment = 224,
|
||||
ShorthandPropertyAssignment = 225,
|
||||
EnumMember = 226,
|
||||
SourceFile = 227,
|
||||
SyntaxList = 228,
|
||||
Count = 229,
|
||||
FirstAssignment = 53,
|
||||
LastAssignment = 64,
|
||||
FirstReservedWord = 66,
|
||||
LastReservedWord = 101,
|
||||
FirstKeyword = 66,
|
||||
LastKeyword = 125,
|
||||
FirstFutureReservedWord = 103,
|
||||
LastFutureReservedWord = 111,
|
||||
FirstTypeNode = 141,
|
||||
LastTypeNode = 149,
|
||||
FirstPunctuation = 14,
|
||||
LastPunctuation = 63,
|
||||
LastPunctuation = 64,
|
||||
FirstToken = 0,
|
||||
LastToken = 122,
|
||||
LastToken = 125,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 6,
|
||||
FirstLiteralToken = 7,
|
||||
@@ -256,8 +273,8 @@ declare module "typescript" {
|
||||
FirstTemplateToken = 10,
|
||||
LastTemplateToken = 13,
|
||||
FirstBinaryOperator = 24,
|
||||
LastBinaryOperator = 63,
|
||||
FirstNode = 123,
|
||||
LastBinaryOperator = 64,
|
||||
FirstNode = 126,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
Export = 1,
|
||||
@@ -266,25 +283,28 @@ declare module "typescript" {
|
||||
Private = 32,
|
||||
Protected = 64,
|
||||
Static = 128,
|
||||
MultiLine = 256,
|
||||
Synthetic = 512,
|
||||
DeclarationFile = 1024,
|
||||
Let = 2048,
|
||||
Const = 4096,
|
||||
OctalLiteral = 8192,
|
||||
Modifier = 243,
|
||||
Default = 256,
|
||||
MultiLine = 512,
|
||||
Synthetic = 1024,
|
||||
DeclarationFile = 2048,
|
||||
Let = 4096,
|
||||
Const = 8192,
|
||||
OctalLiteral = 16384,
|
||||
ExportContext = 32768,
|
||||
Modifier = 499,
|
||||
AccessibilityModifier = 112,
|
||||
BlockScoped = 6144,
|
||||
BlockScoped = 12288,
|
||||
}
|
||||
const enum ParserContextFlags {
|
||||
StrictMode = 1,
|
||||
DisallowIn = 2,
|
||||
Yield = 4,
|
||||
GeneratorParameter = 8,
|
||||
ThisNodeHasError = 16,
|
||||
ParserGeneratedFlags = 31,
|
||||
ThisNodeOrAnySubNodesHasError = 32,
|
||||
HasAggregatedChildData = 64,
|
||||
Decorator = 16,
|
||||
ThisNodeHasError = 32,
|
||||
ParserGeneratedFlags = 63,
|
||||
ThisNodeOrAnySubNodesHasError = 64,
|
||||
HasAggregatedChildData = 128,
|
||||
}
|
||||
const enum RelationComparisonResult {
|
||||
Succeeded = 1,
|
||||
@@ -295,13 +315,14 @@ declare module "typescript" {
|
||||
kind: SyntaxKind;
|
||||
flags: NodeFlags;
|
||||
parserContextFlags?: ParserContextFlags;
|
||||
decorators?: NodeArray<Decorator>;
|
||||
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;
|
||||
@@ -325,6 +346,9 @@ declare module "typescript" {
|
||||
interface ComputedPropertyName extends Node {
|
||||
expression: Expression;
|
||||
}
|
||||
interface Decorator extends Node {
|
||||
expression: LeftHandSideExpression;
|
||||
}
|
||||
interface TypeParameterDeclaration extends Declaration {
|
||||
name: Identifier;
|
||||
constraint?: TypeNode;
|
||||
@@ -402,7 +426,7 @@ declare module "typescript" {
|
||||
body?: Block | Expression;
|
||||
}
|
||||
interface FunctionDeclaration extends FunctionLikeDeclaration, Statement {
|
||||
name: Identifier;
|
||||
name?: Identifier;
|
||||
body?: Block;
|
||||
}
|
||||
interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
|
||||
@@ -411,6 +435,9 @@ declare module "typescript" {
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement {
|
||||
body?: Block;
|
||||
}
|
||||
interface SemicolonClassElement extends ClassElement {
|
||||
_semicolonClassElementBrand: any;
|
||||
}
|
||||
interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
|
||||
_accessorDeclarationBrand: any;
|
||||
body: Block;
|
||||
@@ -495,16 +522,22 @@ declare module "typescript" {
|
||||
}
|
||||
interface ConditionalExpression extends Expression {
|
||||
condition: Expression;
|
||||
questionToken: Node;
|
||||
whenTrue: Expression;
|
||||
colonToken: Node;
|
||||
whenFalse: Expression;
|
||||
}
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration {
|
||||
name?: Identifier;
|
||||
body: Block | Expression;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclaration {
|
||||
equalsGreaterThanToken: Node;
|
||||
}
|
||||
interface LiteralExpression extends PrimaryExpression {
|
||||
text: string;
|
||||
isUnterminated?: boolean;
|
||||
hasExtendedUnicodeEscape?: boolean;
|
||||
}
|
||||
interface StringLiteralExpression extends LiteralExpression {
|
||||
_stringLiteralExpressionBrand: any;
|
||||
@@ -531,6 +564,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface PropertyAccessExpression extends MemberExpression {
|
||||
expression: LeftHandSideExpression;
|
||||
dotToken: Node;
|
||||
name: Identifier;
|
||||
}
|
||||
interface ElementAccessExpression extends MemberExpression {
|
||||
@@ -542,6 +576,10 @@ declare module "typescript" {
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
arguments: NodeArray<Expression>;
|
||||
}
|
||||
interface HeritageClauseElement extends Node {
|
||||
expression: LeftHandSideExpression;
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
}
|
||||
interface NewExpression extends CallExpression, PrimaryExpression {
|
||||
}
|
||||
interface TaggedTemplateExpression extends MemberExpression {
|
||||
@@ -604,6 +642,9 @@ declare module "typescript" {
|
||||
}
|
||||
interface SwitchStatement extends Statement {
|
||||
expression: Expression;
|
||||
caseBlock: CaseBlock;
|
||||
}
|
||||
interface CaseBlock extends Node {
|
||||
clauses: NodeArray<CaseOrDefaultClause>;
|
||||
}
|
||||
interface CaseClause extends Node {
|
||||
@@ -626,20 +667,23 @@ declare module "typescript" {
|
||||
catchClause?: CatchClause;
|
||||
finallyBlock?: Block;
|
||||
}
|
||||
interface CatchClause extends Declaration {
|
||||
name: Identifier;
|
||||
type?: TypeNode;
|
||||
interface CatchClause extends Node {
|
||||
variableDeclaration: VariableDeclaration;
|
||||
block: Block;
|
||||
}
|
||||
interface ModuleElement extends Node {
|
||||
_moduleElementBrand: any;
|
||||
}
|
||||
interface ClassDeclaration extends Declaration, ModuleElement {
|
||||
name: Identifier;
|
||||
interface ClassLikeDeclaration extends Declaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
members: NodeArray<ClassElement>;
|
||||
}
|
||||
interface ClassDeclaration extends ClassLikeDeclaration, Statement {
|
||||
}
|
||||
interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
|
||||
}
|
||||
interface ClassElement extends Declaration {
|
||||
_classElementBrand: any;
|
||||
}
|
||||
@@ -651,7 +695,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface HeritageClause extends Node {
|
||||
token: SyntaxKind;
|
||||
types?: NodeArray<TypeReferenceNode>;
|
||||
types?: NodeArray<HeritageClauseElement>;
|
||||
}
|
||||
interface TypeAliasDeclaration extends Declaration, ModuleElement {
|
||||
name: Identifier;
|
||||
@@ -672,15 +716,43 @@ declare module "typescript" {
|
||||
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 ExportAssignment extends Statement, ModuleElement {
|
||||
exportName: Identifier;
|
||||
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 Declaration, 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 Declaration, ModuleElement {
|
||||
isExportEquals?: boolean;
|
||||
expression?: Expression;
|
||||
type?: TypeNode;
|
||||
}
|
||||
interface FileReference extends TextRange {
|
||||
fileName: string;
|
||||
@@ -715,14 +787,14 @@ declare module "typescript" {
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
@@ -793,6 +865,7 @@ declare module "typescript" {
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
|
||||
}
|
||||
interface SymbolDisplayBuilder {
|
||||
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -840,9 +913,10 @@ declare module "typescript" {
|
||||
NotAccessible = 1,
|
||||
CannotBeNamed = 2,
|
||||
}
|
||||
type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
|
||||
interface SymbolVisibilityResult {
|
||||
accessibility: SymbolAccessibility;
|
||||
aliasesToMakeVisible?: ImportDeclaration[];
|
||||
aliasesToMakeVisible?: AnyImportSyntax[];
|
||||
errorSymbolName?: string;
|
||||
errorNode?: Node;
|
||||
}
|
||||
@@ -850,20 +924,23 @@ declare module "typescript" {
|
||||
errorModuleName?: string;
|
||||
}
|
||||
interface EmitResolver {
|
||||
getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string;
|
||||
getExpressionNamePrefix(node: Identifier): string;
|
||||
getExportAssignmentName(node: SourceFile): string;
|
||||
isReferencedImportDeclaration(node: ImportDeclaration): boolean;
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
hasGlobalName(name: string): boolean;
|
||||
getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string;
|
||||
isValueAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
collectLinkedAliases(node: Identifier): Node[];
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
|
||||
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isUnknownIdentifier(location: Node, name: string): boolean;
|
||||
resolvesToSomeValue(location: Node, name: string): boolean;
|
||||
getBlockScopedVariableId(node: Identifier): number;
|
||||
}
|
||||
const enum SymbolFlags {
|
||||
FunctionScopedVariable = 1,
|
||||
@@ -889,13 +966,14 @@ declare module "typescript" {
|
||||
ExportValue = 1048576,
|
||||
ExportType = 2097152,
|
||||
ExportNamespace = 4194304,
|
||||
Import = 8388608,
|
||||
Alias = 8388608,
|
||||
Instantiated = 16777216,
|
||||
Merged = 33554432,
|
||||
Transient = 67108864,
|
||||
Prototype = 134217728,
|
||||
UnionProperty = 268435456,
|
||||
Optional = 536870912,
|
||||
ExportStar = 1073741824,
|
||||
Enum = 384,
|
||||
Variable = 3,
|
||||
Value = 107455,
|
||||
@@ -920,7 +998,7 @@ declare module "typescript" {
|
||||
SetAccessorExcludes = 74687,
|
||||
TypeParameterExcludes = 530912,
|
||||
TypeAliasExcludes = 793056,
|
||||
ImportExcludes = 8388608,
|
||||
AliasExcludes = 8388608,
|
||||
ModuleMember = 8914931,
|
||||
ExportHasLocal = 944,
|
||||
HasLocals = 255504,
|
||||
@@ -949,8 +1027,9 @@ declare module "typescript" {
|
||||
declaredType?: Type;
|
||||
mapper?: TypeMapper;
|
||||
referenced?: boolean;
|
||||
exportAssignSymbol?: Symbol;
|
||||
unionType?: UnionType;
|
||||
resolvedExports?: SymbolTable;
|
||||
exportsChecked?: boolean;
|
||||
}
|
||||
interface TransientSymbol extends Symbol, SymbolLinks {
|
||||
}
|
||||
@@ -966,6 +1045,8 @@ declare module "typescript" {
|
||||
SuperStatic = 32,
|
||||
ContextChecked = 64,
|
||||
EnumValuesComputed = 128,
|
||||
BlockScopedBindingInLoop = 256,
|
||||
EmitDecorate = 512,
|
||||
}
|
||||
interface NodeLinks {
|
||||
resolvedType?: Type;
|
||||
@@ -975,7 +1056,8 @@ declare module "typescript" {
|
||||
enumMemberValue?: number;
|
||||
isIllegalTypeReferenceInConstraint?: boolean;
|
||||
isVisible?: boolean;
|
||||
localModuleName?: string;
|
||||
generatedName?: string;
|
||||
generatedNames?: Map<string>;
|
||||
assignmentChecks?: Map<boolean>;
|
||||
hasReportedStatementInAmbientContext?: boolean;
|
||||
importOnRightSide?: Symbol;
|
||||
@@ -1084,17 +1166,6 @@ declare module "typescript" {
|
||||
interface TypeMapper {
|
||||
(t: Type): Type;
|
||||
}
|
||||
interface TypeInferences {
|
||||
primary: Type[];
|
||||
secondary: Type[];
|
||||
}
|
||||
interface InferenceContext {
|
||||
typeParameters: TypeParameter[];
|
||||
inferUnionTypes: boolean;
|
||||
inferences: TypeInferences[];
|
||||
inferredTypes: Type[];
|
||||
failedTypeParameterIndex?: number;
|
||||
}
|
||||
interface DiagnosticMessage {
|
||||
key: string;
|
||||
category: DiagnosticCategory;
|
||||
@@ -1122,7 +1193,6 @@ declare module "typescript" {
|
||||
interface CompilerOptions {
|
||||
allowNonTsExtensions?: boolean;
|
||||
charset?: string;
|
||||
codepage?: number;
|
||||
declaration?: boolean;
|
||||
diagnostics?: boolean;
|
||||
emitBOM?: boolean;
|
||||
@@ -1136,7 +1206,6 @@ declare module "typescript" {
|
||||
noErrorTruncation?: boolean;
|
||||
noImplicitAny?: boolean;
|
||||
noLib?: boolean;
|
||||
noLibCheck?: boolean;
|
||||
noResolve?: boolean;
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
@@ -1149,7 +1218,7 @@ declare module "typescript" {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
separateCompilation?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
@@ -1341,6 +1410,7 @@ declare module "typescript" {
|
||||
getTokenPos(): number;
|
||||
getTokenText(): string;
|
||||
getTokenValue(): string;
|
||||
hasExtendedUnicodeEscape(): boolean;
|
||||
hasPrecedingLineBreak(): boolean;
|
||||
isIdentifier(): boolean;
|
||||
isReservedWord(): boolean;
|
||||
@@ -1389,13 +1459,31 @@ declare module "typescript" {
|
||||
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
|
||||
}
|
||||
declare module "typescript" {
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
||||
/** The version of the TypeScript compiler release */
|
||||
let version: string;
|
||||
function findConfigFile(searchPath: string): string;
|
||||
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
}
|
||||
declare module "typescript" {
|
||||
var servicesVersion: string;
|
||||
/**
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
*/
|
||||
function readConfigFile(fileName: string): any;
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
|
||||
}
|
||||
declare module "typescript" {
|
||||
/** The version of the language service API */
|
||||
let servicesVersion: string;
|
||||
interface Node {
|
||||
getSourceFile(): SourceFile;
|
||||
getChildCount(sourceFile?: SourceFile): number;
|
||||
@@ -1437,9 +1525,6 @@ declare module "typescript" {
|
||||
getDocumentationComment(): SymbolDisplayPart[];
|
||||
}
|
||||
interface SourceFile {
|
||||
version: string;
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
@@ -1505,6 +1590,7 @@ declare module "typescript" {
|
||||
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
findReferences(fileName: string, position: number): ReferencedSymbol[];
|
||||
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
|
||||
getNavigationBarItems(fileName: string): NavigationBarItem[];
|
||||
getOutliningSpans(fileName: string): OutliningSpan[];
|
||||
@@ -1560,6 +1646,7 @@ declare module "typescript" {
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
matchKind: string;
|
||||
isCaseSensitive: boolean;
|
||||
fileName: string;
|
||||
textSpan: TextSpan;
|
||||
containerName: string;
|
||||
@@ -1590,6 +1677,10 @@ declare module "typescript" {
|
||||
containerKind: string;
|
||||
containerName: string;
|
||||
}
|
||||
interface ReferencedSymbol {
|
||||
definition: DefinitionInfo;
|
||||
references: ReferenceEntry[];
|
||||
}
|
||||
enum SymbolDisplayPartKind {
|
||||
aliasName = 0,
|
||||
className = 1,
|
||||
@@ -1792,25 +1883,17 @@ declare module "typescript" {
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
* Note: It is not allowed to call update on a SourceFile that was not acquired from this
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
* @parm scriptSnapshot Text of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
||||
* was not found in the registry and a new one was created.
|
||||
* @param scriptSnapshot Text of the file.
|
||||
* @param version Current version of the file.
|
||||
*/
|
||||
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
@@ -1891,8 +1974,9 @@ declare module "typescript" {
|
||||
isCancellationRequested(): boolean;
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
var disableIncrementalParsing: boolean;
|
||||
let disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
function createDocumentRegistry(): DocumentRegistry;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
||||
|
||||
+11120
-6638
File diff suppressed because it is too large
Load Diff
Vendored
+331
-247
@@ -74,181 +74,198 @@ declare module ts {
|
||||
BarBarToken = 49,
|
||||
QuestionToken = 50,
|
||||
ColonToken = 51,
|
||||
EqualsToken = 52,
|
||||
PlusEqualsToken = 53,
|
||||
MinusEqualsToken = 54,
|
||||
AsteriskEqualsToken = 55,
|
||||
SlashEqualsToken = 56,
|
||||
PercentEqualsToken = 57,
|
||||
LessThanLessThanEqualsToken = 58,
|
||||
GreaterThanGreaterThanEqualsToken = 59,
|
||||
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
|
||||
AmpersandEqualsToken = 61,
|
||||
BarEqualsToken = 62,
|
||||
CaretEqualsToken = 63,
|
||||
Identifier = 64,
|
||||
BreakKeyword = 65,
|
||||
CaseKeyword = 66,
|
||||
CatchKeyword = 67,
|
||||
ClassKeyword = 68,
|
||||
ConstKeyword = 69,
|
||||
ContinueKeyword = 70,
|
||||
DebuggerKeyword = 71,
|
||||
DefaultKeyword = 72,
|
||||
DeleteKeyword = 73,
|
||||
DoKeyword = 74,
|
||||
ElseKeyword = 75,
|
||||
EnumKeyword = 76,
|
||||
ExportKeyword = 77,
|
||||
ExtendsKeyword = 78,
|
||||
FalseKeyword = 79,
|
||||
FinallyKeyword = 80,
|
||||
ForKeyword = 81,
|
||||
FunctionKeyword = 82,
|
||||
IfKeyword = 83,
|
||||
ImportKeyword = 84,
|
||||
InKeyword = 85,
|
||||
InstanceOfKeyword = 86,
|
||||
NewKeyword = 87,
|
||||
NullKeyword = 88,
|
||||
ReturnKeyword = 89,
|
||||
SuperKeyword = 90,
|
||||
SwitchKeyword = 91,
|
||||
ThisKeyword = 92,
|
||||
ThrowKeyword = 93,
|
||||
TrueKeyword = 94,
|
||||
TryKeyword = 95,
|
||||
TypeOfKeyword = 96,
|
||||
VarKeyword = 97,
|
||||
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,
|
||||
SymbolKeyword = 120,
|
||||
TypeKeyword = 121,
|
||||
OfKeyword = 122,
|
||||
QualifiedName = 123,
|
||||
ComputedPropertyName = 124,
|
||||
TypeParameter = 125,
|
||||
Parameter = 126,
|
||||
PropertySignature = 127,
|
||||
PropertyDeclaration = 128,
|
||||
MethodSignature = 129,
|
||||
MethodDeclaration = 130,
|
||||
Constructor = 131,
|
||||
GetAccessor = 132,
|
||||
SetAccessor = 133,
|
||||
CallSignature = 134,
|
||||
ConstructSignature = 135,
|
||||
IndexSignature = 136,
|
||||
TypeReference = 137,
|
||||
FunctionType = 138,
|
||||
ConstructorType = 139,
|
||||
TypeQuery = 140,
|
||||
TypeLiteral = 141,
|
||||
ArrayType = 142,
|
||||
TupleType = 143,
|
||||
UnionType = 144,
|
||||
ParenthesizedType = 145,
|
||||
ObjectBindingPattern = 146,
|
||||
ArrayBindingPattern = 147,
|
||||
BindingElement = 148,
|
||||
ArrayLiteralExpression = 149,
|
||||
ObjectLiteralExpression = 150,
|
||||
PropertyAccessExpression = 151,
|
||||
ElementAccessExpression = 152,
|
||||
CallExpression = 153,
|
||||
NewExpression = 154,
|
||||
TaggedTemplateExpression = 155,
|
||||
TypeAssertionExpression = 156,
|
||||
ParenthesizedExpression = 157,
|
||||
FunctionExpression = 158,
|
||||
ArrowFunction = 159,
|
||||
DeleteExpression = 160,
|
||||
TypeOfExpression = 161,
|
||||
VoidExpression = 162,
|
||||
PrefixUnaryExpression = 163,
|
||||
PostfixUnaryExpression = 164,
|
||||
BinaryExpression = 165,
|
||||
ConditionalExpression = 166,
|
||||
TemplateExpression = 167,
|
||||
YieldExpression = 168,
|
||||
SpreadElementExpression = 169,
|
||||
OmittedExpression = 170,
|
||||
TemplateSpan = 171,
|
||||
Block = 172,
|
||||
VariableStatement = 173,
|
||||
EmptyStatement = 174,
|
||||
ExpressionStatement = 175,
|
||||
IfStatement = 176,
|
||||
DoStatement = 177,
|
||||
WhileStatement = 178,
|
||||
ForStatement = 179,
|
||||
ForInStatement = 180,
|
||||
ForOfStatement = 181,
|
||||
ContinueStatement = 182,
|
||||
BreakStatement = 183,
|
||||
ReturnStatement = 184,
|
||||
WithStatement = 185,
|
||||
SwitchStatement = 186,
|
||||
LabeledStatement = 187,
|
||||
ThrowStatement = 188,
|
||||
TryStatement = 189,
|
||||
DebuggerStatement = 190,
|
||||
VariableDeclaration = 191,
|
||||
VariableDeclarationList = 192,
|
||||
FunctionDeclaration = 193,
|
||||
ClassDeclaration = 194,
|
||||
InterfaceDeclaration = 195,
|
||||
TypeAliasDeclaration = 196,
|
||||
EnumDeclaration = 197,
|
||||
ModuleDeclaration = 198,
|
||||
ModuleBlock = 199,
|
||||
ImportDeclaration = 200,
|
||||
ExportAssignment = 201,
|
||||
ExternalModuleReference = 202,
|
||||
CaseClause = 203,
|
||||
DefaultClause = 204,
|
||||
HeritageClause = 205,
|
||||
CatchClause = 206,
|
||||
PropertyAssignment = 207,
|
||||
ShorthandPropertyAssignment = 208,
|
||||
EnumMember = 209,
|
||||
SourceFile = 210,
|
||||
SyntaxList = 211,
|
||||
Count = 212,
|
||||
FirstAssignment = 52,
|
||||
LastAssignment = 63,
|
||||
FirstReservedWord = 65,
|
||||
LastReservedWord = 100,
|
||||
FirstKeyword = 65,
|
||||
LastKeyword = 122,
|
||||
FirstFutureReservedWord = 101,
|
||||
LastFutureReservedWord = 109,
|
||||
FirstTypeNode = 137,
|
||||
LastTypeNode = 145,
|
||||
AtToken = 52,
|
||||
EqualsToken = 53,
|
||||
PlusEqualsToken = 54,
|
||||
MinusEqualsToken = 55,
|
||||
AsteriskEqualsToken = 56,
|
||||
SlashEqualsToken = 57,
|
||||
PercentEqualsToken = 58,
|
||||
LessThanLessThanEqualsToken = 59,
|
||||
GreaterThanGreaterThanEqualsToken = 60,
|
||||
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
|
||||
AmpersandEqualsToken = 62,
|
||||
BarEqualsToken = 63,
|
||||
CaretEqualsToken = 64,
|
||||
Identifier = 65,
|
||||
BreakKeyword = 66,
|
||||
CaseKeyword = 67,
|
||||
CatchKeyword = 68,
|
||||
ClassKeyword = 69,
|
||||
ConstKeyword = 70,
|
||||
ContinueKeyword = 71,
|
||||
DebuggerKeyword = 72,
|
||||
DefaultKeyword = 73,
|
||||
DeleteKeyword = 74,
|
||||
DoKeyword = 75,
|
||||
ElseKeyword = 76,
|
||||
EnumKeyword = 77,
|
||||
ExportKeyword = 78,
|
||||
ExtendsKeyword = 79,
|
||||
FalseKeyword = 80,
|
||||
FinallyKeyword = 81,
|
||||
ForKeyword = 82,
|
||||
FunctionKeyword = 83,
|
||||
IfKeyword = 84,
|
||||
ImportKeyword = 85,
|
||||
InKeyword = 86,
|
||||
InstanceOfKeyword = 87,
|
||||
NewKeyword = 88,
|
||||
NullKeyword = 89,
|
||||
ReturnKeyword = 90,
|
||||
SuperKeyword = 91,
|
||||
SwitchKeyword = 92,
|
||||
ThisKeyword = 93,
|
||||
ThrowKeyword = 94,
|
||||
TrueKeyword = 95,
|
||||
TryKeyword = 96,
|
||||
TypeOfKeyword = 97,
|
||||
VarKeyword = 98,
|
||||
VoidKeyword = 99,
|
||||
WhileKeyword = 100,
|
||||
WithKeyword = 101,
|
||||
AsKeyword = 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,
|
||||
FromKeyword = 124,
|
||||
OfKeyword = 125,
|
||||
QualifiedName = 126,
|
||||
ComputedPropertyName = 127,
|
||||
TypeParameter = 128,
|
||||
Parameter = 129,
|
||||
Decorator = 130,
|
||||
PropertySignature = 131,
|
||||
PropertyDeclaration = 132,
|
||||
MethodSignature = 133,
|
||||
MethodDeclaration = 134,
|
||||
Constructor = 135,
|
||||
GetAccessor = 136,
|
||||
SetAccessor = 137,
|
||||
CallSignature = 138,
|
||||
ConstructSignature = 139,
|
||||
IndexSignature = 140,
|
||||
TypeReference = 141,
|
||||
FunctionType = 142,
|
||||
ConstructorType = 143,
|
||||
TypeQuery = 144,
|
||||
TypeLiteral = 145,
|
||||
ArrayType = 146,
|
||||
TupleType = 147,
|
||||
UnionType = 148,
|
||||
ParenthesizedType = 149,
|
||||
ObjectBindingPattern = 150,
|
||||
ArrayBindingPattern = 151,
|
||||
BindingElement = 152,
|
||||
ArrayLiteralExpression = 153,
|
||||
ObjectLiteralExpression = 154,
|
||||
PropertyAccessExpression = 155,
|
||||
ElementAccessExpression = 156,
|
||||
CallExpression = 157,
|
||||
NewExpression = 158,
|
||||
TaggedTemplateExpression = 159,
|
||||
TypeAssertionExpression = 160,
|
||||
ParenthesizedExpression = 161,
|
||||
FunctionExpression = 162,
|
||||
ArrowFunction = 163,
|
||||
DeleteExpression = 164,
|
||||
TypeOfExpression = 165,
|
||||
VoidExpression = 166,
|
||||
PrefixUnaryExpression = 167,
|
||||
PostfixUnaryExpression = 168,
|
||||
BinaryExpression = 169,
|
||||
ConditionalExpression = 170,
|
||||
TemplateExpression = 171,
|
||||
YieldExpression = 172,
|
||||
SpreadElementExpression = 173,
|
||||
ClassExpression = 174,
|
||||
OmittedExpression = 175,
|
||||
TemplateSpan = 176,
|
||||
HeritageClauseElement = 177,
|
||||
SemicolonClassElement = 178,
|
||||
Block = 179,
|
||||
VariableStatement = 180,
|
||||
EmptyStatement = 181,
|
||||
ExpressionStatement = 182,
|
||||
IfStatement = 183,
|
||||
DoStatement = 184,
|
||||
WhileStatement = 185,
|
||||
ForStatement = 186,
|
||||
ForInStatement = 187,
|
||||
ForOfStatement = 188,
|
||||
ContinueStatement = 189,
|
||||
BreakStatement = 190,
|
||||
ReturnStatement = 191,
|
||||
WithStatement = 192,
|
||||
SwitchStatement = 193,
|
||||
LabeledStatement = 194,
|
||||
ThrowStatement = 195,
|
||||
TryStatement = 196,
|
||||
DebuggerStatement = 197,
|
||||
VariableDeclaration = 198,
|
||||
VariableDeclarationList = 199,
|
||||
FunctionDeclaration = 200,
|
||||
ClassDeclaration = 201,
|
||||
InterfaceDeclaration = 202,
|
||||
TypeAliasDeclaration = 203,
|
||||
EnumDeclaration = 204,
|
||||
ModuleDeclaration = 205,
|
||||
ModuleBlock = 206,
|
||||
CaseBlock = 207,
|
||||
ImportEqualsDeclaration = 208,
|
||||
ImportDeclaration = 209,
|
||||
ImportClause = 210,
|
||||
NamespaceImport = 211,
|
||||
NamedImports = 212,
|
||||
ImportSpecifier = 213,
|
||||
ExportAssignment = 214,
|
||||
ExportDeclaration = 215,
|
||||
NamedExports = 216,
|
||||
ExportSpecifier = 217,
|
||||
MissingDeclaration = 218,
|
||||
ExternalModuleReference = 219,
|
||||
CaseClause = 220,
|
||||
DefaultClause = 221,
|
||||
HeritageClause = 222,
|
||||
CatchClause = 223,
|
||||
PropertyAssignment = 224,
|
||||
ShorthandPropertyAssignment = 225,
|
||||
EnumMember = 226,
|
||||
SourceFile = 227,
|
||||
SyntaxList = 228,
|
||||
Count = 229,
|
||||
FirstAssignment = 53,
|
||||
LastAssignment = 64,
|
||||
FirstReservedWord = 66,
|
||||
LastReservedWord = 101,
|
||||
FirstKeyword = 66,
|
||||
LastKeyword = 125,
|
||||
FirstFutureReservedWord = 103,
|
||||
LastFutureReservedWord = 111,
|
||||
FirstTypeNode = 141,
|
||||
LastTypeNode = 149,
|
||||
FirstPunctuation = 14,
|
||||
LastPunctuation = 63,
|
||||
LastPunctuation = 64,
|
||||
FirstToken = 0,
|
||||
LastToken = 122,
|
||||
LastToken = 125,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 6,
|
||||
FirstLiteralToken = 7,
|
||||
@@ -256,8 +273,8 @@ declare module ts {
|
||||
FirstTemplateToken = 10,
|
||||
LastTemplateToken = 13,
|
||||
FirstBinaryOperator = 24,
|
||||
LastBinaryOperator = 63,
|
||||
FirstNode = 123,
|
||||
LastBinaryOperator = 64,
|
||||
FirstNode = 126,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
Export = 1,
|
||||
@@ -266,25 +283,28 @@ declare module ts {
|
||||
Private = 32,
|
||||
Protected = 64,
|
||||
Static = 128,
|
||||
MultiLine = 256,
|
||||
Synthetic = 512,
|
||||
DeclarationFile = 1024,
|
||||
Let = 2048,
|
||||
Const = 4096,
|
||||
OctalLiteral = 8192,
|
||||
Modifier = 243,
|
||||
Default = 256,
|
||||
MultiLine = 512,
|
||||
Synthetic = 1024,
|
||||
DeclarationFile = 2048,
|
||||
Let = 4096,
|
||||
Const = 8192,
|
||||
OctalLiteral = 16384,
|
||||
ExportContext = 32768,
|
||||
Modifier = 499,
|
||||
AccessibilityModifier = 112,
|
||||
BlockScoped = 6144,
|
||||
BlockScoped = 12288,
|
||||
}
|
||||
const enum ParserContextFlags {
|
||||
StrictMode = 1,
|
||||
DisallowIn = 2,
|
||||
Yield = 4,
|
||||
GeneratorParameter = 8,
|
||||
ThisNodeHasError = 16,
|
||||
ParserGeneratedFlags = 31,
|
||||
ThisNodeOrAnySubNodesHasError = 32,
|
||||
HasAggregatedChildData = 64,
|
||||
Decorator = 16,
|
||||
ThisNodeHasError = 32,
|
||||
ParserGeneratedFlags = 63,
|
||||
ThisNodeOrAnySubNodesHasError = 64,
|
||||
HasAggregatedChildData = 128,
|
||||
}
|
||||
const enum RelationComparisonResult {
|
||||
Succeeded = 1,
|
||||
@@ -295,13 +315,14 @@ declare module ts {
|
||||
kind: SyntaxKind;
|
||||
flags: NodeFlags;
|
||||
parserContextFlags?: ParserContextFlags;
|
||||
decorators?: NodeArray<Decorator>;
|
||||
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;
|
||||
@@ -325,6 +346,9 @@ declare module ts {
|
||||
interface ComputedPropertyName extends Node {
|
||||
expression: Expression;
|
||||
}
|
||||
interface Decorator extends Node {
|
||||
expression: LeftHandSideExpression;
|
||||
}
|
||||
interface TypeParameterDeclaration extends Declaration {
|
||||
name: Identifier;
|
||||
constraint?: TypeNode;
|
||||
@@ -402,7 +426,7 @@ declare module ts {
|
||||
body?: Block | Expression;
|
||||
}
|
||||
interface FunctionDeclaration extends FunctionLikeDeclaration, Statement {
|
||||
name: Identifier;
|
||||
name?: Identifier;
|
||||
body?: Block;
|
||||
}
|
||||
interface MethodDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
|
||||
@@ -411,6 +435,9 @@ declare module ts {
|
||||
interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement {
|
||||
body?: Block;
|
||||
}
|
||||
interface SemicolonClassElement extends ClassElement {
|
||||
_semicolonClassElementBrand: any;
|
||||
}
|
||||
interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
|
||||
_accessorDeclarationBrand: any;
|
||||
body: Block;
|
||||
@@ -495,16 +522,22 @@ declare module ts {
|
||||
}
|
||||
interface ConditionalExpression extends Expression {
|
||||
condition: Expression;
|
||||
questionToken: Node;
|
||||
whenTrue: Expression;
|
||||
colonToken: Node;
|
||||
whenFalse: Expression;
|
||||
}
|
||||
interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclaration {
|
||||
name?: Identifier;
|
||||
body: Block | Expression;
|
||||
}
|
||||
interface ArrowFunction extends Expression, FunctionLikeDeclaration {
|
||||
equalsGreaterThanToken: Node;
|
||||
}
|
||||
interface LiteralExpression extends PrimaryExpression {
|
||||
text: string;
|
||||
isUnterminated?: boolean;
|
||||
hasExtendedUnicodeEscape?: boolean;
|
||||
}
|
||||
interface StringLiteralExpression extends LiteralExpression {
|
||||
_stringLiteralExpressionBrand: any;
|
||||
@@ -531,6 +564,7 @@ declare module ts {
|
||||
}
|
||||
interface PropertyAccessExpression extends MemberExpression {
|
||||
expression: LeftHandSideExpression;
|
||||
dotToken: Node;
|
||||
name: Identifier;
|
||||
}
|
||||
interface ElementAccessExpression extends MemberExpression {
|
||||
@@ -542,6 +576,10 @@ declare module ts {
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
arguments: NodeArray<Expression>;
|
||||
}
|
||||
interface HeritageClauseElement extends Node {
|
||||
expression: LeftHandSideExpression;
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
}
|
||||
interface NewExpression extends CallExpression, PrimaryExpression {
|
||||
}
|
||||
interface TaggedTemplateExpression extends MemberExpression {
|
||||
@@ -604,6 +642,9 @@ declare module ts {
|
||||
}
|
||||
interface SwitchStatement extends Statement {
|
||||
expression: Expression;
|
||||
caseBlock: CaseBlock;
|
||||
}
|
||||
interface CaseBlock extends Node {
|
||||
clauses: NodeArray<CaseOrDefaultClause>;
|
||||
}
|
||||
interface CaseClause extends Node {
|
||||
@@ -626,20 +667,23 @@ declare module ts {
|
||||
catchClause?: CatchClause;
|
||||
finallyBlock?: Block;
|
||||
}
|
||||
interface CatchClause extends Declaration {
|
||||
name: Identifier;
|
||||
type?: TypeNode;
|
||||
interface CatchClause extends Node {
|
||||
variableDeclaration: VariableDeclaration;
|
||||
block: Block;
|
||||
}
|
||||
interface ModuleElement extends Node {
|
||||
_moduleElementBrand: any;
|
||||
}
|
||||
interface ClassDeclaration extends Declaration, ModuleElement {
|
||||
name: Identifier;
|
||||
interface ClassLikeDeclaration extends Declaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
members: NodeArray<ClassElement>;
|
||||
}
|
||||
interface ClassDeclaration extends ClassLikeDeclaration, Statement {
|
||||
}
|
||||
interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
|
||||
}
|
||||
interface ClassElement extends Declaration {
|
||||
_classElementBrand: any;
|
||||
}
|
||||
@@ -651,7 +695,7 @@ declare module ts {
|
||||
}
|
||||
interface HeritageClause extends Node {
|
||||
token: SyntaxKind;
|
||||
types?: NodeArray<TypeReferenceNode>;
|
||||
types?: NodeArray<HeritageClauseElement>;
|
||||
}
|
||||
interface TypeAliasDeclaration extends Declaration, ModuleElement {
|
||||
name: Identifier;
|
||||
@@ -672,15 +716,43 @@ declare module ts {
|
||||
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 ExportAssignment extends Statement, ModuleElement {
|
||||
exportName: Identifier;
|
||||
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 Declaration, 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 Declaration, ModuleElement {
|
||||
isExportEquals?: boolean;
|
||||
expression?: Expression;
|
||||
type?: TypeNode;
|
||||
}
|
||||
interface FileReference extends TextRange {
|
||||
fileName: string;
|
||||
@@ -715,14 +787,14 @@ declare module ts {
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
@@ -793,6 +865,7 @@ declare module ts {
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfExternalModule(node: ImportDeclaration): Symbol[];
|
||||
}
|
||||
interface SymbolDisplayBuilder {
|
||||
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -840,9 +913,10 @@ declare module ts {
|
||||
NotAccessible = 1,
|
||||
CannotBeNamed = 2,
|
||||
}
|
||||
type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
|
||||
interface SymbolVisibilityResult {
|
||||
accessibility: SymbolAccessibility;
|
||||
aliasesToMakeVisible?: ImportDeclaration[];
|
||||
aliasesToMakeVisible?: AnyImportSyntax[];
|
||||
errorSymbolName?: string;
|
||||
errorNode?: Node;
|
||||
}
|
||||
@@ -850,20 +924,23 @@ declare module ts {
|
||||
errorModuleName?: string;
|
||||
}
|
||||
interface EmitResolver {
|
||||
getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string;
|
||||
getExpressionNamePrefix(node: Identifier): string;
|
||||
getExportAssignmentName(node: SourceFile): string;
|
||||
isReferencedImportDeclaration(node: ImportDeclaration): boolean;
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
hasGlobalName(name: string): boolean;
|
||||
getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string;
|
||||
isValueAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
collectLinkedAliases(node: Identifier): Node[];
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
|
||||
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isUnknownIdentifier(location: Node, name: string): boolean;
|
||||
resolvesToSomeValue(location: Node, name: string): boolean;
|
||||
getBlockScopedVariableId(node: Identifier): number;
|
||||
}
|
||||
const enum SymbolFlags {
|
||||
FunctionScopedVariable = 1,
|
||||
@@ -889,13 +966,14 @@ declare module ts {
|
||||
ExportValue = 1048576,
|
||||
ExportType = 2097152,
|
||||
ExportNamespace = 4194304,
|
||||
Import = 8388608,
|
||||
Alias = 8388608,
|
||||
Instantiated = 16777216,
|
||||
Merged = 33554432,
|
||||
Transient = 67108864,
|
||||
Prototype = 134217728,
|
||||
UnionProperty = 268435456,
|
||||
Optional = 536870912,
|
||||
ExportStar = 1073741824,
|
||||
Enum = 384,
|
||||
Variable = 3,
|
||||
Value = 107455,
|
||||
@@ -920,7 +998,7 @@ declare module ts {
|
||||
SetAccessorExcludes = 74687,
|
||||
TypeParameterExcludes = 530912,
|
||||
TypeAliasExcludes = 793056,
|
||||
ImportExcludes = 8388608,
|
||||
AliasExcludes = 8388608,
|
||||
ModuleMember = 8914931,
|
||||
ExportHasLocal = 944,
|
||||
HasLocals = 255504,
|
||||
@@ -949,8 +1027,9 @@ declare module ts {
|
||||
declaredType?: Type;
|
||||
mapper?: TypeMapper;
|
||||
referenced?: boolean;
|
||||
exportAssignSymbol?: Symbol;
|
||||
unionType?: UnionType;
|
||||
resolvedExports?: SymbolTable;
|
||||
exportsChecked?: boolean;
|
||||
}
|
||||
interface TransientSymbol extends Symbol, SymbolLinks {
|
||||
}
|
||||
@@ -966,6 +1045,8 @@ declare module ts {
|
||||
SuperStatic = 32,
|
||||
ContextChecked = 64,
|
||||
EnumValuesComputed = 128,
|
||||
BlockScopedBindingInLoop = 256,
|
||||
EmitDecorate = 512,
|
||||
}
|
||||
interface NodeLinks {
|
||||
resolvedType?: Type;
|
||||
@@ -975,7 +1056,8 @@ declare module ts {
|
||||
enumMemberValue?: number;
|
||||
isIllegalTypeReferenceInConstraint?: boolean;
|
||||
isVisible?: boolean;
|
||||
localModuleName?: string;
|
||||
generatedName?: string;
|
||||
generatedNames?: Map<string>;
|
||||
assignmentChecks?: Map<boolean>;
|
||||
hasReportedStatementInAmbientContext?: boolean;
|
||||
importOnRightSide?: Symbol;
|
||||
@@ -1084,17 +1166,6 @@ declare module ts {
|
||||
interface TypeMapper {
|
||||
(t: Type): Type;
|
||||
}
|
||||
interface TypeInferences {
|
||||
primary: Type[];
|
||||
secondary: Type[];
|
||||
}
|
||||
interface InferenceContext {
|
||||
typeParameters: TypeParameter[];
|
||||
inferUnionTypes: boolean;
|
||||
inferences: TypeInferences[];
|
||||
inferredTypes: Type[];
|
||||
failedTypeParameterIndex?: number;
|
||||
}
|
||||
interface DiagnosticMessage {
|
||||
key: string;
|
||||
category: DiagnosticCategory;
|
||||
@@ -1122,7 +1193,6 @@ declare module ts {
|
||||
interface CompilerOptions {
|
||||
allowNonTsExtensions?: boolean;
|
||||
charset?: string;
|
||||
codepage?: number;
|
||||
declaration?: boolean;
|
||||
diagnostics?: boolean;
|
||||
emitBOM?: boolean;
|
||||
@@ -1136,7 +1206,6 @@ declare module ts {
|
||||
noErrorTruncation?: boolean;
|
||||
noImplicitAny?: boolean;
|
||||
noLib?: boolean;
|
||||
noLibCheck?: boolean;
|
||||
noResolve?: boolean;
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
@@ -1149,7 +1218,7 @@ declare module ts {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
separateCompilation?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
@@ -1341,6 +1410,7 @@ declare module ts {
|
||||
getTokenPos(): number;
|
||||
getTokenText(): string;
|
||||
getTokenValue(): string;
|
||||
hasExtendedUnicodeEscape(): boolean;
|
||||
hasPrecedingLineBreak(): boolean;
|
||||
isIdentifier(): boolean;
|
||||
isReservedWord(): boolean;
|
||||
@@ -1389,13 +1459,31 @@ declare module ts {
|
||||
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
|
||||
}
|
||||
declare module ts {
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
||||
/** The version of the TypeScript compiler release */
|
||||
let version: string;
|
||||
function findConfigFile(searchPath: string): string;
|
||||
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
}
|
||||
declare module ts {
|
||||
var servicesVersion: string;
|
||||
/**
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
*/
|
||||
function readConfigFile(fileName: string): any;
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
|
||||
}
|
||||
declare module ts {
|
||||
/** The version of the language service API */
|
||||
let servicesVersion: string;
|
||||
interface Node {
|
||||
getSourceFile(): SourceFile;
|
||||
getChildCount(sourceFile?: SourceFile): number;
|
||||
@@ -1437,9 +1525,6 @@ declare module ts {
|
||||
getDocumentationComment(): SymbolDisplayPart[];
|
||||
}
|
||||
interface SourceFile {
|
||||
version: string;
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
@@ -1505,6 +1590,7 @@ declare module ts {
|
||||
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
findReferences(fileName: string, position: number): ReferencedSymbol[];
|
||||
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
|
||||
getNavigationBarItems(fileName: string): NavigationBarItem[];
|
||||
getOutliningSpans(fileName: string): OutliningSpan[];
|
||||
@@ -1560,6 +1646,7 @@ declare module ts {
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
matchKind: string;
|
||||
isCaseSensitive: boolean;
|
||||
fileName: string;
|
||||
textSpan: TextSpan;
|
||||
containerName: string;
|
||||
@@ -1590,6 +1677,10 @@ declare module ts {
|
||||
containerKind: string;
|
||||
containerName: string;
|
||||
}
|
||||
interface ReferencedSymbol {
|
||||
definition: DefinitionInfo;
|
||||
references: ReferenceEntry[];
|
||||
}
|
||||
enum SymbolDisplayPartKind {
|
||||
aliasName = 0,
|
||||
className = 1,
|
||||
@@ -1792,25 +1883,17 @@ declare module ts {
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
* Note: It is not allowed to call update on a SourceFile that was not acquired from this
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
* @parm scriptSnapshot Text of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
||||
* was not found in the registry and a new one was created.
|
||||
* @param scriptSnapshot Text of the file.
|
||||
* @param version Current version of the file.
|
||||
*/
|
||||
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
@@ -1891,8 +1974,9 @@ declare module ts {
|
||||
isCancellationRequested(): boolean;
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
var disableIncrementalParsing: boolean;
|
||||
let disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
function createDocumentRegistry(): DocumentRegistry;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
||||
|
||||
+11120
-6638
File diff suppressed because it is too large
Load Diff
Vendored
+96
-24
@@ -41,6 +41,10 @@ declare module ts {
|
||||
*/
|
||||
function lastOrUndefined<T>(array: T[]): T;
|
||||
function binarySearch(array: number[], value: number): number;
|
||||
function reduceLeft<T>(array: T[], f: (a: T, x: T) => T): T;
|
||||
function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
|
||||
function reduceRight<T>(array: T[], f: (a: T, x: T) => T): T;
|
||||
function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
|
||||
function hasProperty<T>(map: Map<T>, key: string): boolean;
|
||||
function getProperty<T>(map: Map<T>, key: string): T;
|
||||
function isEmpty<T>(map: Map<T>): boolean;
|
||||
@@ -49,7 +53,6 @@ declare module ts {
|
||||
function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U;
|
||||
function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U;
|
||||
function lookUp<T>(map: Map<T>, key: string): T;
|
||||
function mapToArray<T>(map: Map<T>): T[];
|
||||
function copyMap<T>(source: Map<T>, target: Map<T>): void;
|
||||
/**
|
||||
* Creates a map from the elements of an array.
|
||||
@@ -62,7 +65,7 @@ declare module ts {
|
||||
* index in the array will be the one associated with the produced key.
|
||||
*/
|
||||
function arrayToMap<T>(array: T[], makeKey: (value: T) => string): Map<T>;
|
||||
var localizedDiagnosticMessages: Map<string>;
|
||||
let localizedDiagnosticMessages: Map<string>;
|
||||
function getLocaleSpecificMessage(message: string): string;
|
||||
function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
@@ -74,7 +77,7 @@ declare module ts {
|
||||
function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[];
|
||||
function normalizeSlashes(path: string): string;
|
||||
function getRootLength(path: string): number;
|
||||
var directorySeparator: string;
|
||||
let directorySeparator: string;
|
||||
function normalizePath(path: string): string;
|
||||
function getDirectoryPath(path: string): string;
|
||||
function isUrl(path: string): boolean;
|
||||
@@ -87,12 +90,6 @@ declare module ts {
|
||||
function combinePaths(path1: string, path2: string): string;
|
||||
function fileExtensionIs(path: string, extension: string): boolean;
|
||||
function removeFileExtension(path: string): string;
|
||||
/**
|
||||
* Based heavily on the abstract 'Quote' operation from ECMA-262 (24.3.2.2),
|
||||
* but augmented for a few select characters.
|
||||
* Note that this doesn't actually wrap the input in double quotes.
|
||||
*/
|
||||
function escapeString(s: string): string;
|
||||
function getDefaultLibFileName(options: CompilerOptions): string;
|
||||
interface ObjectAllocator {
|
||||
getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
@@ -100,7 +97,7 @@ declare module ts {
|
||||
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
|
||||
getSignatureConstructor(): new (checker: TypeChecker) => Signature;
|
||||
}
|
||||
var objectAllocator: ObjectAllocator;
|
||||
let objectAllocator: ObjectAllocator;
|
||||
const enum AssertionLevel {
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
@@ -143,6 +140,11 @@ declare module ts {
|
||||
diagnosticMessage?: DiagnosticMessage;
|
||||
isNoDefaultLib?: boolean;
|
||||
}
|
||||
interface SynthesizedNode extends Node {
|
||||
leadingCommentRanges?: CommentRange[];
|
||||
trailingCommentRanges?: CommentRange[];
|
||||
startsOnNewLine: boolean;
|
||||
}
|
||||
function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration;
|
||||
interface StringSymbolWriter extends SymbolWriter {
|
||||
string(): string;
|
||||
@@ -170,10 +172,14 @@ declare module ts {
|
||||
function getTextOfNode(node: Node): string;
|
||||
function escapeIdentifier(identifier: string): string;
|
||||
function unescapeIdentifier(identifier: string): string;
|
||||
function makeIdentifierFromModuleName(moduleName: string): string;
|
||||
function isBlockOrCatchScoped(declaration: Declaration): boolean;
|
||||
function getEnclosingBlockScopeContainer(node: Node): Node;
|
||||
function isCatchClauseVariableDeclaration(declaration: Declaration): boolean;
|
||||
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;
|
||||
function getErrorSpanForNode(node: Node): Node;
|
||||
function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan;
|
||||
function isExternalModule(file: SourceFile): boolean;
|
||||
function isDeclarationFile(file: SourceFile): boolean;
|
||||
function isConstEnumDeclaration(node: Node): boolean;
|
||||
@@ -181,22 +187,27 @@ declare module ts {
|
||||
function isConst(node: Node): boolean;
|
||||
function isLet(node: Node): boolean;
|
||||
function isPrologueDirective(node: Node): boolean;
|
||||
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile): CommentRange[];
|
||||
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
|
||||
function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
|
||||
var fullTripleSlashReferencePathRegEx: RegExp;
|
||||
let fullTripleSlashReferencePathRegEx: RegExp;
|
||||
function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T;
|
||||
function isAnyFunction(node: Node): boolean;
|
||||
function isFunctionLike(node: Node): boolean;
|
||||
function isFunctionBlock(node: Node): boolean;
|
||||
function isObjectLiteralMethod(node: Node): boolean;
|
||||
function getContainingFunction(node: Node): FunctionLikeDeclaration;
|
||||
function getThisContainer(node: Node, includeArrowFunctions: boolean): Node;
|
||||
function getSuperContainer(node: Node, includeFunctions: boolean): Node;
|
||||
function getInvokedExpression(node: CallLikeExpression): Expression;
|
||||
function nodeCanBeDecorated(node: Node): boolean;
|
||||
function nodeIsDecorated(node: Node): boolean;
|
||||
function childIsDecorated(node: Node): boolean;
|
||||
function nodeOrChildIsDecorated(node: Node): boolean;
|
||||
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;
|
||||
@@ -207,10 +218,12 @@ declare module ts {
|
||||
function isInAmbientContext(node: Node): boolean;
|
||||
function isDeclaration(node: Node): boolean;
|
||||
function isStatement(n: Node): boolean;
|
||||
function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean;
|
||||
function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode;
|
||||
function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray<TypeReferenceNode>;
|
||||
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<TypeReferenceNode>;
|
||||
function isClassElement(n: Node): boolean;
|
||||
function isDeclarationName(name: Node): boolean;
|
||||
function isAliasSymbolDeclaration(node: Node): boolean;
|
||||
function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration): HeritageClauseElement;
|
||||
function getClassImplementsHeritageClauseElements(node: ClassDeclaration): NodeArray<HeritageClauseElement>;
|
||||
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<HeritageClauseElement>;
|
||||
function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind): HeritageClause;
|
||||
function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile;
|
||||
function getAncestor(node: Node, kind: SyntaxKind): Node;
|
||||
@@ -253,7 +266,7 @@ declare module ts {
|
||||
function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
|
||||
function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
|
||||
function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
|
||||
var unchangedTextChangeRange: TextChangeRange;
|
||||
let unchangedTextChangeRange: TextChangeRange;
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
@@ -263,11 +276,64 @@ declare module ts {
|
||||
* Vn.
|
||||
*/
|
||||
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
function nodeStartsNewLexicalEnvironment(n: Node): boolean;
|
||||
function nodeIsSynthesized(node: Node): boolean;
|
||||
function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node;
|
||||
/**
|
||||
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
|
||||
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
|
||||
* Note that this doesn't actually wrap the input in double quotes.
|
||||
*/
|
||||
function escapeString(s: string): string;
|
||||
function escapeNonAsciiCharacters(s: string): string;
|
||||
interface EmitTextWriter {
|
||||
write(s: string): void;
|
||||
writeTextOfNode(sourceFile: SourceFile, node: Node): void;
|
||||
writeLine(): void;
|
||||
increaseIndent(): void;
|
||||
decreaseIndent(): void;
|
||||
getText(): string;
|
||||
rawWrite(s: string): void;
|
||||
writeLiteral(s: string): void;
|
||||
getTextPos(): number;
|
||||
getLine(): number;
|
||||
getColumn(): number;
|
||||
getIndent(): number;
|
||||
}
|
||||
function getIndentString(level: number): string;
|
||||
function getIndentSize(): number;
|
||||
function createTextWriter(newLine: String): EmitTextWriter;
|
||||
function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string;
|
||||
function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string;
|
||||
function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean): void;
|
||||
function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number;
|
||||
function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration;
|
||||
function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean;
|
||||
function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration): {
|
||||
firstAccessor: AccessorDeclaration;
|
||||
secondAccessor: AccessorDeclaration;
|
||||
getAccessor: AccessorDeclaration;
|
||||
setAccessor: AccessorDeclaration;
|
||||
};
|
||||
function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void;
|
||||
function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void): void;
|
||||
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string): void;
|
||||
function isSupportedHeritageClauseElement(node: HeritageClauseElement): boolean;
|
||||
function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean;
|
||||
function getLocalSymbolForExportDefault(symbol: Symbol): Symbol;
|
||||
}
|
||||
declare module ts {
|
||||
var optionDeclarations: CommandLineOption[];
|
||||
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
|
||||
/**
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
*/
|
||||
function readConfigFile(fileName: string): any;
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
|
||||
}
|
||||
declare module ts {
|
||||
@@ -282,7 +348,10 @@ declare module ts {
|
||||
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
|
||||
function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean;
|
||||
function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean;
|
||||
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean;
|
||||
function isCompletedNode(n: Node, sourceFile: SourceFile): boolean;
|
||||
function findListItemInfo(node: Node): ListItemInfo;
|
||||
function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean;
|
||||
function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node;
|
||||
function findContainingList(node: Node): Node;
|
||||
function getTouchingWord(sourceFile: SourceFile, position: number): Node;
|
||||
@@ -305,9 +374,11 @@ declare module ts {
|
||||
function getNodeModifiers(node: Node): string;
|
||||
function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node>;
|
||||
function isToken(n: Node): boolean;
|
||||
function isWord(kind: SyntaxKind): boolean;
|
||||
function isComment(kind: SyntaxKind): boolean;
|
||||
function isPunctuation(kind: SyntaxKind): boolean;
|
||||
function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean;
|
||||
function isAccessibilityModifier(kind: SyntaxKind): boolean;
|
||||
function compareDataObjects(dst: any, src: any): boolean;
|
||||
}
|
||||
declare module ts {
|
||||
@@ -318,6 +389,7 @@ declare module ts {
|
||||
function keywordPart(kind: SyntaxKind): SymbolDisplayPart;
|
||||
function punctuationPart(kind: SyntaxKind): SymbolDisplayPart;
|
||||
function operatorPart(kind: SyntaxKind): SymbolDisplayPart;
|
||||
function textOrKeywordPart(text: string): SymbolDisplayPart;
|
||||
function textPart(text: string): SymbolDisplayPart;
|
||||
function lineBreakPart(): SymbolDisplayPart;
|
||||
function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[];
|
||||
|
||||
Vendored
+96
-24
@@ -41,6 +41,10 @@ declare module "typescript" {
|
||||
*/
|
||||
function lastOrUndefined<T>(array: T[]): T;
|
||||
function binarySearch(array: number[], value: number): number;
|
||||
function reduceLeft<T>(array: T[], f: (a: T, x: T) => T): T;
|
||||
function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
|
||||
function reduceRight<T>(array: T[], f: (a: T, x: T) => T): T;
|
||||
function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
|
||||
function hasProperty<T>(map: Map<T>, key: string): boolean;
|
||||
function getProperty<T>(map: Map<T>, key: string): T;
|
||||
function isEmpty<T>(map: Map<T>): boolean;
|
||||
@@ -49,7 +53,6 @@ declare module "typescript" {
|
||||
function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U;
|
||||
function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U;
|
||||
function lookUp<T>(map: Map<T>, key: string): T;
|
||||
function mapToArray<T>(map: Map<T>): T[];
|
||||
function copyMap<T>(source: Map<T>, target: Map<T>): void;
|
||||
/**
|
||||
* Creates a map from the elements of an array.
|
||||
@@ -62,7 +65,7 @@ declare module "typescript" {
|
||||
* index in the array will be the one associated with the produced key.
|
||||
*/
|
||||
function arrayToMap<T>(array: T[], makeKey: (value: T) => string): Map<T>;
|
||||
var localizedDiagnosticMessages: Map<string>;
|
||||
let localizedDiagnosticMessages: Map<string>;
|
||||
function getLocaleSpecificMessage(message: string): string;
|
||||
function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
@@ -74,7 +77,7 @@ declare module "typescript" {
|
||||
function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[];
|
||||
function normalizeSlashes(path: string): string;
|
||||
function getRootLength(path: string): number;
|
||||
var directorySeparator: string;
|
||||
let directorySeparator: string;
|
||||
function normalizePath(path: string): string;
|
||||
function getDirectoryPath(path: string): string;
|
||||
function isUrl(path: string): boolean;
|
||||
@@ -87,12 +90,6 @@ declare module "typescript" {
|
||||
function combinePaths(path1: string, path2: string): string;
|
||||
function fileExtensionIs(path: string, extension: string): boolean;
|
||||
function removeFileExtension(path: string): string;
|
||||
/**
|
||||
* Based heavily on the abstract 'Quote' operation from ECMA-262 (24.3.2.2),
|
||||
* but augmented for a few select characters.
|
||||
* Note that this doesn't actually wrap the input in double quotes.
|
||||
*/
|
||||
function escapeString(s: string): string;
|
||||
function getDefaultLibFileName(options: CompilerOptions): string;
|
||||
interface ObjectAllocator {
|
||||
getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
@@ -100,7 +97,7 @@ declare module "typescript" {
|
||||
getTypeConstructor(): new (checker: TypeChecker, flags: TypeFlags) => Type;
|
||||
getSignatureConstructor(): new (checker: TypeChecker) => Signature;
|
||||
}
|
||||
var objectAllocator: ObjectAllocator;
|
||||
let objectAllocator: ObjectAllocator;
|
||||
const enum AssertionLevel {
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
@@ -143,6 +140,11 @@ declare module "typescript" {
|
||||
diagnosticMessage?: DiagnosticMessage;
|
||||
isNoDefaultLib?: boolean;
|
||||
}
|
||||
interface SynthesizedNode extends Node {
|
||||
leadingCommentRanges?: CommentRange[];
|
||||
trailingCommentRanges?: CommentRange[];
|
||||
startsOnNewLine: boolean;
|
||||
}
|
||||
function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration;
|
||||
interface StringSymbolWriter extends SymbolWriter {
|
||||
string(): string;
|
||||
@@ -170,10 +172,14 @@ declare module "typescript" {
|
||||
function getTextOfNode(node: Node): string;
|
||||
function escapeIdentifier(identifier: string): string;
|
||||
function unescapeIdentifier(identifier: string): string;
|
||||
function makeIdentifierFromModuleName(moduleName: string): string;
|
||||
function isBlockOrCatchScoped(declaration: Declaration): boolean;
|
||||
function getEnclosingBlockScopeContainer(node: Node): Node;
|
||||
function isCatchClauseVariableDeclaration(declaration: Declaration): boolean;
|
||||
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;
|
||||
function getErrorSpanForNode(node: Node): Node;
|
||||
function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan;
|
||||
function isExternalModule(file: SourceFile): boolean;
|
||||
function isDeclarationFile(file: SourceFile): boolean;
|
||||
function isConstEnumDeclaration(node: Node): boolean;
|
||||
@@ -181,22 +187,27 @@ declare module "typescript" {
|
||||
function isConst(node: Node): boolean;
|
||||
function isLet(node: Node): boolean;
|
||||
function isPrologueDirective(node: Node): boolean;
|
||||
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile): CommentRange[];
|
||||
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
|
||||
function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
|
||||
var fullTripleSlashReferencePathRegEx: RegExp;
|
||||
let fullTripleSlashReferencePathRegEx: RegExp;
|
||||
function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T;
|
||||
function isAnyFunction(node: Node): boolean;
|
||||
function isFunctionLike(node: Node): boolean;
|
||||
function isFunctionBlock(node: Node): boolean;
|
||||
function isObjectLiteralMethod(node: Node): boolean;
|
||||
function getContainingFunction(node: Node): FunctionLikeDeclaration;
|
||||
function getThisContainer(node: Node, includeArrowFunctions: boolean): Node;
|
||||
function getSuperContainer(node: Node, includeFunctions: boolean): Node;
|
||||
function getInvokedExpression(node: CallLikeExpression): Expression;
|
||||
function nodeCanBeDecorated(node: Node): boolean;
|
||||
function nodeIsDecorated(node: Node): boolean;
|
||||
function childIsDecorated(node: Node): boolean;
|
||||
function nodeOrChildIsDecorated(node: Node): boolean;
|
||||
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;
|
||||
@@ -207,10 +218,12 @@ declare module "typescript" {
|
||||
function isInAmbientContext(node: Node): boolean;
|
||||
function isDeclaration(node: Node): boolean;
|
||||
function isStatement(n: Node): boolean;
|
||||
function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean;
|
||||
function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode;
|
||||
function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray<TypeReferenceNode>;
|
||||
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<TypeReferenceNode>;
|
||||
function isClassElement(n: Node): boolean;
|
||||
function isDeclarationName(name: Node): boolean;
|
||||
function isAliasSymbolDeclaration(node: Node): boolean;
|
||||
function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration): HeritageClauseElement;
|
||||
function getClassImplementsHeritageClauseElements(node: ClassDeclaration): NodeArray<HeritageClauseElement>;
|
||||
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<HeritageClauseElement>;
|
||||
function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind): HeritageClause;
|
||||
function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile;
|
||||
function getAncestor(node: Node, kind: SyntaxKind): Node;
|
||||
@@ -253,7 +266,7 @@ declare module "typescript" {
|
||||
function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
|
||||
function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
|
||||
function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
|
||||
var unchangedTextChangeRange: TextChangeRange;
|
||||
let unchangedTextChangeRange: TextChangeRange;
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
@@ -263,11 +276,64 @@ declare module "typescript" {
|
||||
* Vn.
|
||||
*/
|
||||
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
function nodeStartsNewLexicalEnvironment(n: Node): boolean;
|
||||
function nodeIsSynthesized(node: Node): boolean;
|
||||
function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node;
|
||||
/**
|
||||
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
|
||||
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
|
||||
* Note that this doesn't actually wrap the input in double quotes.
|
||||
*/
|
||||
function escapeString(s: string): string;
|
||||
function escapeNonAsciiCharacters(s: string): string;
|
||||
interface EmitTextWriter {
|
||||
write(s: string): void;
|
||||
writeTextOfNode(sourceFile: SourceFile, node: Node): void;
|
||||
writeLine(): void;
|
||||
increaseIndent(): void;
|
||||
decreaseIndent(): void;
|
||||
getText(): string;
|
||||
rawWrite(s: string): void;
|
||||
writeLiteral(s: string): void;
|
||||
getTextPos(): number;
|
||||
getLine(): number;
|
||||
getColumn(): number;
|
||||
getIndent(): number;
|
||||
}
|
||||
function getIndentString(level: number): string;
|
||||
function getIndentSize(): number;
|
||||
function createTextWriter(newLine: String): EmitTextWriter;
|
||||
function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string;
|
||||
function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string;
|
||||
function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean): void;
|
||||
function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number;
|
||||
function getFirstConstructorWithBody(node: ClassLikeDeclaration): ConstructorDeclaration;
|
||||
function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean;
|
||||
function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration): {
|
||||
firstAccessor: AccessorDeclaration;
|
||||
secondAccessor: AccessorDeclaration;
|
||||
getAccessor: AccessorDeclaration;
|
||||
setAccessor: AccessorDeclaration;
|
||||
};
|
||||
function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void;
|
||||
function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void): void;
|
||||
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string): void;
|
||||
function isSupportedHeritageClauseElement(node: HeritageClauseElement): boolean;
|
||||
function isRightSideOfQualifiedNameOrPropertyAccess(node: Node): boolean;
|
||||
function getLocalSymbolForExportDefault(symbol: Symbol): Symbol;
|
||||
}
|
||||
declare module "typescript" {
|
||||
var optionDeclarations: CommandLineOption[];
|
||||
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
|
||||
/**
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
*/
|
||||
function readConfigFile(fileName: string): any;
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
|
||||
}
|
||||
declare module "typescript" {
|
||||
@@ -282,7 +348,10 @@ declare module "typescript" {
|
||||
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
|
||||
function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean;
|
||||
function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean;
|
||||
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean;
|
||||
function isCompletedNode(n: Node, sourceFile: SourceFile): boolean;
|
||||
function findListItemInfo(node: Node): ListItemInfo;
|
||||
function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean;
|
||||
function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node;
|
||||
function findContainingList(node: Node): Node;
|
||||
function getTouchingWord(sourceFile: SourceFile, position: number): Node;
|
||||
@@ -305,9 +374,11 @@ declare module "typescript" {
|
||||
function getNodeModifiers(node: Node): string;
|
||||
function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node>;
|
||||
function isToken(n: Node): boolean;
|
||||
function isWord(kind: SyntaxKind): boolean;
|
||||
function isComment(kind: SyntaxKind): boolean;
|
||||
function isPunctuation(kind: SyntaxKind): boolean;
|
||||
function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean;
|
||||
function isAccessibilityModifier(kind: SyntaxKind): boolean;
|
||||
function compareDataObjects(dst: any, src: any): boolean;
|
||||
}
|
||||
declare module "typescript" {
|
||||
@@ -318,6 +389,7 @@ declare module "typescript" {
|
||||
function keywordPart(kind: SyntaxKind): SymbolDisplayPart;
|
||||
function punctuationPart(kind: SyntaxKind): SymbolDisplayPart;
|
||||
function operatorPart(kind: SyntaxKind): SymbolDisplayPart;
|
||||
function textOrKeywordPart(text: string): SymbolDisplayPart;
|
||||
function textPart(text: string): SymbolDisplayPart;
|
||||
function lineBreakPart(): SymbolDisplayPart;
|
||||
function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[];
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+1
-1
@@ -545,7 +545,7 @@ class CheckingAccount extends BankAccount {
|
||||
}
|
||||
```
|
||||
|
||||
In this example, the class 'CheckingAccount' *derives* from class 'BankAccount'. The constructor for 'CheckingAccount' calls the constructor for class 'BankAccount' using the 'super' keyword. In the emitted JavaScript code, the prototype of 'CheckingAccount' will chain to the prototype of 'BankingAccount'.
|
||||
In this example, the class 'CheckingAccount' *derives* from class 'BankAccount'. The constructor for 'CheckingAccount' calls the constructor for class 'BankAccount' using the 'super' keyword. In the emitted JavaScript code, the prototype of 'CheckingAccount' will chain to the prototype of 'BankAccount'.
|
||||
|
||||
TypeScript classes may also specify static members. Static class members become properties of the class constructor.
|
||||
|
||||
|
||||
+2
-3
@@ -38,10 +38,9 @@
|
||||
"mocha": "latest",
|
||||
"chai": "latest",
|
||||
"browserify": "latest",
|
||||
"istanbul": "latest",
|
||||
"codeclimate-test-reporter": "latest"
|
||||
"istanbul": "latest"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jake generate-code-coverage"
|
||||
"test": "jake runtests"
|
||||
}
|
||||
}
|
||||
|
||||
+32
-6
@@ -2,7 +2,7 @@
|
||||
.SYNOPSIS
|
||||
Run this PowerShell script to enable dev mode and/or a custom script for the TypeScript language service, e.g.
|
||||
|
||||
PS C:\> .\scripts\VSDevMode.ps1 -enableDevMode -tsScript C:\src\TypeScript\built\local\typescriptServices.js
|
||||
PS C:\> .\scripts\VSDevMode.ps1 -enableDevMode -tsScript C:\src\TypeScript\built\local\
|
||||
|
||||
Note: If you get security errors, try running powershell as an Administrator and with the "-executionPolicy remoteSigned" switch
|
||||
|
||||
@@ -13,7 +13,7 @@ Set to "12" for Dev12 (VS2013) or "14" (the default) for Dev14 (VS2015)
|
||||
Pass this switch to enable attaching a debugger to the language service
|
||||
|
||||
.PARAMETER tsScript
|
||||
The path to a custom language service script to use, e.g. "C:\src\TypeScript\built\local\typescriptServices.js"
|
||||
The path to a directory containing a custom language service script to use (typescriptServices.js), e.g. "C:\src\TypeScript\built\local\"
|
||||
#>
|
||||
Param(
|
||||
[int]$vsVersion = 14,
|
||||
@@ -37,12 +37,38 @@ if(!(Test-Path $tsRegKey)){
|
||||
}
|
||||
|
||||
if($tsScript -ne ""){
|
||||
if(!(Test-Path $tsScript)){
|
||||
Throw "Could not locate the TypeScript language service script at ${tsScript}"
|
||||
$tsScriptServices = "${tsScript}\typescriptServices.js"
|
||||
$tsScriptlib = "${tsScript}\lib.d.ts"
|
||||
$tsES6Scriptlib = "${tsScript}\lib.es6.d.ts"
|
||||
|
||||
if(!(Test-Path $tsScriptServices)){
|
||||
Throw "Could not locate the TypeScript language service script at ${tsScriptServices}"
|
||||
}
|
||||
else {
|
||||
$path = resolve-path ${tsScriptServices}
|
||||
Set-ItemProperty -path $tsRegKey -name CustomTypeScriptServicesFileLocation -value "${path}"
|
||||
Write-Host "Enabled custom TypeScript language service at ${path} for Dev${vsVersion}"
|
||||
}
|
||||
|
||||
if(!(Test-Path $tsScriptlib)){
|
||||
Throw "Could not locate the TypeScript default library at ${tsScriptlib}"
|
||||
}
|
||||
else {
|
||||
$path = resolve-path ${tsScriptlib}
|
||||
Set-ItemProperty -path $tsRegKey -name CustomDefaultLibraryLocation -value "${path}"
|
||||
Write-Host "Enabled custom TypeScript default library at ${path} for Dev${vsVersion}"
|
||||
}
|
||||
|
||||
if(!(Test-Path $tsES6Scriptlib)){
|
||||
Throw "Could not locate the TypeScript default ES6 library at ${tsES6Scriptlib}"
|
||||
}
|
||||
else {
|
||||
$path = resolve-path ${tsES6Scriptlib}
|
||||
Set-ItemProperty -path $tsRegKey -name CustomDefaultES6LibraryLocation -value "${path}"
|
||||
Write-Host "Enabled custom TypeScript default ES6 library at ${path} for Dev${vsVersion}"
|
||||
}
|
||||
Set-ItemProperty -path $tsRegKey -name CustomTypeScriptServicesFileLocation -value "${tsScript}"
|
||||
Write-Host "Enabled custom TypeScript language service at ${tsScript} for Dev${vsVersion}"
|
||||
}
|
||||
|
||||
if($enableDevMode){
|
||||
Set-ItemProperty -path $tsRegKey -name EnableDevMode -value 1
|
||||
Write-Host "Enabled developer mode for Dev${vsVersion}"
|
||||
|
||||
@@ -65,8 +65,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
|
||||
' ' + convertPropertyName(nameMap[name]) +
|
||||
': { code: ' + diagnosticDetails.code +
|
||||
', category: DiagnosticCategory.' + diagnosticDetails.category +
|
||||
', key: "' + name.replace('"', '\\"') + '"' +
|
||||
(diagnosticDetails.isEarly ? ', isEarly: true' : '') +
|
||||
', key: "' + name.replace(/[\"]/g, '\\"') + '"' +
|
||||
' },\r\n';
|
||||
}
|
||||
|
||||
|
||||
+140
-79
@@ -1,7 +1,7 @@
|
||||
/// <reference path="parser.ts"/>
|
||||
|
||||
module ts {
|
||||
/* @internal */ export var bindTime = 0;
|
||||
/* @internal */ export let bindTime = 0;
|
||||
|
||||
export const enum ModuleInstanceState {
|
||||
NonInstantiated = 0,
|
||||
@@ -25,7 +25,7 @@ module ts {
|
||||
}
|
||||
// 4. other uninstantiated module declarations.
|
||||
else if (node.kind === SyntaxKind.ModuleBlock) {
|
||||
var state = ModuleInstanceState.NonInstantiated;
|
||||
let state = ModuleInstanceState.NonInstantiated;
|
||||
forEachChild(node, n => {
|
||||
switch (getModuleInstanceState(n)) {
|
||||
case ModuleInstanceState.NonInstantiated:
|
||||
@@ -52,22 +52,23 @@ module ts {
|
||||
}
|
||||
|
||||
export function bindSourceFile(file: SourceFile): void {
|
||||
var start = new Date().getTime();
|
||||
let start = new Date().getTime();
|
||||
bindSourceFileWorker(file);
|
||||
bindTime += new Date().getTime() - start;
|
||||
}
|
||||
|
||||
function bindSourceFileWorker(file: SourceFile): void {
|
||||
var parent: Node;
|
||||
var container: Node;
|
||||
var blockScopeContainer: Node;
|
||||
var lastContainer: Node;
|
||||
var symbolCount = 0;
|
||||
var Symbol = objectAllocator.getSymbolConstructor();
|
||||
let parent: Node;
|
||||
let container: Node;
|
||||
let blockScopeContainer: Node;
|
||||
let lastContainer: Node;
|
||||
let symbolCount = 0;
|
||||
let Symbol = objectAllocator.getSymbolConstructor();
|
||||
|
||||
if (!file.locals) {
|
||||
file.locals = {};
|
||||
container = blockScopeContainer = file;
|
||||
container = file;
|
||||
setBlockScopeContainer(file, /*cleanLocals*/ false);
|
||||
bind(file);
|
||||
file.symbolCount = symbolCount;
|
||||
}
|
||||
@@ -77,6 +78,13 @@ module ts {
|
||||
return new Symbol(flags, name);
|
||||
}
|
||||
|
||||
function setBlockScopeContainer(node: Node, cleanLocals: boolean) {
|
||||
blockScopeContainer = node;
|
||||
if (cleanLocals) {
|
||||
blockScopeContainer.locals = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolKind: SymbolFlags) {
|
||||
symbol.flags |= symbolKind;
|
||||
if (!symbol.declarations) symbol.declarations = [];
|
||||
@@ -95,7 +103,7 @@ module ts {
|
||||
return '"' + (<LiteralExpression>node.name).text + '"';
|
||||
}
|
||||
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
var nameExpression = (<ComputedPropertyName>node.name).expression;
|
||||
let nameExpression = (<ComputedPropertyName>node.name).expression;
|
||||
Debug.assert(isWellKnownSymbolSyntactically(nameExpression));
|
||||
return getPropertyNameForKnownSymbolName((<PropertyAccessExpression>nameExpression).name.text);
|
||||
}
|
||||
@@ -112,6 +120,13 @@ module ts {
|
||||
return "__new";
|
||||
case SyntaxKind.IndexSignature:
|
||||
return "__index";
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return "__export";
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return (<ExportAssignment>node).isExportEquals ? "export=" : "default";
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return node.flags & NodeFlags.Default ? "default" : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,9 +137,12 @@ module ts {
|
||||
function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
|
||||
var name = getDeclarationName(node);
|
||||
// The exported symbol for an export default function/class node is always named "default"
|
||||
let name = node.flags & NodeFlags.Default && parent ? "default" : getDeclarationName(node);
|
||||
|
||||
let symbol: Symbol;
|
||||
if (name !== undefined) {
|
||||
var symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name));
|
||||
symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name));
|
||||
if (symbol.flags & excludes) {
|
||||
if (node.name) {
|
||||
node.name.parent = node;
|
||||
@@ -132,14 +150,14 @@ module ts {
|
||||
|
||||
// Report errors every position with duplicate declaration
|
||||
// Report errors on previous encountered declarations
|
||||
var message = symbol.flags & SymbolFlags.BlockScopedVariable
|
||||
let message = symbol.flags & SymbolFlags.BlockScopedVariable
|
||||
? Diagnostics.Cannot_redeclare_block_scoped_variable_0
|
||||
: Diagnostics.Duplicate_identifier_0;
|
||||
|
||||
forEach(symbol.declarations, declaration => {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(declaration.name, message, getDisplayName(declaration)));
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration)));
|
||||
});
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node.name, message, getDisplayName(node)));
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node)));
|
||||
|
||||
symbol = createSymbol(0, name);
|
||||
}
|
||||
@@ -150,12 +168,12 @@ module ts {
|
||||
addDeclarationToSymbol(symbol, node, includes);
|
||||
symbol.parent = parent;
|
||||
|
||||
if (node.kind === SyntaxKind.ClassDeclaration && symbol.exports) {
|
||||
if ((node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression) && symbol.exports) {
|
||||
// TypeScript 1.0 spec (April 2014): 8.4
|
||||
// Every class automatically contains a static property member named 'prototype',
|
||||
// the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter.
|
||||
// It is an error to explicitly declare a static property member with the name 'prototype'.
|
||||
var prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype");
|
||||
let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype");
|
||||
if (hasProperty(symbol.exports, prototypeSymbol.name)) {
|
||||
if (node.name) {
|
||||
node.name.parent = node;
|
||||
@@ -170,17 +188,9 @@ module ts {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
function isAmbientContext(node: Node): boolean {
|
||||
while (node) {
|
||||
if (node.flags & NodeFlags.Ambient) return true;
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function declareModuleMember(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) {
|
||||
var hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export;
|
||||
if (symbolKind & SymbolFlags.Import) {
|
||||
let hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export;
|
||||
if (symbolKind & SymbolFlags.Alias) {
|
||||
if (node.kind === SyntaxKind.ExportSpecifier || (node.kind === SyntaxKind.ImportEqualsDeclaration && hasExportModifier)) {
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
|
||||
}
|
||||
@@ -200,11 +210,11 @@ module ts {
|
||||
// 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) |
|
||||
if (hasExportModifier || container.flags & NodeFlags.ExportContext) {
|
||||
let 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);
|
||||
let local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
|
||||
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
|
||||
node.localSymbol = local;
|
||||
}
|
||||
@@ -221,9 +231,9 @@ module ts {
|
||||
node.locals = {};
|
||||
}
|
||||
|
||||
var saveParent = parent;
|
||||
var saveContainer = container;
|
||||
var savedBlockScopeContainer = blockScopeContainer;
|
||||
let saveParent = parent;
|
||||
let saveContainer = container;
|
||||
let savedBlockScopeContainer = blockScopeContainer;
|
||||
parent = node;
|
||||
if (symbolKind & SymbolFlags.IsContainer) {
|
||||
container = node;
|
||||
@@ -236,7 +246,13 @@ module ts {
|
||||
}
|
||||
|
||||
if (isBlockScopeContainer) {
|
||||
blockScopeContainer = node;
|
||||
// in incremental scenarios we might reuse nodes that already have locals being allocated
|
||||
// during the bind step these locals should be dropped to prevent using stale data.
|
||||
// locals should always be dropped unless they were previously initialized by the binder
|
||||
// these cases are:
|
||||
// - node has locals (symbolKind & HasLocals) !== 0
|
||||
// - node is a source file
|
||||
setBlockScopeContainer(node, /*cleanLocals*/ (symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile);
|
||||
}
|
||||
|
||||
forEachChild(node, bind);
|
||||
@@ -270,6 +286,7 @@ module ts {
|
||||
case SyntaxKind.ArrowFunction:
|
||||
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes);
|
||||
break;
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
if (node.flags & NodeFlags.Static) {
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
|
||||
@@ -287,36 +304,62 @@ module ts {
|
||||
bindChildren(node, symbolKind, isBlockScopeContainer);
|
||||
}
|
||||
|
||||
function isAmbientContext(node: Node): boolean {
|
||||
while (node) {
|
||||
if (node.flags & NodeFlags.Ambient) return true;
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean {
|
||||
var body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
|
||||
if (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock) {
|
||||
for (let stat of (<Block>body).statements) {
|
||||
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function setExportContextFlag(node: ModuleDeclaration | SourceFile) {
|
||||
// A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
|
||||
// declarations with export modifiers) is an export context in which declarations are implicitly exported.
|
||||
if (isAmbientContext(node) && !hasExportDeclarations(node)) {
|
||||
node.flags |= NodeFlags.ExportContext;
|
||||
}
|
||||
else {
|
||||
node.flags &= ~NodeFlags.ExportContext;
|
||||
}
|
||||
}
|
||||
|
||||
function bindModuleDeclaration(node: ModuleDeclaration) {
|
||||
setExportContextFlag(node);
|
||||
if (node.name.kind === SyntaxKind.StringLiteral) {
|
||||
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
|
||||
}
|
||||
else {
|
||||
var state = getModuleInstanceState(node);
|
||||
let state = getModuleInstanceState(node);
|
||||
if (state === ModuleInstanceState.NonInstantiated) {
|
||||
bindDeclaration(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes, /*isBlockScopeContainer*/ true);
|
||||
}
|
||||
else {
|
||||
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
|
||||
if (state === ModuleInstanceState.ConstEnumOnly) {
|
||||
// mark value module as module that contains only enums
|
||||
node.symbol.constEnumOnlyModule = true;
|
||||
let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly;
|
||||
if (node.symbol.constEnumOnlyModule === undefined) {
|
||||
// non-merged case - use the current state
|
||||
node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly;
|
||||
}
|
||||
else if (node.symbol.constEnumOnlyModule) {
|
||||
// const only value module was merged with instantiated module - reset flag
|
||||
node.symbol.constEnumOnlyModule = false;
|
||||
else {
|
||||
// merged case: module is const enum only if all its pieces are non-instantiated or const enum
|
||||
node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 }
|
||||
@@ -325,50 +368,48 @@ module ts {
|
||||
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
|
||||
// from an actual type literal symbol you would have gotten had you used the long form.
|
||||
|
||||
var symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node));
|
||||
let symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node));
|
||||
addDeclarationToSymbol(symbol, node, SymbolFlags.Signature);
|
||||
bindChildren(node, SymbolFlags.Signature, /*isBlockScopeContainer:*/ false);
|
||||
|
||||
var typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
|
||||
let typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
|
||||
addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral);
|
||||
typeLiteralSymbol.members = {};
|
||||
typeLiteralSymbol.members[node.kind === SyntaxKind.FunctionType ? "__call" : "__new"] = symbol
|
||||
}
|
||||
|
||||
function bindAnonymousDeclaration(node: Declaration, symbolKind: SymbolFlags, name: string, isBlockScopeContainer: boolean) {
|
||||
var symbol = createSymbol(symbolKind, name);
|
||||
let symbol = createSymbol(symbolKind, name);
|
||||
addDeclarationToSymbol(symbol, node, symbolKind);
|
||||
bindChildren(node, symbolKind, isBlockScopeContainer);
|
||||
}
|
||||
|
||||
function bindCatchVariableDeclaration(node: CatchClause) {
|
||||
var symbol = createSymbol(SymbolFlags.FunctionScopedVariable, node.name.text || "__missing");
|
||||
addDeclarationToSymbol(symbol, node, SymbolFlags.FunctionScopedVariable);
|
||||
var saveParent = parent;
|
||||
var savedBlockScopeContainer = blockScopeContainer;
|
||||
parent = blockScopeContainer = node;
|
||||
forEachChild(node, bind);
|
||||
parent = saveParent;
|
||||
blockScopeContainer = savedBlockScopeContainer;
|
||||
bindChildren(node, /*symbolKind:*/ 0, /*isBlockScopeContainer:*/ true);
|
||||
}
|
||||
|
||||
function bindBlockScopedVariableDeclaration(node: Declaration) {
|
||||
function bindBlockScopedDeclaration(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) {
|
||||
switch (blockScopeContainer.kind) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
declareModuleMember(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
|
||||
declareModuleMember(node, symbolKind, symbolExcludes);
|
||||
break;
|
||||
case SyntaxKind.SourceFile:
|
||||
if (isExternalModule(<SourceFile>container)) {
|
||||
declareModuleMember(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
|
||||
declareModuleMember(node, symbolKind, symbolExcludes);
|
||||
break;
|
||||
}
|
||||
// fall through.
|
||||
default:
|
||||
if (!blockScopeContainer.locals) {
|
||||
blockScopeContainer.locals = {};
|
||||
}
|
||||
declareSymbol(blockScopeContainer.locals, undefined, node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
|
||||
declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes);
|
||||
}
|
||||
bindChildren(node, SymbolFlags.BlockScopedVariable, /*isBlockScopeContainer*/ false);
|
||||
bindChildren(node, symbolKind, /*isBlockScopeContainer*/ false);
|
||||
}
|
||||
|
||||
function bindBlockScopedVariableDeclaration(node: Declaration) {
|
||||
bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
|
||||
}
|
||||
|
||||
function getDestructuringParameterName(node: Declaration) {
|
||||
@@ -377,6 +418,7 @@ module ts {
|
||||
|
||||
function bind(node: Node) {
|
||||
node.parent = parent;
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeParameter:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false);
|
||||
@@ -389,7 +431,7 @@ module ts {
|
||||
if (isBindingPattern((<Declaration>node).name)) {
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
|
||||
}
|
||||
else if (getCombinedNodeFlags(node) & NodeFlags.BlockScoped) {
|
||||
else if (isBlockOrCatchScoped(<Declaration>node)) {
|
||||
bindBlockScopedVariableDeclaration(<Declaration>node);
|
||||
}
|
||||
else {
|
||||
@@ -449,11 +491,14 @@ module ts {
|
||||
case SyntaxKind.ArrowFunction:
|
||||
bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, "__function", /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
case SyntaxKind.ClassExpression:
|
||||
bindAnonymousDeclaration(<ClassExpression>node, SymbolFlags.Class, "__class", /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.CatchClause:
|
||||
bindCatchVariableDeclaration(<CatchClause>node);
|
||||
break;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes, /*isBlockScopeContainer*/ false);
|
||||
bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
|
||||
break;
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false);
|
||||
@@ -476,20 +521,36 @@ module ts {
|
||||
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);
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.ImportClause:
|
||||
if ((<ImportClause>node).name) {
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Import, SymbolFlags.ImportExcludes, /*isBlockScopeContainer*/ false);
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes, /*isBlockScopeContainer*/ false);
|
||||
}
|
||||
else {
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
if (!(<ExportDeclaration>node).exportClause) {
|
||||
// All export * declarations are collected in an __export symbol
|
||||
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.ExportStar, 0);
|
||||
}
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
if ((<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
|
||||
// An export default clause with an identifier exports all meanings of that identifier
|
||||
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
|
||||
}
|
||||
else {
|
||||
// An export default clause with an expression exports a value
|
||||
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
|
||||
}
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.SourceFile:
|
||||
setExportContextFlag(<SourceFile>node);
|
||||
if (isExternalModule(<SourceFile>node)) {
|
||||
bindAnonymousDeclaration(<SourceFile>node, SymbolFlags.ValueModule, '"' + removeFileExtension((<SourceFile>node).fileName) + '"', /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
@@ -500,20 +561,20 @@ module ts {
|
||||
// Otherwise this won't be considered as redeclaration of a block scoped local:
|
||||
// function foo() {
|
||||
// let x;
|
||||
// var x;
|
||||
// let x;
|
||||
// }
|
||||
// 'var x' will be placed into the function locals and 'let x' - into the locals of the block
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ !isAnyFunction(node.parent));
|
||||
// 'let x' will be placed into the function locals and 'let x' - into the locals of the block
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ !isFunctionLike(node.parent));
|
||||
break;
|
||||
case SyntaxKind.CatchClause:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.CaseBlock:
|
||||
bindChildren(node, 0, /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
default:
|
||||
var saveParent = parent;
|
||||
let saveParent = parent;
|
||||
parent = node;
|
||||
forEachChild(node, bind);
|
||||
parent = saveParent;
|
||||
@@ -532,9 +593,9 @@ module ts {
|
||||
// containing class.
|
||||
if (node.flags & NodeFlags.AccessibilityModifier &&
|
||||
node.parent.kind === SyntaxKind.Constructor &&
|
||||
node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
(node.parent.parent.kind === SyntaxKind.ClassDeclaration || node.parent.parent.kind === SyntaxKind.ClassExpression)) {
|
||||
|
||||
var classDeclaration = <ClassDeclaration>node.parent.parent;
|
||||
let classDeclaration = <ClassLikeDeclaration>node.parent.parent;
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
}
|
||||
|
||||
+2879
-2034
File diff suppressed because it is too large
Load Diff
@@ -4,15 +4,12 @@
|
||||
/// <reference path="scanner.ts"/>
|
||||
|
||||
module ts {
|
||||
/* @internal */
|
||||
export var optionDeclarations: CommandLineOption[] = [
|
||||
{
|
||||
name: "charset",
|
||||
type: "string",
|
||||
},
|
||||
{
|
||||
name: "codepage",
|
||||
type: "number",
|
||||
},
|
||||
{
|
||||
name: "declaration",
|
||||
shortName: "d",
|
||||
@@ -78,10 +75,6 @@ module ts {
|
||||
name: "noLib",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "noLibCheck",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "noResolve",
|
||||
type: "boolean",
|
||||
@@ -117,6 +110,10 @@ module ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_emit_comments_to_output,
|
||||
},
|
||||
{
|
||||
name: "separateCompilation",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "sourceMap",
|
||||
type: "boolean",
|
||||
@@ -161,7 +158,8 @@ module ts {
|
||||
description: Diagnostics.Watch_input_files,
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
/* @internal */
|
||||
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
|
||||
var options: CompilerOptions = {};
|
||||
var fileNames: string[] = [];
|
||||
@@ -271,6 +269,10 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
*/
|
||||
export function readConfigFile(fileName: string): any {
|
||||
try {
|
||||
var text = sys.readFile(fileName);
|
||||
@@ -280,6 +282,12 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
export function parseConfigFile(json: any, basePath?: string): ParsedCommandLine {
|
||||
var errors: Diagnostic[] = [];
|
||||
|
||||
|
||||
+133
-122
@@ -25,8 +25,8 @@ module ts {
|
||||
|
||||
export function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U {
|
||||
if (array) {
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
var result = callback(array[i], i);
|
||||
for (let i = 0, len = array.length; i < len; i++) {
|
||||
let result = callback(array[i], i);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -37,8 +37,8 @@ module ts {
|
||||
|
||||
export function contains<T>(array: T[], value: T): boolean {
|
||||
if (array) {
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
if (array[i] === value) {
|
||||
for (let v of array) {
|
||||
if (v === value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ module ts {
|
||||
|
||||
export function indexOf<T>(array: T[], value: T): number {
|
||||
if (array) {
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
for (let i = 0, len = array.length; i < len; i++) {
|
||||
if (array[i] === value) {
|
||||
return i;
|
||||
}
|
||||
@@ -58,10 +58,10 @@ module ts {
|
||||
}
|
||||
|
||||
export function countWhere<T>(array: T[], predicate: (x: T) => boolean): number {
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
if (array) {
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
if (predicate(array[i])) {
|
||||
for (let v of array) {
|
||||
if (predicate(v)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -69,11 +69,11 @@ module ts {
|
||||
return count;
|
||||
}
|
||||
|
||||
export function filter<T>(array: T[], f: (x: T) => boolean): T[] {
|
||||
export function filter<T>(array: T[], f: (x: T) => boolean): T[]{
|
||||
let result: T[];
|
||||
if (array) {
|
||||
var result: T[] = [];
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
var item = array[i];
|
||||
result = [];
|
||||
for (let item of array) {
|
||||
if (f(item)) {
|
||||
result.push(item);
|
||||
}
|
||||
@@ -82,11 +82,12 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function map<T, U>(array: T[], f: (x: T) => U): U[] {
|
||||
export function map<T, U>(array: T[], f: (x: T) => U): U[]{
|
||||
let result: U[];
|
||||
if (array) {
|
||||
var result: U[] = [];
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
result.push(f(array[i]));
|
||||
result = [];
|
||||
for (let v of array) {
|
||||
result.push(f(v));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -99,28 +100,32 @@ module ts {
|
||||
return array1.concat(array2);
|
||||
}
|
||||
|
||||
export function deduplicate<T>(array: T[]): T[] {
|
||||
export function deduplicate<T>(array: T[]): T[]{
|
||||
let result: T[];
|
||||
if (array) {
|
||||
var result: T[] = [];
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
var item = array[i];
|
||||
if (!contains(result, item)) result.push(item);
|
||||
result = [];
|
||||
for (let item of array) {
|
||||
if (!contains(result, item)) {
|
||||
result.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function sum(array: any[], prop: string): number {
|
||||
var result = 0;
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
result += array[i][prop];
|
||||
let result = 0;
|
||||
for (let v of array) {
|
||||
result += v[prop];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function addRange<T>(to: T[], from: T[]): void {
|
||||
for (var i = 0, n = from.length; i < n; i++) {
|
||||
to.push(from[i]);
|
||||
if (to && from) {
|
||||
for (let v of from) {
|
||||
to.push(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,12 +141,12 @@ module ts {
|
||||
}
|
||||
|
||||
export function binarySearch(array: number[], value: number): number {
|
||||
var low = 0;
|
||||
var high = array.length - 1;
|
||||
let low = 0;
|
||||
let high = array.length - 1;
|
||||
|
||||
while (low <= high) {
|
||||
var middle = low + ((high - low) >> 1);
|
||||
var midValue = array[middle];
|
||||
let middle = low + ((high - low) >> 1);
|
||||
let midValue = array[middle];
|
||||
|
||||
if (midValue === value) {
|
||||
return middle;
|
||||
@@ -157,7 +162,40 @@ module ts {
|
||||
return ~low;
|
||||
}
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
export function reduceLeft<T>(array: T[], f: (a: T, x: T) => T): T;
|
||||
export function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
|
||||
export function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
|
||||
if (array) {
|
||||
var count = array.length;
|
||||
if (count > 0) {
|
||||
var pos = 0;
|
||||
var result = arguments.length <= 2 ? array[pos++] : initial;
|
||||
while (pos < count) {
|
||||
result = f(<U>result, array[pos++]);
|
||||
}
|
||||
return <U>result;
|
||||
}
|
||||
}
|
||||
return initial;
|
||||
}
|
||||
|
||||
export function reduceRight<T>(array: T[], f: (a: T, x: T) => T): T;
|
||||
export function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
|
||||
export function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
|
||||
if (array) {
|
||||
var pos = array.length - 1;
|
||||
if (pos >= 0) {
|
||||
var result = arguments.length <= 2 ? array[pos--] : initial;
|
||||
while (pos >= 0) {
|
||||
result = f(<U>result, array[pos--]);
|
||||
}
|
||||
return <U>result;
|
||||
}
|
||||
}
|
||||
return initial;
|
||||
}
|
||||
|
||||
let hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
export function hasProperty<T>(map: Map<T>, key: string): boolean {
|
||||
return hasOwnProperty.call(map, key);
|
||||
@@ -168,7 +206,7 @@ module ts {
|
||||
}
|
||||
|
||||
export function isEmpty<T>(map: Map<T>) {
|
||||
for (var id in map) {
|
||||
for (let id in map) {
|
||||
if (hasProperty(map, id)) {
|
||||
return false;
|
||||
}
|
||||
@@ -177,19 +215,19 @@ module ts {
|
||||
}
|
||||
|
||||
export function clone<T>(object: T): T {
|
||||
var result: any = {};
|
||||
for (var id in object) {
|
||||
let result: any = {};
|
||||
for (let id in object) {
|
||||
result[id] = (<any>object)[id];
|
||||
}
|
||||
return <T>result;
|
||||
}
|
||||
|
||||
export function extend<T>(first: Map<T>, second: Map<T>): Map<T> {
|
||||
var result: Map<T> = {};
|
||||
for (var id in first) {
|
||||
let result: Map<T> = {};
|
||||
for (let id in first) {
|
||||
result[id] = first[id];
|
||||
}
|
||||
for (var id in second) {
|
||||
for (let id in second) {
|
||||
if (!hasProperty(result, id)) {
|
||||
result[id] = second[id];
|
||||
}
|
||||
@@ -198,16 +236,16 @@ module ts {
|
||||
}
|
||||
|
||||
export function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U {
|
||||
var result: U;
|
||||
for (var id in map) {
|
||||
let result: U;
|
||||
for (let id in map) {
|
||||
if (result = callback(map[id])) break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U {
|
||||
var result: U;
|
||||
for (var id in map) {
|
||||
let result: U;
|
||||
for (let id in map) {
|
||||
if (result = callback(id)) break;
|
||||
}
|
||||
return result;
|
||||
@@ -217,18 +255,8 @@ module ts {
|
||||
return hasProperty(map, key) ? map[key] : undefined;
|
||||
}
|
||||
|
||||
export function mapToArray<T>(map: Map<T>): T[] {
|
||||
var result: T[] = [];
|
||||
|
||||
for (var id in map) {
|
||||
result.push(map[id]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function copyMap<T>(source: Map<T>, target: Map<T>): void {
|
||||
for (var p in source) {
|
||||
for (let p in source) {
|
||||
target[p] = source[p];
|
||||
}
|
||||
}
|
||||
@@ -244,7 +272,7 @@ module ts {
|
||||
* index in the array will be the one associated with the produced key.
|
||||
*/
|
||||
export function arrayToMap<T>(array: T[], makeKey: (value: T) => string): Map<T> {
|
||||
var result: Map<T> = {};
|
||||
let result: Map<T> = {};
|
||||
|
||||
forEach(array, value => {
|
||||
result[makeKey(value)] = value;
|
||||
@@ -259,7 +287,7 @@ module ts {
|
||||
return text.replace(/{(\d+)}/g, (match, index?) => args[+index + baseIndex]);
|
||||
}
|
||||
|
||||
export var localizedDiagnosticMessages: Map<string> = undefined;
|
||||
export let localizedDiagnosticMessages: Map<string> = undefined;
|
||||
|
||||
export function getLocaleSpecificMessage(message: string) {
|
||||
return localizedDiagnosticMessages && localizedDiagnosticMessages[message]
|
||||
@@ -269,10 +297,14 @@ module ts {
|
||||
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
|
||||
let end = start + length;
|
||||
|
||||
Debug.assert(start >= 0, "start must be non-negative, is " + start);
|
||||
Debug.assert(length >= 0, "length must be non-negative, is " + length);
|
||||
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
|
||||
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
|
||||
|
||||
var text = getLocaleSpecificMessage(message.key);
|
||||
let text = getLocaleSpecificMessage(message.key);
|
||||
|
||||
if (arguments.length > 4) {
|
||||
text = formatStringFromArgs(text, arguments, 4);
|
||||
@@ -291,7 +323,7 @@ module ts {
|
||||
|
||||
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
export function createCompilerDiagnostic(message: DiagnosticMessage): Diagnostic {
|
||||
var text = getLocaleSpecificMessage(message.key);
|
||||
let text = getLocaleSpecificMessage(message.key);
|
||||
|
||||
if (arguments.length > 1) {
|
||||
text = formatStringFromArgs(text, arguments, 1);
|
||||
@@ -310,7 +342,7 @@ module ts {
|
||||
|
||||
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
|
||||
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage): DiagnosticMessageChain {
|
||||
var text = getLocaleSpecificMessage(message.key);
|
||||
let text = getLocaleSpecificMessage(message.key);
|
||||
|
||||
if (arguments.length > 2) {
|
||||
text = formatStringFromArgs(text, arguments, 2);
|
||||
@@ -354,10 +386,10 @@ module ts {
|
||||
function compareMessageText(text1: string | DiagnosticMessageChain, text2: string | DiagnosticMessageChain): Comparison {
|
||||
while (text1 && text2) {
|
||||
// We still have both chains.
|
||||
var string1 = typeof text1 === "string" ? text1 : text1.messageText;
|
||||
var string2 = typeof text2 === "string" ? text2 : text2.messageText;
|
||||
let string1 = typeof text1 === "string" ? text1 : text1.messageText;
|
||||
let string2 = typeof text2 === "string" ? text2 : text2.messageText;
|
||||
|
||||
var res = compareValues(string1, string2);
|
||||
let res = compareValues(string1, string2);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
@@ -384,11 +416,11 @@ module ts {
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
var newDiagnostics = [diagnostics[0]];
|
||||
var previousDiagnostic = diagnostics[0];
|
||||
for (var i = 1; i < diagnostics.length; i++) {
|
||||
var currentDiagnostic = diagnostics[i];
|
||||
var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === Comparison.EqualTo;
|
||||
let newDiagnostics = [diagnostics[0]];
|
||||
let previousDiagnostic = diagnostics[0];
|
||||
for (let i = 1; i < diagnostics.length; i++) {
|
||||
let currentDiagnostic = diagnostics[i];
|
||||
let isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === Comparison.EqualTo;
|
||||
if (!isDupe) {
|
||||
newDiagnostics.push(currentDiagnostic);
|
||||
previousDiagnostic = currentDiagnostic;
|
||||
@@ -406,9 +438,9 @@ module ts {
|
||||
export function getRootLength(path: string): number {
|
||||
if (path.charCodeAt(0) === CharacterCodes.slash) {
|
||||
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
|
||||
var p1 = path.indexOf("/", 2);
|
||||
let p1 = path.indexOf("/", 2);
|
||||
if (p1 < 0) return 2;
|
||||
var p2 = path.indexOf("/", p1 + 1);
|
||||
let p2 = path.indexOf("/", p1 + 1);
|
||||
if (p2 < 0) return p1 + 1;
|
||||
return p2 + 1;
|
||||
}
|
||||
@@ -419,18 +451,21 @@ module ts {
|
||||
return 0;
|
||||
}
|
||||
|
||||
export var directorySeparator = "/";
|
||||
export let directorySeparator = "/";
|
||||
function getNormalizedParts(normalizedSlashedPath: string, rootLength: number) {
|
||||
var parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator);
|
||||
var normalized: string[] = [];
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
var part = parts[i];
|
||||
let parts = normalizedSlashedPath.substr(rootLength).split(directorySeparator);
|
||||
let normalized: string[] = [];
|
||||
for (let part of parts) {
|
||||
if (part !== ".") {
|
||||
if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") {
|
||||
normalized.pop();
|
||||
}
|
||||
else {
|
||||
normalized.push(part);
|
||||
// A part may be an empty string (which is 'falsy') if the path had consecutive slashes,
|
||||
// e.g. "path//file.ts". Drop these before re-joining the parts.
|
||||
if(part) {
|
||||
normalized.push(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,9 +474,9 @@ module ts {
|
||||
}
|
||||
|
||||
export function normalizePath(path: string): string {
|
||||
var path = normalizeSlashes(path);
|
||||
var rootLength = getRootLength(path);
|
||||
var normalized = getNormalizedParts(path, rootLength);
|
||||
path = normalizeSlashes(path);
|
||||
let rootLength = getRootLength(path);
|
||||
let normalized = getNormalizedParts(path, rootLength);
|
||||
return path.substr(0, rootLength) + normalized.join(directorySeparator);
|
||||
}
|
||||
|
||||
@@ -458,13 +493,13 @@ module ts {
|
||||
}
|
||||
|
||||
function normalizedPathComponents(path: string, rootLength: number) {
|
||||
var normalizedParts = getNormalizedParts(path, rootLength);
|
||||
let normalizedParts = getNormalizedParts(path, rootLength);
|
||||
return [path.substr(0, rootLength)].concat(normalizedParts);
|
||||
}
|
||||
|
||||
export function getNormalizedPathComponents(path: string, currentDirectory: string) {
|
||||
var path = normalizeSlashes(path);
|
||||
var rootLength = getRootLength(path);
|
||||
path = normalizeSlashes(path);
|
||||
let rootLength = getRootLength(path);
|
||||
if (rootLength == 0) {
|
||||
// If the path is not rooted it is relative to current directory
|
||||
path = combinePaths(normalizeSlashes(currentDirectory), path);
|
||||
@@ -489,9 +524,9 @@ module ts {
|
||||
// In this example the root is: http://www.website.com/
|
||||
// normalized path components should be ["http://www.website.com/", "folder1", "folder2"]
|
||||
|
||||
var urlLength = url.length;
|
||||
let urlLength = url.length;
|
||||
// Initial root length is http:// part
|
||||
var rootLength = url.indexOf("://") + "://".length;
|
||||
let rootLength = url.indexOf("://") + "://".length;
|
||||
while (rootLength < urlLength) {
|
||||
// Consume all immediate slashes in the protocol
|
||||
// eg.initial rootlength is just file:// but it needs to consume another "/" in file:///
|
||||
@@ -510,7 +545,7 @@ module ts {
|
||||
}
|
||||
|
||||
// Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://)
|
||||
var indexOfNextSlash = url.indexOf(directorySeparator, rootLength);
|
||||
let indexOfNextSlash = url.indexOf(directorySeparator, rootLength);
|
||||
if (indexOfNextSlash !== -1) {
|
||||
// Found the "/" after the website.com so the root is length of http://www.website.com/
|
||||
// and get components afetr the root normally like any other folder components
|
||||
@@ -536,8 +571,8 @@ module ts {
|
||||
}
|
||||
|
||||
export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean) {
|
||||
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
|
||||
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
|
||||
let pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
|
||||
let directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
|
||||
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
|
||||
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
|
||||
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]
|
||||
@@ -553,8 +588,8 @@ module ts {
|
||||
|
||||
// Get the relative path
|
||||
if (joinStartIndex) {
|
||||
var relativePath = "";
|
||||
var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length);
|
||||
let relativePath = "";
|
||||
let relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length);
|
||||
for (; joinStartIndex < directoryComponents.length; joinStartIndex++) {
|
||||
if (directoryComponents[joinStartIndex] !== "") {
|
||||
relativePath = relativePath + ".." + directorySeparator;
|
||||
@@ -565,7 +600,7 @@ module ts {
|
||||
}
|
||||
|
||||
// Cant find the relative path, get the absolute path
|
||||
var absolutePath = getNormalizedPathFromPathComponents(pathComponents);
|
||||
let absolutePath = getNormalizedPathFromPathComponents(pathComponents);
|
||||
if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) {
|
||||
absolutePath = "file:///" + absolutePath;
|
||||
}
|
||||
@@ -574,7 +609,7 @@ module ts {
|
||||
}
|
||||
|
||||
export function getBaseFileName(path: string) {
|
||||
var i = path.lastIndexOf(directorySeparator);
|
||||
let i = path.lastIndexOf(directorySeparator);
|
||||
return i < 0 ? path : path.substring(i + 1);
|
||||
}
|
||||
|
||||
@@ -587,16 +622,15 @@ module ts {
|
||||
}
|
||||
|
||||
export function fileExtensionIs(path: string, extension: string): boolean {
|
||||
var pathLen = path.length;
|
||||
var extLen = extension.length;
|
||||
let pathLen = path.length;
|
||||
let extLen = extension.length;
|
||||
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
|
||||
}
|
||||
|
||||
var supportedExtensions = [".d.ts", ".ts", ".js"];
|
||||
let supportedExtensions = [".d.ts", ".ts", ".js"];
|
||||
|
||||
export function removeFileExtension(path: string): string {
|
||||
for (var i = 0; i < supportedExtensions.length; i++) {
|
||||
var ext = supportedExtensions[i];
|
||||
for (let ext of supportedExtensions) {
|
||||
|
||||
if (fileExtensionIs(path, ext)) {
|
||||
return path.substr(0, path.length - ext.length);
|
||||
@@ -606,9 +640,9 @@ module ts {
|
||||
return path;
|
||||
}
|
||||
|
||||
var backslashOrDoubleQuote = /[\"\\]/g;
|
||||
var escapedCharsRegExp = /[\0-\19\t\v\f\b\0\r\n\u2028\u2029\u0085]/g;
|
||||
var escapedCharsMap: Map<string> = {
|
||||
let backslashOrDoubleQuote = /[\"\\]/g;
|
||||
let escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
||||
let escapedCharsMap: Map<string> = {
|
||||
"\0": "\\0",
|
||||
"\t": "\\t",
|
||||
"\v": "\\v",
|
||||
@@ -623,29 +657,6 @@ module ts {
|
||||
"\u0085": "\\u0085" // nextLine
|
||||
};
|
||||
|
||||
/**
|
||||
* Based heavily on the abstract 'Quote' operation from ECMA-262 (24.3.2.2),
|
||||
* but augmented for a few select characters.
|
||||
* Note that this doesn't actually wrap the input in double quotes.
|
||||
*/
|
||||
export function escapeString(s: string): string {
|
||||
// Prioritize '"' and '\'
|
||||
s = backslashOrDoubleQuote.test(s) ? s.replace(backslashOrDoubleQuote, getReplacement) : s;
|
||||
s = escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, getReplacement) : s;
|
||||
|
||||
return s;
|
||||
|
||||
function getReplacement(c: string) {
|
||||
return escapedCharsMap[c] || unicodeEscape(c);
|
||||
}
|
||||
|
||||
function unicodeEscape(c: string): string {
|
||||
var hexCharCode = c.charCodeAt(0).toString(16);
|
||||
var paddedHexCode = ("0000" + hexCharCode).slice(-4);
|
||||
return "\\u" + paddedHexCode;
|
||||
}
|
||||
}
|
||||
|
||||
export function getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts";
|
||||
}
|
||||
@@ -670,7 +681,7 @@ module ts {
|
||||
function Signature(checker: TypeChecker) {
|
||||
}
|
||||
|
||||
export var objectAllocator: ObjectAllocator = {
|
||||
export let objectAllocator: ObjectAllocator = {
|
||||
getNodeConstructor: kind => {
|
||||
function Node() {
|
||||
}
|
||||
@@ -696,7 +707,7 @@ module ts {
|
||||
}
|
||||
|
||||
export module Debug {
|
||||
var currentAssertionLevel = AssertionLevel.None;
|
||||
let currentAssertionLevel = AssertionLevel.None;
|
||||
|
||||
export function shouldAssert(level: AssertionLevel): boolean {
|
||||
return currentAssertionLevel >= level;
|
||||
@@ -704,7 +715,7 @@ module ts {
|
||||
|
||||
export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void {
|
||||
if (!expression) {
|
||||
var verboseDebugString = "";
|
||||
let verboseDebugString = "";
|
||||
if (verboseDebugInfo) {
|
||||
verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,6 @@ module ts {
|
||||
Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed." },
|
||||
Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." },
|
||||
Unexpected_token: { code: 1012, category: DiagnosticCategory.Error, key: "Unexpected token." },
|
||||
Catch_clause_parameter_cannot_have_a_type_annotation: { code: 1013, category: DiagnosticCategory.Error, key: "Catch clause parameter cannot have a type annotation." },
|
||||
A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." },
|
||||
Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." },
|
||||
A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." },
|
||||
@@ -117,7 +116,6 @@ module ts {
|
||||
const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" },
|
||||
const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." },
|
||||
let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." },
|
||||
Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." },
|
||||
Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." },
|
||||
Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." },
|
||||
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." },
|
||||
@@ -151,9 +149,26 @@ module ts {
|
||||
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." },
|
||||
External_module_0_has_no_default_export: { code: 1192, category: DiagnosticCategory.Error, key: "External module '{0}' has no default export." },
|
||||
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." },
|
||||
Catch_clause_variable_name_must_be_an_identifier: { code: 1195, category: DiagnosticCategory.Error, key: "Catch clause variable name must be an identifier." },
|
||||
Catch_clause_variable_cannot_have_a_type_annotation: { code: 1196, category: DiagnosticCategory.Error, key: "Catch clause variable cannot have a type annotation." },
|
||||
Catch_clause_variable_cannot_have_an_initializer: { code: 1197, category: DiagnosticCategory.Error, key: "Catch clause variable cannot have an initializer." },
|
||||
An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." },
|
||||
Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." },
|
||||
Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
|
||||
A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." },
|
||||
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
|
||||
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
|
||||
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },
|
||||
Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." },
|
||||
Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." },
|
||||
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
|
||||
Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." },
|
||||
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
|
||||
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
|
||||
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
|
||||
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." },
|
||||
@@ -324,9 +339,24 @@ module ts {
|
||||
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}'" },
|
||||
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." },
|
||||
The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." },
|
||||
Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." },
|
||||
The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." },
|
||||
The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." },
|
||||
The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." },
|
||||
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." },
|
||||
Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" },
|
||||
Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: DiagnosticCategory.Error, key: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." },
|
||||
Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: DiagnosticCategory.Error, key: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." },
|
||||
Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type or a string type." },
|
||||
The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 2496, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." },
|
||||
External_module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct: { code: 2497, category: DiagnosticCategory.Error, key: "External module '{0}' resolves to a non-module entity and cannot be imported using this construct." },
|
||||
External_module_0_uses_export_and_cannot_be_used_with_export_Asterisk: { code: 2498, category: DiagnosticCategory.Error, key: "External module '{0}' uses 'export =' and cannot be used with 'export *'." },
|
||||
An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2499, category: DiagnosticCategory.Error, key: "An interface can only extend an identifier/qualified-name with optional type arguments." },
|
||||
A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments: { code: 2500, category: DiagnosticCategory.Error, key: "A class can only implement an identifier/qualified-name with optional type arguments." },
|
||||
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}'." },
|
||||
@@ -396,6 +426,8 @@ module ts {
|
||||
Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." },
|
||||
Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." },
|
||||
Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." },
|
||||
Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: DiagnosticCategory.Error, key: "Default export of the module has or is using private name '{0}'." },
|
||||
Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher: { code: 4091, category: DiagnosticCategory.Error, key: "Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher." },
|
||||
The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." },
|
||||
Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." },
|
||||
Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" },
|
||||
@@ -408,6 +440,11 @@ module ts {
|
||||
Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." },
|
||||
Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." },
|
||||
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
|
||||
Option_sourceMap_cannot_be_specified_with_option_separateCompilation: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'separateCompilation'." },
|
||||
Option_declaration_cannot_be_specified_with_option_separateCompilation: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'separateCompilation'." },
|
||||
Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." },
|
||||
Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." },
|
||||
Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
|
||||
Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
|
||||
Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
|
||||
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
|
||||
@@ -451,6 +488,7 @@ module ts {
|
||||
File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." },
|
||||
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
|
||||
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." },
|
||||
Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -469,9 +507,26 @@ module ts {
|
||||
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
|
||||
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
|
||||
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." },
|
||||
import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." },
|
||||
export_can_only_be_used_in_a_ts_file: { code: 8003, category: DiagnosticCategory.Error, key: "'export=' can only be used in a .ts file." },
|
||||
type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: DiagnosticCategory.Error, key: "'type parameter declarations' can only be used in a .ts file." },
|
||||
implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: DiagnosticCategory.Error, key: "'implements clauses' can only be used in a .ts file." },
|
||||
interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: DiagnosticCategory.Error, key: "'interface declarations' can only be used in a .ts file." },
|
||||
module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: DiagnosticCategory.Error, key: "'module declarations' can only be used in a .ts file." },
|
||||
type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: DiagnosticCategory.Error, key: "'type aliases' can only be used in a .ts file." },
|
||||
_0_can_only_be_used_in_a_ts_file: { code: 8009, category: DiagnosticCategory.Error, key: "'{0}' can only be used in a .ts file." },
|
||||
types_can_only_be_used_in_a_ts_file: { code: 8010, category: DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." },
|
||||
type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." },
|
||||
parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." },
|
||||
can_only_be_used_in_a_ts_file: { code: 8013, category: DiagnosticCategory.Error, key: "'?' can only be used in a .ts file." },
|
||||
property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." },
|
||||
enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." },
|
||||
type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." },
|
||||
decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." },
|
||||
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." },
|
||||
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." },
|
||||
class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." },
|
||||
class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration: { code: 9004, category: DiagnosticCategory.Error, key: "'class' declarations are only supported directly inside a module or as a top level declaration." },
|
||||
};
|
||||
}
|
||||
@@ -27,10 +27,6 @@
|
||||
"category": "Error",
|
||||
"code": 1012
|
||||
},
|
||||
"Catch clause parameter cannot have a type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 1013
|
||||
},
|
||||
"A rest parameter must be last in a parameter list.": {
|
||||
"category": "Error",
|
||||
"code": 1014
|
||||
@@ -459,10 +455,6 @@
|
||||
"category": "Error",
|
||||
"code": 1157
|
||||
},
|
||||
"Tagged templates are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1159
|
||||
},
|
||||
"Unterminated template literal.": {
|
||||
"category": "Error",
|
||||
"code": 1160
|
||||
@@ -595,7 +587,7 @@
|
||||
"category": "Error",
|
||||
"code": 1191
|
||||
},
|
||||
"External module '{0}' has no default export or export assignment.": {
|
||||
"External module '{0}' has no default export.": {
|
||||
"category": "Error",
|
||||
"code": 1192
|
||||
},
|
||||
@@ -607,7 +599,74 @@
|
||||
"category": "Error",
|
||||
"code": 1194
|
||||
},
|
||||
|
||||
"Catch clause variable name must be an identifier.": {
|
||||
"category": "Error",
|
||||
"code": 1195
|
||||
},
|
||||
"Catch clause variable cannot have a type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 1196
|
||||
},
|
||||
"Catch clause variable cannot have an initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1197
|
||||
},
|
||||
"An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive.": {
|
||||
"category": "Error",
|
||||
"code": 1198
|
||||
},
|
||||
"Unterminated Unicode escape sequence.": {
|
||||
"category": "Error",
|
||||
"code": 1199
|
||||
},
|
||||
"Line terminator not permitted before arrow.": {
|
||||
"category": "Error",
|
||||
"code": 1200
|
||||
},
|
||||
"A type annotation on an export statement is only allowed in an ambient external module declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1201
|
||||
},
|
||||
"Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": {
|
||||
"category": "Error",
|
||||
"code": 1202
|
||||
},
|
||||
"Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": {
|
||||
"category": "Error",
|
||||
"code": 1203
|
||||
},
|
||||
"Cannot compile external modules into amd or commonjs when targeting es6 or higher.": {
|
||||
"category": "Error",
|
||||
"code": 1204
|
||||
},
|
||||
"Decorators are only available when targeting ECMAScript 5 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1205
|
||||
},
|
||||
"Decorators are not valid here.": {
|
||||
"category": "Error",
|
||||
"code": 1206
|
||||
},
|
||||
"Decorators cannot be applied to multiple get/set accessors of the same name.": {
|
||||
"category": "Error",
|
||||
"code": 1207
|
||||
},
|
||||
"Cannot compile non-external modules when the '--separateCompilation' flag is provided.": {
|
||||
"category": "Error",
|
||||
"code": 1208
|
||||
},
|
||||
"Ambient const enums are not allowed when the '--separateCompilation' flag is provided.": {
|
||||
"category": "Error",
|
||||
"code": 1209
|
||||
},
|
||||
"Invalid use of '{0}'. Class definitions are automatically in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1210
|
||||
},
|
||||
"A class declaration without the 'default' modifier must have a name": {
|
||||
"category": "Error",
|
||||
"code": 1211
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2300
|
||||
@@ -1288,10 +1347,6 @@
|
||||
"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
|
||||
@@ -1300,6 +1355,70 @@
|
||||
"category": "Error",
|
||||
"code": 2484
|
||||
},
|
||||
"The left-hand side of a 'for...of' statement cannot be a previously defined constant.": {
|
||||
"category": "Error",
|
||||
"code": 2485
|
||||
},
|
||||
"The left-hand side of a 'for...in' statement cannot be a previously defined constant.": {
|
||||
"category": "Error",
|
||||
"code": 2486
|
||||
},
|
||||
"Invalid left-hand side in 'for...of' statement.": {
|
||||
"category": "Error",
|
||||
"code": 2487
|
||||
},
|
||||
"The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.": {
|
||||
"category": "Error",
|
||||
"code": 2488
|
||||
},
|
||||
"The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.": {
|
||||
"category": "Error",
|
||||
"code": 2489
|
||||
},
|
||||
"The type returned by the 'next()' method of an iterator must have a 'value' property.": {
|
||||
"category": "Error",
|
||||
"code": 2490
|
||||
},
|
||||
"The left-hand side of a 'for...in' statement cannot be a destructuring pattern.": {
|
||||
"category": "Error",
|
||||
"code": 2491
|
||||
},
|
||||
"Cannot redeclare identifier '{0}' in catch clause": {
|
||||
"category": "Error",
|
||||
"code": 2492
|
||||
},
|
||||
"Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 2493
|
||||
},
|
||||
"Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 2494
|
||||
},
|
||||
"Type '{0}' is not an array type or a string type.": {
|
||||
"category": "Error",
|
||||
"code": 2495
|
||||
},
|
||||
"The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression.": {
|
||||
"category": "Error",
|
||||
"code": 2496
|
||||
},
|
||||
"External module '{0}' resolves to a non-module entity and cannot be imported using this construct.": {
|
||||
"category": "Error",
|
||||
"code": 2497
|
||||
},
|
||||
"External module '{0}' uses 'export =' and cannot be used with 'export *'.": {
|
||||
"category": "Error",
|
||||
"code": 2498
|
||||
},
|
||||
"An interface can only extend an identifier/qualified-name with optional type arguments.": {
|
||||
"category": "Error",
|
||||
"code": 2499
|
||||
},
|
||||
"A class can only implement an identifier/qualified-name with optional type arguments.": {
|
||||
"category": "Error",
|
||||
"code": 2500
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@@ -1576,7 +1695,15 @@
|
||||
"Exported type alias '{0}' has or is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4081
|
||||
},
|
||||
},
|
||||
"Default export of the module has or is using private name '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 4082
|
||||
},
|
||||
"Loop contains block-scoped variable '{0}' referenced by a function in the loop. This is only supported in ECMAScript 6 or higher.": {
|
||||
"category": "Error",
|
||||
"code": 4091
|
||||
},
|
||||
"The current host does not support the '{0}' option.": {
|
||||
"category": "Error",
|
||||
"code": 5001
|
||||
@@ -1625,6 +1752,26 @@
|
||||
"category": "Error",
|
||||
"code": 5042
|
||||
},
|
||||
"Option 'sourceMap' cannot be specified with option 'separateCompilation'.": {
|
||||
"category": "Error",
|
||||
"code": 5043
|
||||
},
|
||||
"Option 'declaration' cannot be specified with option 'separateCompilation'.": {
|
||||
"category": "Error",
|
||||
"code": 5044
|
||||
},
|
||||
"Option 'noEmitOnError' cannot be specified with option 'separateCompilation'.": {
|
||||
"category": "Error",
|
||||
"code": 5045
|
||||
},
|
||||
"Option 'out' cannot be specified with option 'separateCompilation'.": {
|
||||
"category": "Error",
|
||||
"code": 5046
|
||||
},
|
||||
"Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": {
|
||||
"category": "Error",
|
||||
"code": 5047
|
||||
},
|
||||
"Concatenate and emit output to single file.": {
|
||||
"category": "Message",
|
||||
"code": 6001
|
||||
@@ -1797,6 +1944,10 @@
|
||||
"category": "Message",
|
||||
"code": 6056
|
||||
},
|
||||
"Preserve new-lines when emitting code.": {
|
||||
"category": "Message",
|
||||
"code": 6057
|
||||
},
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
@@ -1870,6 +2021,71 @@
|
||||
"category": "Error",
|
||||
"code": 8001
|
||||
},
|
||||
"'import ... =' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8002
|
||||
},
|
||||
"'export=' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8003
|
||||
},
|
||||
"'type parameter declarations' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8004
|
||||
},
|
||||
"'implements clauses' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8005
|
||||
},
|
||||
"'interface declarations' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8006
|
||||
},
|
||||
"'module declarations' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8007
|
||||
},
|
||||
"'type aliases' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8008
|
||||
},
|
||||
"'{0}' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8009
|
||||
},
|
||||
"'types' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8010
|
||||
},
|
||||
"'type arguments' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8011
|
||||
},
|
||||
"'parameter modifiers' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8012
|
||||
},
|
||||
"'?' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8013
|
||||
},
|
||||
"'property declarations' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8014
|
||||
},
|
||||
"'enum declarations' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8015
|
||||
},
|
||||
"'type assertion expressions' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8016
|
||||
},
|
||||
"'decorators' can only be used in a .ts file.": {
|
||||
"category": "Error",
|
||||
"code": 8017
|
||||
},
|
||||
|
||||
"'yield' expressions are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9000
|
||||
@@ -1878,12 +2094,16 @@
|
||||
"category": "Error",
|
||||
"code": 9001
|
||||
},
|
||||
"The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression.": {
|
||||
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": {
|
||||
"category": "Error",
|
||||
"code": 9002
|
||||
},
|
||||
"'for...of' statements are not currently supported.": {
|
||||
"'class' expressions are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9003
|
||||
},
|
||||
"'class' declarations are only supported directly inside a module or as a top level declaration.": {
|
||||
"category": "Error",
|
||||
"code": 9004
|
||||
}
|
||||
}
|
||||
|
||||
+2237
-2372
File diff suppressed because it is too large
Load Diff
+927
-610
File diff suppressed because it is too large
Load Diff
+174
-90
@@ -2,11 +2,33 @@
|
||||
/// <reference path="emitter.ts" />
|
||||
|
||||
module ts {
|
||||
/* @internal */ export var emitTime = 0;
|
||||
/* @internal */ export let programTime = 0;
|
||||
/* @internal */ export let emitTime = 0;
|
||||
/* @internal */ export let ioReadTime = 0;
|
||||
/* @internal */ export let ioWriteTime = 0;
|
||||
|
||||
export function createCompilerHost(options: CompilerOptions): CompilerHost {
|
||||
var currentDirectory: string;
|
||||
var existingDirectories: Map<boolean> = {};
|
||||
/** The version of the TypeScript compiler release */
|
||||
export let version = "1.5.0";
|
||||
|
||||
export function findConfigFile(searchPath: string): string {
|
||||
var fileName = "tsconfig.json";
|
||||
while (true) {
|
||||
if (sys.fileExists(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
searchPath = parentPath;
|
||||
fileName = "../" + fileName;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost {
|
||||
let currentDirectory: string;
|
||||
let existingDirectories: Map<boolean> = {};
|
||||
|
||||
function getCanonicalFileName(fileName: string): string {
|
||||
// if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form.
|
||||
@@ -15,11 +37,14 @@ module ts {
|
||||
}
|
||||
|
||||
// returned by CScript sys environment
|
||||
var unsupportedFileEncodingErrorCode = -2147024809;
|
||||
let unsupportedFileEncodingErrorCode = -2147024809;
|
||||
|
||||
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
|
||||
let text: string;
|
||||
try {
|
||||
var text = sys.readFile(fileName, options.charset);
|
||||
let start = new Date().getTime();
|
||||
text = sys.readFile(fileName, options.charset);
|
||||
ioReadTime += new Date().getTime() - start;
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
@@ -29,33 +54,34 @@ module ts {
|
||||
}
|
||||
text = "";
|
||||
}
|
||||
return text !== undefined ? createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
|
||||
}
|
||||
|
||||
return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined;
|
||||
function directoryExists(directoryPath: string): boolean {
|
||||
if (hasProperty(existingDirectories, directoryPath)) {
|
||||
return true;
|
||||
}
|
||||
if (sys.directoryExists(directoryPath)) {
|
||||
existingDirectories[directoryPath] = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function ensureDirectoriesExist(directoryPath: string) {
|
||||
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
|
||||
let parentDirectory = getDirectoryPath(directoryPath);
|
||||
ensureDirectoriesExist(parentDirectory);
|
||||
sys.createDirectory(directoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
|
||||
function directoryExists(directoryPath: string): boolean {
|
||||
if (hasProperty(existingDirectories, directoryPath)) {
|
||||
return true;
|
||||
}
|
||||
if (sys.directoryExists(directoryPath)) {
|
||||
existingDirectories[directoryPath] = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function ensureDirectoriesExist(directoryPath: string) {
|
||||
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
|
||||
var parentDirectory = getDirectoryPath(directoryPath);
|
||||
ensureDirectoriesExist(parentDirectory);
|
||||
sys.createDirectory(directoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
var start = new Date().getTime();
|
||||
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
|
||||
sys.writeFile(fileName, data, writeByteOrderMark);
|
||||
ioWriteTime += new Date().getTime() - start;
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
@@ -76,7 +102,12 @@ module ts {
|
||||
}
|
||||
|
||||
export function getPreEmitDiagnostics(program: Program): Diagnostic[] {
|
||||
var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics());
|
||||
let diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics());
|
||||
|
||||
if (program.getCompilerOptions().declaration) {
|
||||
diagnostics.concat(program.getDeclarationDiagnostics());
|
||||
}
|
||||
|
||||
return sortAndDeduplicateDiagnostics(diagnostics);
|
||||
}
|
||||
|
||||
@@ -85,15 +116,15 @@ module ts {
|
||||
return messageText;
|
||||
}
|
||||
else {
|
||||
var diagnosticChain = messageText;
|
||||
var result = "";
|
||||
let diagnosticChain = messageText;
|
||||
let result = "";
|
||||
|
||||
var indent = 0;
|
||||
let indent = 0;
|
||||
while (diagnosticChain) {
|
||||
if (indent) {
|
||||
result += newLine;
|
||||
|
||||
for (var i = 0; i < indent; i++) {
|
||||
for (let i = 0; i < indent; i++) {
|
||||
result += " ";
|
||||
}
|
||||
}
|
||||
@@ -107,22 +138,25 @@ module ts {
|
||||
}
|
||||
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program {
|
||||
var program: Program;
|
||||
var files: SourceFile[] = [];
|
||||
var filesByName: Map<SourceFile> = {};
|
||||
var diagnostics = createDiagnosticCollection();
|
||||
var seenNoDefaultLib = options.noLib;
|
||||
var commonSourceDirectory: string;
|
||||
host = host || createCompilerHost(options);
|
||||
let program: Program;
|
||||
let files: SourceFile[] = [];
|
||||
let filesByName: Map<SourceFile> = {};
|
||||
let diagnostics = createDiagnosticCollection();
|
||||
let seenNoDefaultLib = options.noLib;
|
||||
let commonSourceDirectory: string;
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
let noDiagnosticsTypeChecker: TypeChecker;
|
||||
|
||||
let start = new Date().getTime();
|
||||
|
||||
host = host || createCompilerHost(options);
|
||||
forEach(rootNames, name => processRootFile(name, false));
|
||||
if (!seenNoDefaultLib) {
|
||||
processRootFile(host.getDefaultLibFileName(options), true);
|
||||
}
|
||||
verifyCompilerOptions();
|
||||
|
||||
var diagnosticsProducingTypeChecker: TypeChecker;
|
||||
var noDiagnosticsTypeChecker: TypeChecker;
|
||||
programTime += new Date().getTime() - start;
|
||||
|
||||
program = {
|
||||
getSourceFile: getSourceFile,
|
||||
@@ -165,11 +199,6 @@ module ts {
|
||||
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false));
|
||||
}
|
||||
|
||||
function getDeclarationDiagnostics(targetSourceFile: SourceFile): Diagnostic[] {
|
||||
var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(targetSourceFile);
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(), resolver, targetSourceFile);
|
||||
}
|
||||
|
||||
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback): EmitResult {
|
||||
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
|
||||
// immediately bail out.
|
||||
@@ -177,10 +206,15 @@ module ts {
|
||||
return { diagnostics: [], sourceMaps: undefined, emitSkipped: true };
|
||||
}
|
||||
|
||||
var start = new Date().getTime();
|
||||
// Create the emit resolver outside of the "emitTime" tracking code below. That way
|
||||
// any cost associated with it (like type checking) are appropriate associated with
|
||||
// the type-checking counter.
|
||||
let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile);
|
||||
|
||||
var emitResult = emitFiles(
|
||||
getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile),
|
||||
let start = new Date().getTime();
|
||||
|
||||
let emitResult = emitFiles(
|
||||
emitResolver,
|
||||
getEmitHost(writeFileCallback),
|
||||
sourceFile);
|
||||
|
||||
@@ -198,7 +232,7 @@ module ts {
|
||||
return getDiagnostics(sourceFile);
|
||||
}
|
||||
|
||||
var allDiagnostics: Diagnostic[] = [];
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
addRange(allDiagnostics, getDiagnostics(sourceFile));
|
||||
});
|
||||
@@ -214,25 +248,38 @@ module ts {
|
||||
return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile);
|
||||
}
|
||||
|
||||
function getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile);
|
||||
}
|
||||
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
return sourceFile.parseDiagnostics;
|
||||
}
|
||||
|
||||
function getSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
var typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
let typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
var bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
var checkDiagnostics = typeChecker.getDiagnostics(sourceFile);
|
||||
var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
|
||||
let bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
let checkDiagnostics = typeChecker.getDiagnostics(sourceFile);
|
||||
let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
|
||||
|
||||
return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
|
||||
}
|
||||
|
||||
function getGlobalDiagnostics(): Diagnostic[] {
|
||||
var typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile);
|
||||
// Don't actually write any files since we're just getting diagnostics.
|
||||
var writeFile: WriteFileCallback = () => { };
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
var allDiagnostics: Diagnostic[] = [];
|
||||
function getGlobalDiagnostics(): Diagnostic[] {
|
||||
let typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, typeChecker.getGlobalDiagnostics());
|
||||
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
|
||||
|
||||
@@ -248,11 +295,13 @@ module ts {
|
||||
}
|
||||
|
||||
function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
|
||||
let start: number;
|
||||
let length: number;
|
||||
if (refEnd !== undefined && refPos !== undefined) {
|
||||
var start = refPos;
|
||||
var length = refEnd - refPos;
|
||||
start = refPos;
|
||||
length = refEnd - refPos;
|
||||
}
|
||||
var diagnostic: DiagnosticMessage;
|
||||
let diagnostic: DiagnosticMessage;
|
||||
if (hasExtension(fileName)) {
|
||||
if (!options.allowNonTsExtensions && !fileExtensionIs(host.getCanonicalFileName(fileName), ".ts")) {
|
||||
diagnostic = Diagnostics.File_0_must_have_extension_ts_or_d_ts;
|
||||
@@ -286,20 +335,20 @@ module ts {
|
||||
|
||||
// Get source file from normalized fileName
|
||||
function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refStart?: number, refLength?: number): SourceFile {
|
||||
var canonicalName = host.getCanonicalFileName(fileName);
|
||||
let canonicalName = host.getCanonicalFileName(fileName);
|
||||
if (hasProperty(filesByName, canonicalName)) {
|
||||
// We've already looked for this file, use cached result
|
||||
return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false);
|
||||
}
|
||||
else {
|
||||
var normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
|
||||
var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
|
||||
let normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
|
||||
let canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
|
||||
if (hasProperty(filesByName, canonicalAbsolutePath)) {
|
||||
return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true);
|
||||
}
|
||||
|
||||
// We haven't looked for this file, do so now and cache result
|
||||
var file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
let file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
if (refFile) {
|
||||
diagnostics.add(createFileDiagnostic(refFile, refStart, refLength,
|
||||
Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
@@ -315,7 +364,7 @@ module ts {
|
||||
filesByName[canonicalAbsolutePath] = file;
|
||||
|
||||
if (!options.noResolve) {
|
||||
var basePath = getDirectoryPath(fileName);
|
||||
let basePath = getDirectoryPath(fileName);
|
||||
processReferencedFiles(file, basePath);
|
||||
processImportedModules(file, basePath);
|
||||
}
|
||||
@@ -326,13 +375,14 @@ module ts {
|
||||
files.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
return file;
|
||||
|
||||
function getSourceFileFromCache(fileName: string, canonicalName: string, useAbsolutePath: boolean): SourceFile {
|
||||
var file = filesByName[canonicalName];
|
||||
let file = filesByName[canonicalName];
|
||||
if (file && host.useCaseSensitiveFileNames()) {
|
||||
var sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
|
||||
let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
|
||||
if (canonicalName !== sourceFileName) {
|
||||
diagnostics.add(createFileDiagnostic(refFile, refStart, refLength,
|
||||
Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
|
||||
@@ -344,7 +394,7 @@ module ts {
|
||||
|
||||
function processReferencedFiles(file: SourceFile, basePath: string) {
|
||||
forEach(file.referencedFiles, ref => {
|
||||
var referencedFileName = isRootedDiskPath(ref.fileName) ? ref.fileName : combinePaths(basePath, ref.fileName);
|
||||
let referencedFileName = isRootedDiskPath(ref.fileName) ? ref.fileName : combinePaths(basePath, ref.fileName);
|
||||
processSourceFile(normalizePath(referencedFileName), /* isDefaultLib */ false, file, ref.pos, ref.end);
|
||||
});
|
||||
}
|
||||
@@ -352,17 +402,17 @@ module ts {
|
||||
function processImportedModules(file: SourceFile, basePath: string) {
|
||||
forEach(file.statements, node => {
|
||||
if (node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.ExportDeclaration) {
|
||||
var moduleNameExpr = getExternalModuleName(node);
|
||||
let moduleNameExpr = getExternalModuleName(node);
|
||||
if (moduleNameExpr && moduleNameExpr.kind === SyntaxKind.StringLiteral) {
|
||||
var moduleNameText = (<LiteralExpression>moduleNameExpr).text;
|
||||
let moduleNameText = (<LiteralExpression>moduleNameExpr).text;
|
||||
if (moduleNameText) {
|
||||
var searchPath = basePath;
|
||||
let searchPath = basePath;
|
||||
while (true) {
|
||||
var searchName = normalizePath(combinePaths(searchPath, moduleNameText));
|
||||
let searchName = normalizePath(combinePaths(searchPath, moduleNameText));
|
||||
if (findModuleSourceFile(searchName + ".ts", moduleNameExpr) || findModuleSourceFile(searchName + ".d.ts", moduleNameExpr)) {
|
||||
break;
|
||||
}
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
let parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
@@ -381,14 +431,14 @@ module ts {
|
||||
if (isExternalModuleImportEqualsDeclaration(node) &&
|
||||
getExternalModuleImportEqualsDeclarationExpression(node).kind === SyntaxKind.StringLiteral) {
|
||||
|
||||
var nameLiteral = <LiteralExpression>getExternalModuleImportEqualsDeclarationExpression(node);
|
||||
var moduleName = nameLiteral.text;
|
||||
let nameLiteral = <LiteralExpression>getExternalModuleImportEqualsDeclarationExpression(node);
|
||||
let moduleName = nameLiteral.text;
|
||||
if (moduleName) {
|
||||
// TypeScript 1.0 spec (April 2014): 12.1.6
|
||||
// An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
|
||||
// only through top - level external module names. Relative external module names are not permitted.
|
||||
var searchName = normalizePath(combinePaths(basePath, moduleName));
|
||||
var tsFile = findModuleSourceFile(searchName + ".ts", nameLiteral);
|
||||
let searchName = normalizePath(combinePaths(basePath, moduleName));
|
||||
let tsFile = findModuleSourceFile(searchName + ".ts", nameLiteral);
|
||||
if (!tsFile) {
|
||||
findModuleSourceFile(searchName + ".d.ts", nameLiteral);
|
||||
}
|
||||
@@ -404,6 +454,24 @@ module ts {
|
||||
}
|
||||
|
||||
function verifyCompilerOptions() {
|
||||
if (options.separateCompilation) {
|
||||
if (options.sourceMap) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_separateCompilation));
|
||||
}
|
||||
|
||||
if (options.declaration) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_separateCompilation));
|
||||
}
|
||||
|
||||
if (options.noEmitOnError) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation));
|
||||
}
|
||||
|
||||
if (options.out) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation));
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
|
||||
// Error to specify --mapRoot or --sourceRoot without mapSourceFiles
|
||||
if (options.mapRoot) {
|
||||
@@ -415,31 +483,47 @@ module ts {
|
||||
return;
|
||||
}
|
||||
|
||||
var firstExternalModule = forEach(files, f => isExternalModule(f) ? f : undefined);
|
||||
if (firstExternalModule && !options.module) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
var externalModuleErrorSpan = getErrorSpanForNode(firstExternalModule.externalModuleIndicator);
|
||||
var errorStart = skipTrivia(firstExternalModule.text, externalModuleErrorSpan.pos);
|
||||
var errorLength = externalModuleErrorSpan.end - errorStart;
|
||||
diagnostics.add(createFileDiagnostic(firstExternalModule, errorStart, errorLength, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided));
|
||||
let languageVersion = options.target || ScriptTarget.ES3;
|
||||
|
||||
let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
|
||||
if (options.separateCompilation) {
|
||||
if (!options.module && languageVersion < ScriptTarget.ES6) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
|
||||
}
|
||||
|
||||
let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
|
||||
if (firstNonExternalModuleSourceFile) {
|
||||
let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
|
||||
diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided));
|
||||
}
|
||||
}
|
||||
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided));
|
||||
}
|
||||
|
||||
// there has to be common source directory if user specified --outdir || --sourcRoot
|
||||
// Cannot specify module gen target when in es6 or above
|
||||
if (options.module && languageVersion >= ScriptTarget.ES6) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher));
|
||||
}
|
||||
|
||||
// there has to be common source directory if user specified --outdir || --sourceRoot
|
||||
// if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted
|
||||
if (options.outDir || // there is --outDir specified
|
||||
options.sourceRoot || // there is --sourceRoot specified
|
||||
(options.mapRoot && // there is --mapRoot Specified and there would be multiple js files generated
|
||||
(!options.out || firstExternalModule !== undefined))) {
|
||||
(options.mapRoot && // there is --mapRoot specified and there would be multiple js files generated
|
||||
(!options.out || firstExternalModuleSourceFile !== undefined))) {
|
||||
|
||||
var commonPathComponents: string[];
|
||||
let commonPathComponents: string[];
|
||||
forEach(files, sourceFile => {
|
||||
// Each file contributes into common source file path
|
||||
if (!(sourceFile.flags & NodeFlags.DeclarationFile)
|
||||
&& !fileExtensionIs(sourceFile.fileName, ".js")) {
|
||||
var sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory());
|
||||
let sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory());
|
||||
sourcePathComponents.pop(); // FileName is not part of directory
|
||||
if (commonPathComponents) {
|
||||
for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) {
|
||||
for (let i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) {
|
||||
if (commonPathComponents[i] !== sourcePathComponents[i]) {
|
||||
if (i === 0) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||
|
||||
+231
-107
File diff suppressed because one or more lines are too long
+7
-8
@@ -124,15 +124,14 @@ module ts {
|
||||
function visitDirectory(path: string) {
|
||||
var folder = fso.GetFolder(path || ".");
|
||||
var files = getNames(folder.files);
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var name = files[i];
|
||||
for (let name of files) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(combinePaths(path, name));
|
||||
}
|
||||
}
|
||||
var subfolders = getNames(folder.subfolders);
|
||||
for (var i = 0; i < subfolders.length; i++) {
|
||||
visitDirectory(combinePaths(path, subfolders[i]));
|
||||
for (let current of subfolders) {
|
||||
visitDirectory(combinePaths(path, current));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,8 +229,8 @@ module ts {
|
||||
function visitDirectory(path: string) {
|
||||
var files = _fs.readdirSync(path || ".").sort();
|
||||
var directories: string[] = [];
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var name = combinePaths(path, files[i]);
|
||||
for (let current of files) {
|
||||
var name = combinePaths(path, current);
|
||||
var stat = _fs.lstatSync(name);
|
||||
if (stat.isFile()) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
@@ -242,8 +241,8 @@ module ts {
|
||||
directories.push(name);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < directories.length; i++) {
|
||||
visitDirectory(directories[i]);
|
||||
for (let current of directories) {
|
||||
visitDirectory(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
-38
@@ -2,8 +2,6 @@
|
||||
/// <reference path="commandLineParser.ts"/>
|
||||
|
||||
module ts {
|
||||
var version = "1.5.0.0";
|
||||
|
||||
export interface SourceFile {
|
||||
fileWatcher: FileWatcher;
|
||||
}
|
||||
@@ -134,23 +132,6 @@ module ts {
|
||||
return typeof JSON === "object" && typeof JSON.parse === "function";
|
||||
}
|
||||
|
||||
function findConfigFile(): string {
|
||||
var searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
var fileName = "tsconfig.json";
|
||||
while (true) {
|
||||
if (sys.fileExists(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
searchPath = parentPath;
|
||||
fileName = "../" + fileName;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function executeCommandLine(args: string[]): void {
|
||||
var commandLine = parseCommandLine(args);
|
||||
var configFileName: string; // Configuration file name (if any)
|
||||
@@ -178,7 +159,7 @@ module ts {
|
||||
}
|
||||
|
||||
if (commandLine.options.version) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, version));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version));
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
@@ -200,7 +181,8 @@ module ts {
|
||||
}
|
||||
}
|
||||
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
|
||||
configFileName = findConfigFile();
|
||||
var searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
configFileName = findConfigFile(searchPath);
|
||||
}
|
||||
|
||||
if (commandLine.fileNames.length === 0 && !configFileName) {
|
||||
@@ -250,7 +232,7 @@ module ts {
|
||||
|
||||
var compileResult = compile(rootFileNames, compilerOptions, compilerHost);
|
||||
|
||||
if (!commandLine.options.watch) {
|
||||
if (!compilerOptions.watch) {
|
||||
return sys.exit(compileResult.exitStatus);
|
||||
}
|
||||
|
||||
@@ -269,7 +251,7 @@ module ts {
|
||||
}
|
||||
// Use default host function
|
||||
var sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
if (sourceFile && commandLine.options.watch) {
|
||||
if (sourceFile && compilerOptions.watch) {
|
||||
// Attach a file watcher
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, () => sourceFileChanged(sourceFile));
|
||||
}
|
||||
@@ -294,6 +276,7 @@ module ts {
|
||||
|
||||
// If a source file changes, mark it as unwatched and start the recompilation timer
|
||||
function sourceFileChanged(sourceFile: SourceFile) {
|
||||
sourceFile.fileWatcher.close();
|
||||
sourceFile.fileWatcher = undefined;
|
||||
startTimer();
|
||||
}
|
||||
@@ -322,18 +305,16 @@ module ts {
|
||||
}
|
||||
|
||||
function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
|
||||
ts.parseTime = 0;
|
||||
ts.bindTime = 0;
|
||||
ts.checkTime = 0;
|
||||
ts.emitTime = 0;
|
||||
|
||||
var start = new Date().getTime();
|
||||
ioReadTime = 0;
|
||||
ioWriteTime = 0;
|
||||
programTime = 0;
|
||||
bindTime = 0;
|
||||
checkTime = 0;
|
||||
emitTime = 0;
|
||||
|
||||
var program = createProgram(fileNames, compilerOptions, compilerHost);
|
||||
var exitStatus = compileProgram();
|
||||
|
||||
var end = new Date().getTime() - start;
|
||||
|
||||
if (compilerOptions.listFiles) {
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
sys.write(file.fileName + sys.newLine);
|
||||
@@ -353,11 +334,17 @@ module ts {
|
||||
reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
|
||||
}
|
||||
|
||||
reportTimeStatistic("Parse time", ts.parseTime);
|
||||
reportTimeStatistic("Bind time", ts.bindTime);
|
||||
reportTimeStatistic("Check time", ts.checkTime);
|
||||
reportTimeStatistic("Emit time", ts.emitTime);
|
||||
reportTimeStatistic("Total time", end);
|
||||
// Individual component times.
|
||||
// Note: To match the behavior of previous versions of the compiler, the reported parse time includes
|
||||
// I/O read time and processing time for triple-slash references and module imports, and the reported
|
||||
// emit time includes I/O write time. We preserve this behavior so we can accurately compare times.
|
||||
reportTimeStatistic("I/O read", ioReadTime);
|
||||
reportTimeStatistic("I/O write", ioWriteTime);
|
||||
reportTimeStatistic("Parse time", programTime);
|
||||
reportTimeStatistic("Bind time", bindTime);
|
||||
reportTimeStatistic("Check time", checkTime);
|
||||
reportTimeStatistic("Emit time", emitTime);
|
||||
reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
|
||||
}
|
||||
|
||||
return { program, exitStatus };
|
||||
@@ -398,7 +385,7 @@ module ts {
|
||||
// The emitter emitted something, inform the caller if that happened in the presence
|
||||
// of diagnostics or not.
|
||||
if (diagnostics.length > 0 || emitOutput.diagnostics.length > 0) {
|
||||
ExitStatus.DiagnosticsPresent_OutputsGenerated;
|
||||
return ExitStatus.DiagnosticsPresent_OutputsGenerated;
|
||||
}
|
||||
|
||||
return ExitStatus.Success;
|
||||
@@ -406,7 +393,7 @@ module ts {
|
||||
}
|
||||
|
||||
function printVersion() {
|
||||
sys.write(getDiagnosticText(Diagnostics.Version_0, version) + sys.newLine);
|
||||
sys.write(getDiagnosticText(Diagnostics.Version_0, ts.version) + sys.newLine);
|
||||
}
|
||||
|
||||
function printHelp() {
|
||||
|
||||
+145
-90
@@ -67,6 +67,7 @@ module ts {
|
||||
BarBarToken,
|
||||
QuestionToken,
|
||||
ColonToken,
|
||||
AtToken,
|
||||
// Assignments
|
||||
EqualsToken,
|
||||
PlusEqualsToken,
|
||||
@@ -121,7 +122,6 @@ module ts {
|
||||
WithKeyword,
|
||||
// Strict mode reserved words
|
||||
AsKeyword,
|
||||
FromKeyword,
|
||||
ImplementsKeyword,
|
||||
InterfaceKeyword,
|
||||
LetKeyword,
|
||||
@@ -131,7 +131,7 @@ module ts {
|
||||
PublicKeyword,
|
||||
StaticKeyword,
|
||||
YieldKeyword,
|
||||
// TypeScript keywords
|
||||
// Contextual keywords
|
||||
AnyKeyword,
|
||||
BooleanKeyword,
|
||||
ConstructorKeyword,
|
||||
@@ -144,7 +144,9 @@ module ts {
|
||||
StringKeyword,
|
||||
SymbolKeyword,
|
||||
TypeKeyword,
|
||||
FromKeyword,
|
||||
OfKeyword, // LastKeyword and LastToken
|
||||
|
||||
// Parse tree nodes
|
||||
|
||||
// Names
|
||||
@@ -153,6 +155,7 @@ module ts {
|
||||
// Signature elements
|
||||
TypeParameter,
|
||||
Parameter,
|
||||
Decorator,
|
||||
// TypeMember
|
||||
PropertySignature,
|
||||
PropertyDeclaration,
|
||||
@@ -200,9 +203,12 @@ module ts {
|
||||
TemplateExpression,
|
||||
YieldExpression,
|
||||
SpreadElementExpression,
|
||||
ClassExpression,
|
||||
OmittedExpression,
|
||||
// Misc
|
||||
TemplateSpan,
|
||||
HeritageClauseElement,
|
||||
SemicolonClassElement,
|
||||
// Element
|
||||
Block,
|
||||
VariableStatement,
|
||||
@@ -232,6 +238,7 @@ module ts {
|
||||
EnumDeclaration,
|
||||
ModuleDeclaration,
|
||||
ModuleBlock,
|
||||
CaseBlock,
|
||||
ImportEqualsDeclaration,
|
||||
ImportDeclaration,
|
||||
ImportClause,
|
||||
@@ -242,6 +249,7 @@ module ts {
|
||||
ExportDeclaration,
|
||||
NamedExports,
|
||||
ExportSpecifier,
|
||||
MissingDeclaration,
|
||||
|
||||
// Module references
|
||||
ExternalModuleReference,
|
||||
@@ -279,7 +287,7 @@ module ts {
|
||||
FirstPunctuation = OpenBraceToken,
|
||||
LastPunctuation = CaretEqualsToken,
|
||||
FirstToken = Unknown,
|
||||
LastToken = OfKeyword,
|
||||
LastToken = LastKeyword,
|
||||
FirstTriviaToken = SingleLineCommentTrivia,
|
||||
LastTriviaToken = ConflictMarkerTrivia,
|
||||
FirstLiteralToken = NumericLiteral,
|
||||
@@ -298,14 +306,16 @@ module ts {
|
||||
Private = 0x00000020, // Property/Method
|
||||
Protected = 0x00000040, // Property/Method
|
||||
Static = 0x00000080, // Property/Method
|
||||
MultiLine = 0x00000100, // Multi-line array or object literal
|
||||
Synthetic = 0x00000200, // Synthetic node (for full fidelity)
|
||||
DeclarationFile = 0x00000400, // Node is a .d.ts file
|
||||
Let = 0x00000800, // Variable declaration
|
||||
Const = 0x00001000, // Variable declaration
|
||||
OctalLiteral = 0x00002000,
|
||||
Default = 0x00000100, // Function/Class (export default declaration)
|
||||
MultiLine = 0x00000200, // Multi-line array or object literal
|
||||
Synthetic = 0x00000400, // Synthetic node (for full fidelity)
|
||||
DeclarationFile = 0x00000800, // Node is a .d.ts file
|
||||
Let = 0x00001000, // Variable declaration
|
||||
Const = 0x00002000, // Variable declaration
|
||||
OctalLiteral = 0x00004000,
|
||||
ExportContext = 0x00008000, // Export context (initialized by binding)
|
||||
|
||||
Modifier = Export | Ambient | Public | Private | Protected | Static,
|
||||
Modifier = Export | Ambient | Public | Private | Protected | Static | Default,
|
||||
AccessibilityModifier = Public | Private | Protected,
|
||||
BlockScoped = Let | Const
|
||||
}
|
||||
@@ -324,22 +334,25 @@ module ts {
|
||||
// If this node was parsed in the parameters of a generator.
|
||||
GeneratorParameter = 1 << 3,
|
||||
|
||||
// If this node was parsed as part of a decorator
|
||||
Decorator = 1 << 4,
|
||||
|
||||
// If the parser encountered an error when parsing the code that created this node. Note
|
||||
// the parser only sets this directly on the node it creates right after encountering the
|
||||
// error.
|
||||
ThisNodeHasError = 1 << 4,
|
||||
// error.
|
||||
ThisNodeHasError = 1 << 5,
|
||||
|
||||
// Context flags set directly by the parser.
|
||||
ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | ThisNodeHasError,
|
||||
ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError,
|
||||
|
||||
// Context flags computed by aggregating child flags upwards.
|
||||
|
||||
// Used during incremental parsing to determine if this node or any of its children had an
|
||||
// Used during incremental parsing to determine if this node or any of its children had an
|
||||
// error. Computed only once and then cached.
|
||||
ThisNodeOrAnySubNodesHasError = 1 << 5,
|
||||
ThisNodeOrAnySubNodesHasError = 1 << 6,
|
||||
|
||||
// Used to know if we've computed data from children and cached it in this node.
|
||||
HasAggregatedChildData = 1 << 6
|
||||
HasAggregatedChildData = 1 << 7
|
||||
}
|
||||
|
||||
export const enum RelationComparisonResult {
|
||||
@@ -351,16 +364,17 @@ module ts {
|
||||
export interface Node extends TextRange {
|
||||
kind: SyntaxKind;
|
||||
flags: NodeFlags;
|
||||
// Specific context the parser was in when this node was created. Normally undefined.
|
||||
// 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)
|
||||
decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
|
||||
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)
|
||||
}
|
||||
|
||||
export interface NodeArray<T> extends Array<T>, TextRange {
|
||||
@@ -394,6 +408,10 @@ module ts {
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface Decorator extends Node {
|
||||
expression: LeftHandSideExpression;
|
||||
}
|
||||
|
||||
export interface TypeParameterDeclaration extends Declaration {
|
||||
name: Identifier;
|
||||
constraint?: TypeNode;
|
||||
@@ -500,7 +518,7 @@ module ts {
|
||||
}
|
||||
|
||||
export interface FunctionDeclaration extends FunctionLikeDeclaration, Statement {
|
||||
name: Identifier;
|
||||
name?: Identifier;
|
||||
body?: Block;
|
||||
}
|
||||
|
||||
@@ -521,7 +539,12 @@ module ts {
|
||||
body?: Block;
|
||||
}
|
||||
|
||||
// See the comment on MethodDeclaration for the intuition behind AccessorDeclaration being a
|
||||
// For when we encounter a semicolon in a class declaration. ES6 allows these as class elements.
|
||||
export interface SemicolonClassElement extends ClassElement {
|
||||
_semicolonClassElementBrand: any;
|
||||
}
|
||||
|
||||
// See the comment on MethodDeclaration for the intuition behind AccessorDeclaration being a
|
||||
// ClassElement and an ObjectLiteralElement.
|
||||
export interface AccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement {
|
||||
_accessorDeclarationBrand: any;
|
||||
@@ -572,12 +595,12 @@ module ts {
|
||||
|
||||
export interface StringLiteralTypeNode extends LiteralExpression, TypeNode { }
|
||||
|
||||
// Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing.
|
||||
// Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing.
|
||||
// Consider 'Expression'. Without the brand, 'Expression' is actually no different
|
||||
// (structurally) than 'Node'. Because of this you can pass any Node to a function that
|
||||
// takes an Expression without any error. By using the 'brands' we ensure that the type
|
||||
// checker actually thinks you have something of the right type. Note: the brands are
|
||||
// never actually given values. At runtime they have zero cost.
|
||||
// checker actually thinks you have something of the right type. Note: the brands are
|
||||
// never actually given values. At runtime they have zero cost.
|
||||
|
||||
export interface Expression extends Node {
|
||||
_expressionBrand: any;
|
||||
@@ -639,7 +662,9 @@ module ts {
|
||||
|
||||
export interface ConditionalExpression extends Expression {
|
||||
condition: Expression;
|
||||
questionToken: Node;
|
||||
whenTrue: Expression;
|
||||
colonToken: Node;
|
||||
whenFalse: Expression;
|
||||
}
|
||||
|
||||
@@ -648,12 +673,17 @@ module ts {
|
||||
body: Block | Expression; // Required, whereas the member inherited from FunctionDeclaration is optional
|
||||
}
|
||||
|
||||
export interface ArrowFunction extends Expression, FunctionLikeDeclaration {
|
||||
equalsGreaterThanToken: Node;
|
||||
}
|
||||
|
||||
// The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral,
|
||||
// or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters.
|
||||
// For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1".
|
||||
export interface LiteralExpression extends PrimaryExpression {
|
||||
text: string;
|
||||
isUnterminated?: boolean;
|
||||
hasExtendedUnicodeEscape?: boolean;
|
||||
}
|
||||
|
||||
export interface StringLiteralExpression extends LiteralExpression {
|
||||
@@ -691,6 +721,7 @@ module ts {
|
||||
|
||||
export interface PropertyAccessExpression extends MemberExpression {
|
||||
expression: LeftHandSideExpression;
|
||||
dotToken: Node;
|
||||
name: Identifier;
|
||||
}
|
||||
|
||||
@@ -705,6 +736,11 @@ module ts {
|
||||
arguments: NodeArray<Expression>;
|
||||
}
|
||||
|
||||
export interface HeritageClauseElement extends Node {
|
||||
expression: LeftHandSideExpression;
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface NewExpression extends CallExpression, PrimaryExpression { }
|
||||
|
||||
export interface TaggedTemplateExpression extends MemberExpression {
|
||||
@@ -728,7 +764,7 @@ module ts {
|
||||
}
|
||||
|
||||
export interface VariableStatement extends Statement {
|
||||
declarationList: VariableDeclarationList;
|
||||
declarationList: VariableDeclarationList;
|
||||
}
|
||||
|
||||
export interface ExpressionStatement extends Statement {
|
||||
@@ -784,6 +820,10 @@ module ts {
|
||||
|
||||
export interface SwitchStatement extends Statement {
|
||||
expression: Expression;
|
||||
caseBlock: CaseBlock;
|
||||
}
|
||||
|
||||
export interface CaseBlock extends Node {
|
||||
clauses: NodeArray<CaseOrDefaultClause>;
|
||||
}
|
||||
|
||||
@@ -813,9 +853,8 @@ module ts {
|
||||
finallyBlock?: Block;
|
||||
}
|
||||
|
||||
export interface CatchClause extends Declaration {
|
||||
name: Identifier;
|
||||
type?: TypeNode;
|
||||
export interface CatchClause extends Node {
|
||||
variableDeclaration: VariableDeclaration;
|
||||
block: Block;
|
||||
}
|
||||
|
||||
@@ -823,13 +862,19 @@ module ts {
|
||||
_moduleElementBrand: any;
|
||||
}
|
||||
|
||||
export interface ClassDeclaration extends Declaration, ModuleElement {
|
||||
name: Identifier;
|
||||
export interface ClassLikeDeclaration extends Declaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
members: NodeArray<ClassElement>;
|
||||
}
|
||||
|
||||
export interface ClassDeclaration extends ClassLikeDeclaration, Statement {
|
||||
}
|
||||
|
||||
export interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression {
|
||||
}
|
||||
|
||||
export interface ClassElement extends Declaration {
|
||||
_classElementBrand: any;
|
||||
}
|
||||
@@ -843,7 +888,7 @@ module ts {
|
||||
|
||||
export interface HeritageClause extends Node {
|
||||
token: SyntaxKind;
|
||||
types?: NodeArray<TypeReferenceNode>;
|
||||
types?: NodeArray<HeritageClauseElement>;
|
||||
}
|
||||
|
||||
export interface TypeAliasDeclaration extends Declaration, ModuleElement {
|
||||
@@ -863,11 +908,7 @@ module ts {
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
|
||||
export interface ExportContainer {
|
||||
exportStars?: ExportDeclaration[]; // List of 'export *' statements (initialized by binding)
|
||||
}
|
||||
|
||||
export interface ModuleDeclaration extends Declaration, ModuleElement, ExportContainer {
|
||||
export interface ModuleDeclaration extends Declaration, ModuleElement {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: ModuleBlock | ModuleDeclaration;
|
||||
}
|
||||
@@ -892,12 +933,12 @@ module ts {
|
||||
// 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 {
|
||||
export interface ImportDeclaration extends ModuleElement {
|
||||
importClause?: ImportClause;
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
|
||||
// In case of:
|
||||
// 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 }
|
||||
@@ -912,7 +953,7 @@ module ts {
|
||||
name: Identifier;
|
||||
}
|
||||
|
||||
export interface ExportDeclaration extends Statement, ModuleElement {
|
||||
export interface ExportDeclaration extends Declaration, ModuleElement {
|
||||
exportClause?: NamedExports;
|
||||
moduleSpecifier?: Expression;
|
||||
}
|
||||
@@ -932,8 +973,10 @@ module ts {
|
||||
export type ImportSpecifier = ImportOrExportSpecifier;
|
||||
export type ExportSpecifier = ImportOrExportSpecifier;
|
||||
|
||||
export interface ExportAssignment extends Statement, ModuleElement {
|
||||
exportName: Identifier;
|
||||
export interface ExportAssignment extends Declaration, ModuleElement {
|
||||
isExportEquals?: boolean;
|
||||
expression?: Expression;
|
||||
type?: TypeNode;
|
||||
}
|
||||
|
||||
export interface FileReference extends TextRange {
|
||||
@@ -945,7 +988,7 @@ module ts {
|
||||
}
|
||||
|
||||
// Source files are declarations when they are external modules.
|
||||
export interface SourceFile extends Declaration, ExportContainer {
|
||||
export interface SourceFile extends Declaration {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
endOfFileToken: Node;
|
||||
|
||||
@@ -962,7 +1005,7 @@ module ts {
|
||||
externalModuleIndicator: Node;
|
||||
languageVersion: ScriptTarget;
|
||||
identifiers: Map<string>;
|
||||
|
||||
|
||||
/* @internal */ nodeCount: number;
|
||||
/* @internal */ identifierCount: number;
|
||||
/* @internal */ symbolCount: number;
|
||||
@@ -970,10 +1013,10 @@ module ts {
|
||||
// File level diagnostics reported by the parser (includes diagnostics about /// references
|
||||
// as well as code diagnostics).
|
||||
/* @internal */ parseDiagnostics: Diagnostic[];
|
||||
|
||||
|
||||
// File level diagnostics reported by the binder.
|
||||
/* @internal */ bindDiagnostics: Diagnostic[];
|
||||
|
||||
|
||||
// Stores a line map for the file.
|
||||
// This field should never be used directly to obtain line map, use getLineMap function instead.
|
||||
/* @internal */ lineMap: number[];
|
||||
@@ -993,14 +1036,14 @@ module ts {
|
||||
getSourceFiles(): SourceFile[];
|
||||
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* specific file will be generated.
|
||||
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
|
||||
* the JavaScript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the JavaScript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
|
||||
@@ -1014,7 +1057,7 @@ module ts {
|
||||
|
||||
getCommonSourceDirectory(): string;
|
||||
|
||||
// For testing purposes only. Should not be used by any other consumers (including the
|
||||
// For testing purposes only. Should not be used by any other consumers (including the
|
||||
// language service).
|
||||
/* @internal */ getDiagnosticsProducingTypeChecker(): TypeChecker;
|
||||
|
||||
@@ -1051,7 +1094,7 @@ module ts {
|
||||
// when -version or -help was provided, or this was a normal compilation, no diagnostics
|
||||
// were produced, and all outputs were generated successfully.
|
||||
Success = 0,
|
||||
|
||||
|
||||
// Diagnostics were produced and because of them no code was generated.
|
||||
DiagnosticsPresent_OutputsSkipped = 1,
|
||||
|
||||
@@ -1080,6 +1123,9 @@ module ts {
|
||||
getSignaturesOfType(type: Type, kind: SignatureKind): Signature[];
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
|
||||
getReturnTypeOfSignature(signature: Signature): Type;
|
||||
|
||||
// If 'predicate' is supplied, then only the first symbol in scope matching the predicate
|
||||
// will be returned. Otherwise, all symbols in scope will be returned.
|
||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||
getSymbolAtLocation(node: Node): Symbol;
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
||||
@@ -1100,6 +1146,7 @@ module ts {
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
|
||||
// Should not be called directly. Should only be accessed through the Program instance.
|
||||
/* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
@@ -1160,12 +1207,12 @@ module ts {
|
||||
|
||||
// Write symbols's type argument if it is instantiated symbol
|
||||
// eg. class C<T> { p: T } <-- Show p as C<T>.p here
|
||||
// var a: C<number>;
|
||||
// var a: C<number>;
|
||||
// var p = a.p; <--- Here p is property of C<number> so show it as C<number>.p instead of just C.p
|
||||
WriteTypeParametersOrArguments = 0x00000001,
|
||||
WriteTypeParametersOrArguments = 0x00000001,
|
||||
|
||||
// Use only external alias information to get the symbol name in the given context
|
||||
// eg. module m { export class c { } } import x = m.c;
|
||||
// eg. module m { export class c { } } import x = m.c;
|
||||
// When this flag is specified m.c will be used to refer to the class instead of alias symbol x
|
||||
UseOnlyExternalAliasing = 0x00000002,
|
||||
}
|
||||
@@ -1176,9 +1223,11 @@ module ts {
|
||||
CannotBeNamed
|
||||
}
|
||||
|
||||
export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
|
||||
|
||||
export interface SymbolVisibilityResult {
|
||||
accessibility: SymbolAccessibility;
|
||||
aliasesToMakeVisible?: ImportEqualsDeclaration[]; // aliases that need to have this symbol visible
|
||||
aliasesToMakeVisible?: AnyImportSyntax[]; // 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
|
||||
}
|
||||
@@ -1188,21 +1237,24 @@ module ts {
|
||||
}
|
||||
|
||||
export interface EmitResolver {
|
||||
getGeneratedNameForNode(node: ModuleDeclaration | EnumDeclaration | ImportDeclaration | ExportDeclaration): string;
|
||||
getExpressionNameSubstitution(node: Identifier): string;
|
||||
getExportAssignmentName(node: SourceFile): string;
|
||||
isReferencedImportDeclaration(node: Node): boolean;
|
||||
hasGlobalName(name: string): boolean;
|
||||
getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string;
|
||||
isValueAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
collectLinkedAliases(node: Identifier): Node[];
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
|
||||
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isUnknownIdentifier(location: Node, name: string): boolean;
|
||||
resolvesToSomeValue(location: Node, name: string): boolean;
|
||||
getBlockScopedVariableId(node: Identifier): number;
|
||||
}
|
||||
|
||||
export const enum SymbolFlags {
|
||||
@@ -1226,18 +1278,17 @@ module ts {
|
||||
Signature = 0x00020000, // Call, construct, or index signature
|
||||
TypeParameter = 0x00040000, // Type parameter
|
||||
TypeAlias = 0x00080000, // Type alias
|
||||
|
||||
// Export markers (see comment in declareModuleMember in binder)
|
||||
ExportValue = 0x00100000, // Exported value marker
|
||||
ExportType = 0x00200000, // Exported type marker
|
||||
ExportNamespace = 0x00400000, // Exported namespace marker
|
||||
Import = 0x00800000, // Import
|
||||
ExportValue = 0x00100000, // Exported value marker (see comment in declareModuleMember in binder)
|
||||
ExportType = 0x00200000, // Exported type marker (see comment in declareModuleMember in binder)
|
||||
ExportNamespace = 0x00400000, // Exported namespace marker (see comment in declareModuleMember in binder)
|
||||
Alias = 0x00800000, // An alias for another symbol (see comment in isAliasSymbolDeclaration in checker)
|
||||
Instantiated = 0x01000000, // Instantiated symbol
|
||||
Merged = 0x02000000, // Merged symbol (created during program binding)
|
||||
Transient = 0x04000000, // Transient symbol (created during type check)
|
||||
Prototype = 0x08000000, // Prototype property (no source representation)
|
||||
UnionProperty = 0x10000000, // Property in union type
|
||||
Optional = 0x20000000, // Optional property
|
||||
ExportStar = 0x40000000, // Export * declaration
|
||||
|
||||
Enum = RegularEnum | ConstEnum,
|
||||
Variable = FunctionScopedVariable | BlockScopedVariable,
|
||||
@@ -1270,9 +1321,9 @@ module ts {
|
||||
SetAccessorExcludes = Value & ~GetAccessor,
|
||||
TypeParameterExcludes = Type & ~TypeParameter,
|
||||
TypeAliasExcludes = Type,
|
||||
ImportExcludes = Import, // Imports collide with all other imports with the same name
|
||||
AliasExcludes = Alias,
|
||||
|
||||
ModuleMember = Variable | Function | Class | Interface | Enum | Module | TypeAlias | Import,
|
||||
ModuleMember = Variable | Function | Class | Interface | Enum | Module | TypeAlias | Alias,
|
||||
|
||||
ExportHasLocal = Function | Class | Enum | ValueModule,
|
||||
|
||||
@@ -1305,10 +1356,9 @@ module ts {
|
||||
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
|
||||
exportsChecked?: boolean; // True if exports of external module have been checked
|
||||
}
|
||||
|
||||
export interface TransientSymbol extends Symbol, SymbolLinks { }
|
||||
@@ -1318,16 +1368,18 @@ module ts {
|
||||
}
|
||||
|
||||
export const enum NodeCheckFlags {
|
||||
TypeChecked = 0x00000001, // Node has been type checked
|
||||
LexicalThis = 0x00000002, // Lexical 'this' reference
|
||||
CaptureThis = 0x00000004, // Lexical 'this' used in body
|
||||
EmitExtends = 0x00000008, // Emit __extends
|
||||
SuperInstance = 0x00000010, // Instance 'super' reference
|
||||
SuperStatic = 0x00000020, // Static 'super' reference
|
||||
ContextChecked = 0x00000040, // Contextual types have been assigned
|
||||
TypeChecked = 0x00000001, // Node has been type checked
|
||||
LexicalThis = 0x00000002, // Lexical 'this' reference
|
||||
CaptureThis = 0x00000004, // Lexical 'this' used in body
|
||||
EmitExtends = 0x00000008, // Emit __extends
|
||||
SuperInstance = 0x00000010, // Instance 'super' reference
|
||||
SuperStatic = 0x00000020, // Static 'super' reference
|
||||
ContextChecked = 0x00000040, // Contextual types have been assigned
|
||||
|
||||
// Values for enum members have been computed, and any errors have been reported for them.
|
||||
EnumValuesComputed = 0x00000080,
|
||||
EnumValuesComputed = 0x00000080,
|
||||
BlockScopedBindingInLoop = 0x00000100,
|
||||
EmitDecorate = 0x00000200, // Emit __decorate
|
||||
}
|
||||
|
||||
export interface NodeLinks {
|
||||
@@ -1474,11 +1526,15 @@ module ts {
|
||||
(t: Type): Type;
|
||||
}
|
||||
|
||||
// @internal
|
||||
export interface TypeInferences {
|
||||
primary: Type[]; // Inferences made directly to a type parameter
|
||||
secondary: Type[]; // Inferences made to a type parameter in a union type
|
||||
isFixed: boolean; // Whether the type parameter is fixed, as defined in section 4.12.2 of the TypeScript spec
|
||||
// If a type parameter is fixed, no more inferences can be made for the type parameter
|
||||
}
|
||||
|
||||
// @internal
|
||||
export interface InferenceContext {
|
||||
typeParameters: TypeParameter[]; // Type parameters for which inferences are made
|
||||
inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType)
|
||||
@@ -1523,7 +1579,6 @@ module ts {
|
||||
export interface CompilerOptions {
|
||||
allowNonTsExtensions?: boolean;
|
||||
charset?: string;
|
||||
codepage?: number;
|
||||
declaration?: boolean;
|
||||
diagnostics?: boolean;
|
||||
emitBOM?: boolean;
|
||||
@@ -1537,7 +1592,6 @@ module ts {
|
||||
noErrorTruncation?: boolean;
|
||||
noImplicitAny?: boolean;
|
||||
noLib?: boolean;
|
||||
noLibCheck?: boolean;
|
||||
noResolve?: boolean;
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
@@ -1550,7 +1604,8 @@ module ts {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
separateCompilation?: boolean;
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
|
||||
@@ -1768,7 +1823,7 @@ module ts {
|
||||
// Gets a count of how many times this collection has been modified. This value changes
|
||||
// each time 'add' is called (regardless of whether or not an equivalent diagnostic was
|
||||
// already in the collection). As such, it can be used as a simple way to tell if any
|
||||
// operation caused diagnostics to be returned by storing and comparing the return value
|
||||
// operation caused diagnostics to be returned by storing and comparing the return value
|
||||
// of this method before/after the operation is performed.
|
||||
getModificationCount(): number;
|
||||
}
|
||||
|
||||
+734
-127
File diff suppressed because it is too large
Load Diff
@@ -152,7 +152,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
if (this.errors) {
|
||||
Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.ts$/, '.errors.txt'), (): string => {
|
||||
if (result.errors.length === 0) return null;
|
||||
|
||||
return getErrorBaseline(toBeCompiled, otherFiles, result);
|
||||
});
|
||||
}
|
||||
|
||||
+53
-24
@@ -14,6 +14,7 @@
|
||||
//
|
||||
|
||||
/// <reference path='..\services\services.ts' />
|
||||
/// <reference path='..\services\shims.ts' />
|
||||
/// <reference path='harnessLanguageService.ts' />
|
||||
/// <reference path='harness.ts' />
|
||||
/// <reference path='fourslashRunner.ts' />
|
||||
@@ -115,7 +116,7 @@ module FourSlash {
|
||||
// Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions
|
||||
// To add additional option, add property into the testOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames
|
||||
// Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data
|
||||
var testOptMetadataNames = {
|
||||
var metadataOptionNames = {
|
||||
baselineFile: 'BaselineFile',
|
||||
declaration: 'declaration',
|
||||
emitThisFile: 'emitThisFile', // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project
|
||||
@@ -126,14 +127,15 @@ module FourSlash {
|
||||
outDir: 'outDir',
|
||||
sourceMap: 'sourceMap',
|
||||
sourceRoot: 'sourceRoot',
|
||||
allowNonTsExtensions: 'allowNonTsExtensions',
|
||||
resolveReference: 'ResolveReference', // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file
|
||||
};
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = [testOptMetadataNames.fileName, testOptMetadataNames.emitThisFile, testOptMetadataNames.resolveReference];
|
||||
var globalMetadataNames = [testOptMetadataNames.baselineFile, testOptMetadataNames.declaration,
|
||||
testOptMetadataNames.mapRoot, testOptMetadataNames.module, testOptMetadataNames.out,
|
||||
testOptMetadataNames.outDir, testOptMetadataNames.sourceMap, testOptMetadataNames.sourceRoot]
|
||||
var fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference];
|
||||
var globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration,
|
||||
metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out,
|
||||
metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot]
|
||||
|
||||
function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions {
|
||||
var settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 };
|
||||
@@ -141,13 +143,16 @@ module FourSlash {
|
||||
for (var prop in globalOptions) {
|
||||
if (globalOptions.hasOwnProperty(prop)) {
|
||||
switch (prop) {
|
||||
case testOptMetadataNames.declaration:
|
||||
case metadataOptionNames.allowNonTsExtensions:
|
||||
settings.allowNonTsExtensions = true;
|
||||
break;
|
||||
case metadataOptionNames.declaration:
|
||||
settings.declaration = true;
|
||||
break;
|
||||
case testOptMetadataNames.mapRoot:
|
||||
case metadataOptionNames.mapRoot:
|
||||
settings.mapRoot = globalOptions[prop];
|
||||
break;
|
||||
case testOptMetadataNames.module:
|
||||
case metadataOptionNames.module:
|
||||
// create appropriate external module target for CompilationSettings
|
||||
switch (globalOptions[prop]) {
|
||||
case "AMD":
|
||||
@@ -162,16 +167,16 @@ module FourSlash {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case testOptMetadataNames.out:
|
||||
case metadataOptionNames.out:
|
||||
settings.out = globalOptions[prop];
|
||||
break;
|
||||
case testOptMetadataNames.outDir:
|
||||
case metadataOptionNames.outDir:
|
||||
settings.outDir = globalOptions[prop];
|
||||
break;
|
||||
case testOptMetadataNames.sourceMap:
|
||||
case metadataOptionNames.sourceMap:
|
||||
settings.sourceMap = true;
|
||||
break;
|
||||
case testOptMetadataNames.sourceRoot:
|
||||
case metadataOptionNames.sourceRoot:
|
||||
settings.sourceRoot = globalOptions[prop];
|
||||
break;
|
||||
}
|
||||
@@ -303,7 +308,7 @@ module FourSlash {
|
||||
ts.forEach(testData.files, file => {
|
||||
// Create map between fileName and its content for easily looking up when resolveReference flag is specified
|
||||
this.inputFiles[file.fileName] = file.content;
|
||||
if (!startResolveFileRef && file.fileOptions[testOptMetadataNames.resolveReference]) {
|
||||
if (!startResolveFileRef && file.fileOptions[metadataOptionNames.resolveReference]) {
|
||||
startResolveFileRef = file;
|
||||
} else if (startResolveFileRef) {
|
||||
// If entry point for resolving file references is already specified, report duplication error
|
||||
@@ -620,7 +625,7 @@ module FourSlash {
|
||||
this.scenarioActions.push('<VerifyCompletionDoesNotContainItem ItemName="' + escapeXmlAttributeValue(symbol) + '" />');
|
||||
|
||||
var members = this.getMemberListAtCaret();
|
||||
if (members.entries.filter(e => e.name === symbol).length !== 0) {
|
||||
if (members && members.entries.filter(e => e.name === symbol).length !== 0) {
|
||||
this.raiseError('Member list did contain ' + symbol);
|
||||
}
|
||||
}
|
||||
@@ -691,7 +696,12 @@ module FourSlash {
|
||||
|
||||
public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
var completions = this.getCompletionListAtCaret();
|
||||
this.assertItemInCompletionList(completions.entries, symbol, text, documentation, kind);
|
||||
if (completions) {
|
||||
this.assertItemInCompletionList(completions.entries, symbol, text, documentation, kind);
|
||||
}
|
||||
else {
|
||||
this.raiseError(`No completions at position '${ this.currentCaretPosition }' when looking for '${ symbol }'.`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCompletionListDoesNotContain(symbol: string) {
|
||||
@@ -699,7 +709,7 @@ module FourSlash {
|
||||
this.scenarioActions.push('<VerifyCompletionDoesNotContainItem ItemName="' + escapeXmlAttributeValue(symbol) + '" />');
|
||||
|
||||
var completions = this.getCompletionListAtCaret();
|
||||
if (completions && completions.entries && completions.entries.filter(e => e.name === symbol).length !== 0) {
|
||||
if (completions && completions.entries.filter(e => e.name === symbol).length !== 0) {
|
||||
this.raiseError('Completion list did contain ' + symbol);
|
||||
}
|
||||
}
|
||||
@@ -788,6 +798,13 @@ module FourSlash {
|
||||
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
|
||||
}
|
||||
|
||||
public getSemanticDiagnostics(expected: string) {
|
||||
var diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName);
|
||||
var realized = ts.realizeDiagnostics(diagnostics, "\r\n");
|
||||
var actual = JSON.stringify(realized, null, " ");
|
||||
assert.equal(actual, expected);
|
||||
}
|
||||
|
||||
public verifyQuickInfoString(negative: boolean, expectedText?: string, expectedDocumentation?: string) {
|
||||
[expectedText, expectedDocumentation].forEach(str => {
|
||||
if (str) {
|
||||
@@ -1126,7 +1143,7 @@ module FourSlash {
|
||||
|
||||
Harness.Baseline.runBaseline(
|
||||
"Breakpoint Locations for " + this.activeFile.fileName,
|
||||
this.testData.globalOptions[testOptMetadataNames.baselineFile],
|
||||
this.testData.globalOptions[metadataOptionNames.baselineFile],
|
||||
() => {
|
||||
return this.baselineCurrentFileLocations(pos => this.getBreakpointStatementLocation(pos));
|
||||
},
|
||||
@@ -1141,7 +1158,7 @@ module FourSlash {
|
||||
var allFourSlashFiles = this.testData.files;
|
||||
for (var idx = 0; idx < allFourSlashFiles.length; ++idx) {
|
||||
var file = allFourSlashFiles[idx];
|
||||
if (file.fileOptions[testOptMetadataNames.emitThisFile]) {
|
||||
if (file.fileOptions[metadataOptionNames.emitThisFile]) {
|
||||
// Find a file with the flag emitThisFile turned on
|
||||
emitFiles.push(file);
|
||||
}
|
||||
@@ -1154,7 +1171,7 @@ module FourSlash {
|
||||
|
||||
Harness.Baseline.runBaseline(
|
||||
"Generate getEmitOutput baseline : " + emitFiles.join(" "),
|
||||
this.testData.globalOptions[testOptMetadataNames.baselineFile],
|
||||
this.testData.globalOptions[metadataOptionNames.baselineFile],
|
||||
() => {
|
||||
var resultString = "";
|
||||
// Loop through all the emittedFiles and emit them one by one
|
||||
@@ -1480,6 +1497,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 />');
|
||||
|
||||
@@ -1611,8 +1638,9 @@ module FourSlash {
|
||||
this.taoInvalidReason = 'verifyIndentationAtCurrentPosition NYI';
|
||||
|
||||
var actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (actual != numberOfSpaces) {
|
||||
this.raiseError('verifyIndentationAtCurrentPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual);
|
||||
var lineCol = this.getLineColStringAtPosition(this.currentCaretPosition);
|
||||
if (actual !== numberOfSpaces) {
|
||||
this.raiseError('verifyIndentationAtCurrentPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1620,8 +1648,9 @@ module FourSlash {
|
||||
this.taoInvalidReason = 'verifyIndentationAtPosition NYI';
|
||||
|
||||
var actual = this.getIndentation(fileName, position);
|
||||
var lineCol = this.getLineColStringAtPosition(position);
|
||||
if (actual !== numberOfSpaces) {
|
||||
this.raiseError('verifyIndentationAtPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual);
|
||||
this.raiseError('verifyIndentationAtPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1687,7 +1716,7 @@ module FourSlash {
|
||||
|
||||
Harness.Baseline.runBaseline(
|
||||
"Name OrDottedNameSpans for " + this.activeFile.fileName,
|
||||
this.testData.globalOptions[testOptMetadataNames.baselineFile],
|
||||
this.testData.globalOptions[metadataOptionNames.baselineFile],
|
||||
() => {
|
||||
return this.baselineCurrentFileLocations(pos =>
|
||||
this.getNameOrDottedNameSpan(pos));
|
||||
@@ -2263,7 +2292,7 @@ module FourSlash {
|
||||
if (globalMetadataNamesIndex === -1) {
|
||||
if (fileMetadataNamesIndex === -1) {
|
||||
throw new Error('Unrecognized metadata name "' + match[1] + '". Available global metadata names are: ' + globalMetadataNames.join(', ') + '; file metadata names are: ' + fileMetadataNames.join(', '));
|
||||
} else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(testOptMetadataNames.fileName)) {
|
||||
} else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) {
|
||||
// Found an @FileName directive, if this is not the first then create a new subfile
|
||||
if (currentFileContent) {
|
||||
var file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges);
|
||||
|
||||
+20
-22
@@ -835,7 +835,7 @@ module Harness {
|
||||
// Register input files
|
||||
function register(file: { unitName: string; content: string; }) {
|
||||
if (file.content !== undefined) {
|
||||
var fileName = ts.normalizeSlashes(file.unitName);
|
||||
var fileName = ts.normalizePath(file.unitName);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
}
|
||||
};
|
||||
@@ -844,6 +844,7 @@ module Harness {
|
||||
return {
|
||||
getCurrentDirectory,
|
||||
getSourceFile: (fn, languageVersion) => {
|
||||
fn = ts.normalizePath(fn);
|
||||
if (Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(fn))) {
|
||||
return filemap[getCanonicalFileName(fn)];
|
||||
}
|
||||
@@ -1035,17 +1036,7 @@ module Harness {
|
||||
useCaseSensitiveFileNames = setting.value === 'true';
|
||||
break;
|
||||
|
||||
case 'mapsourcefiles':
|
||||
case 'maproot':
|
||||
case 'generatedeclarationfiles':
|
||||
case 'gatherDiagnostics':
|
||||
case 'codepage':
|
||||
case 'createFileLog':
|
||||
case 'filename':
|
||||
case 'removecomments':
|
||||
case 'watch':
|
||||
case 'allowautomaticsemicoloninsertion':
|
||||
case 'locale':
|
||||
// Not supported yet
|
||||
break;
|
||||
|
||||
@@ -1061,6 +1052,10 @@ module Harness {
|
||||
options.preserveConstEnums = setting.value === 'true';
|
||||
break;
|
||||
|
||||
case 'separatecompilation':
|
||||
options.separateCompilation = setting.value === 'true';
|
||||
break;
|
||||
|
||||
case 'suppressimplicitanyindexerrors':
|
||||
options.suppressImplicitAnyIndexErrors = setting.value === 'true';
|
||||
break;
|
||||
@@ -1074,16 +1069,6 @@ module Harness {
|
||||
}
|
||||
});
|
||||
|
||||
var filemap: { [name: string]: ts.SourceFile; } = {};
|
||||
var register = (file: { unitName: string; content: string; }) => {
|
||||
if (file.content !== undefined) {
|
||||
var fileName = ts.normalizeSlashes(file.unitName);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, options.target, assertInvariants);
|
||||
}
|
||||
};
|
||||
inputFiles.forEach(register);
|
||||
otherFiles.forEach(register);
|
||||
|
||||
var fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
var programFiles = inputFiles.map(file => file.unitName);
|
||||
@@ -1470,7 +1455,12 @@ module Harness {
|
||||
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal"];
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module",
|
||||
"nolib", "sourcemap", "target", "out", "outdir", "noemitonerror",
|
||||
"noimplicitany", "noresolve", "newline", "newlines", "emitbom",
|
||||
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
|
||||
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
|
||||
"separatecompilation"];
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSetting[] {
|
||||
|
||||
@@ -1708,6 +1698,14 @@ module Harness {
|
||||
return (Path.getFileName(filePath) === 'lib.d.ts') || (Path.getFileName(filePath) === 'lib.core.d.ts');
|
||||
}
|
||||
|
||||
export function getDefaultLibraryFile(): { unitName: string, content: string } {
|
||||
var libFile = Harness.userSpecifiedroot + Harness.libFolder + "/" + "lib.d.ts";
|
||||
return {
|
||||
unitName: libFile,
|
||||
content: IO.readFile(libFile)
|
||||
}
|
||||
}
|
||||
|
||||
if (Error) (<any>Error).stackTraceLimit = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path='..\services\services.ts' />
|
||||
/// <reference path='..\services\services.ts' />
|
||||
/// <reference path='..\services\shims.ts' />
|
||||
/// <reference path='..\server\client.ts' />
|
||||
/// <reference path='harness.ts' />
|
||||
@@ -330,6 +330,9 @@ module Harness.LanguageService {
|
||||
getReferencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] {
|
||||
return unwrapJSONCallResult(this.shim.getReferencesAtPosition(fileName, position));
|
||||
}
|
||||
findReferences(fileName: string, position: number): ts.ReferencedSymbol[] {
|
||||
return unwrapJSONCallResult(this.shim.findReferences(fileName, position));
|
||||
}
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] {
|
||||
return unwrapJSONCallResult(this.shim.getOccurrencesAtPosition(fileName, position));
|
||||
}
|
||||
@@ -469,6 +472,7 @@ module Harness.LanguageService {
|
||||
this.writeMessage(message);
|
||||
}
|
||||
|
||||
|
||||
readFile(fileName: string): string {
|
||||
if (fileName.indexOf(Harness.Compiler.defaultLibFileName) >= 0) {
|
||||
fileName = Harness.Compiler.defaultLibFileName;
|
||||
@@ -526,6 +530,15 @@ module Harness.LanguageService {
|
||||
msg(message: string) {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
loggingEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
isVerbose() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
endGroup(): void {
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ interface IOLog {
|
||||
arguments: string[];
|
||||
executingPath: string;
|
||||
currentDirectory: string;
|
||||
useCustomLibraryFile?: boolean;
|
||||
filesRead: {
|
||||
path: string;
|
||||
codepage: number;
|
||||
|
||||
+38
-14
@@ -32,6 +32,7 @@ module RWC {
|
||||
};
|
||||
var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
|
||||
var currentDirectory: string;
|
||||
var useCustomLibraryFile: boolean;
|
||||
|
||||
after(() => {
|
||||
// Mocha holds onto the closure environment of the describe callback even after the test is done.
|
||||
@@ -43,6 +44,10 @@ module RWC {
|
||||
baselineOpts = undefined;
|
||||
baseName = undefined;
|
||||
currentDirectory = undefined;
|
||||
// useCustomLibraryFile is a flag specified in the json object to indicate whether to use built/local/lib.d.ts
|
||||
// or to use lib.d.ts inside the json object. If the flag is true, use the lib.d.ts inside json file
|
||||
// otherwise use the lib.d.ts from built/local
|
||||
useCustomLibraryFile = undefined;
|
||||
});
|
||||
|
||||
it('can compile', () => {
|
||||
@@ -51,34 +56,52 @@ module RWC {
|
||||
|
||||
var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath));
|
||||
currentDirectory = ioLog.currentDirectory;
|
||||
useCustomLibraryFile = ioLog.useCustomLibraryFile;
|
||||
runWithIOLog(ioLog, () => {
|
||||
opts = ts.parseCommandLine(ioLog.arguments);
|
||||
assert.equal(opts.errors.length, 0);
|
||||
|
||||
// To provide test coverage of output javascript file,
|
||||
// we will set noEmitOnError flag to be false.
|
||||
opts.options.noEmitOnError = false;
|
||||
});
|
||||
|
||||
runWithIOLog(ioLog, () => {
|
||||
harnessCompiler.reset();
|
||||
|
||||
// Load the files
|
||||
ts.forEach(opts.fileNames, fileName => {
|
||||
inputFiles.push(getHarnessCompilerInputUnit(fileName));
|
||||
});
|
||||
|
||||
if (!opts.options.noLib) {
|
||||
// Find the lib.d.ts file in the input file and add it to the input files list
|
||||
var libFile = ts.forEach(ioLog.filesRead, fileRead=> Harness.isLibraryFile(fileRead.path) ? fileRead.path : undefined);
|
||||
if (libFile) {
|
||||
inputFiles.push(getHarnessCompilerInputUnit(libFile));
|
||||
}
|
||||
}
|
||||
|
||||
ts.forEach(ioLog.filesRead, fileRead => {
|
||||
// Add files to compilation
|
||||
for(let fileRead of ioLog.filesRead) {
|
||||
// Check if the file is already added into the set of input files.
|
||||
var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
|
||||
var inInputList = ts.forEach(inputFiles, inputFile=> inputFile.unitName === resolvedPath);
|
||||
if (!inInputList) {
|
||||
// Add the file to other files
|
||||
var inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath);
|
||||
|
||||
if (!Harness.isLibraryFile(fileRead.path)) {
|
||||
if (inInputList) {
|
||||
continue;
|
||||
}
|
||||
otherFiles.push(getHarnessCompilerInputUnit(fileRead.path));
|
||||
}
|
||||
});
|
||||
else if (!opts.options.noLib && Harness.isLibraryFile(fileRead.path)){
|
||||
if (!inInputList) {
|
||||
// If useCustomLibraryFile is true, we will use lib.d.ts from json object
|
||||
// otherwise use the lib.d.ts from built/local
|
||||
// Majority of RWC code will be using built/local/lib.d.ts instead of
|
||||
// lib.d.ts inside json file. However, some RWC cases will still use
|
||||
// their own version of lib.d.ts because they have customized lib.d.ts
|
||||
if (useCustomLibraryFile) {
|
||||
inputFiles.push(getHarnessCompilerInputUnit(fileRead.path));
|
||||
}
|
||||
else {
|
||||
inputFiles.push(Harness.getDefaultLibraryFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// do not use lib since we already read it in above
|
||||
opts.options.noLib = true;
|
||||
@@ -115,9 +138,10 @@ module RWC {
|
||||
|
||||
it('has the expected declaration file content', () => {
|
||||
Harness.Baseline.runBaseline('has the expected declaration file content', baseName + '.d.ts', () => {
|
||||
if (compilerResult.errors.length || !compilerResult.declFilesCode.length) {
|
||||
if (!compilerResult.declFilesCode.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Harness.Compiler.collateOutputs(compilerResult.declFilesCode);
|
||||
}, false, baselineOpts);
|
||||
});
|
||||
|
||||
@@ -38,7 +38,6 @@ class TypeWriterWalker {
|
||||
case ts.SyntaxKind.SuperKeyword:
|
||||
case ts.SyntaxKind.ArrayLiteralExpression:
|
||||
case ts.SyntaxKind.ObjectLiteralExpression:
|
||||
case ts.SyntaxKind.PropertyAccessExpression:
|
||||
case ts.SyntaxKind.ElementAccessExpression:
|
||||
case ts.SyntaxKind.CallExpression:
|
||||
case ts.SyntaxKind.NewExpression:
|
||||
@@ -56,6 +55,14 @@ class TypeWriterWalker {
|
||||
this.log(node, this.getTypeOfNode(node));
|
||||
break;
|
||||
|
||||
case ts.SyntaxKind.PropertyAccessExpression:
|
||||
for (var current = node; current.kind === ts.SyntaxKind.PropertyAccessExpression; current = current.parent) {
|
||||
}
|
||||
if (current.kind !== ts.SyntaxKind.HeritageClauseElement) {
|
||||
this.log(node, this.getTypeOfNode(node));
|
||||
}
|
||||
break;
|
||||
|
||||
// Should not change expression status (maybe expressions)
|
||||
// TODO: Again, ideally should log number and string literals too,
|
||||
// but to be consistent with the old typeWriter, just log identifiers
|
||||
|
||||
Vendored
+23
-3
@@ -164,19 +164,19 @@ interface ObjectConstructor {
|
||||
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
seal(o: any): any;
|
||||
seal<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
|
||||
* @param o Object on which to lock the attributes.
|
||||
*/
|
||||
freeze(o: any): any;
|
||||
freeze<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Prevents the addition of new properties to an object.
|
||||
* @param o Object to make non-extensible.
|
||||
*/
|
||||
preventExtensions(o: any): any;
|
||||
preventExtensions<T>(o: T): T;
|
||||
|
||||
/**
|
||||
* Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
|
||||
@@ -410,6 +410,9 @@ interface String {
|
||||
*/
|
||||
substr(from: number, length?: number): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): string;
|
||||
|
||||
[index: number]: string;
|
||||
}
|
||||
|
||||
@@ -462,6 +465,9 @@ interface Number {
|
||||
* @param precision Number of significant digits. Must be in the range 1 - 21, inclusive.
|
||||
*/
|
||||
toPrecision(precision?: number): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): number;
|
||||
}
|
||||
|
||||
interface NumberConstructor {
|
||||
@@ -1149,3 +1155,17 @@ interface ArrayConstructor {
|
||||
}
|
||||
|
||||
declare var Array: ArrayConstructor;
|
||||
|
||||
interface TypedPropertyDescriptor<T> {
|
||||
enumerable?: boolean;
|
||||
configurable?: boolean;
|
||||
writable?: boolean;
|
||||
value?: T;
|
||||
get?: () => T;
|
||||
set?: (value: T) => void;
|
||||
}
|
||||
|
||||
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
|
||||
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
|
||||
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
||||
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
|
||||
|
||||
Vendored
+158
-8
@@ -4,7 +4,11 @@
|
||||
/// Windows Script Host APIS
|
||||
/////////////////////////////
|
||||
|
||||
declare var ActiveXObject: { new (s: string): any; };
|
||||
|
||||
interface ActiveXObject {
|
||||
new (s: string): any;
|
||||
}
|
||||
declare var ActiveXObject: ActiveXObject;
|
||||
|
||||
interface ITextWriter {
|
||||
Write(s: string): void;
|
||||
@@ -12,11 +16,157 @@ interface ITextWriter {
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
declare var WScript: {
|
||||
Echo(s: any): void;
|
||||
StdErr: ITextWriter;
|
||||
StdOut: ITextWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
ScriptFullName: string;
|
||||
Quit(exitCode?: number): number;
|
||||
interface TextStreamBase {
|
||||
/**
|
||||
* The column number of the current character position in an input stream.
|
||||
*/
|
||||
Column: number;
|
||||
/**
|
||||
* The current line number in an input stream.
|
||||
*/
|
||||
Line: number;
|
||||
/**
|
||||
* Closes a text stream.
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
||||
*/
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
interface TextStreamWriter extends TextStreamBase {
|
||||
/**
|
||||
* Sends a string to an output stream.
|
||||
*/
|
||||
Write(s: string): void;
|
||||
/**
|
||||
* Sends a specified number of blank lines (newline characters) to an output stream.
|
||||
*/
|
||||
WriteBlankLines(intLines: number): void;
|
||||
/**
|
||||
* Sends a string followed by a newline character to an output stream.
|
||||
*/
|
||||
WriteLine(s: string): void;
|
||||
}
|
||||
|
||||
interface TextStreamReader extends TextStreamBase {
|
||||
/**
|
||||
* Returns a specified number of characters from an input stream, beginning at the current pointer position.
|
||||
* Does not return until the ENTER key is pressed.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
Read(characters: number): string;
|
||||
/**
|
||||
* Returns all characters from an input stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadAll(): string;
|
||||
/**
|
||||
* Returns an entire line from an input stream.
|
||||
* Although this method extracts the newline character, it does not add it to the returned string.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadLine(): string;
|
||||
/**
|
||||
* Skips a specified number of characters when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
|
||||
*/
|
||||
Skip(characters: number): void;
|
||||
/**
|
||||
* Skips the next line when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode, not writing or appending mode.
|
||||
*/
|
||||
SkipLine(): void;
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a line.
|
||||
*/
|
||||
AtEndOfLine: boolean;
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a stream.
|
||||
*/
|
||||
AtEndOfStream: boolean;
|
||||
}
|
||||
|
||||
declare var WScript: {
|
||||
/**
|
||||
* Outputs text to either a message box (under WScript.exe) or the command console window followed by a newline (under CScript.ext).
|
||||
*/
|
||||
Echo(s: any): void;
|
||||
/**
|
||||
* Exposes the write-only error output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdErr: TextStreamWriter;
|
||||
/**
|
||||
* Exposes the write-only output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdOut: TextStreamWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
/**
|
||||
* The full path of the currently running script.
|
||||
*/
|
||||
ScriptFullName: string;
|
||||
/**
|
||||
* Forces the script to stop immediately, with an optional exit code.
|
||||
*/
|
||||
Quit(exitCode?: number): number;
|
||||
/**
|
||||
* The Windows Script Host build version number.
|
||||
*/
|
||||
BuildVersion: number;
|
||||
/**
|
||||
* Fully qualified path of the host executable.
|
||||
*/
|
||||
FullName: string;
|
||||
/**
|
||||
* Gets/sets the script mode - interactive(true) or batch(false).
|
||||
*/
|
||||
Interactive: boolean;
|
||||
/**
|
||||
* The name of the host executable (WScript.exe or CScript.exe).
|
||||
*/
|
||||
Name: string;
|
||||
/**
|
||||
* Path of the directory containing the host executable.
|
||||
*/
|
||||
Path: string;
|
||||
/**
|
||||
* The filename of the currently running script.
|
||||
*/
|
||||
ScriptName: string;
|
||||
/**
|
||||
* Exposes the read-only input stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdIn: TextStreamReader;
|
||||
/**
|
||||
* Windows Script Host version
|
||||
*/
|
||||
Version: string;
|
||||
/**
|
||||
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
|
||||
*/
|
||||
ConnectObject(objEventSource: any, strPrefix: string): void;
|
||||
/**
|
||||
* Creates a COM object.
|
||||
* @param strProgiID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
CreateObject(strProgID: string, strPrefix?: string): any;
|
||||
/**
|
||||
* Disconnects a COM object from its event sources.
|
||||
*/
|
||||
DisconnectObject(obj: any): void;
|
||||
/**
|
||||
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
|
||||
* @param strPathname Fully qualified path to the file containing the object persisted to disk. For objects in memory, pass a zero-length string.
|
||||
* @param strProgID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
|
||||
/**
|
||||
* Suspends script execution for a specified length of time, then continues execution.
|
||||
* @param intTime Interval (in milliseconds) to suspend script execution.
|
||||
*/
|
||||
Sleep(intTime: number): void;
|
||||
};
|
||||
|
||||
+94
-61
@@ -46,21 +46,21 @@ module ts.server {
|
||||
return lineMap;
|
||||
}
|
||||
|
||||
private lineColToPosition(fileName: string, lineCol: protocol.Location): number {
|
||||
return ts.computePositionOfLineAndCharacter(this.getLineMap(fileName), lineCol.line - 1, lineCol.col - 1);
|
||||
private lineOffsetToPosition(fileName: string, lineOffset: protocol.Location): number {
|
||||
return ts.computePositionOfLineAndCharacter(this.getLineMap(fileName), lineOffset.line - 1, lineOffset.offset - 1);
|
||||
}
|
||||
|
||||
private positionToOneBasedLineCol(fileName: string, position: number): protocol.Location {
|
||||
var lineCol = ts.computeLineAndCharacterOfPosition(this.getLineMap(fileName), position);
|
||||
private positionToOneBasedLineOffset(fileName: string, position: number): protocol.Location {
|
||||
var lineOffset = ts.computeLineAndCharacterOfPosition(this.getLineMap(fileName), position);
|
||||
return {
|
||||
line: lineCol.line + 1,
|
||||
col: lineCol.character + 1
|
||||
line: lineOffset.line + 1,
|
||||
offset: lineOffset.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);
|
||||
var start = this.lineOffsetToPosition(fileName, codeEdit.start);
|
||||
var end = this.lineOffsetToPosition(fileName, codeEdit.end);
|
||||
|
||||
return {
|
||||
span: ts.createTextSpanFromBounds(start, end),
|
||||
@@ -68,12 +68,12 @@ module ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
private processRequest<T extends protocol.Request>(command: string, arguments?: any): T {
|
||||
private processRequest<T extends protocol.Request>(command: string, args?: any): T {
|
||||
var request: protocol.Request = {
|
||||
seq: this.sequence++,
|
||||
type: "request",
|
||||
command: command,
|
||||
arguments: arguments
|
||||
arguments: args,
|
||||
command
|
||||
};
|
||||
|
||||
this.writeMessage(JSON.stringify(request));
|
||||
@@ -134,15 +134,15 @@ module ts.server {
|
||||
// clear the line map after an edit
|
||||
this.lineMaps[fileName] = undefined;
|
||||
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, start);
|
||||
var endLineCol = this.positionToOneBasedLineCol(fileName, end);
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, start);
|
||||
var endLineOffset = this.positionToOneBasedLineOffset(fileName, end);
|
||||
|
||||
var args: protocol.ChangeRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
endLine: endLineCol.line,
|
||||
endCol: endLineCol.col,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
endLine: endLineOffset.line,
|
||||
endOffset: endLineOffset.offset,
|
||||
insertString: newText
|
||||
};
|
||||
|
||||
@@ -150,18 +150,18 @@ module ts.server {
|
||||
}
|
||||
|
||||
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset
|
||||
};
|
||||
|
||||
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);
|
||||
var start = this.lineOffsetToPosition(fileName, response.body.start);
|
||||
var end = this.lineOffsetToPosition(fileName, response.body.end);
|
||||
|
||||
return {
|
||||
kind: response.body.kind,
|
||||
@@ -173,11 +173,11 @@ module ts.server {
|
||||
}
|
||||
|
||||
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.CompletionsRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
prefix: undefined
|
||||
};
|
||||
|
||||
@@ -194,11 +194,11 @@ module ts.server {
|
||||
}
|
||||
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.CompletionDetailsRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
entryNames: [entryName]
|
||||
};
|
||||
|
||||
@@ -219,8 +219,8 @@ module ts.server {
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
|
||||
return {
|
||||
name: entry.name,
|
||||
@@ -237,14 +237,14 @@ module ts.server {
|
||||
}
|
||||
|
||||
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 startLineOffset = this.positionToOneBasedLineOffset(fileName, start);
|
||||
var endLineOffset = this.positionToOneBasedLineOffset(fileName, end);
|
||||
var args: protocol.FormatRequestArgs = {
|
||||
file: fileName,
|
||||
line: startLineCol.line,
|
||||
col: startLineCol.col,
|
||||
endLine: endLineCol.line,
|
||||
endCol: endLineCol.col,
|
||||
line: startLineOffset.line,
|
||||
offset: startLineOffset.offset,
|
||||
endLine: endLineOffset.line,
|
||||
endOffset: endLineOffset.offset,
|
||||
};
|
||||
|
||||
// TODO: handle FormatCodeOptions
|
||||
@@ -259,11 +259,11 @@ module ts.server {
|
||||
}
|
||||
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): ts.TextChange[] {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FormatOnKeyRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
key: key
|
||||
};
|
||||
|
||||
@@ -275,11 +275,11 @@ module ts.server {
|
||||
}
|
||||
|
||||
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.DefinitionRequest>(CommandNames.Definition, args);
|
||||
@@ -287,8 +287,8 @@ module ts.server {
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
containerKind: "",
|
||||
containerName: "",
|
||||
@@ -300,12 +300,17 @@ module ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
findReferences(fileName: string, position: number): ReferencedSymbol[]{
|
||||
// Not yet implemented.
|
||||
return [];
|
||||
}
|
||||
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.ReferencesRequest>(CommandNames.References, args);
|
||||
@@ -313,8 +318,8 @@ module ts.server {
|
||||
|
||||
return response.body.refs.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
fileName: fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
@@ -340,11 +345,11 @@ module ts.server {
|
||||
}
|
||||
|
||||
getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.RenameRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
findInStrings,
|
||||
findInComments
|
||||
};
|
||||
@@ -355,8 +360,8 @@ module ts.server {
|
||||
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);
|
||||
var start = this.lineOffsetToPosition(fileName, loc.start);
|
||||
var end = this.lineOffsetToPosition(fileName, loc.end);
|
||||
locations.push({
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
fileName: fileName
|
||||
@@ -400,7 +405,7 @@ module ts.server {
|
||||
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))),
|
||||
spans: item.spans.map(span=> createTextSpanFromBounds(this.lineOffsetToPosition(fileName, span.start), this.lineOffsetToPosition(fileName, span.end))),
|
||||
childItems: this.decodeNavigationBarItems(item.childItems, fileName),
|
||||
indent: 0,
|
||||
bolded: false,
|
||||
@@ -428,7 +433,35 @@ module ts.server {
|
||||
}
|
||||
|
||||
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.SignatureHelpRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.SignatureHelpRequest>(CommandNames.SignatureHelp, args);
|
||||
var response = this.processResponse<protocol.SignatureHelpResponse>(request);
|
||||
|
||||
if (!response.body) {
|
||||
return undefined;
|
||||
}
|
||||
var helpItems: protocol.SignatureHelpItems = response.body;
|
||||
var span = helpItems.applicableSpan;
|
||||
var start = this.lineOffsetToPosition(fileName, span.start);
|
||||
var end = this.lineOffsetToPosition(fileName, span.end);
|
||||
|
||||
var result: SignatureHelpItems = {
|
||||
items: helpItems.items,
|
||||
applicableSpan: {
|
||||
start: start,
|
||||
length: end - start
|
||||
},
|
||||
selectedItemIndex: helpItems.selectedItemIndex,
|
||||
argumentIndex: helpItems.argumentIndex,
|
||||
argumentCount: helpItems.argumentCount,
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
@@ -444,19 +477,19 @@ module ts.server {
|
||||
}
|
||||
|
||||
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] {
|
||||
var lineCol = this.positionToOneBasedLineCol(fileName, position);
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineCol.line,
|
||||
col: lineCol.col,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
};
|
||||
|
||||
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);
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
start: start,
|
||||
length: end - start,
|
||||
|
||||
+371
-149
@@ -1,10 +1,14 @@
|
||||
/// <reference path="..\compiler\commandLineParser.ts" />
|
||||
/// <reference path="..\services\services.ts" />
|
||||
/// <reference path="protocol.d.ts" />
|
||||
/// <reference path="session.ts" />
|
||||
/// <reference path="node.d.ts" />
|
||||
|
||||
module ts.server {
|
||||
export interface Logger {
|
||||
close(): void;
|
||||
isVerbose(): boolean;
|
||||
loggingEnabled(): boolean;
|
||||
perftrc(s: string): void;
|
||||
info(s: string): void;
|
||||
startGroup(): void;
|
||||
@@ -14,18 +18,33 @@ module ts.server {
|
||||
|
||||
var lineCollectionCapacity = 4;
|
||||
|
||||
function mergeFormatOptions(formatCodeOptions: FormatCodeOptions, formatOptions: protocol.FormatOptions): void {
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
Object.keys(formatOptions).forEach((key) => {
|
||||
var codeKey = key.charAt(0).toUpperCase() + key.substring(1);
|
||||
if (hasOwnProperty.call(formatCodeOptions, codeKey)) {
|
||||
formatCodeOptions[codeKey] = formatOptions[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class ScriptInfo {
|
||||
svc: ScriptVersionCache;
|
||||
children: ScriptInfo[] = []; // files referenced by this file
|
||||
|
||||
defaultProject: Project; // project to use by default for file
|
||||
|
||||
fileWatcher: FileWatcher;
|
||||
formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions);
|
||||
|
||||
constructor(private host: ServerHost, public fileName: string, public content: string, public isOpen = false) {
|
||||
this.svc = ScriptVersionCache.fromString(content);
|
||||
}
|
||||
|
||||
setFormatOptions(formatOptions: protocol.FormatOptions): void {
|
||||
if (formatOptions) {
|
||||
mergeFormatOptions(this.formatCodeOptions, formatOptions);
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
this.isOpen = false;
|
||||
}
|
||||
@@ -101,13 +120,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
getScriptFileNames() {
|
||||
var filenames: string[] = [];
|
||||
for (var filename in this.filenameToScript) {
|
||||
if (this.filenameToScript[filename] && this.filenameToScript[filename].isOpen) {
|
||||
filenames.push(filename);
|
||||
}
|
||||
}
|
||||
return filenames;
|
||||
return this.roots.map(root => root.fileName);
|
||||
}
|
||||
|
||||
getScriptVersion(filename: string) {
|
||||
@@ -204,33 +217,33 @@ module ts.server {
|
||||
}
|
||||
else {
|
||||
var nextLineInfo = index.lineNumberToInfo(line + 2);
|
||||
len = nextLineInfo.col - lineInfo.col;
|
||||
len = nextLineInfo.offset - lineInfo.offset;
|
||||
}
|
||||
return ts.createTextSpan(lineInfo.col, len);
|
||||
return ts.createTextSpan(lineInfo.offset, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 1 based index
|
||||
* @param col 1 based index
|
||||
* @param offset 1 based index
|
||||
*/
|
||||
lineColToPosition(filename: string, line: number, col: number): number {
|
||||
lineOffsetToPosition(filename: string, line: number, offset: number): number {
|
||||
var script: ScriptInfo = this.filenameToScript[filename];
|
||||
var index = script.snap().index;
|
||||
|
||||
var lineInfo = index.lineNumberToInfo(line);
|
||||
// TODO: assert this column is actually on the line
|
||||
return (lineInfo.col + col - 1);
|
||||
// TODO: assert this offset is actually on the line
|
||||
return (lineInfo.offset + offset - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 1-based index
|
||||
* @param col 1-based index
|
||||
* @param offset 1-based index
|
||||
*/
|
||||
positionToLineCol(filename: string, position: number): ILineInfo {
|
||||
positionToLineOffset(filename: string, position: number): ILineInfo {
|
||||
var script: ScriptInfo = this.filenameToScript[filename];
|
||||
var index = script.snap().index;
|
||||
var lineCol = index.charOffsetToLineNumberAndPos(position);
|
||||
return { line: lineCol.line, col: lineCol.col + 1 };
|
||||
var lineOffset = index.charOffsetToLineNumberAndPos(position);
|
||||
return { line: lineOffset.line, offset: lineOffset.offset + 1 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,20 +276,29 @@ module ts.server {
|
||||
interface ProjectOptions {
|
||||
// these fields can be present in the project file
|
||||
files?: string[];
|
||||
formatCodeOptions?: ts.FormatCodeOptions;
|
||||
compilerOptions?: ts.CompilerOptions;
|
||||
}
|
||||
|
||||
export class Project {
|
||||
compilerService: CompilerService;
|
||||
projectOptions: ProjectOptions;
|
||||
projectFilename: string;
|
||||
program: ts.Program;
|
||||
filenameToSourceFile: ts.Map<ts.SourceFile> = {};
|
||||
updateGraphSeq = 0;
|
||||
/** Used for configured projects which may have multiple open roots */
|
||||
openRefCount = 0;
|
||||
|
||||
constructor(public projectService: ProjectService) {
|
||||
this.compilerService = new CompilerService(this);
|
||||
constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) {
|
||||
this.compilerService = new CompilerService(this,projectOptions && projectOptions.compilerOptions);
|
||||
}
|
||||
|
||||
addOpenRef() {
|
||||
this.openRefCount++;
|
||||
}
|
||||
|
||||
deleteOpenRef() {
|
||||
this.openRefCount--;
|
||||
return this.openRefCount;
|
||||
}
|
||||
|
||||
openReferencedFile(filename: string) {
|
||||
@@ -296,6 +318,10 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
isRoot(info: ScriptInfo) {
|
||||
return this.compilerService.host.roots.some(root => root === info);
|
||||
}
|
||||
|
||||
removeReferencedFile(info: ScriptInfo) {
|
||||
this.compilerService.host.removeReferencedFile(info);
|
||||
this.updateGraph();
|
||||
@@ -342,7 +368,6 @@ module ts.server {
|
||||
if (projectOptions.compilerOptions) {
|
||||
this.compilerService.setCompilerOptions(projectOptions.compilerOptions);
|
||||
}
|
||||
// TODO: format code options
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,16 +391,45 @@ module ts.server {
|
||||
(eventName: string, project: Project, fileName: string): void;
|
||||
}
|
||||
|
||||
interface HostConfiguration {
|
||||
formatCodeOptions: ts.FormatCodeOptions;
|
||||
hostInfo: string;
|
||||
}
|
||||
|
||||
export class ProjectService {
|
||||
filenameToScriptInfo: ts.Map<ScriptInfo> = {};
|
||||
// open, non-configured files in two lists
|
||||
// open, non-configured root files
|
||||
openFileRoots: ScriptInfo[] = [];
|
||||
openFilesReferenced: ScriptInfo[] = [];
|
||||
// projects covering open files
|
||||
// projects built from openFileRoots
|
||||
inferredProjects: Project[] = [];
|
||||
// projects specified by a tsconfig.json file
|
||||
configuredProjects: Project[] = [];
|
||||
// open files referenced by a project
|
||||
openFilesReferenced: ScriptInfo[] = [];
|
||||
// open files that are roots of a configured project
|
||||
openFileRootsConfigured: ScriptInfo[] = [];
|
||||
hostConfiguration: HostConfiguration;
|
||||
|
||||
constructor(public host: ServerHost, public psLogger: Logger, public eventHandler?: ProjectServiceEventHandler) {
|
||||
// ts.disableIncrementalParsing = true;
|
||||
this.addDefaultHostConfiguration();
|
||||
}
|
||||
|
||||
addDefaultHostConfiguration() {
|
||||
this.hostConfiguration = {
|
||||
formatCodeOptions: ts.clone(CompilerService.defaultFormatCodeOptions),
|
||||
hostInfo: "Unknown host"
|
||||
}
|
||||
}
|
||||
|
||||
getFormatCodeOptions(file?: string) {
|
||||
if (file) {
|
||||
var info = this.filenameToScriptInfo[file];
|
||||
if (info) {
|
||||
return info.formatCodeOptions;
|
||||
}
|
||||
}
|
||||
return this.hostConfiguration.formatCodeOptions;
|
||||
}
|
||||
|
||||
watchedFileChanged(fileName: string) {
|
||||
@@ -399,6 +453,26 @@ module ts.server {
|
||||
this.psLogger.msg(msg, type);
|
||||
}
|
||||
|
||||
setHostConfiguration(args: ts.server.protocol.ConfigureRequestArguments) {
|
||||
if (args.file) {
|
||||
var info = this.filenameToScriptInfo[args.file];
|
||||
if (info) {
|
||||
info.setFormatOptions(args.formatOptions);
|
||||
this.log("Host configuration update for file " + args.file);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (args.hostInfo !== undefined) {
|
||||
this.hostConfiguration.hostInfo = args.hostInfo;
|
||||
this.log("Host information " + args.hostInfo, "Info");
|
||||
}
|
||||
if (args.formatOptions) {
|
||||
mergeFormatOptions(this.hostConfiguration.formatCodeOptions, args.formatOptions);
|
||||
this.log("Format host information updated", "Info");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeLog() {
|
||||
this.psLogger.close();
|
||||
}
|
||||
@@ -442,44 +516,77 @@ module ts.server {
|
||||
this.printProjects();
|
||||
}
|
||||
|
||||
addOpenFile(info: ScriptInfo) {
|
||||
this.findReferencingProjects(info);
|
||||
if (info.defaultProject) {
|
||||
this.openFilesReferenced.push(info);
|
||||
}
|
||||
else {
|
||||
// create new inferred project p with the newly opened file as root
|
||||
info.defaultProject = this.createInferredProject(info);
|
||||
var openFileRoots: ScriptInfo[] = [];
|
||||
// for each inferred project root r
|
||||
for (var i = 0, len = this.openFileRoots.length; i < len; i++) {
|
||||
var r = this.openFileRoots[i];
|
||||
// if r referenced by the new project
|
||||
if (info.defaultProject.getSourceFile(r)) {
|
||||
// remove project rooted at r
|
||||
this.inferredProjects =
|
||||
copyListRemovingItem(r.defaultProject, this.inferredProjects);
|
||||
// put r in referenced open file list
|
||||
this.openFilesReferenced.push(r);
|
||||
// set default project of r to the new project
|
||||
r.defaultProject = info.defaultProject;
|
||||
}
|
||||
else {
|
||||
// otherwise, keep r as root of inferred project
|
||||
openFileRoots.push(r);
|
||||
}
|
||||
updateConfiguredProjectList() {
|
||||
var configuredProjects: Project[] = [];
|
||||
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
|
||||
if (this.configuredProjects[i].openRefCount > 0) {
|
||||
configuredProjects.push(this.configuredProjects[i]);
|
||||
}
|
||||
this.openFileRoots = openFileRoots;
|
||||
this.openFileRoots.push(info);
|
||||
}
|
||||
this.configuredProjects = configuredProjects;
|
||||
}
|
||||
|
||||
setConfiguredProjectRoot(info: ScriptInfo) {
|
||||
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
|
||||
let configuredProject = this.configuredProjects[i];
|
||||
if (configuredProject.isRoot(info)) {
|
||||
info.defaultProject = configuredProject;
|
||||
configuredProject.addOpenRef();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
addOpenFile(info: ScriptInfo) {
|
||||
if (this.setConfiguredProjectRoot(info)) {
|
||||
this.openFileRootsConfigured.push(info);
|
||||
}
|
||||
else {
|
||||
this.findReferencingProjects(info);
|
||||
if (info.defaultProject) {
|
||||
this.openFilesReferenced.push(info);
|
||||
}
|
||||
else {
|
||||
// create new inferred project p with the newly opened file as root
|
||||
info.defaultProject = this.createInferredProject(info);
|
||||
var openFileRoots: ScriptInfo[] = [];
|
||||
// for each inferred project root r
|
||||
for (var i = 0, len = this.openFileRoots.length; i < len; i++) {
|
||||
var r = this.openFileRoots[i];
|
||||
// if r referenced by the new project
|
||||
if (info.defaultProject.getSourceFile(r)) {
|
||||
// remove project rooted at r
|
||||
this.inferredProjects =
|
||||
copyListRemovingItem(r.defaultProject, this.inferredProjects);
|
||||
// put r in referenced open file list
|
||||
this.openFilesReferenced.push(r);
|
||||
// set default project of r to the new project
|
||||
r.defaultProject = info.defaultProject;
|
||||
}
|
||||
else {
|
||||
// otherwise, keep r as root of inferred project
|
||||
openFileRoots.push(r);
|
||||
}
|
||||
}
|
||||
this.openFileRoots = openFileRoots;
|
||||
this.openFileRoots.push(info);
|
||||
}
|
||||
}
|
||||
this.updateConfiguredProjectList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this file from the set of open, non-configured files.
|
||||
* @param info The file that has been closed or newly configured
|
||||
* @param openedByConfig True if info has become a root of a configured project
|
||||
*/
|
||||
closeOpenFile(info: ScriptInfo) {
|
||||
var openFileRoots: ScriptInfo[] = [];
|
||||
var removedProject: Project;
|
||||
for (var i = 0, len = this.openFileRoots.length; i < len; i++) {
|
||||
// if closed file is root of project
|
||||
if (info == this.openFileRoots[i]) {
|
||||
if (info === this.openFileRoots[i]) {
|
||||
// remove that project and remember it
|
||||
removedProject = info.defaultProject;
|
||||
}
|
||||
@@ -488,9 +595,29 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
this.openFileRoots = openFileRoots;
|
||||
if (!removedProject) {
|
||||
var openFileRootsConfigured: ScriptInfo[] = [];
|
||||
|
||||
for (var i = 0, len = this.openFileRootsConfigured.length; i < len; i++) {
|
||||
if (info === this.openFileRootsConfigured[i]) {
|
||||
if (info.defaultProject.deleteOpenRef() === 0) {
|
||||
removedProject = info.defaultProject;
|
||||
}
|
||||
}
|
||||
else {
|
||||
openFileRootsConfigured.push(this.openFileRootsConfigured[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.openFileRootsConfigured = openFileRootsConfigured;
|
||||
}
|
||||
if (removedProject) {
|
||||
// remove project from inferred projects list
|
||||
this.inferredProjects = copyListRemovingItem(removedProject, this.inferredProjects);
|
||||
if (removedProject.isConfiguredProject()) {
|
||||
this.configuredProjects = copyListRemovingItem(removedProject, this.configuredProjects);
|
||||
}
|
||||
else {
|
||||
this.inferredProjects = copyListRemovingItem(removedProject, this.inferredProjects);
|
||||
}
|
||||
var openFilesReferenced: ScriptInfo[] = [];
|
||||
var orphanFiles: ScriptInfo[] = [];
|
||||
// for all open, referenced files f
|
||||
@@ -522,29 +649,57 @@ module ts.server {
|
||||
var referencingProjects: Project[] = [];
|
||||
info.defaultProject = undefined;
|
||||
for (var i = 0, len = this.inferredProjects.length; i < len; i++) {
|
||||
this.inferredProjects[i].updateGraph();
|
||||
if (this.inferredProjects[i] != excludedProject) {
|
||||
if (this.inferredProjects[i].getSourceFile(info)) {
|
||||
info.defaultProject = this.inferredProjects[i];
|
||||
referencingProjects.push(this.inferredProjects[i]);
|
||||
var inferredProject = this.inferredProjects[i];
|
||||
inferredProject.updateGraph();
|
||||
if (inferredProject != excludedProject) {
|
||||
if (inferredProject.getSourceFile(info)) {
|
||||
info.defaultProject = inferredProject;
|
||||
referencingProjects.push(inferredProject);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
|
||||
var configuredProject = this.configuredProjects[i];
|
||||
configuredProject.updateGraph();
|
||||
if (configuredProject.getSourceFile(info)) {
|
||||
info.defaultProject = configuredProject;
|
||||
}
|
||||
}
|
||||
return referencingProjects;
|
||||
}
|
||||
|
||||
updateProjectStructure() {
|
||||
this.log("updating project structure from ...", "Info");
|
||||
this.printProjects();
|
||||
|
||||
// First loop through all open files that are referenced by projects but are not
|
||||
// project roots. For each referenced file, see if the default project still
|
||||
// references that file. If so, then just keep the file in the referenced list.
|
||||
// If not, add the file to an unattached list, to be rechecked later.
|
||||
|
||||
var openFilesReferenced: ScriptInfo[] = [];
|
||||
var unattachedOpenFiles: ScriptInfo[] = [];
|
||||
|
||||
for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) {
|
||||
var refdFile = this.openFilesReferenced[i];
|
||||
refdFile.defaultProject.updateGraph();
|
||||
var sourceFile = refdFile.defaultProject.getSourceFile(refdFile);
|
||||
if (!sourceFile) {
|
||||
this.openFilesReferenced = copyListRemovingItem(refdFile, this.openFilesReferenced);
|
||||
this.addOpenFile(refdFile);
|
||||
var referencedFile = this.openFilesReferenced[i];
|
||||
referencedFile.defaultProject.updateGraph();
|
||||
var sourceFile = referencedFile.defaultProject.getSourceFile(referencedFile);
|
||||
if (sourceFile) {
|
||||
openFilesReferenced.push(referencedFile);
|
||||
}
|
||||
else {
|
||||
unattachedOpenFiles.push(referencedFile);
|
||||
}
|
||||
}
|
||||
this.openFilesReferenced = openFilesReferenced;
|
||||
|
||||
// Then, loop through all of the open files that are project roots.
|
||||
// For each root file, note the project that it roots. Then see if
|
||||
// any other projects newly reference the file. If zero projects
|
||||
// newly reference the file, keep it as a root. If one or more
|
||||
// projects newly references the file, remove its project from the
|
||||
// inferred projects list (since it is no longer a root) and add
|
||||
// the file to the open, referenced file list.
|
||||
var openFileRoots: ScriptInfo[] = [];
|
||||
for (var i = 0, len = this.openFileRoots.length; i < len; i++) {
|
||||
var rootFile = this.openFileRoots[i];
|
||||
@@ -555,12 +710,19 @@ module ts.server {
|
||||
openFileRoots.push(rootFile);
|
||||
}
|
||||
else {
|
||||
// remove project from inferred projects list
|
||||
// remove project from inferred projects list because root captured
|
||||
this.inferredProjects = copyListRemovingItem(rootedProject, this.inferredProjects);
|
||||
this.openFilesReferenced.push(rootFile);
|
||||
}
|
||||
}
|
||||
this.openFileRoots = openFileRoots;
|
||||
|
||||
// Finally, if we found any open, referenced files that are no longer
|
||||
// referenced by their default project, treat them as newly opened
|
||||
// by the editor.
|
||||
for (var i = 0, len = unattachedOpenFiles.length; i < len; i++) {
|
||||
this.addOpenFile(unattachedOpenFiles[i]);
|
||||
}
|
||||
this.printProjects();
|
||||
}
|
||||
|
||||
@@ -572,7 +734,7 @@ module ts.server {
|
||||
/**
|
||||
* @param filename is absolute pathname
|
||||
*/
|
||||
openFile(fileName: string, openedByClient = false) {
|
||||
openFile(fileName: string, openedByClient: boolean) {
|
||||
fileName = ts.normalizePath(fileName);
|
||||
var info = ts.lookUp(this.filenameToScriptInfo, fileName);
|
||||
if (!info) {
|
||||
@@ -586,6 +748,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
if (content !== undefined) {
|
||||
var indentSize: number;
|
||||
info = new ScriptInfo(this.host, fileName, content, openedByClient);
|
||||
this.filenameToScriptInfo[fileName] = info;
|
||||
if (!info.isOpen) {
|
||||
@@ -601,14 +764,54 @@ module ts.server {
|
||||
return info;
|
||||
}
|
||||
|
||||
// This is different from the method the compiler uses because
|
||||
// the compiler can assume it will always start searching in the
|
||||
// current directory (the directory in which tsc was invoked).
|
||||
// The server must start searching from the directory containing
|
||||
// the newly opened file.
|
||||
findConfigFile(searchPath: string): string {
|
||||
while (true) {
|
||||
var fileName = ts.combinePaths(searchPath, "tsconfig.json");
|
||||
if (sys.fileExists(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
var parentPath = ts.getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
searchPath = parentPath;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open file whose contents is managed by the client
|
||||
* @param filename is absolute pathname
|
||||
*/
|
||||
|
||||
openClientFile(filename: string) {
|
||||
// TODO: tsconfig check
|
||||
var info = this.openFile(filename, true);
|
||||
openClientFile(fileName: string) {
|
||||
var searchPath = ts.normalizePath(getDirectoryPath(fileName));
|
||||
this.log("Search path: " + searchPath,"Info");
|
||||
var configFileName = this.findConfigFile(searchPath);
|
||||
if (configFileName) {
|
||||
this.log("Config file name: " + configFileName, "Info");
|
||||
} else {
|
||||
this.log("no config file");
|
||||
}
|
||||
if (configFileName) {
|
||||
configFileName = getAbsolutePath(configFileName, searchPath);
|
||||
}
|
||||
if (configFileName && (!this.configProjectIsActive(configFileName))) {
|
||||
var configResult = this.openConfigFile(configFileName, fileName);
|
||||
if (!configResult.success) {
|
||||
this.log("Error opening config file " + configFileName + " " + configResult.errorMsg);
|
||||
}
|
||||
else {
|
||||
this.log("Opened configuration file " + configFileName,"Info");
|
||||
this.configuredProjects.push(configResult.project);
|
||||
}
|
||||
}
|
||||
var info = this.openFile(fileName, true);
|
||||
this.addOpenFile(info);
|
||||
this.printProjects();
|
||||
return info;
|
||||
@@ -629,19 +832,6 @@ module ts.server {
|
||||
this.printProjects();
|
||||
}
|
||||
|
||||
getProjectsReferencingFile(filename: string) {
|
||||
var scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename);
|
||||
if (scriptInfo) {
|
||||
var projects: Project[] = [];
|
||||
for (var i = 0, len = this.inferredProjects.length; i < len; i++) {
|
||||
if (this.inferredProjects[i].getSourceFile(scriptInfo)) {
|
||||
projects.push(this.inferredProjects[i]);
|
||||
}
|
||||
}
|
||||
return projects;
|
||||
}
|
||||
}
|
||||
|
||||
getProjectForFile(filename: string) {
|
||||
var scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename);
|
||||
if (scriptInfo) {
|
||||
@@ -654,9 +844,9 @@ module ts.server {
|
||||
if (scriptInfo) {
|
||||
this.psLogger.startGroup();
|
||||
this.psLogger.info("Projects for " + filename)
|
||||
var projects = this.getProjectsReferencingFile(filename);
|
||||
var projects = this.findReferencingProjects(scriptInfo);
|
||||
for (var i = 0, len = projects.length; i < len; i++) {
|
||||
this.psLogger.info("Inferred Project " + i.toString());
|
||||
this.psLogger.info("Project " + i.toString());
|
||||
}
|
||||
this.psLogger.endGroup();
|
||||
}
|
||||
@@ -674,18 +864,42 @@ module ts.server {
|
||||
this.psLogger.info(project.filesToString());
|
||||
this.psLogger.info("-----------------------------------------------");
|
||||
}
|
||||
this.psLogger.info("Open file roots: ")
|
||||
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
|
||||
var project = this.configuredProjects[i];
|
||||
project.updateGraph();
|
||||
this.psLogger.info("Project (configured) " + (i+this.inferredProjects.length).toString());
|
||||
this.psLogger.info(project.filesToString());
|
||||
this.psLogger.info("-----------------------------------------------");
|
||||
}
|
||||
this.psLogger.info("Open file roots of inferred projects: ")
|
||||
for (var i = 0, len = this.openFileRoots.length; i < len; i++) {
|
||||
this.psLogger.info(this.openFileRoots[i].fileName);
|
||||
}
|
||||
this.psLogger.info("Open files referenced: ")
|
||||
this.psLogger.info("Open files referenced by inferred or configured projects: ")
|
||||
for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) {
|
||||
this.psLogger.info(this.openFilesReferenced[i].fileName);
|
||||
var fileInfo = this.openFilesReferenced[i].fileName;
|
||||
if (this.openFilesReferenced[i].defaultProject.isConfiguredProject()) {
|
||||
fileInfo += " (configured)";
|
||||
}
|
||||
this.psLogger.info(fileInfo);
|
||||
}
|
||||
this.psLogger.info("Open file roots of configured projects: ")
|
||||
for (var i = 0, len = this.openFileRootsConfigured.length; i < len; i++) {
|
||||
this.psLogger.info(this.openFileRootsConfigured[i].fileName);
|
||||
}
|
||||
this.psLogger.endGroup();
|
||||
}
|
||||
|
||||
openConfigFile(configFilename: string): ProjectOpenResult {
|
||||
configProjectIsActive(fileName: string) {
|
||||
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
|
||||
if (this.configuredProjects[i].projectFilename == fileName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult {
|
||||
configFilename = ts.normalizePath(configFilename);
|
||||
// file references will be relative to dirPath (or absolute)
|
||||
var dirPath = ts.getDirectoryPath(configFilename);
|
||||
@@ -694,35 +908,27 @@ module ts.server {
|
||||
return { errorMsg: "tsconfig syntax error" };
|
||||
}
|
||||
else {
|
||||
// REVIEW: specify no base path so can get absolute path below
|
||||
var parsedCommandLine = ts.parseConfigFile(rawConfig);
|
||||
|
||||
if (parsedCommandLine.errors) {
|
||||
// TODO: gather diagnostics and transmit
|
||||
var parsedCommandLine = ts.parseConfigFile(rawConfig, dirPath);
|
||||
if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) {
|
||||
return { errorMsg: "tsconfig option errors" };
|
||||
}
|
||||
else if (parsedCommandLine.fileNames) {
|
||||
var proj = this.createProject(configFilename);
|
||||
var projectOptions: ProjectOptions = {
|
||||
files: parsedCommandLine.fileNames,
|
||||
compilerOptions: parsedCommandLine.options
|
||||
};
|
||||
var proj = this.createProject(configFilename, projectOptions);
|
||||
for (var i = 0, len = parsedCommandLine.fileNames.length; i < len; i++) {
|
||||
var rootFilename = parsedCommandLine.fileNames[i];
|
||||
var normRootFilename = ts.normalizePath(rootFilename);
|
||||
normRootFilename = getAbsolutePath(normRootFilename, dirPath);
|
||||
if (this.host.fileExists(normRootFilename)) {
|
||||
var info = this.openFile(normRootFilename);
|
||||
if (ts.sys.fileExists(rootFilename)) {
|
||||
var info = this.openFile(rootFilename, clientFileName == rootFilename);
|
||||
proj.addRoot(info);
|
||||
}
|
||||
else {
|
||||
return { errorMsg: "specified file " + rootFilename + " not found" };
|
||||
}
|
||||
}
|
||||
var projectOptions: ProjectOptions = {
|
||||
files: parsedCommandLine.fileNames,
|
||||
compilerOptions: parsedCommandLine.options
|
||||
};
|
||||
if (rawConfig.formatCodeOptions) {
|
||||
projectOptions.formatCodeOptions = rawConfig.formatCodeOptions;
|
||||
}
|
||||
proj.setProjectOptions(projectOptions);
|
||||
proj.finishGraph();
|
||||
return { success: true, project: proj };
|
||||
}
|
||||
else {
|
||||
@@ -731,10 +937,10 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
createProject(projectFilename: string) {
|
||||
var eproj = new Project(this);
|
||||
eproj.projectFilename = projectFilename;
|
||||
return eproj;
|
||||
createProject(projectFilename: string, projectOptions?: ProjectOptions) {
|
||||
var project = new Project(this, projectOptions);
|
||||
project.projectFilename = projectFilename;
|
||||
return project;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -743,15 +949,17 @@ module ts.server {
|
||||
host: LSHost;
|
||||
languageService: ts.LanguageService;
|
||||
classifier: ts.Classifier;
|
||||
settings = ts.getDefaultCompilerOptions();
|
||||
settings: ts.CompilerOptions;
|
||||
documentRegistry = ts.createDocumentRegistry();
|
||||
formatCodeOptions: ts.FormatCodeOptions = CompilerService.defaultFormatCodeOptions;
|
||||
|
||||
constructor(public project: Project) {
|
||||
constructor(public project: Project, opt?: ts.CompilerOptions) {
|
||||
this.host = new LSHost(project.projectService.host, project);
|
||||
// override default ES6 (remove when compiler default back at ES5)
|
||||
this.settings.target = ts.ScriptTarget.ES5;
|
||||
this.host.setCompilationSettings(this.settings);
|
||||
if (opt) {
|
||||
this.setCompilerOptions(opt);
|
||||
}
|
||||
else {
|
||||
this.setCompilerOptions(ts.getDefaultCompilerOptions());
|
||||
}
|
||||
this.languageService = ts.createLanguageService(this.host, this.documentRegistry);
|
||||
this.classifier = ts.createClassifier();
|
||||
}
|
||||
@@ -792,7 +1000,7 @@ module ts.server {
|
||||
|
||||
export interface ILineInfo {
|
||||
line: number;
|
||||
col: number;
|
||||
offset: number;
|
||||
text?: string;
|
||||
leaf?: LineLeaf;
|
||||
}
|
||||
@@ -1042,7 +1250,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
class ScriptVersionCache {
|
||||
export class ScriptVersionCache {
|
||||
changes: TextChange[] = [];
|
||||
versions: LineIndexSnapshot[] = [];
|
||||
minVersion = 0; // no versions earlier than min version will maintain change history
|
||||
@@ -1050,6 +1258,7 @@ module ts.server {
|
||||
|
||||
static changeNumberThreshold = 8;
|
||||
static changeLengthThreshold = 256;
|
||||
static maxVersions = 8;
|
||||
|
||||
// REVIEW: can optimize by coalescing simple edits
|
||||
edit(pos: number, deleteLen: number, insertedText?: string) {
|
||||
@@ -1110,6 +1319,13 @@ module ts.server {
|
||||
this.currentVersion = snap.version;
|
||||
this.versions[snap.version] = snap;
|
||||
this.changes = [];
|
||||
if ((this.currentVersion - this.minVersion) >= ScriptVersionCache.maxVersions) {
|
||||
var oldMin = this.minVersion;
|
||||
this.minVersion = (this.currentVersion - ScriptVersionCache.maxVersions) + 1;
|
||||
for (var j = oldMin; j < this.minVersion; j++) {
|
||||
this.versions[j] = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
return snap;
|
||||
}
|
||||
@@ -1177,7 +1393,7 @@ module ts.server {
|
||||
|
||||
getLineMapper() {
|
||||
return ((line: number) => {
|
||||
return this.index.lineNumberToInfo(line).col;
|
||||
return this.index.lineNumberToInfo(line).offset;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1195,7 +1411,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
class LineIndex {
|
||||
export class LineIndex {
|
||||
root: LineNode;
|
||||
// set this to true to check each edit for accuracy
|
||||
checkEdits = false;
|
||||
@@ -1214,7 +1430,7 @@ module ts.server {
|
||||
else {
|
||||
return {
|
||||
line: lineNumber,
|
||||
col: this.root.charCount()
|
||||
offset: this.root.charCount()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1238,7 +1454,7 @@ module ts.server {
|
||||
|
||||
getText(rangeStart: number, rangeLength: number) {
|
||||
var accum = "";
|
||||
if (rangeLength > 0) {
|
||||
if ((rangeLength > 0) && (rangeStart < this.root.charCount())) {
|
||||
this.walk(rangeStart, rangeLength, {
|
||||
goSubtree: true,
|
||||
done: false,
|
||||
@@ -1250,6 +1466,10 @@ module ts.server {
|
||||
return accum;
|
||||
}
|
||||
|
||||
getLength(): number {
|
||||
return this.root.charCount();
|
||||
}
|
||||
|
||||
every(f: (ll: LineLeaf, s: number, len: number) => boolean, rangeStart: number, rangeEnd?: number) {
|
||||
if (!rangeEnd) {
|
||||
rangeEnd = this.root.charCount();
|
||||
@@ -1283,11 +1503,24 @@ module ts.server {
|
||||
var checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText);
|
||||
}
|
||||
var walker = new EditWalker();
|
||||
if (deleteLength > 0) {
|
||||
if (pos >= this.root.charCount()) {
|
||||
// insert at end
|
||||
pos = this.root.charCount() - 1;
|
||||
var endString = this.getText(pos, 1);
|
||||
if (newText) {
|
||||
newText = endString + newText;
|
||||
}
|
||||
else {
|
||||
newText = endString;
|
||||
}
|
||||
deleteLength = 0;
|
||||
walker.suppressTrailingText = true;
|
||||
}
|
||||
else if (deleteLength > 0) {
|
||||
// check whether last characters deleted are line break
|
||||
var e = pos + deleteLength;
|
||||
var lineInfo = this.charOffsetToLineNumberAndPos(e);
|
||||
if ((lineInfo && (lineInfo.col == 0))) {
|
||||
if ((lineInfo && (lineInfo.offset == 0))) {
|
||||
// move range end just past line that will merge with previous line
|
||||
deleteLength += lineInfo.text.length;
|
||||
// store text by appending to end of insertedText
|
||||
@@ -1299,21 +1532,10 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pos >= this.root.charCount()) {
|
||||
// insert at end
|
||||
var endString = this.getText(pos - 1, 1);
|
||||
if (newText) {
|
||||
newText = endString + newText;
|
||||
}
|
||||
else {
|
||||
newText = endString;
|
||||
}
|
||||
pos = pos - 1;
|
||||
deleteLength = 0;
|
||||
walker.suppressTrailingText = true;
|
||||
if (pos < this.root.charCount()) {
|
||||
this.root.walk(pos, deleteLength, walker);
|
||||
walker.insertLines(newText);
|
||||
}
|
||||
this.root.walk(pos, deleteLength, walker);
|
||||
walker.insertLines(newText);
|
||||
if (this.checkEdits) {
|
||||
var updatedText = this.getText(0, this.root.charCount());
|
||||
Debug.assert(checkText == updatedText, "buffer edit mismatch");
|
||||
@@ -1474,14 +1696,14 @@ module ts.server {
|
||||
if (!childInfo.child) {
|
||||
return {
|
||||
line: lineNumber,
|
||||
col: charOffset,
|
||||
offset: charOffset,
|
||||
}
|
||||
}
|
||||
else if (childInfo.childIndex < this.children.length) {
|
||||
if (childInfo.child.isLeaf()) {
|
||||
return {
|
||||
line: childInfo.lineNumber,
|
||||
col: childInfo.charOffset,
|
||||
offset: childInfo.charOffset,
|
||||
text: (<LineLeaf>(childInfo.child)).text,
|
||||
leaf: (<LineLeaf>(childInfo.child))
|
||||
};
|
||||
@@ -1493,7 +1715,7 @@ module ts.server {
|
||||
}
|
||||
else {
|
||||
var lineInfo = this.lineNumberToInfo(this.lineCount(), 0);
|
||||
return { line: this.lineCount(), col: lineInfo.leaf.charCount() };
|
||||
return { line: this.lineCount(), offset: lineInfo.leaf.charCount() };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1502,13 +1724,13 @@ module ts.server {
|
||||
if (!childInfo.child) {
|
||||
return {
|
||||
line: lineNumber,
|
||||
col: charOffset
|
||||
offset: charOffset
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (childInfo.child.isLeaf()) {
|
||||
return {
|
||||
line: lineNumber,
|
||||
col: childInfo.charOffset,
|
||||
offset: childInfo.charOffset,
|
||||
text: (<LineLeaf>(childInfo.child)).text,
|
||||
leaf: (<LineLeaf>(childInfo.child))
|
||||
}
|
||||
|
||||
Vendored
+241
-13
@@ -96,7 +96,7 @@ declare module ts.server.protocol {
|
||||
|
||||
/**
|
||||
* Instances of this interface specify a location in a source file:
|
||||
* (file, line, col), where line and column are 1-based.
|
||||
* (file, line, character offset), where line and character offset are 1-based.
|
||||
*/
|
||||
export interface FileLocationRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
@@ -105,9 +105,9 @@ declare module ts.server.protocol {
|
||||
line: number;
|
||||
|
||||
/**
|
||||
* The column for the request (1-based).
|
||||
* The character offset (on the line) for the request (1-based).
|
||||
*/
|
||||
col: number;
|
||||
offset: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,11 +126,11 @@ declare module ts.server.protocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* Location in source code expressed as (one-based) line and column.
|
||||
* Location in source code expressed as (one-based) line and character offset.
|
||||
*/
|
||||
export interface Location {
|
||||
line: number;
|
||||
col: number;
|
||||
offset: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,9 +202,9 @@ declare module ts.server.protocol {
|
||||
symbolName: string;
|
||||
|
||||
/**
|
||||
* The start column of the symbol (on the line provided by the references request).
|
||||
* The start character offset of the symbol (on the line provided by the references request).
|
||||
*/
|
||||
symbolStartCol: number;
|
||||
symbolStartOffset: number;
|
||||
|
||||
/**
|
||||
* The full display name of the symbol.
|
||||
@@ -299,6 +299,100 @@ declare module ts.server.protocol {
|
||||
body?: RenameResponseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor options
|
||||
*/
|
||||
export interface EditorOptions {
|
||||
|
||||
/** Number of spaces for each tab. Default value is 4. */
|
||||
tabSize?: number;
|
||||
|
||||
/** Number of spaces to indent during formatting. Default value is 4. */
|
||||
indentSize?: number;
|
||||
|
||||
/** The new line character to be used. Default value is the OS line delimiter. */
|
||||
newLineCharacter?: string;
|
||||
|
||||
/** Whether tabs should be converted to spaces. Default value is true. */
|
||||
convertTabsToSpaces?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format options
|
||||
*/
|
||||
export interface FormatOptions extends EditorOptions {
|
||||
|
||||
/** Defines space handling after a comma delimiter. Default value is true. */
|
||||
insertSpaceAfterCommaDelimiter?: boolean;
|
||||
|
||||
/** Defines space handling after a semicolon in a for statemen. Default value is true */
|
||||
insertSpaceAfterSemicolonInForStatements?: boolean;
|
||||
|
||||
/** Defines space handling after a binary operator. Default value is true. */
|
||||
insertSpaceBeforeAndAfterBinaryOperators?: boolean;
|
||||
|
||||
/** Defines space handling after keywords in control flow statement. Default value is true. */
|
||||
insertSpaceAfterKeywordsInControlFlowStatements?: boolean;
|
||||
|
||||
/** Defines space handling after function keyword for anonymous functions. Default value is false. */
|
||||
insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean;
|
||||
|
||||
/** Defines space handling after opening and before closing non empty parenthesis. Default value is false. */
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean;
|
||||
|
||||
/** Defines whether an open brace is put onto a new line for functions or not. Default value is false. */
|
||||
placeOpenBraceOnNewLineForFunctions?: boolean;
|
||||
|
||||
/** Defines whether an open brace is put onto a new line for control blocks or not. Default value is false. */
|
||||
placeOpenBraceOnNewLineForControlBlocks?: boolean;
|
||||
|
||||
/** Index operator */
|
||||
[key:string] : string | number | boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information found in a configure request.
|
||||
*/
|
||||
export interface ConfigureRequestArguments {
|
||||
|
||||
/**
|
||||
* Information about the host, for example 'Emacs 24.4' or
|
||||
* 'Sublime Text version 3075'
|
||||
*/
|
||||
hostInfo?: string;
|
||||
|
||||
/**
|
||||
* If present, tab settings apply only to this file.
|
||||
*/
|
||||
file?: string;
|
||||
|
||||
/**
|
||||
* The format options to use during formatting and other code editing features.
|
||||
*/
|
||||
formatOptions?: FormatOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure request; value of command field is "configure". Specifies
|
||||
* host information, such as host type, tab size, and indent size.
|
||||
*/
|
||||
export interface ConfigureRequest extends Request {
|
||||
arguments: ConfigureRequestArguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response to "configure" request. This is just an acknowledgement, so
|
||||
* no body field is required.
|
||||
*/
|
||||
export interface ConfigureResponse extends Response {
|
||||
}
|
||||
|
||||
/**
|
||||
* Information found in an "open" request.
|
||||
*/
|
||||
export interface OpenRequestArgs extends FileRequestArgs {
|
||||
}
|
||||
|
||||
/**
|
||||
* Open request; value of command field is "open". Notify the
|
||||
* server that the client has file open. The server will not
|
||||
@@ -307,7 +401,8 @@ declare module ts.server.protocol {
|
||||
* reload messages) when the file changes. Server does not currently
|
||||
* send a response to an open request.
|
||||
*/
|
||||
export interface OpenRequest extends FileRequest {
|
||||
export interface OpenRequest extends Request {
|
||||
arguments: OpenRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,9 +476,9 @@ declare module ts.server.protocol {
|
||||
endLine: number;
|
||||
|
||||
/**
|
||||
* Last column of range for which to format text in file.
|
||||
* Character offset on last line of range for which to format text in file.
|
||||
*/
|
||||
endCol: number;
|
||||
endOffset: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -522,12 +617,29 @@ declare module ts.server.protocol {
|
||||
* Optional modifiers for the kind (such as 'public').
|
||||
*/
|
||||
kindModifiers: string;
|
||||
/**
|
||||
* A string that is used for comparing completion items so that they can be ordered. This
|
||||
* is often the same as the name but may be different in certain circumstances.
|
||||
*/
|
||||
sortText: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional completion entry details, available on demand
|
||||
*/
|
||||
export interface CompletionEntryDetails extends CompletionEntry {
|
||||
export interface CompletionEntryDetails {
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* Display parts of the symbol (similar to quick info).
|
||||
*/
|
||||
@@ -547,6 +659,122 @@ declare module ts.server.protocol {
|
||||
body?: CompletionEntryDetails[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Signature help information for a single parameter
|
||||
*/
|
||||
export interface SignatureHelpParameter {
|
||||
|
||||
/**
|
||||
* The parameter's name
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Documentation of the parameter.
|
||||
*/
|
||||
documentation: SymbolDisplayPart[];
|
||||
|
||||
/**
|
||||
* Display parts of the parameter.
|
||||
*/
|
||||
displayParts: SymbolDisplayPart[];
|
||||
|
||||
/**
|
||||
* Whether the parameter is optional or not.
|
||||
*/
|
||||
isOptional: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a single signature to show in signature help.
|
||||
*/
|
||||
export interface SignatureHelpItem {
|
||||
|
||||
/**
|
||||
* Whether the signature accepts a variable number of arguments.
|
||||
*/
|
||||
isVariadic: boolean;
|
||||
|
||||
/**
|
||||
* The prefix display parts.
|
||||
*/
|
||||
prefixDisplayParts: SymbolDisplayPart[];
|
||||
|
||||
/**
|
||||
* The suffix disaply parts.
|
||||
*/
|
||||
suffixDisplayParts: SymbolDisplayPart[];
|
||||
|
||||
/**
|
||||
* The separator display parts.
|
||||
*/
|
||||
separatorDisplayParts: SymbolDisplayPart[];
|
||||
|
||||
/**
|
||||
* The signature helps items for the parameters.
|
||||
*/
|
||||
parameters: SignatureHelpParameter[];
|
||||
|
||||
/**
|
||||
* The signature's documentation
|
||||
*/
|
||||
documentation: SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Signature help items found in the response of a signature help request.
|
||||
*/
|
||||
export interface SignatureHelpItems {
|
||||
|
||||
/**
|
||||
* The signature help items.
|
||||
*/
|
||||
items: SignatureHelpItem[];
|
||||
|
||||
/**
|
||||
* The span for which signature help should appear on a signature
|
||||
*/
|
||||
applicableSpan: TextSpan;
|
||||
|
||||
/**
|
||||
* The item selected in the set of available help items.
|
||||
*/
|
||||
selectedItemIndex: number;
|
||||
|
||||
/**
|
||||
* The argument selected in the set of parameters.
|
||||
*/
|
||||
argumentIndex: number;
|
||||
|
||||
/**
|
||||
* The argument count
|
||||
*/
|
||||
argumentCount: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments of a signature help request.
|
||||
*/
|
||||
export interface SignatureHelpRequestArgs extends FileLocationRequestArgs {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Signature help request; value of command field is "signatureHelp".
|
||||
* Given a file location (file, line, col), return the signature
|
||||
* help.
|
||||
*/
|
||||
export interface SignatureHelpRequest extends FileLocationRequest {
|
||||
arguments: SignatureHelpRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repsonse object for a SignatureHelpRequest.
|
||||
*/
|
||||
export interface SignatureHelpResponse extends Response {
|
||||
body?: SignatureHelpItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for geterr messages.
|
||||
*/
|
||||
@@ -762,7 +990,7 @@ declare module ts.server.protocol {
|
||||
*/
|
||||
export interface ChangeRequestArgs extends FormatRequestArgs {
|
||||
/**
|
||||
* Optional string to insert at location (file, line, col).
|
||||
* Optional string to insert at location (file, line, offset).
|
||||
*/
|
||||
insertString?: string;
|
||||
}
|
||||
@@ -786,7 +1014,7 @@ declare module ts.server.protocol {
|
||||
/**
|
||||
* 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.
|
||||
* found in file at location line, offset.
|
||||
*/
|
||||
export interface BraceRequest extends FileLocationRequest {
|
||||
}
|
||||
|
||||
+64
-6
@@ -19,7 +19,7 @@ module ts.server {
|
||||
inGroup = false;
|
||||
firstInGroup = true;
|
||||
|
||||
constructor(public logFilename: string) {
|
||||
constructor(public logFilename: string, public level: string) {
|
||||
}
|
||||
|
||||
static padStringRight(str: string, padding: string) {
|
||||
@@ -51,9 +51,20 @@ module ts.server {
|
||||
this.firstInGroup = true;
|
||||
}
|
||||
|
||||
loggingEnabled() {
|
||||
return !!this.logFilename;
|
||||
}
|
||||
|
||||
isVerbose() {
|
||||
return this.loggingEnabled() && (this.level == "verbose");
|
||||
}
|
||||
|
||||
|
||||
msg(s: string, type = "Err") {
|
||||
if (this.fd < 0) {
|
||||
this.fd = fs.openSync(this.logFilename, "w");
|
||||
if (this.logFilename) {
|
||||
this.fd = fs.openSync(this.logFilename, "w");
|
||||
}
|
||||
}
|
||||
if (this.fd >= 0) {
|
||||
s = s + "\n";
|
||||
@@ -173,17 +184,61 @@ module ts.server {
|
||||
});
|
||||
|
||||
rl.on('close',() => {
|
||||
this.projectService.closeLog();
|
||||
this.projectService.log("Exiting...");
|
||||
this.projectService.closeLog();
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
interface LogOptions {
|
||||
file?: string;
|
||||
detailLevel?: string;
|
||||
}
|
||||
|
||||
function parseLoggingEnvironmentString(logEnvStr: string): LogOptions {
|
||||
var logEnv: LogOptions = {};
|
||||
var args = logEnvStr.split(' ');
|
||||
for (var i = 0, len = args.length; i < (len - 1); i += 2) {
|
||||
var option = args[i];
|
||||
var value = args[i + 1];
|
||||
if (option && value) {
|
||||
switch (option) {
|
||||
case "-file":
|
||||
logEnv.file = value;
|
||||
break;
|
||||
case "-level":
|
||||
logEnv.detailLevel = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return logEnv;
|
||||
}
|
||||
|
||||
// TSS_LOG "{ level: "normal | verbose | terse", file?: string}"
|
||||
function createLoggerFromEnv() {
|
||||
var fileName: string = undefined;
|
||||
var detailLevel = "normal";
|
||||
var logEnvStr = process.env["TSS_LOG"];
|
||||
if (logEnvStr) {
|
||||
var logEnv = parseLoggingEnvironmentString(logEnvStr);
|
||||
if (logEnv.file) {
|
||||
fileName = logEnv.file;
|
||||
}
|
||||
else {
|
||||
fileName = __dirname + "/.log" + process.pid.toString();
|
||||
}
|
||||
if (logEnv.detailLevel) {
|
||||
detailLevel = logEnv.detailLevel;
|
||||
}
|
||||
}
|
||||
return new Logger(fileName, detailLevel);
|
||||
}
|
||||
// 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());
|
||||
|
||||
var logger = createLoggerFromEnv();
|
||||
|
||||
// REVIEW: for now this implementation uses polling.
|
||||
// The advantage of polling is that it works reliably
|
||||
@@ -206,7 +261,10 @@ module ts.server {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var ioSession = new IOSession(ts.sys, logger);
|
||||
process.on('uncaughtException', function(err: Error) {
|
||||
ioSession.logError(err, "unknown");
|
||||
});
|
||||
// Start listening
|
||||
new IOSession(ts.sys, logger).listen();
|
||||
ioSession.listen();
|
||||
}
|
||||
+192
-90
@@ -5,13 +5,13 @@
|
||||
/// <reference path="editorServices.ts" />
|
||||
|
||||
module ts.server {
|
||||
var spaceCache = [" ", " ", " ", " "];
|
||||
var spaceCache:string[] = [];
|
||||
|
||||
interface StackTraceError extends Error {
|
||||
stack?: string;
|
||||
}
|
||||
|
||||
function generateSpaces(n: number): string {
|
||||
export function generateSpaces(n: number): string {
|
||||
if (!spaceCache[n]) {
|
||||
var strBuilder = "";
|
||||
for (var i = 0; i < n; i++) {
|
||||
@@ -44,7 +44,7 @@ module ts.server {
|
||||
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);
|
||||
return compareNumber(a.start.offset, b.start.offset);
|
||||
}
|
||||
else return n;
|
||||
}
|
||||
@@ -55,8 +55,8 @@ module ts.server {
|
||||
|
||||
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),
|
||||
start: project.compilerService.host.positionToLineOffset(fileName, diag.start),
|
||||
end: project.compilerService.host.positionToLineOffset(fileName, diag.start + diag.length),
|
||||
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n")
|
||||
};
|
||||
}
|
||||
@@ -80,6 +80,8 @@ module ts.server {
|
||||
export var Close = "close";
|
||||
export var Completions = "completions";
|
||||
export var CompletionDetails = "completionEntryDetails";
|
||||
export var SignatureHelp = "signatureHelp";
|
||||
export var Configure = "configure";
|
||||
export var Definition = "definition";
|
||||
export var Format = "format";
|
||||
export var Formatonkey = "formatonkey";
|
||||
@@ -145,6 +147,9 @@ module ts.server {
|
||||
|
||||
send(msg: NodeJS._debugger.Message) {
|
||||
var json = JSON.stringify(msg);
|
||||
if (this.logger.isVerbose()) {
|
||||
this.logger.info(msg.type + ": " + json);
|
||||
}
|
||||
this.sendLineToClient('Content-Length: ' + (1 + Buffer.byteLength(json, 'utf8')) +
|
||||
'\r\n\r\n' + json);
|
||||
}
|
||||
@@ -181,18 +186,29 @@ module ts.server {
|
||||
}
|
||||
|
||||
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");
|
||||
try {
|
||||
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");
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.logError(err, "semantic check");
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
try {
|
||||
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");
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.logError(err, "syntactic check");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +261,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
getDefinition(line: number, col: number, fileName: string): protocol.FileSpan[] {
|
||||
getDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -253,7 +269,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
var definitions = compilerService.languageService.getDefinitionAtPosition(file, position);
|
||||
if (!definitions) {
|
||||
@@ -262,12 +278,12 @@ module ts.server {
|
||||
|
||||
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))
|
||||
start: compilerService.host.positionToLineOffset(def.fileName, def.textSpan.start),
|
||||
end: compilerService.host.positionToLineOffset(def.fileName, ts.textSpanEnd(def.textSpan))
|
||||
}));
|
||||
}
|
||||
|
||||
getRenameLocations(line: number, col: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
|
||||
getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -275,7 +291,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var renameInfo = compilerService.languageService.getRenameInfo(file, position);
|
||||
if (!renameInfo) {
|
||||
return undefined;
|
||||
@@ -295,8 +311,8 @@ module ts.server {
|
||||
|
||||
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)),
|
||||
start: compilerService.host.positionToLineOffset(location.fileName, location.textSpan.start),
|
||||
end: compilerService.host.positionToLineOffset(location.fileName, ts.textSpanEnd(location.textSpan)),
|
||||
})).sort((a, b) => {
|
||||
if (a.file < b.file) {
|
||||
return -1;
|
||||
@@ -313,7 +329,7 @@ module ts.server {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
return b.start.col - a.start.col;
|
||||
return b.start.offset - a.start.offset;
|
||||
}
|
||||
}
|
||||
}).reduce<protocol.SpanGroup[]>((accum: protocol.SpanGroup[], cur: protocol.FileSpan) => {
|
||||
@@ -335,7 +351,7 @@ module ts.server {
|
||||
return { info: renameInfo, locs: bakedRenameLocs };
|
||||
}
|
||||
|
||||
getReferences(line: number, col: number, fileName: string): protocol.ReferencesResponseBody {
|
||||
getReferences(line: number, offset: 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);
|
||||
@@ -345,7 +361,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
var references = compilerService.languageService.getReferencesAtPosition(file, position);
|
||||
if (!references) {
|
||||
@@ -359,10 +375,10 @@ module ts.server {
|
||||
|
||||
var displayString = ts.displayPartsToString(nameInfo.displayParts);
|
||||
var nameSpan = nameInfo.textSpan;
|
||||
var nameColStart = compilerService.host.positionToLineCol(file, nameSpan.start).col;
|
||||
var nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset;
|
||||
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 start = compilerService.host.positionToLineOffset(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, "");
|
||||
@@ -370,14 +386,14 @@ module ts.server {
|
||||
file: ref.fileName,
|
||||
start: start,
|
||||
lineText: lineText,
|
||||
end: compilerService.host.positionToLineCol(ref.fileName, ts.textSpanEnd(ref.textSpan)),
|
||||
end: compilerService.host.positionToLineOffset(ref.fileName, ts.textSpanEnd(ref.textSpan)),
|
||||
isWriteAccess: ref.isWriteAccess
|
||||
};
|
||||
}).sort(compareFileStart);
|
||||
return {
|
||||
refs: bakedRefs,
|
||||
symbolName: nameText,
|
||||
symbolStartCol: nameColStart,
|
||||
symbolStartOffset: nameColStart,
|
||||
symbolDisplayString: displayString
|
||||
};
|
||||
}
|
||||
@@ -387,7 +403,7 @@ module ts.server {
|
||||
this.projectService.openClientFile(file);
|
||||
}
|
||||
|
||||
getQuickInfo(line: number, col: number, fileName: string): protocol.QuickInfoResponseBody {
|
||||
getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -395,7 +411,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position);
|
||||
if (!quickInfo) {
|
||||
return undefined;
|
||||
@@ -406,14 +422,14 @@ module ts.server {
|
||||
return {
|
||||
kind: quickInfo.kind,
|
||||
kindModifiers: quickInfo.kindModifiers,
|
||||
start: compilerService.host.positionToLineCol(file, quickInfo.textSpan.start),
|
||||
end: compilerService.host.positionToLineCol(file, ts.textSpanEnd(quickInfo.textSpan)),
|
||||
start: compilerService.host.positionToLineOffset(file, quickInfo.textSpan.start),
|
||||
end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(quickInfo.textSpan)),
|
||||
displayString: displayString,
|
||||
documentation: docString,
|
||||
};
|
||||
}
|
||||
|
||||
getFormattingEditsForRange(line: number, col: number, endLine: number, endCol: number, fileName: string): protocol.CodeEdit[] {
|
||||
getFormattingEditsForRange(line: number, offset: number, endLine: number, endOffset: number, fileName: string): protocol.CodeEdit[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -421,25 +437,26 @@ module ts.server {
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var startPosition = compilerService.host.lineColToPosition(file, line, col);
|
||||
var endPosition = compilerService.host.lineColToPosition(file, endLine, endCol);
|
||||
var startPosition = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var endPosition = compilerService.host.lineOffsetToPosition(file, endLine, endOffset);
|
||||
|
||||
// TODO: avoid duplicate code (with formatonkey)
|
||||
var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, compilerService.formatCodeOptions);
|
||||
var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition,
|
||||
this.projectService.getFormatCodeOptions(file));
|
||||
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)),
|
||||
start: compilerService.host.positionToLineOffset(file, edit.span.start),
|
||||
end: compilerService.host.positionToLineOffset(file, ts.textSpanEnd(edit.span)),
|
||||
newText: edit.newText ? edit.newText : ""
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getFormattingEditsAfterKeystroke(line: number, col: number, key: string, fileName: string): protocol.CodeEdit[] {
|
||||
getFormattingEditsAfterKeystroke(line: number, offset: number, key: string, fileName: string): protocol.CodeEdit[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
@@ -448,21 +465,52 @@ module ts.server {
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var formatOptions = this.projectService.getFormatCodeOptions(file);
|
||||
var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key,
|
||||
compilerService.formatCodeOptions);
|
||||
formatOptions);
|
||||
// Check whether we should auto-indent. This will be when
|
||||
// the position is on a line containing only whitespace.
|
||||
// This should leave the edits returned from
|
||||
// getFormattingEditsAfterKeytroke either empty or pertaining
|
||||
// only to the previous line. If all this is true, then
|
||||
// add edits necessary to properly indent the current line.
|
||||
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 });
|
||||
var scriptInfo = compilerService.host.getScriptInfo(file);
|
||||
if (scriptInfo) {
|
||||
var lineInfo = scriptInfo.getLineInfo(line);
|
||||
if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) {
|
||||
var lineText = lineInfo.leaf.text;
|
||||
if (lineText.search("\\S") < 0) {
|
||||
// TODO: get these options from host
|
||||
var editorOptions: ts.EditorOptions = {
|
||||
IndentSize: formatOptions.IndentSize,
|
||||
TabSize: formatOptions.TabSize,
|
||||
NewLineCharacter: "\n",
|
||||
ConvertTabsToSpaces: true,
|
||||
};
|
||||
var indentPosition =
|
||||
compilerService.languageService.getIndentationAtPosition(file, position, editorOptions);
|
||||
for (var i = 0, len = lineText.length; i < len; i++) {
|
||||
if (lineText.charAt(i) == " ") {
|
||||
indentPosition--;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (indentPosition > 0) {
|
||||
var spaces = generateSpaces(indentPosition);
|
||||
edits.push({ span: ts.createTextSpanFromBounds(position, position), newText: spaces });
|
||||
}
|
||||
else if (indentPosition < 0) {
|
||||
edits.push({
|
||||
span: ts.createTextSpanFromBounds(position, position - indentPosition),
|
||||
newText: ""
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,16 +520,16 @@ module ts.server {
|
||||
|
||||
return edits.map((edit) => {
|
||||
return {
|
||||
start: compilerService.host.positionToLineCol(file,
|
||||
start: compilerService.host.positionToLineOffset(file,
|
||||
edit.span.start),
|
||||
end: compilerService.host.positionToLineCol(file,
|
||||
end: compilerService.host.positionToLineOffset(file,
|
||||
ts.textSpanEnd(edit.span)),
|
||||
newText: edit.newText ? edit.newText : ""
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getCompletions(line: number, col: number, prefix: string, fileName: string): protocol.CompletionEntry[] {
|
||||
|
||||
getCompletions(line: number, offset: number, prefix: string, fileName: string): protocol.CompletionEntry[] {
|
||||
if (!prefix) {
|
||||
prefix = "";
|
||||
}
|
||||
@@ -492,7 +540,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
var completions = compilerService.languageService.getCompletionsAtPosition(file, position);
|
||||
if (!completions) {
|
||||
@@ -500,14 +548,14 @@ module ts.server {
|
||||
}
|
||||
|
||||
return completions.entries.reduce((result: protocol.CompletionEntry[], entry: ts.CompletionEntry) => {
|
||||
if (completions.isMemberCompletion || entry.name.indexOf(prefix) == 0) {
|
||||
if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) == 0)) {
|
||||
result.push(entry);
|
||||
}
|
||||
return result;
|
||||
}, []);
|
||||
}, []).sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
|
||||
getCompletionEntryDetails(line: number, col: number,
|
||||
getCompletionEntryDetails(line: number, offset: number,
|
||||
entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
@@ -516,7 +564,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
return entryNames.reduce((accum: protocol.CompletionEntryDetails[], entryName: string) => {
|
||||
var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName);
|
||||
@@ -527,6 +575,35 @@ module ts.server {
|
||||
}, []);
|
||||
}
|
||||
|
||||
getSignatureHelpItems(line: number, offset: number, fileName: string): protocol.SignatureHelpItems {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var helpItems = compilerService.languageService.getSignatureHelpItems(file, position);
|
||||
if (!helpItems) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var span = helpItems.applicableSpan;
|
||||
var result: protocol.SignatureHelpItems = {
|
||||
items: helpItems.items,
|
||||
applicableSpan: {
|
||||
start: compilerService.host.positionToLineOffset(file, span.start),
|
||||
end: compilerService.host.positionToLineOffset(file, span.start + span.length)
|
||||
},
|
||||
selectedItemIndex: helpItems.selectedItemIndex,
|
||||
argumentIndex: helpItems.argumentIndex,
|
||||
argumentCount: helpItems.argumentCount,
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
getDiagnostics(delay: number, fileNames: string[]) {
|
||||
var checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => {
|
||||
fileName = ts.normalizePath(fileName);
|
||||
@@ -542,21 +619,18 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
change(line: number, col: number, endLine: number, endCol: number, insertString: string, fileName: string) {
|
||||
change(line: number, offset: number, endLine: number, endOffset: 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);
|
||||
var start = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset);
|
||||
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);
|
||||
this.updateProjectStructure(this.changeSeq, (n) => n == this.changeSeq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,7 +641,7 @@ module ts.server {
|
||||
if (project) {
|
||||
this.changeSeq++;
|
||||
// make sure no changes happen before this one is finished
|
||||
project.compilerService.host.reloadScript(file, tmpfile,() => {
|
||||
project.compilerService.host.reloadScript(file, tmpfile, () => {
|
||||
this.output(undefined, CommandNames.Reload, reqSeq);
|
||||
});
|
||||
}
|
||||
@@ -600,8 +674,8 @@ module ts.server {
|
||||
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))
|
||||
start: compilerService.host.positionToLineOffset(fileName, span.start),
|
||||
end: compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(span))
|
||||
})),
|
||||
childItems: this.decorateNavigationBarItem(project, fileName, item.childItems)
|
||||
}));
|
||||
@@ -637,8 +711,8 @@ module ts.server {
|
||||
}
|
||||
|
||||
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 start = compilerService.host.positionToLineOffset(navItem.fileName, navItem.textSpan.start);
|
||||
var end = compilerService.host.positionToLineOffset(navItem.fileName, ts.textSpanEnd(navItem.textSpan));
|
||||
var bakedItem: protocol.NavtoItem = {
|
||||
name: navItem.name,
|
||||
kind: navItem.kind,
|
||||
@@ -662,7 +736,7 @@ module ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
getBraceMatching(line: number, col: number, fileName: string): protocol.TextSpan[] {
|
||||
getBraceMatching(line: number, offset: number, fileName: string): protocol.TextSpan[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
@@ -671,7 +745,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineColToPosition(file, line, col);
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
|
||||
var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position);
|
||||
if (!spans) {
|
||||
@@ -679,12 +753,16 @@ module ts.server {
|
||||
}
|
||||
|
||||
return spans.map(span => ({
|
||||
start: compilerService.host.positionToLineCol(file, span.start),
|
||||
end: compilerService.host.positionToLineCol(file, span.start + span.length)
|
||||
start: compilerService.host.positionToLineOffset(file, span.start),
|
||||
end: compilerService.host.positionToLineOffset(file, span.start + span.length)
|
||||
}));
|
||||
}
|
||||
|
||||
onMessage(message: string) {
|
||||
if (this.logger.isVerbose()) {
|
||||
this.logger.info("request: " + message);
|
||||
var start = process.hrtime();
|
||||
}
|
||||
try {
|
||||
var request = <protocol.Request>JSON.parse(message);
|
||||
var response: any;
|
||||
@@ -693,51 +771,57 @@ module ts.server {
|
||||
switch (request.command) {
|
||||
case CommandNames.Definition: {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getDefinition(defArgs.line, defArgs.col, defArgs.file);
|
||||
response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.References: {
|
||||
var refArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getReferences(refArgs.line, refArgs.col, refArgs.file);
|
||||
response = this.getReferences(refArgs.line, refArgs.offset, 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);
|
||||
response = this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Open: {
|
||||
var openArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
var openArgs = <protocol.OpenRequestArgs>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);
|
||||
response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, 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);
|
||||
response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Formatonkey: {
|
||||
var formatOnKeyArgs = <protocol.FormatOnKeyRequestArgs>request.arguments;
|
||||
response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.col, formatOnKeyArgs.key, formatOnKeyArgs.file);
|
||||
response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, 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);
|
||||
response = this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.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);
|
||||
response =
|
||||
this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset,
|
||||
completionDetailsArgs.entryNames,completionDetailsArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.SignatureHelp: {
|
||||
var signatureHelpArgs = <protocol.SignatureHelpRequestArgs>request.arguments;
|
||||
response = this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Geterr: {
|
||||
var geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
|
||||
response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files);
|
||||
@@ -746,14 +830,22 @@ module ts.server {
|
||||
}
|
||||
case CommandNames.Change: {
|
||||
var changeArgs = <protocol.ChangeRequestArgs>request.arguments;
|
||||
this.change(changeArgs.line, changeArgs.col, changeArgs.endLine, changeArgs.endCol,
|
||||
this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset,
|
||||
changeArgs.insertString, changeArgs.file);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Configure: {
|
||||
var configureArgs = <protocol.ConfigureRequestArguments>request.arguments;
|
||||
this.projectService.setHostConfiguration(configureArgs);
|
||||
this.output(undefined, CommandNames.Configure, request.seq);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Reload: {
|
||||
var reloadArgs = <protocol.ReloadRequestArgs>request.arguments;
|
||||
this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Saveto: {
|
||||
@@ -775,7 +867,7 @@ module ts.server {
|
||||
}
|
||||
case CommandNames.Brace: {
|
||||
var braceArguments = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getBraceMatching(braceArguments.line, braceArguments.col, braceArguments.file);
|
||||
response = this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.NavBar: {
|
||||
@@ -790,13 +882,23 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.logger.isVerbose()) {
|
||||
var elapsed = process.hrtime(start);
|
||||
var seconds = elapsed[0]
|
||||
var nanoseconds = elapsed[1];
|
||||
var elapsedMs = ((1e9 * seconds) + nanoseconds)/1000000.0;
|
||||
var leader = "Elapsed time (in milliseconds)";
|
||||
if (!responseRequired) {
|
||||
leader = "Async elapsed time (in milliseconds)";
|
||||
}
|
||||
this.logger.msg(leader + ": " + elapsedMs.toFixed(4).toString(), "Perf");
|
||||
}
|
||||
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
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"removeComments": true,
|
||||
"preserveConstEnums": true,
|
||||
"out": "../../built/local/tsserver.js",
|
||||
"sourceMap": true
|
||||
},
|
||||
"files": [
|
||||
"node.d.ts",
|
||||
"editorServices.ts",
|
||||
"protocol.d.ts",
|
||||
"server.ts",
|
||||
"session.ts"
|
||||
]
|
||||
}
|
||||
+38
-26
@@ -13,13 +13,13 @@ module ts.BreakpointResolver {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var tokenAtLocation = getTokenAtPosition(sourceFile, position);
|
||||
var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
let tokenAtLocation = getTokenAtPosition(sourceFile, position);
|
||||
let 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; |--- 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
|
||||
// eg: let x =10; |--- cursor is here
|
||||
// let y = 10;
|
||||
// token at position will return let 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);
|
||||
|
||||
@@ -173,12 +173,24 @@ module ts.BreakpointResolver {
|
||||
return textSpan(node, (<ThrowStatement>node).expression);
|
||||
|
||||
case SyntaxKind.ExportAssignment:
|
||||
if (!(<ExportAssignment>node).expression) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// span on export = id
|
||||
return textSpan(node, (<ExportAssignment>node).exportName);
|
||||
return textSpan(node, (<ExportAssignment>node).expression);
|
||||
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
// import statement without including semicolon
|
||||
return textSpan(node,(<ImportEqualsDeclaration>node).moduleReference);
|
||||
return textSpan(node, (<ImportEqualsDeclaration>node).moduleReference);
|
||||
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
// import statement without including semicolon
|
||||
return textSpan(node, (<ImportDeclaration>node).moduleSpecifier);
|
||||
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
// import statement without including semicolon
|
||||
return textSpan(node, (<ExportDeclaration>node).moduleSpecifier);
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
// span on complete module if it is instantiated
|
||||
@@ -251,7 +263,7 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
// return type of function go to previous token
|
||||
if (isAnyFunction(node.parent) && (<FunctionLikeDeclaration>node.parent).type === node) {
|
||||
if (isFunctionLike(node.parent) && (<FunctionLikeDeclaration>node.parent).type === node) {
|
||||
return spanInPreviousNode(node);
|
||||
}
|
||||
|
||||
@@ -267,9 +279,9 @@ module ts.BreakpointResolver {
|
||||
return spanInNode(variableDeclaration.parent.parent);
|
||||
}
|
||||
|
||||
var isParentVariableStatement = variableDeclaration.parent.parent.kind === SyntaxKind.VariableStatement;
|
||||
var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement && contains((<VariableDeclarationList>(<ForStatement>variableDeclaration.parent.parent).initializer).declarations, variableDeclaration);
|
||||
var declarations = isParentVariableStatement
|
||||
let isParentVariableStatement = variableDeclaration.parent.parent.kind === SyntaxKind.VariableStatement;
|
||||
let isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement && contains((<VariableDeclarationList>(<ForStatement>variableDeclaration.parent.parent).initializer).declarations, variableDeclaration);
|
||||
let declarations = isParentVariableStatement
|
||||
? (<VariableStatement>variableDeclaration.parent.parent).declarationList.declarations
|
||||
: isDeclarationOfForStatement
|
||||
? (<VariableDeclarationList>(<ForStatement>variableDeclaration.parent.parent).initializer).declarations
|
||||
@@ -279,12 +291,12 @@ module ts.BreakpointResolver {
|
||||
if (variableDeclaration.initializer || (variableDeclaration.flags & NodeFlags.Export)) {
|
||||
if (declarations && declarations[0] === variableDeclaration) {
|
||||
if (isParentVariableStatement) {
|
||||
// First declaration - include var keyword
|
||||
// First declaration - include let keyword
|
||||
return textSpan(variableDeclaration.parent, variableDeclaration);
|
||||
}
|
||||
else {
|
||||
Debug.assert(isDeclarationOfForStatement);
|
||||
// Include var keyword from for statement declarations in the span
|
||||
// Include let keyword from for statement declarations in the span
|
||||
return textSpan(findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration);
|
||||
}
|
||||
}
|
||||
@@ -295,7 +307,7 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
else if (declarations && declarations[0] !== variableDeclaration) {
|
||||
// If we cant set breakpoint on this declaration, set it on previous one
|
||||
var indexOfCurrentDeclaration = indexOf(declarations, variableDeclaration);
|
||||
let indexOfCurrentDeclaration = indexOf(declarations, variableDeclaration);
|
||||
return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]);
|
||||
}
|
||||
}
|
||||
@@ -311,8 +323,8 @@ module ts.BreakpointResolver {
|
||||
return textSpan(parameter);
|
||||
}
|
||||
else {
|
||||
var functionDeclaration = <FunctionLikeDeclaration>parameter.parent;
|
||||
var indexOfParameter = indexOf(functionDeclaration.parameters, parameter);
|
||||
let functionDeclaration = <FunctionLikeDeclaration>parameter.parent;
|
||||
let indexOfParameter = indexOf(functionDeclaration.parameters, parameter);
|
||||
if (indexOfParameter) {
|
||||
// Not a first parameter, go to previous parameter
|
||||
return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]);
|
||||
@@ -345,7 +357,7 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
function spanInFunctionBlock(block: Block): TextSpan {
|
||||
var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
|
||||
let nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
|
||||
if (canFunctionHaveSpanInWholeDeclaration(<FunctionLikeDeclaration>block.parent)) {
|
||||
return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock);
|
||||
}
|
||||
@@ -379,7 +391,7 @@ module ts.BreakpointResolver {
|
||||
function spanInForStatement(forStatement: ForStatement): TextSpan {
|
||||
if (forStatement.initializer) {
|
||||
if (forStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||
var variableDeclarationList = <VariableDeclarationList>forStatement.initializer;
|
||||
let variableDeclarationList = <VariableDeclarationList>forStatement.initializer;
|
||||
if (variableDeclarationList.declarations.length > 0) {
|
||||
return spanInNode(variableDeclarationList.declarations[0]);
|
||||
}
|
||||
@@ -401,15 +413,15 @@ module ts.BreakpointResolver {
|
||||
function spanInOpenBraceToken(node: Node): TextSpan {
|
||||
switch (node.parent.kind) {
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
var enumDeclaration = <EnumDeclaration>node.parent;
|
||||
let enumDeclaration = <EnumDeclaration>node.parent;
|
||||
return spanInNodeIfStartsOnSameLine(findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile));
|
||||
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
var classDeclaration = <ClassDeclaration>node.parent;
|
||||
let classDeclaration = <ClassDeclaration>node.parent;
|
||||
return spanInNodeIfStartsOnSameLine(findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile));
|
||||
|
||||
case SyntaxKind.SwitchStatement:
|
||||
return spanInNodeIfStartsOnSameLine(node.parent, (<SwitchStatement>node.parent).clauses[0]);
|
||||
case SyntaxKind.CaseBlock:
|
||||
return spanInNodeIfStartsOnSameLine(node.parent.parent, (<CaseBlock>node.parent).clauses[0]);
|
||||
}
|
||||
|
||||
// Default to parent node
|
||||
@@ -439,10 +451,10 @@ module ts.BreakpointResolver {
|
||||
case SyntaxKind.CatchClause:
|
||||
return spanInNode((<Block>node.parent).statements[(<Block>node.parent).statements.length - 1]);;
|
||||
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.CaseBlock:
|
||||
// breakpoint in last statement of the last clause
|
||||
var switchStatement = <SwitchStatement>node.parent;
|
||||
var lastClause = switchStatement.clauses[switchStatement.clauses.length - 1];
|
||||
let caseBlock = <CaseBlock>node.parent;
|
||||
let lastClause = caseBlock.clauses[caseBlock.clauses.length - 1];
|
||||
if (lastClause) {
|
||||
return spanInNode(lastClause.statements[lastClause.statements.length - 1]);
|
||||
}
|
||||
@@ -491,7 +503,7 @@ module ts.BreakpointResolver {
|
||||
|
||||
function spanInColonToken(node: Node): TextSpan {
|
||||
// Is this : specifying return annotation of the function declaration
|
||||
if (isAnyFunction(node.parent) || node.parent.kind === SyntaxKind.PropertyAssignment) {
|
||||
if (isFunctionLike(node.parent) || node.parent.kind === SyntaxKind.PropertyAssignment) {
|
||||
return spanInPreviousNode(node);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ module ts.formatting {
|
||||
* Indentation for the scope that can be dynamically recomputed.
|
||||
* i.e
|
||||
* while(true)
|
||||
* { var x;
|
||||
* { let x;
|
||||
* }
|
||||
* Normally indentation is applied only to the first token in line so at glance 'var' should not be touched.
|
||||
* However if some format rule adds new line between '}' and 'var' 'var' will become
|
||||
@@ -67,12 +67,12 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
export function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
var line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
let line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
if (line === 0) {
|
||||
return [];
|
||||
}
|
||||
// get the span for the previous\current line
|
||||
var span = {
|
||||
let span = {
|
||||
// get start position for the previous line
|
||||
pos: getStartPositionOfLine(line - 1, sourceFile),
|
||||
// get end position for the current line (end value is exclusive so add 1 to the result)
|
||||
@@ -90,7 +90,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
export function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
var span = {
|
||||
let span = {
|
||||
pos: 0,
|
||||
end: sourceFile.text.length
|
||||
};
|
||||
@@ -99,7 +99,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 = {
|
||||
let span = {
|
||||
pos: getLineStartPositionForPosition(start, sourceFile),
|
||||
end: end
|
||||
};
|
||||
@@ -107,11 +107,11 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function formatOutermostParent(position: number, expectedLastToken: SyntaxKind, sourceFile: SourceFile, options: FormatCodeOptions, rulesProvider: RulesProvider, requestKind: FormattingRequestKind): TextChange[] {
|
||||
var parent = findOutermostParent(position, expectedLastToken, sourceFile);
|
||||
let parent = findOutermostParent(position, expectedLastToken, sourceFile);
|
||||
if (!parent) {
|
||||
return [];
|
||||
}
|
||||
var span = {
|
||||
let span = {
|
||||
pos: getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile),
|
||||
end: parent.end
|
||||
};
|
||||
@@ -119,7 +119,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function findOutermostParent(position: number, expectedTokenKind: SyntaxKind, sourceFile: SourceFile): Node {
|
||||
var precedingToken = findPrecedingToken(position, sourceFile);
|
||||
let precedingToken = findPrecedingToken(position, sourceFile);
|
||||
|
||||
// when it is claimed that trigger character was typed at given position
|
||||
// we verify that there is a token with a matching kind whose end is equal to position (because the character was just typed).
|
||||
@@ -134,13 +134,13 @@ module ts.formatting {
|
||||
// walk up and search for the parent node that ends at the same position with precedingToken.
|
||||
// for cases like this
|
||||
//
|
||||
// var x = 1;
|
||||
// let x = 1;
|
||||
// while (true) {
|
||||
// }
|
||||
// after typing close curly in while statement we want to reformat just the while statement.
|
||||
// However if we just walk upwards searching for the parent that has the same end value -
|
||||
// we'll end up with the whole source file. isListElement allows to stop on the list element level
|
||||
var current = precedingToken;
|
||||
let current = precedingToken;
|
||||
while (current &&
|
||||
current.parent &&
|
||||
current.parent.end === precedingToken.end &&
|
||||
@@ -159,7 +159,7 @@ module ts.formatting {
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return rangeContainsRange((<InterfaceDeclaration>parent).members, node);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
var body = (<ModuleDeclaration>parent).body;
|
||||
let body = (<ModuleDeclaration>parent).body;
|
||||
return body && body.kind === SyntaxKind.Block && rangeContainsRange((<Block>body).statements, node);
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.Block:
|
||||
@@ -177,9 +177,9 @@ module ts.formatting {
|
||||
return find(sourceFile);
|
||||
|
||||
function find(n: Node): Node {
|
||||
var candidate = forEachChild(n, c => startEndContainsRange(c.getStart(sourceFile), c.end, range) && c);
|
||||
let candidate = forEachChild(n, c => startEndContainsRange(c.getStart(sourceFile), c.end, range) && c);
|
||||
if (candidate) {
|
||||
var result = find(candidate);
|
||||
let result = find(candidate);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
// pick only errors that fall in range
|
||||
var sorted = errors
|
||||
let sorted = errors
|
||||
.filter(d => rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length))
|
||||
.sort((e1, e2) => e1.start - e2.start);
|
||||
|
||||
@@ -207,7 +207,7 @@ module ts.formatting {
|
||||
return rangeHasNoErrors;
|
||||
}
|
||||
|
||||
var index = 0;
|
||||
let index = 0;
|
||||
|
||||
return r => {
|
||||
// in current implementation sequence of arguments [r1, r2...] is monotonically increasing.
|
||||
@@ -218,7 +218,7 @@ module ts.formatting {
|
||||
return false;
|
||||
}
|
||||
|
||||
var error = sorted[index];
|
||||
let error = sorted[index];
|
||||
if (r.end <= error.start) {
|
||||
// specified range ends before the error refered by 'index' - no error in range
|
||||
return false;
|
||||
@@ -244,12 +244,12 @@ module ts.formatting {
|
||||
* and return its end as start position for the scanner.
|
||||
*/
|
||||
function getScanStartPosition(enclosingNode: Node, originalRange: TextRange, sourceFile: SourceFile): number {
|
||||
var start = enclosingNode.getStart(sourceFile);
|
||||
let start = enclosingNode.getStart(sourceFile);
|
||||
if (start === originalRange.pos && enclosingNode.end === originalRange.end) {
|
||||
return start;
|
||||
}
|
||||
|
||||
var precedingToken = findPrecedingToken(originalRange.pos, sourceFile);
|
||||
let precedingToken = findPrecedingToken(originalRange.pos, sourceFile);
|
||||
if (!precedingToken) {
|
||||
// no preceding token found - start from the beginning of enclosing node
|
||||
return enclosingNode.pos;
|
||||
@@ -280,10 +280,10 @@ module ts.formatting {
|
||||
* to the initial indentation.
|
||||
*/
|
||||
function getOwnOrInheritedDelta(n: Node, options: FormatCodeOptions, sourceFile: SourceFile): number {
|
||||
var previousLine = Constants.Unknown;
|
||||
var childKind = SyntaxKind.Unknown;
|
||||
let previousLine = Constants.Unknown;
|
||||
let childKind = SyntaxKind.Unknown;
|
||||
while (n) {
|
||||
var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
|
||||
let line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
|
||||
if (previousLine !== Constants.Unknown && line !== previousLine) {
|
||||
break;
|
||||
}
|
||||
@@ -305,30 +305,30 @@ module ts.formatting {
|
||||
rulesProvider: RulesProvider,
|
||||
requestKind: FormattingRequestKind): TextChange[] {
|
||||
|
||||
var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange);
|
||||
let rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange);
|
||||
|
||||
// formatting context is used by rules provider
|
||||
var formattingContext = new FormattingContext(sourceFile, requestKind);
|
||||
let formattingContext = new FormattingContext(sourceFile, requestKind);
|
||||
|
||||
// find the smallest node that fully wraps the range and compute the initial indentation for the node
|
||||
var enclosingNode = findEnclosingNode(originalRange, sourceFile);
|
||||
let enclosingNode = findEnclosingNode(originalRange, sourceFile);
|
||||
|
||||
var formattingScanner = getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end);
|
||||
let formattingScanner = getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end);
|
||||
|
||||
var initialIndentation = SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options);
|
||||
let initialIndentation = SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options);
|
||||
|
||||
var previousRangeHasError: boolean;
|
||||
var previousRange: TextRangeWithKind;
|
||||
var previousParent: Node;
|
||||
var previousRangeStartLine: number;
|
||||
let previousRangeHasError: boolean;
|
||||
let previousRange: TextRangeWithKind;
|
||||
let previousParent: Node;
|
||||
let previousRangeStartLine: number;
|
||||
|
||||
var edits: TextChange[] = [];
|
||||
let edits: TextChange[] = [];
|
||||
|
||||
formattingScanner.advance();
|
||||
|
||||
if (formattingScanner.isOnToken()) {
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
|
||||
let startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
let delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
|
||||
processNode(enclosingNode, enclosingNode, startLine, initialIndentation, delta);
|
||||
}
|
||||
|
||||
@@ -357,9 +357,9 @@ module ts.formatting {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line;
|
||||
var startLinePosition = getLineStartPositionForPosition(startPos, sourceFile);
|
||||
var column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options);
|
||||
let startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line;
|
||||
let startLinePosition = getLineStartPositionForPosition(startPos, sourceFile);
|
||||
let column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options);
|
||||
if (startLine !== parentStartLine || startPos === column) {
|
||||
return column
|
||||
}
|
||||
@@ -376,7 +376,7 @@ module ts.formatting {
|
||||
parentDynamicIndentation: DynamicIndentation,
|
||||
effectiveParentStartLine: number): Indentation {
|
||||
|
||||
var indentation = inheritedIndentation;
|
||||
let indentation = inheritedIndentation;
|
||||
if (indentation === Constants.Unknown) {
|
||||
if (isSomeBlock(node.kind)) {
|
||||
// blocks should be indented in
|
||||
@@ -419,6 +419,29 @@ module ts.formatting {
|
||||
}
|
||||
}
|
||||
|
||||
function getFirstNonDecoratorTokenOfNode(node: Node) {
|
||||
if (node.modifiers && node.modifiers.length) {
|
||||
return node.modifiers[0].kind;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration: return SyntaxKind.ClassKeyword;
|
||||
case SyntaxKind.InterfaceDeclaration: return SyntaxKind.InterfaceKeyword;
|
||||
case SyntaxKind.FunctionDeclaration: return SyntaxKind.FunctionKeyword;
|
||||
case SyntaxKind.EnumDeclaration: return SyntaxKind.EnumDeclaration;
|
||||
case SyntaxKind.GetAccessor: return SyntaxKind.GetKeyword;
|
||||
case SyntaxKind.SetAccessor: return SyntaxKind.SetKeyword;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
if ((<MethodDeclaration>node).asteriskToken) {
|
||||
return SyntaxKind.AsteriskToken;
|
||||
}
|
||||
// fall-through
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.Parameter:
|
||||
return (<Declaration>node).name.kind;
|
||||
}
|
||||
}
|
||||
|
||||
function getDynamicIndentation(node: Node, nodeStartLine: number, indentation: number, delta: number): DynamicIndentation {
|
||||
return {
|
||||
getIndentationForComment: kind => {
|
||||
@@ -434,6 +457,12 @@ module ts.formatting {
|
||||
return indentation;
|
||||
},
|
||||
getIndentationForToken: (line, kind) => {
|
||||
if (nodeStartLine !== line && node.decorators) {
|
||||
if (kind === getFirstNonDecoratorTokenOfNode(node)) {
|
||||
// if this token is the first token following the list of decorators, we do not need to indent
|
||||
return indentation;
|
||||
}
|
||||
}
|
||||
switch (kind) {
|
||||
// open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
@@ -442,6 +471,7 @@ module ts.formatting {
|
||||
case SyntaxKind.CloseBracketToken:
|
||||
case SyntaxKind.ElseKeyword:
|
||||
case SyntaxKind.WhileKeyword:
|
||||
case SyntaxKind.AtToken:
|
||||
return indentation;
|
||||
default:
|
||||
// if token line equals to the line of containing node (this is a first token in the node) - use node indentation
|
||||
@@ -475,7 +505,7 @@ module ts.formatting {
|
||||
return;
|
||||
}
|
||||
|
||||
var nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta);
|
||||
let nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta);
|
||||
|
||||
// a useful observations when tracking context node
|
||||
// /
|
||||
@@ -489,7 +519,7 @@ module ts.formatting {
|
||||
// context node is set to parent node value after processing every child node
|
||||
// context node is set to parent of the token after processing every token
|
||||
|
||||
var childContextNode = contextNode;
|
||||
let childContextNode = contextNode;
|
||||
|
||||
// if there are any tokens that logically belong to node and interleave child nodes
|
||||
// such tokens will be consumed in processChildNode for for the child that follows them
|
||||
@@ -504,7 +534,7 @@ module ts.formatting {
|
||||
|
||||
// proceed any tokens in the node that are located after child nodes
|
||||
while (formattingScanner.isOnToken()) {
|
||||
var tokenInfo = formattingScanner.readTokenInfo(node);
|
||||
let tokenInfo = formattingScanner.readTokenInfo(node);
|
||||
if (tokenInfo.token.end > node.end) {
|
||||
break;
|
||||
}
|
||||
@@ -519,12 +549,12 @@ module ts.formatting {
|
||||
parentStartLine: number,
|
||||
isListItem: boolean): number {
|
||||
|
||||
var childStartPos = child.getStart(sourceFile);
|
||||
let childStartPos = child.getStart(sourceFile);
|
||||
|
||||
var childStart = sourceFile.getLineAndCharacterOfPosition(childStartPos);
|
||||
let childStart = sourceFile.getLineAndCharacterOfPosition(childStartPos);
|
||||
|
||||
// if child is a list item - try to get its indentation
|
||||
var childIndentationAmount = Constants.Unknown;
|
||||
let childIndentationAmount = Constants.Unknown;
|
||||
if (isListItem) {
|
||||
childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation);
|
||||
if (childIndentationAmount !== Constants.Unknown) {
|
||||
@@ -543,7 +573,7 @@ module ts.formatting {
|
||||
|
||||
while (formattingScanner.isOnToken()) {
|
||||
// proceed any parent tokens that are located prior to child.getStart()
|
||||
var tokenInfo = formattingScanner.readTokenInfo(node);
|
||||
let tokenInfo = formattingScanner.readTokenInfo(node);
|
||||
if (tokenInfo.token.end > childStartPos) {
|
||||
// stop when formatting scanner advances past the beginning of the child
|
||||
break;
|
||||
@@ -558,13 +588,13 @@ module ts.formatting {
|
||||
|
||||
if (isToken(child)) {
|
||||
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
|
||||
var tokenInfo = formattingScanner.readTokenInfo(child);
|
||||
let tokenInfo = formattingScanner.readTokenInfo(child);
|
||||
Debug.assert(tokenInfo.token.end === child.end);
|
||||
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation);
|
||||
return inheritedIndentation;
|
||||
}
|
||||
|
||||
var childIndentation = computeIndentation(child, childStart.line, childIndentationAmount, node, parentDynamicIndentation, parentStartLine);
|
||||
let childIndentation = computeIndentation(child, childStart.line, childIndentationAmount, node, parentDynamicIndentation, parentStartLine);
|
||||
|
||||
processNode(child, childContextNode, childStart.line, childIndentation.indentation, childIndentation.delta);
|
||||
|
||||
@@ -578,16 +608,16 @@ module ts.formatting {
|
||||
parentStartLine: number,
|
||||
parentDynamicIndentation: DynamicIndentation): void {
|
||||
|
||||
var listStartToken = getOpenTokenForList(parent, nodes);
|
||||
var listEndToken = getCloseTokenForOpenToken(listStartToken);
|
||||
let listStartToken = getOpenTokenForList(parent, nodes);
|
||||
let listEndToken = getCloseTokenForOpenToken(listStartToken);
|
||||
|
||||
var listDynamicIndentation = parentDynamicIndentation;
|
||||
var startLine = parentStartLine;
|
||||
let listDynamicIndentation = parentDynamicIndentation;
|
||||
let startLine = parentStartLine;
|
||||
|
||||
if (listStartToken !== SyntaxKind.Unknown) {
|
||||
// introduce a new indentation scope for lists (including list start and end tokens)
|
||||
while (formattingScanner.isOnToken()) {
|
||||
var tokenInfo = formattingScanner.readTokenInfo(parent);
|
||||
let tokenInfo = formattingScanner.readTokenInfo(parent);
|
||||
if (tokenInfo.token.end > nodes.pos) {
|
||||
// stop when formatting scanner moves past the beginning of node list
|
||||
break;
|
||||
@@ -595,7 +625,7 @@ module ts.formatting {
|
||||
else if (tokenInfo.token.kind === listStartToken) {
|
||||
// consume list start token
|
||||
startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
|
||||
var indentation =
|
||||
let indentation =
|
||||
computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, startLine);
|
||||
|
||||
listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation.indentation, indentation.delta);
|
||||
@@ -608,14 +638,14 @@ module ts.formatting {
|
||||
}
|
||||
}
|
||||
|
||||
var inheritedIndentation = Constants.Unknown;
|
||||
for (var i = 0, len = nodes.length; i < len; ++i) {
|
||||
inheritedIndentation = processChildNode(nodes[i], inheritedIndentation, node, listDynamicIndentation, startLine, /*isListElement*/ true)
|
||||
let inheritedIndentation = Constants.Unknown;
|
||||
for (let child of nodes) {
|
||||
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, /*isListElement*/ true)
|
||||
}
|
||||
|
||||
if (listEndToken !== SyntaxKind.Unknown) {
|
||||
if (formattingScanner.isOnToken()) {
|
||||
var tokenInfo = formattingScanner.readTokenInfo(parent);
|
||||
let tokenInfo = formattingScanner.readTokenInfo(parent);
|
||||
// consume the list end token only if it is still belong to the parent
|
||||
// there might be the case when current token matches end token but does not considered as one
|
||||
// function (x: function) <--
|
||||
@@ -631,21 +661,21 @@ module ts.formatting {
|
||||
function consumeTokenAndAdvanceScanner(currentTokenInfo: TokenInfo, parent: Node, dynamicIndentation: DynamicIndentation): void {
|
||||
Debug.assert(rangeContainsRange(parent, currentTokenInfo.token));
|
||||
|
||||
var lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine();
|
||||
var indentToken = false;
|
||||
let lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine();
|
||||
let indentToken = false;
|
||||
|
||||
if (currentTokenInfo.leadingTrivia) {
|
||||
processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation);
|
||||
}
|
||||
|
||||
var lineAdded: boolean;
|
||||
var isTokenInRange = rangeContainsRange(originalRange, currentTokenInfo.token);
|
||||
let lineAdded: boolean;
|
||||
let isTokenInRange = rangeContainsRange(originalRange, currentTokenInfo.token);
|
||||
|
||||
var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
|
||||
let tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
|
||||
if (isTokenInRange) {
|
||||
var rangeHasError = rangeContainsError(currentTokenInfo.token);
|
||||
let rangeHasError = rangeContainsError(currentTokenInfo.token);
|
||||
// save prevStartLine since processRange will overwrite this value with current ones
|
||||
var prevStartLine = previousRangeStartLine;
|
||||
let prevStartLine = previousRangeStartLine;
|
||||
lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation);
|
||||
if (rangeHasError) {
|
||||
// do not indent comments\token if token range overlaps with some error
|
||||
@@ -666,24 +696,23 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
if (indentToken) {
|
||||
var indentNextTokenOrTrivia = true;
|
||||
let indentNextTokenOrTrivia = true;
|
||||
if (currentTokenInfo.leadingTrivia) {
|
||||
for (var i = 0, len = currentTokenInfo.leadingTrivia.length; i < len; ++i) {
|
||||
var triviaItem = currentTokenInfo.leadingTrivia[i];
|
||||
for (let triviaItem of currentTokenInfo.leadingTrivia) {
|
||||
if (!rangeContainsRange(originalRange, triviaItem)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line;
|
||||
let triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line;
|
||||
switch (triviaItem.kind) {
|
||||
case SyntaxKind.MultiLineCommentTrivia:
|
||||
var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
|
||||
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
|
||||
indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia);
|
||||
indentNextTokenOrTrivia = false;
|
||||
break;
|
||||
case SyntaxKind.SingleLineCommentTrivia:
|
||||
if (indentNextTokenOrTrivia) {
|
||||
var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
|
||||
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
|
||||
insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false);
|
||||
indentNextTokenOrTrivia = false;
|
||||
}
|
||||
@@ -697,7 +726,7 @@ module ts.formatting {
|
||||
|
||||
// indent token only if is it is in target range and does not overlap with any error ranges
|
||||
if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
|
||||
var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
|
||||
let tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
|
||||
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
|
||||
}
|
||||
}
|
||||
@@ -709,10 +738,9 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function processTrivia(trivia: TextRangeWithKind[], parent: Node, contextNode: Node, dynamicIndentation: DynamicIndentation): void {
|
||||
for (var i = 0, len = trivia.length; i < len; ++i) {
|
||||
var triviaItem = trivia[i];
|
||||
for (let triviaItem of trivia) {
|
||||
if (isComment(triviaItem.kind) && rangeContainsRange(originalRange, triviaItem)) {
|
||||
var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos);
|
||||
let triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos);
|
||||
processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation);
|
||||
}
|
||||
}
|
||||
@@ -724,12 +752,12 @@ module ts.formatting {
|
||||
contextNode: Node,
|
||||
dynamicIndentation: DynamicIndentation): boolean {
|
||||
|
||||
var rangeHasError = rangeContainsError(range);
|
||||
var lineAdded: boolean;
|
||||
let rangeHasError = rangeContainsError(range);
|
||||
let lineAdded: boolean;
|
||||
if (!rangeHasError && !previousRangeHasError) {
|
||||
if (!previousRange) {
|
||||
// trim whitespaces starting from the beginning of the span up to the current line
|
||||
var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos);
|
||||
let originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos);
|
||||
trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line);
|
||||
}
|
||||
else {
|
||||
@@ -757,10 +785,10 @@ module ts.formatting {
|
||||
|
||||
formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode);
|
||||
|
||||
var rule = rulesProvider.getRulesMap().GetRule(formattingContext);
|
||||
let rule = rulesProvider.getRulesMap().GetRule(formattingContext);
|
||||
|
||||
var trimTrailingWhitespaces: boolean;
|
||||
var lineAdded: boolean;
|
||||
let trimTrailingWhitespaces: boolean;
|
||||
let lineAdded: boolean;
|
||||
if (rule) {
|
||||
applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine);
|
||||
|
||||
@@ -800,16 +828,16 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function insertIndentation(pos: number, indentation: number, lineAdded: boolean): void {
|
||||
var indentationString = getIndentationString(indentation, options);
|
||||
let indentationString = getIndentationString(indentation, options);
|
||||
if (lineAdded) {
|
||||
// new line is added before the token by the formatting rules
|
||||
// insert indentation string at the very beginning of the token
|
||||
recordReplace(pos, 0, indentationString);
|
||||
}
|
||||
else {
|
||||
var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
|
||||
let tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
|
||||
if (indentation !== tokenStart.character) {
|
||||
var startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
|
||||
let startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
|
||||
recordReplace(startLinePosition, tokenStart.character, indentationString);
|
||||
}
|
||||
}
|
||||
@@ -817,9 +845,9 @@ module ts.formatting {
|
||||
|
||||
function indentMultilineComment(commentRange: TextRange, indentation: number, firstLineIsIndented: boolean) {
|
||||
// split comment in lines
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line;
|
||||
var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line;
|
||||
|
||||
let startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line;
|
||||
let endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line;
|
||||
let parts: TextRange[];
|
||||
if (startLine === endLine) {
|
||||
if (!firstLineIsIndented) {
|
||||
// treat as single line comment
|
||||
@@ -828,10 +856,10 @@ module ts.formatting {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
var parts: TextRange[] = [];
|
||||
var startPos = commentRange.pos;
|
||||
for (var line = startLine; line < endLine; ++line) {
|
||||
var endOfLine = getEndLinePosition(line, sourceFile);
|
||||
parts = [];
|
||||
let startPos = commentRange.pos;
|
||||
for (let line = startLine; line < endLine; ++line) {
|
||||
let endOfLine = getEndLinePosition(line, sourceFile);
|
||||
parts.push({ pos: startPos, end: endOfLine });
|
||||
startPos = getStartPositionOfLine(line + 1, sourceFile);
|
||||
}
|
||||
@@ -839,52 +867,52 @@ module ts.formatting {
|
||||
parts.push({ pos: startPos, end: commentRange.end });
|
||||
}
|
||||
|
||||
var startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
let startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
|
||||
var nonWhitespaceColumnInFirstPart =
|
||||
SmartIndenter.findFirstNonWhitespaceColumn(startLinePos, parts[0].pos, sourceFile, options);
|
||||
let nonWhitespaceColumnInFirstPart =
|
||||
SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options);
|
||||
|
||||
if (indentation === nonWhitespaceColumnInFirstPart) {
|
||||
if (indentation === nonWhitespaceColumnInFirstPart.column) {
|
||||
return;
|
||||
}
|
||||
|
||||
var startIndex = 0;
|
||||
let startIndex = 0;
|
||||
if (firstLineIsIndented) {
|
||||
startIndex = 1;
|
||||
startLine++;
|
||||
}
|
||||
|
||||
// shift all parts on the delta size
|
||||
var delta = indentation - nonWhitespaceColumnInFirstPart;
|
||||
for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) {
|
||||
var startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
var nonWhitespaceColumn =
|
||||
let delta = indentation - nonWhitespaceColumnInFirstPart.column;
|
||||
for (let i = startIndex, len = parts.length; i < len; ++i, ++startLine) {
|
||||
let startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
let 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;
|
||||
let newIndentation = nonWhitespaceCharacterAndColumn.column + delta;
|
||||
if (newIndentation > 0) {
|
||||
var indentationString = getIndentationString(newIndentation, options);
|
||||
recordReplace(startLinePos, nonWhitespaceColumn, indentationString);
|
||||
let indentationString = getIndentationString(newIndentation, options);
|
||||
recordReplace(startLinePos, nonWhitespaceCharacterAndColumn.character, indentationString);
|
||||
}
|
||||
else {
|
||||
recordDelete(startLinePos, nonWhitespaceColumn);
|
||||
recordDelete(startLinePos, nonWhitespaceCharacterAndColumn.character);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function trimTrailingWhitespacesForLines(line1: number, line2: number, range?: TextRangeWithKind) {
|
||||
for (var line = line1; line < line2; ++line) {
|
||||
var lineStartPosition = getStartPositionOfLine(line, sourceFile);
|
||||
var lineEndPosition = getEndLinePosition(line, sourceFile);
|
||||
for (let line = line1; line < line2; ++line) {
|
||||
let lineStartPosition = getStartPositionOfLine(line, sourceFile);
|
||||
let lineEndPosition = getEndLinePosition(line, sourceFile);
|
||||
|
||||
// do not trim whitespaces in comments
|
||||
if (range && isComment(range.kind) && range.pos <= lineEndPosition && range.end > lineEndPosition) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var pos = lineEndPosition;
|
||||
let pos = lineEndPosition;
|
||||
while (pos >= lineStartPosition && isWhiteSpace(sourceFile.text.charCodeAt(pos))) {
|
||||
pos--;
|
||||
}
|
||||
@@ -917,7 +945,7 @@ module ts.formatting {
|
||||
currentRange: TextRangeWithKind,
|
||||
currentStartLine: number): void {
|
||||
|
||||
var between: TextRange;
|
||||
let between: TextRange;
|
||||
switch (rule.Operation.Action) {
|
||||
case RuleAction.Ignore:
|
||||
// no action required
|
||||
@@ -937,7 +965,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
// edit should not be applied only if we have one line feed between elements
|
||||
var lineDelta = currentStartLine - previousStartLine;
|
||||
let lineDelta = currentStartLine - previousStartLine;
|
||||
if (lineDelta !== 1) {
|
||||
recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.NewLineCharacter);
|
||||
}
|
||||
@@ -948,7 +976,7 @@ module ts.formatting {
|
||||
return;
|
||||
}
|
||||
|
||||
var posDelta = currentRange.pos - previousRange.end;
|
||||
let posDelta = currentRange.pos - previousRange.end;
|
||||
if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== CharacterCodes.space) {
|
||||
recordReplace(previousRange.end, currentRange.pos - previousRange.end, " ");
|
||||
}
|
||||
@@ -1010,15 +1038,25 @@ module ts.formatting {
|
||||
return SyntaxKind.Unknown;
|
||||
}
|
||||
|
||||
var internedSizes: { tabSize: number; indentSize: number };
|
||||
var internedTabsIndentation: string[];
|
||||
var internedSpacesIndentation: string[];
|
||||
|
||||
export function getIndentationString(indentation: number, options: FormatCodeOptions): string {
|
||||
if (!options.ConvertTabsToSpaces) {
|
||||
var tabs = Math.floor(indentation / options.TabSize);
|
||||
var spaces = indentation - tabs * options.TabSize;
|
||||
// reset interned strings if FormatCodeOptions were changed
|
||||
let resetInternedStrings =
|
||||
!internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize);
|
||||
|
||||
var tabString: string;
|
||||
if (resetInternedStrings) {
|
||||
internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize };
|
||||
internedTabsIndentation = internedSpacesIndentation = undefined;
|
||||
}
|
||||
|
||||
if (!options.ConvertTabsToSpaces) {
|
||||
let tabs = Math.floor(indentation / options.TabSize);
|
||||
let spaces = indentation - tabs * options.TabSize;
|
||||
|
||||
let tabString: string;
|
||||
if (!internedTabsIndentation) {
|
||||
internedTabsIndentation = [];
|
||||
}
|
||||
@@ -1033,9 +1071,9 @@ module ts.formatting {
|
||||
return spaces ? tabString + repeat(" ", spaces) : tabString;
|
||||
}
|
||||
else {
|
||||
var spacesString: string;
|
||||
var quotient = Math.floor(indentation / options.IndentSize);
|
||||
var remainder = indentation % options.IndentSize;
|
||||
let spacesString: string;
|
||||
let quotient = Math.floor(indentation / options.IndentSize);
|
||||
let remainder = indentation % options.IndentSize;
|
||||
if (!internedSpacesIndentation) {
|
||||
internedSpacesIndentation = [];
|
||||
}
|
||||
@@ -1048,13 +1086,12 @@ module ts.formatting {
|
||||
spacesString = internedSpacesIndentation[quotient];
|
||||
}
|
||||
|
||||
|
||||
return remainder ? spacesString + repeat(" ", remainder) : spacesString;
|
||||
}
|
||||
|
||||
function repeat(value: string, count: number): string {
|
||||
var s = "";
|
||||
for (var i = 0; i < count; ++i) {
|
||||
let s = "";
|
||||
for (let i = 0; i < count; ++i) {
|
||||
s += value;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line;
|
||||
let startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line;
|
||||
let endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line;
|
||||
this.tokensAreOnSameLine = (startLine == endLine);
|
||||
}
|
||||
|
||||
@@ -96,17 +96,17 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
private NodeIsOnOneLine(node: Node): boolean {
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
|
||||
let startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line;
|
||||
let endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
|
||||
return startLine == endLine;
|
||||
}
|
||||
|
||||
private BlockIsOnOneLine(node: Node): boolean {
|
||||
var openBrace = findChildOfKind(node, SyntaxKind.OpenBraceToken, this.sourceFile);
|
||||
var closeBrace = findChildOfKind(node, SyntaxKind.CloseBraceToken, this.sourceFile);
|
||||
let openBrace = findChildOfKind(node, SyntaxKind.OpenBraceToken, this.sourceFile);
|
||||
let closeBrace = findChildOfKind(node, SyntaxKind.CloseBraceToken, this.sourceFile);
|
||||
if (openBrace && closeBrace) {
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line;
|
||||
let startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line;
|
||||
let endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line;
|
||||
return startLine === endLine;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/// <reference path="..\..\compiler\scanner.ts"/>
|
||||
|
||||
module ts.formatting {
|
||||
var scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false);
|
||||
let scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false);
|
||||
|
||||
export interface FormattingScanner {
|
||||
advance(): void;
|
||||
@@ -24,13 +24,13 @@ module ts.formatting {
|
||||
scanner.setText(sourceFile.text);
|
||||
scanner.setTextPos(startPos);
|
||||
|
||||
var wasNewLine: boolean = true;
|
||||
var leadingTrivia: TextRangeWithKind[];
|
||||
var trailingTrivia: TextRangeWithKind[];
|
||||
let wasNewLine: boolean = true;
|
||||
let leadingTrivia: TextRangeWithKind[];
|
||||
let trailingTrivia: TextRangeWithKind[];
|
||||
|
||||
var savedPos: number;
|
||||
var lastScanAction: ScanAction;
|
||||
var lastTokenInfo: TokenInfo;
|
||||
let savedPos: number;
|
||||
let lastScanAction: ScanAction;
|
||||
let lastTokenInfo: TokenInfo;
|
||||
|
||||
return {
|
||||
advance: advance,
|
||||
@@ -45,7 +45,7 @@ module ts.formatting {
|
||||
|
||||
function advance(): void {
|
||||
lastTokenInfo = undefined;
|
||||
var isStarted = scanner.getStartPos() !== startPos;
|
||||
let isStarted = scanner.getStartPos() !== startPos;
|
||||
|
||||
if (isStarted) {
|
||||
if (trailingTrivia) {
|
||||
@@ -64,19 +64,19 @@ module ts.formatting {
|
||||
scanner.scan();
|
||||
}
|
||||
|
||||
var t: SyntaxKind;
|
||||
var pos = scanner.getStartPos();
|
||||
let t: SyntaxKind;
|
||||
let pos = scanner.getStartPos();
|
||||
|
||||
// Read leading trivia and token
|
||||
while (pos < endPos) {
|
||||
var t = scanner.getToken();
|
||||
let t = scanner.getToken();
|
||||
if (!isTrivia(t)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// consume leading trivia
|
||||
scanner.scan();
|
||||
var item = {
|
||||
let item = {
|
||||
pos: pos,
|
||||
end: scanner.getStartPos(),
|
||||
kind: t
|
||||
@@ -133,7 +133,7 @@ module ts.formatting {
|
||||
|
||||
// normally scanner returns the smallest available token
|
||||
// check the kind of context node to determine if scanner should have more greedy behavior and consume more text.
|
||||
var expectedScanAction =
|
||||
let expectedScanAction =
|
||||
shouldRescanGreaterThanToken(n)
|
||||
? ScanAction.RescanGreaterThanToken
|
||||
: shouldRescanSlashToken(n)
|
||||
@@ -159,7 +159,7 @@ module ts.formatting {
|
||||
scanner.scan();
|
||||
}
|
||||
|
||||
var currentToken = scanner.getToken();
|
||||
let currentToken = scanner.getToken();
|
||||
|
||||
if (expectedScanAction === ScanAction.RescanGreaterThanToken && currentToken === SyntaxKind.GreaterThanToken) {
|
||||
currentToken = scanner.reScanGreaterToken();
|
||||
@@ -179,7 +179,7 @@ module ts.formatting {
|
||||
lastScanAction = ScanAction.Scan;
|
||||
}
|
||||
|
||||
var token: TextRangeWithKind = {
|
||||
let token: TextRangeWithKind = {
|
||||
pos: scanner.getStartPos(),
|
||||
end: scanner.getTextPos(),
|
||||
kind: currentToken
|
||||
@@ -194,7 +194,7 @@ module ts.formatting {
|
||||
if (!isTrivia(currentToken)) {
|
||||
break;
|
||||
}
|
||||
var trivia = {
|
||||
let trivia = {
|
||||
pos: scanner.getStartPos(),
|
||||
end: scanner.getTextPos(),
|
||||
kind: currentToken
|
||||
@@ -223,8 +223,8 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function isOnToken(): boolean {
|
||||
var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken();
|
||||
var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos();
|
||||
let current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken();
|
||||
let startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos();
|
||||
return startPos < endPos && current !== SyntaxKind.EndOfFileToken && !isTrivia(current);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
module ts.formatting {
|
||||
|
||||
var internedTabsIndentation: string[];
|
||||
var internedSpacesIndentation: string[];
|
||||
|
||||
export function getIndentationString(indentation: number, options: FormatCodeOptions): string {
|
||||
if (!options.ConvertTabsToSpaces) {
|
||||
var tabs = Math.floor(indentation / options.TabSize);
|
||||
var spaces = indentation - tabs * options.TabSize;
|
||||
|
||||
var tabString: string;
|
||||
if (!internedTabsIndentation) {
|
||||
internedTabsIndentation = [];
|
||||
}
|
||||
|
||||
if (internedTabsIndentation[tabs] === undefined) {
|
||||
internedTabsIndentation[tabs] = tabString = repeat('\t', tabs);
|
||||
}
|
||||
else {
|
||||
tabString = internedTabsIndentation[tabs];
|
||||
}
|
||||
|
||||
return spaces ? tabString + repeat(" ", spaces) : tabString;
|
||||
}
|
||||
else {
|
||||
var spacesString: string;
|
||||
var quotient = Math.floor(indentation / options.IndentSize);
|
||||
var remainder = indentation % options.IndentSize;
|
||||
if (!internedSpacesIndentation) {
|
||||
internedSpacesIndentation = [];
|
||||
}
|
||||
|
||||
if (internedSpacesIndentation[quotient] === undefined) {
|
||||
spacesString = repeat(" ", options.IndentSize * quotient);
|
||||
internedSpacesIndentation[quotient] = spacesString;
|
||||
}
|
||||
else {
|
||||
spacesString = internedSpacesIndentation[quotient];
|
||||
}
|
||||
|
||||
|
||||
return remainder ? spacesString + repeat(" ", remainder) : spacesString;
|
||||
}
|
||||
|
||||
function repeat(value: string, count: number): string {
|
||||
var s = "";
|
||||
for (var i = 0; i < count; ++i) {
|
||||
s += value;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,8 +33,7 @@ module ts.formatting {
|
||||
return RuleDescriptor.create4(left, Shared.TokenRange.FromToken(right));
|
||||
}
|
||||
|
||||
static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor
|
||||
{
|
||||
static create3(left: SyntaxKind, right: Shared.TokenRange): RuleDescriptor {
|
||||
return RuleDescriptor.create4(Shared.TokenRange.FromToken(left), right);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
static create2(context: RuleOperationContext, action: RuleAction) {
|
||||
var result = new RuleOperation();
|
||||
let result = new RuleOperation();
|
||||
result.Context = context;
|
||||
result.Action = action;
|
||||
return result;
|
||||
|
||||
@@ -36,8 +36,8 @@ module ts.formatting {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (var i = 0, len = this.customContextChecks.length; i < len; i++) {
|
||||
if (!this.customContextChecks[i](context)) {
|
||||
for (let check of this.customContextChecks) {
|
||||
if (!check(context)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
module ts.formatting {
|
||||
export class Rules {
|
||||
public getRuleName(rule: Rule) {
|
||||
var o: ts.Map<any> = <any>this;
|
||||
for (var name in o) {
|
||||
let o: ts.Map<any> = <any>this;
|
||||
for (let name in o) {
|
||||
if (o[name] === rule) {
|
||||
return name;
|
||||
}
|
||||
@@ -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;
|
||||
@@ -134,7 +139,7 @@ module ts.formatting {
|
||||
// Lambda expressions
|
||||
public SpaceAfterArrow: Rule;
|
||||
|
||||
// Optional parameters and var args
|
||||
// Optional parameters and let args
|
||||
public NoSpaceAfterEllipsis: Rule;
|
||||
public NoSpaceAfterOptionalParameters: 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));
|
||||
@@ -323,7 +330,7 @@ module ts.formatting {
|
||||
// Lambda expressions
|
||||
this.SpaceAfterArrow = new Rule(RuleDescriptor.create3(SyntaxKind.EqualsGreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Optional parameters and var args
|
||||
// Optional parameters and let args
|
||||
this.NoSpaceAfterEllipsis = new Rule(RuleDescriptor.create1(SyntaxKind.DotDotDotToken, SyntaxKind.Identifier), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOptionalParameters = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.CommaToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 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,
|
||||
@@ -453,7 +462,7 @@ module ts.formatting {
|
||||
|
||||
// equal in import a = module('a');
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
// equal in var a = 0;
|
||||
// equal in let a = 0;
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
// equal in p = 0;
|
||||
case SyntaxKind.Parameter:
|
||||
@@ -461,12 +470,14 @@ module ts.formatting {
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
return context.currentTokenSpan.kind === SyntaxKind.EqualsToken || context.nextTokenSpan.kind === SyntaxKind.EqualsToken;
|
||||
// "in" keyword in for (var x in []) { }
|
||||
// "in" keyword in for (let 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;
|
||||
}
|
||||
@@ -475,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.
|
||||
////
|
||||
@@ -526,7 +541,7 @@ module ts.formatting {
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.CaseBlock:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return true;
|
||||
@@ -634,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;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
static create(rules: Rule[]): RulesMap {
|
||||
var result = new RulesMap();
|
||||
let result = new RulesMap();
|
||||
result.Initialize(rules);
|
||||
return result;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ module ts.formatting {
|
||||
this.map = <any> new Array(this.mapRowLength * this.mapRowLength);//new Array<RulesBucket>(this.mapRowLength * this.mapRowLength);
|
||||
|
||||
// This array is used only during construction of the rulesbucket in the map
|
||||
var rulesBucketConstructionStateList: RulesBucketConstructionState[] = <any> new Array(this.map.length);//new Array<RulesBucketConstructionState>(this.map.length);
|
||||
let rulesBucketConstructionStateList: RulesBucketConstructionState[] = <any> new Array(this.map.length);//new Array<RulesBucketConstructionState>(this.map.length);
|
||||
|
||||
this.FillRules(rules, rulesBucketConstructionStateList);
|
||||
return this.map;
|
||||
@@ -49,20 +49,20 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
private GetRuleBucketIndex(row: number, column: number): number {
|
||||
var rulesBucketIndex = (row * this.mapRowLength) + column;
|
||||
let rulesBucketIndex = (row * this.mapRowLength) + column;
|
||||
//Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array.");
|
||||
return rulesBucketIndex;
|
||||
}
|
||||
|
||||
private FillRule(rule: Rule, rulesBucketConstructionStateList: RulesBucketConstructionState[]): void {
|
||||
var specificRule = rule.Descriptor.LeftTokenRange != Shared.TokenRange.Any &&
|
||||
let specificRule = rule.Descriptor.LeftTokenRange != Shared.TokenRange.Any &&
|
||||
rule.Descriptor.RightTokenRange != Shared.TokenRange.Any;
|
||||
|
||||
rule.Descriptor.LeftTokenRange.GetTokens().forEach((left) => {
|
||||
rule.Descriptor.RightTokenRange.GetTokens().forEach((right) => {
|
||||
var rulesBucketIndex = this.GetRuleBucketIndex(left, right);
|
||||
let rulesBucketIndex = this.GetRuleBucketIndex(left, right);
|
||||
|
||||
var rulesBucket = this.map[rulesBucketIndex];
|
||||
let rulesBucket = this.map[rulesBucketIndex];
|
||||
if (rulesBucket == undefined) {
|
||||
rulesBucket = this.map[rulesBucketIndex] = new RulesBucket();
|
||||
}
|
||||
@@ -73,21 +73,21 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
public GetRule(context: FormattingContext): Rule {
|
||||
var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind);
|
||||
var bucket = this.map[bucketIndex];
|
||||
let bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind);
|
||||
let bucket = this.map[bucketIndex];
|
||||
if (bucket != null) {
|
||||
for (var i = 0, len = bucket.Rules().length; i < len; i++) {
|
||||
var rule = bucket.Rules()[i];
|
||||
if (rule.Operation.Context.InContext(context))
|
||||
for (let rule of bucket.Rules()) {
|
||||
if (rule.Operation.Context.InContext(context)) {
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
var MaskBitSize = 5;
|
||||
var Mask = 0x1f;
|
||||
let MaskBitSize = 5;
|
||||
let Mask = 0x1f;
|
||||
|
||||
export enum RulesPosition {
|
||||
IgnoreRulesSpecific = 0,
|
||||
@@ -121,10 +121,10 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
public GetInsertionIndex(maskPosition: RulesPosition): number {
|
||||
var index = 0;
|
||||
let index = 0;
|
||||
|
||||
var pos = 0;
|
||||
var indexBitmap = this.rulesInsertionIndexBitmap;
|
||||
let pos = 0;
|
||||
let indexBitmap = this.rulesInsertionIndexBitmap;
|
||||
|
||||
while (pos <= maskPosition) {
|
||||
index += (indexBitmap & Mask);
|
||||
@@ -136,11 +136,11 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
public IncreaseInsertionIndex(maskPosition: RulesPosition): void {
|
||||
var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask;
|
||||
let value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask;
|
||||
value++;
|
||||
Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules.");
|
||||
|
||||
var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition);
|
||||
let temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition);
|
||||
temp |= value << maskPosition;
|
||||
|
||||
this.rulesInsertionIndexBitmap = temp;
|
||||
@@ -159,7 +159,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
public AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void {
|
||||
var position: RulesPosition;
|
||||
let position: RulesPosition;
|
||||
|
||||
if (rule.Operation.Action == RuleAction.Ignore) {
|
||||
position = specificTokens ?
|
||||
@@ -177,11 +177,11 @@ module ts.formatting {
|
||||
RulesPosition.NoContextRulesAny;
|
||||
}
|
||||
|
||||
var state = constructionState[rulesBucketIndex];
|
||||
let state = constructionState[rulesBucketIndex];
|
||||
if (state === undefined) {
|
||||
state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState();
|
||||
}
|
||||
var index = state.GetInsertionIndex(position);
|
||||
let index = state.GetInsertionIndex(position);
|
||||
this.rules.splice(index, 0, rule);
|
||||
state.IncreaseInsertionIndex(position);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ module ts.formatting {
|
||||
|
||||
public ensureUpToDate(options: ts.FormatCodeOptions) {
|
||||
if (this.options == null || !ts.compareDataObjects(this.options, options)) {
|
||||
var activeRules = this.createActiveRules(options);
|
||||
var rulesMap = RulesMap.create(activeRules);
|
||||
let activeRules = this.createActiveRules(options);
|
||||
let rulesMap = RulesMap.create(activeRules);
|
||||
|
||||
this.activeRules = activeRules;
|
||||
this.rulesMap = rulesMap;
|
||||
@@ -50,7 +50,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
private createActiveRules(options: ts.FormatCodeOptions): Rule[] {
|
||||
var rules = this.globalRules.HighPriorityCommonRules.slice(0);
|
||||
let rules = this.globalRules.HighPriorityCommonRules.slice(0);
|
||||
|
||||
if (options.InsertSpaceAfterCommaDelimiter) {
|
||||
rules.push(this.globalRules.SpaceAfterComma);
|
||||
|
||||
@@ -2,18 +2,23 @@
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
var precedingToken = findPrecedingToken(position, sourceFile);
|
||||
let precedingToken = findPrecedingToken(position, sourceFile);
|
||||
if (!precedingToken) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// no indentation in string \regex\template literals
|
||||
var precedingTokenIsLiteral =
|
||||
let precedingTokenIsLiteral =
|
||||
precedingToken.kind === SyntaxKind.StringLiteral ||
|
||||
precedingToken.kind === SyntaxKind.RegularExpressionLiteral ||
|
||||
precedingToken.kind === SyntaxKind.NoSubstitutionTemplateLiteral ||
|
||||
@@ -24,22 +29,22 @@ module ts.formatting {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
let 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) {
|
||||
let actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation;
|
||||
}
|
||||
}
|
||||
|
||||
// try to find node that can contribute to indentation and includes 'position' starting from 'precedingToken'
|
||||
// if such node is found - compute initial indentation for 'position' inside this node
|
||||
var previous: Node;
|
||||
var current = precedingToken;
|
||||
var currentStart: LineAndCharacter;
|
||||
var indentationDelta: number;
|
||||
let previous: Node;
|
||||
let current = precedingToken;
|
||||
let currentStart: LineAndCharacter;
|
||||
let indentationDelta: number;
|
||||
|
||||
while (current) {
|
||||
if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current.kind, previous ? previous.kind : SyntaxKind.Unknown)) {
|
||||
@@ -56,8 +61,8 @@ 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) {
|
||||
let actualIndentation = getActualIndentationForListItem(current, sourceFile, options);
|
||||
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.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
let start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options);
|
||||
}
|
||||
|
||||
@@ -86,34 +91,34 @@ module ts.formatting {
|
||||
sourceFile: SourceFile,
|
||||
options: EditorOptions): number {
|
||||
|
||||
var parent: Node = current.parent;
|
||||
var parentStart: LineAndCharacter;
|
||||
let parent: Node = current.parent;
|
||||
let parentStart: LineAndCharacter;
|
||||
|
||||
// walk upwards and collect indentations for pairs of parent-child nodes
|
||||
// indentation is not added if parent and child nodes start on the same line or if parent is IfStatement and child starts on the same line with 'else clause'
|
||||
while (parent) {
|
||||
var useActualIndentation = true;
|
||||
let useActualIndentation = true;
|
||||
if (ignoreActualIndentationRange) {
|
||||
var start = current.getStart(sourceFile);
|
||||
let start = current.getStart(sourceFile);
|
||||
useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end;
|
||||
}
|
||||
|
||||
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) {
|
||||
let actualIndentation = getActualIndentationForListItem(current, sourceFile, options);
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation + indentationDelta;
|
||||
}
|
||||
}
|
||||
parentStart = getParentStart(parent, current, sourceFile);
|
||||
var parentAndChildShareLine =
|
||||
let parentAndChildShareLine =
|
||||
parentStart.line === currentStart.line ||
|
||||
childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile);
|
||||
|
||||
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) {
|
||||
let actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options);
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation + indentationDelta;
|
||||
}
|
||||
}
|
||||
@@ -133,7 +138,7 @@ module ts.formatting {
|
||||
|
||||
|
||||
function getParentStart(parent: Node, child: Node, sourceFile: SourceFile): LineAndCharacter {
|
||||
var containingList = getContainingList(child, sourceFile);
|
||||
let containingList = getContainingList(child, sourceFile);
|
||||
if (containingList) {
|
||||
return sourceFile.getLineAndCharacterOfPosition(containingList.pos);
|
||||
}
|
||||
@@ -142,18 +147,22 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
let commaItemInfo = findListItemInfo(commaToken);
|
||||
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,
|
||||
@@ -165,19 +174,19 @@ module ts.formatting {
|
||||
// actual indentation is used for statements\declarations if one of cases below is true:
|
||||
// - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually
|
||||
// - parent and child are not on the same line
|
||||
var useActualIndentation =
|
||||
let useActualIndentation =
|
||||
(isDeclaration(current) || isStatement(current)) &&
|
||||
(parent.kind === SyntaxKind.SourceFile || !parentAndChildShareLine);
|
||||
|
||||
if (!useActualIndentation) {
|
||||
return -1;
|
||||
return Value.Unknown;
|
||||
}
|
||||
|
||||
return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options);
|
||||
}
|
||||
|
||||
function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken: Node, current: Node, lineAtPosition: number, sourceFile: SourceFile): boolean {
|
||||
var nextToken = findNextToken(precedingToken, current);
|
||||
let nextToken = findNextToken(precedingToken, current);
|
||||
if (!nextToken) {
|
||||
return false;
|
||||
}
|
||||
@@ -196,7 +205,7 @@ module ts.formatting {
|
||||
// class A {
|
||||
// $}
|
||||
|
||||
var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line;
|
||||
let nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line;
|
||||
return lineAtPosition === nextTokenStartLine;
|
||||
}
|
||||
|
||||
@@ -206,17 +215,13 @@ module ts.formatting {
|
||||
function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter {
|
||||
return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
}
|
||||
|
||||
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean {
|
||||
return candidate.end > position || !isCompletedNode(candidate, sourceFile);
|
||||
}
|
||||
|
||||
|
||||
export function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean {
|
||||
if (parent.kind === SyntaxKind.IfStatement && (<IfStatement>parent).elseStatement === child) {
|
||||
var elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile);
|
||||
let elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile);
|
||||
Debug.assert(elseKeyword !== undefined);
|
||||
|
||||
var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
|
||||
let elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
|
||||
return elseKeywordStartLine === childStartLine;
|
||||
}
|
||||
|
||||
@@ -242,8 +247,8 @@ module ts.formatting {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
var start = node.getStart(sourceFile);
|
||||
case SyntaxKind.ConstructSignature: {
|
||||
let start = node.getStart(sourceFile);
|
||||
if ((<SignatureDeclaration>node.parent).typeParameters &&
|
||||
rangeContainsStartEnd((<SignatureDeclaration>node.parent).typeParameters, start, node.getEnd())) {
|
||||
return (<SignatureDeclaration>node.parent).typeParameters;
|
||||
@@ -252,9 +257,10 @@ module ts.formatting {
|
||||
return (<SignatureDeclaration>node.parent).parameters;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
var start = node.getStart(sourceFile);
|
||||
case SyntaxKind.CallExpression: {
|
||||
let start = node.getStart(sourceFile);
|
||||
if ((<CallExpression>node.parent).typeArguments &&
|
||||
rangeContainsStartEnd((<CallExpression>node.parent).typeArguments, start, node.getEnd())) {
|
||||
return (<CallExpression>node.parent).typeArguments;
|
||||
@@ -264,54 +270,63 @@ module ts.formatting {
|
||||
return (<CallExpression>node.parent).arguments;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getActualIndentationForListItem(node: Node, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
var containingList = getContainingList(node, sourceFile);
|
||||
return containingList ? getActualIndentationFromList(containingList) : -1;
|
||||
let containingList = getContainingList(node, sourceFile);
|
||||
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;
|
||||
let index = indexOf(list, node);
|
||||
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];
|
||||
let node = list[index];
|
||||
|
||||
// walk toward the start of the list starting from current node and check if the line is the same for all items.
|
||||
// if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i]
|
||||
var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile);
|
||||
for (var i = index - 1; i >= 0; --i) {
|
||||
let lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile);
|
||||
for (let i = index - 1; i >= 0; --i) {
|
||||
if (list[i].kind === SyntaxKind.CommaToken) {
|
||||
continue;
|
||||
}
|
||||
// skip list items that ends on the same line with the current list element
|
||||
var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line;
|
||||
let 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.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
|
||||
let 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 {
|
||||
var column = 0;
|
||||
for (var pos = startPos; pos < endPos; ++pos) {
|
||||
var ch = sourceFile.text.charCodeAt(pos);
|
||||
/*
|
||||
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) {
|
||||
let character = 0;
|
||||
let column = 0;
|
||||
for (let pos = startPos; pos < endPos; ++pos) {
|
||||
let ch = sourceFile.text.charCodeAt(pos);
|
||||
if (!isWhiteSpace(ch)) {
|
||||
return column;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ch === CharacterCodes.tab) {
|
||||
@@ -320,8 +335,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 {
|
||||
@@ -334,7 +355,8 @@ module ts.formatting {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.TupleType:
|
||||
case SyntaxKind.CaseBlock:
|
||||
case SyntaxKind.DefaultClause:
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
@@ -345,6 +367,8 @@ module ts.formatting {
|
||||
case SyntaxKind.ExportAssignment:
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
case SyntaxKind.ArrayBindingPattern:
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -365,6 +389,7 @@ module ts.formatting {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
@@ -374,82 +399,5 @@ module ts.formatting {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks if node ends with 'expectedLastToken'.
|
||||
* If child at position 'length - 1' is 'SemicolonToken' it is skipped and 'expectedLastToken' is compared with child at position 'length - 2'.
|
||||
*/
|
||||
function nodeEndsWith(n: Node, expectedLastToken: SyntaxKind, sourceFile: SourceFile): boolean {
|
||||
var children = n.getChildren(sourceFile);
|
||||
if (children.length) {
|
||||
var last = children[children.length - 1];
|
||||
if (last.kind === expectedLastToken) {
|
||||
return true;
|
||||
}
|
||||
else if (last.kind === SyntaxKind.SemicolonToken && children.length !== 1) {
|
||||
return children[children.length - 2].kind === expectedLastToken;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is always called when position of the cursor is located after the node
|
||||
*/
|
||||
function isCompletedNode(n: Node, sourceFile: SourceFile): boolean {
|
||||
if (n.getFullWidth() === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (n.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
case SyntaxKind.CatchClause:
|
||||
return isCompletedNode((<CatchClause>n).block, sourceFile);
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile);
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return !(<FunctionLikeDeclaration>n).body || isCompletedNode((<FunctionLikeDeclaration>n).body, sourceFile);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return (<ModuleDeclaration>n).body && isCompletedNode((<ModuleDeclaration>n).body, sourceFile);
|
||||
case SyntaxKind.IfStatement:
|
||||
if ((<IfStatement>n).elseStatement) {
|
||||
return isCompletedNode((<IfStatement>n).elseStatement, sourceFile);
|
||||
}
|
||||
return isCompletedNode((<IfStatement>n).thenStatement, sourceFile);
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
return isCompletedNode((<ExpressionStatement>n).expression, sourceFile);
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return nodeEndsWith(n, SyntaxKind.CloseBracketToken, sourceFile);
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.DefaultClause:
|
||||
// there is no such thing as terminator token for CaseClause\DefaultClause so for simplicitly always consider them non-completed
|
||||
return false;
|
||||
case SyntaxKind.WhileStatement:
|
||||
return isCompletedNode((<WhileStatement>n).statement, sourceFile);
|
||||
case SyntaxKind.DoStatement:
|
||||
// rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')';
|
||||
var hasWhileKeyword = findChildOfKind(n, SyntaxKind.WhileKeyword, sourceFile);
|
||||
if (hasWhileKeyword) {
|
||||
return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile);
|
||||
}
|
||||
return isCompletedNode((<DoStatement>n).statement, sourceFile);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ module ts.formatting {
|
||||
|
||||
constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]) {
|
||||
this.tokens = [];
|
||||
for (var token = from; token <= to; token++) {
|
||||
for (let token = from; token <= to; token++) {
|
||||
if (except.indexOf(token) < 0) {
|
||||
this.tokens.push(token);
|
||||
}
|
||||
@@ -74,8 +74,8 @@ module ts.formatting {
|
||||
|
||||
export class TokenAllAccess implements ITokenAccess {
|
||||
public GetTokens(): SyntaxKind[] {
|
||||
var result: SyntaxKind[] = [];
|
||||
for (var token = SyntaxKind.FirstToken; token <= SyntaxKind.LastToken; token++) {
|
||||
let result: SyntaxKind[] = [];
|
||||
for (let token = SyntaxKind.FirstToken; token <= SyntaxKind.LastToken; token++) {
|
||||
result.push(token);
|
||||
}
|
||||
return result;
|
||||
|
||||
+24
-25
@@ -2,31 +2,30 @@ 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[] = [];
|
||||
let patternMatcher = createPatternMatcher(searchValue);
|
||||
let 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];
|
||||
let declarations = sourceFile.getNamedDeclarations();
|
||||
for (let declaration of declarations) {
|
||||
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);
|
||||
let matches = patternMatcher.getMatchesForLastSegmentOfPattern(name);
|
||||
|
||||
if (!matches) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// It was a match! If the pattern has dots in it, then also see if hte
|
||||
// It was a match! If the pattern has dots in it, then also see if the
|
||||
// declaration container matches as well.
|
||||
if (patternMatcher.patternContainsDots) {
|
||||
var containers = getContainers(declaration);
|
||||
let containers = getContainers(declaration);
|
||||
if (!containers) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -38,8 +37,8 @@ module ts.NavigateTo {
|
||||
}
|
||||
}
|
||||
|
||||
var fileName = sourceFile.fileName;
|
||||
var matchKind = bestMatchKind(matches);
|
||||
let fileName = sourceFile.fileName;
|
||||
let matchKind = bestMatchKind(matches);
|
||||
rawItems.push({ name, fileName, matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration });
|
||||
}
|
||||
}
|
||||
@@ -50,7 +49,7 @@ module ts.NavigateTo {
|
||||
rawItems = rawItems.slice(0, maxResultCount);
|
||||
}
|
||||
|
||||
var items = map(rawItems, createNavigateToItem);
|
||||
let items = map(rawItems, createNavigateToItem);
|
||||
|
||||
return items;
|
||||
|
||||
@@ -58,8 +57,8 @@ module ts.NavigateTo {
|
||||
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) {
|
||||
for (let match of matches) {
|
||||
if (!match.isCaseSensitive) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -68,13 +67,13 @@ module ts.NavigateTo {
|
||||
}
|
||||
|
||||
function getDeclarationName(declaration: Declaration): string {
|
||||
var result = getTextOfIdentifierOrLiteral(declaration.name);
|
||||
let result = getTextOfIdentifierOrLiteral(declaration.name);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (declaration.name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
var expr = (<ComputedPropertyName>declaration.name).expression;
|
||||
let expr = (<ComputedPropertyName>declaration.name).expression;
|
||||
if (expr.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
return (<PropertyAccessExpression>expr).name.text;
|
||||
}
|
||||
@@ -98,7 +97,7 @@ module ts.NavigateTo {
|
||||
|
||||
function tryAddSingleDeclarationName(declaration: Declaration, containers: string[]) {
|
||||
if (declaration && declaration.name) {
|
||||
var text = getTextOfIdentifierOrLiteral(declaration.name);
|
||||
let text = getTextOfIdentifierOrLiteral(declaration.name);
|
||||
if (text !== undefined) {
|
||||
containers.unshift(text);
|
||||
}
|
||||
@@ -118,7 +117,7 @@ module ts.NavigateTo {
|
||||
//
|
||||
// [X.Y.Z]() { }
|
||||
function tryAddComputedPropertyName(expression: Expression, containers: string[], includeLastPortion: boolean): boolean {
|
||||
var text = getTextOfIdentifierOrLiteral(expression);
|
||||
let text = getTextOfIdentifierOrLiteral(expression);
|
||||
if (text !== undefined) {
|
||||
if (includeLastPortion) {
|
||||
containers.unshift(text);
|
||||
@@ -127,7 +126,7 @@ module ts.NavigateTo {
|
||||
}
|
||||
|
||||
if (expression.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
var propertyAccess = <PropertyAccessExpression>expression;
|
||||
let propertyAccess = <PropertyAccessExpression>expression;
|
||||
if (includeLastPortion) {
|
||||
containers.unshift(propertyAccess.name.text);
|
||||
}
|
||||
@@ -139,7 +138,7 @@ module ts.NavigateTo {
|
||||
}
|
||||
|
||||
function getContainers(declaration: Declaration) {
|
||||
var containers: string[] = [];
|
||||
let containers: string[] = [];
|
||||
|
||||
// First, if we started with a computed property name, then add all but the last
|
||||
// portion into the container array.
|
||||
@@ -165,10 +164,10 @@ module ts.NavigateTo {
|
||||
|
||||
function bestMatchKind(matches: PatternMatch[]) {
|
||||
Debug.assert(matches.length > 0);
|
||||
var bestMatchKind = PatternMatchKind.camelCase;
|
||||
let bestMatchKind = PatternMatchKind.camelCase;
|
||||
|
||||
for (var i = 0, n = matches.length; i < n; i++) {
|
||||
var kind = matches[i].kind;
|
||||
for (let match of matches) {
|
||||
let kind = match.kind;
|
||||
if (kind < bestMatchKind) {
|
||||
bestMatchKind = kind;
|
||||
}
|
||||
@@ -178,7 +177,7 @@ module ts.NavigateTo {
|
||||
}
|
||||
|
||||
// This means "compare in a case insensitive manner."
|
||||
var baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
|
||||
let 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.
|
||||
@@ -190,8 +189,8 @@ module ts.NavigateTo {
|
||||
}
|
||||
|
||||
function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem {
|
||||
var declaration = rawItem.declaration;
|
||||
var container = <Declaration>getContainerNode(declaration);
|
||||
let declaration = rawItem.declaration;
|
||||
let container = <Declaration>getContainerNode(declaration);
|
||||
return {
|
||||
name: rawItem.name,
|
||||
kind: getNodeKind(declaration),
|
||||
|
||||
@@ -4,16 +4,16 @@ module ts.NavigationBar {
|
||||
export function getNavigationBarItems(sourceFile: SourceFile): ts.NavigationBarItem[] {
|
||||
// If the source file has any child items, then it included in the tree
|
||||
// and takes lexical ownership of all other top-level items.
|
||||
var hasGlobalNode = false;
|
||||
let hasGlobalNode = false;
|
||||
|
||||
return getItemsWorker(getTopLevelNodes(sourceFile), createTopLevelItem);
|
||||
|
||||
function getIndent(node: Node): number {
|
||||
// If we have a global node in the tree,
|
||||
// then it adds an extra layer of depth to all subnodes.
|
||||
var indent = hasGlobalNode ? 1 : 0;
|
||||
let indent = hasGlobalNode ? 1 : 0;
|
||||
|
||||
var current = node.parent;
|
||||
let current = node.parent;
|
||||
while (current) {
|
||||
switch (current.kind) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
@@ -39,7 +39,7 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
function getChildNodes(nodes: Node[]): Node[] {
|
||||
var childNodes: Node[] = [];
|
||||
let childNodes: Node[] = [];
|
||||
|
||||
function visit(node: Node) {
|
||||
switch (node.kind) {
|
||||
@@ -50,6 +50,38 @@ module ts.NavigationBar {
|
||||
case SyntaxKind.ArrayBindingPattern:
|
||||
forEach((<BindingPattern>node).elements, visit);
|
||||
break;
|
||||
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
// Handle named exports case e.g.:
|
||||
// export {a, b as B} from "mod";
|
||||
if ((<ExportDeclaration>node).exportClause) {
|
||||
forEach((<ExportDeclaration>node).exportClause.elements, visit);
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
let importClause = (<ImportDeclaration>node).importClause;
|
||||
if (importClause) {
|
||||
// Handle default import case e.g.:
|
||||
// import d from "mod";
|
||||
if (importClause.name) {
|
||||
childNodes.push(importClause);
|
||||
}
|
||||
|
||||
// Handle named bindings in imports e.g.:
|
||||
// import * as NS from "mod";
|
||||
// import {a, b as B} from "mod";
|
||||
if (importClause.namedBindings) {
|
||||
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
childNodes.push(importClause.namedBindings);
|
||||
}
|
||||
else {
|
||||
forEach((<NamedImports>importClause.namedBindings).elements, visit);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
if (isBindingPattern((<VariableDeclaration>node).name)) {
|
||||
@@ -62,12 +94,16 @@ module ts.NavigationBar {
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
childNodes.push(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
// var node = nodes[i];
|
||||
//for (let i = 0, n = nodes.length; i < n; i++) {
|
||||
// let node = nodes[i];
|
||||
|
||||
// if (node.kind === SyntaxKind.ClassDeclaration ||
|
||||
// node.kind === SyntaxKind.EnumDeclaration ||
|
||||
@@ -86,7 +122,7 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
function getTopLevelNodes(node: SourceFile): Node[] {
|
||||
var topLevelNodes: Node[] = [];
|
||||
let topLevelNodes: Node[] = [];
|
||||
topLevelNodes.push(node);
|
||||
|
||||
addTopLevelNodes(node.statements, topLevelNodes);
|
||||
@@ -114,8 +150,7 @@ module ts.NavigationBar {
|
||||
function addTopLevelNodes(nodes: Node[], topLevelNodes: Node[]): void {
|
||||
nodes = sortNodes(nodes);
|
||||
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
var node = nodes[i];
|
||||
for (let node of nodes) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
@@ -124,13 +159,13 @@ module ts.NavigationBar {
|
||||
break;
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
var moduleDeclaration = <ModuleDeclaration>node;
|
||||
let moduleDeclaration = <ModuleDeclaration>node;
|
||||
topLevelNodes.push(node);
|
||||
addTopLevelNodes((<Block>getInnermostModule(moduleDeclaration).body).statements, topLevelNodes);
|
||||
break;
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
var functionDeclaration = <FunctionLikeDeclaration>node;
|
||||
let functionDeclaration = <FunctionLikeDeclaration>node;
|
||||
if (isTopLevelFunctionDeclaration(functionDeclaration)) {
|
||||
topLevelNodes.push(node);
|
||||
addTopLevelNodes((<Block>functionDeclaration.body).statements, topLevelNodes);
|
||||
@@ -164,18 +199,17 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
function getItemsWorker(nodes: Node[], createItem: (n: Node) => ts.NavigationBarItem): ts.NavigationBarItem[] {
|
||||
var items: ts.NavigationBarItem[] = [];
|
||||
let items: ts.NavigationBarItem[] = [];
|
||||
|
||||
var keyToItem: Map<NavigationBarItem> = {};
|
||||
let keyToItem: Map<NavigationBarItem> = {};
|
||||
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
var child = nodes[i];
|
||||
var item = createItem(child);
|
||||
for (let child of nodes) {
|
||||
let item = createItem(child);
|
||||
if (item !== undefined) {
|
||||
if (item.text.length > 0) {
|
||||
var key = item.text + "-" + item.kind + "-" + item.indent;
|
||||
let key = item.text + "-" + item.kind + "-" + item.indent;
|
||||
|
||||
var itemWithSameName = keyToItem[key];
|
||||
let itemWithSameName = keyToItem[key];
|
||||
if (itemWithSameName) {
|
||||
// We had an item with the same name. Merge these items together.
|
||||
merge(itemWithSameName, item);
|
||||
@@ -202,12 +236,8 @@ module ts.NavigationBar {
|
||||
|
||||
// Next, recursively merge or add any children in the source as appropriate.
|
||||
outer:
|
||||
for (var i = 0, n = source.childItems.length; i < n; i++) {
|
||||
var sourceChild = source.childItems[i];
|
||||
|
||||
for (var j = 0, m = target.childItems.length; j < m; j++) {
|
||||
var targetChild = target.childItems[j];
|
||||
|
||||
for (let sourceChild of source.childItems) {
|
||||
for (let targetChild of target.childItems) {
|
||||
if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) {
|
||||
// Found a match. merge them.
|
||||
merge(targetChild, sourceChild);
|
||||
@@ -263,8 +293,8 @@ module ts.NavigationBar {
|
||||
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
var variableDeclarationNode: Node;
|
||||
var name: Node;
|
||||
let variableDeclarationNode: Node;
|
||||
let name: Node;
|
||||
|
||||
if (node.kind === SyntaxKind.BindingElement) {
|
||||
name = (<BindingElement>node).name;
|
||||
@@ -291,9 +321,16 @@ module ts.NavigationBar {
|
||||
else {
|
||||
return createItem(node, getTextOfNode(name), ts.ScriptElementKind.variableElement);
|
||||
}
|
||||
|
||||
|
||||
case SyntaxKind.Constructor:
|
||||
return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement);
|
||||
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportClause:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
return createItem(node, getTextOfNode((<Declaration>node).name), ts.ScriptElementKind.alias);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -354,7 +391,7 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
// Otherwise, we need to aggregate each identifier to build up the qualified name.
|
||||
var result: string[] = [];
|
||||
let result: string[] = [];
|
||||
|
||||
result.push(moduleDeclaration.name.text);
|
||||
|
||||
@@ -368,9 +405,9 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createModuleItem(node: ModuleDeclaration): NavigationBarItem {
|
||||
var moduleName = getModuleName(node);
|
||||
let moduleName = getModuleName(node);
|
||||
|
||||
var childItems = getItemsWorker(getChildNodes((<Block>getInnermostModule(node).body).statements), createChildItem);
|
||||
let childItems = getItemsWorker(getChildNodes((<Block>getInnermostModule(node).body).statements), createChildItem);
|
||||
|
||||
return getNavigationBarItem(moduleName,
|
||||
ts.ScriptElementKind.moduleElement,
|
||||
@@ -381,10 +418,10 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createFunctionItem(node: FunctionDeclaration) {
|
||||
if (node.name && node.body && node.body.kind === SyntaxKind.Block) {
|
||||
var childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
|
||||
if (node.body && node.body.kind === SyntaxKind.Block) {
|
||||
let childItems = getItemsWorker(sortNodes((<Block>node.body).statements), createChildItem);
|
||||
|
||||
return getNavigationBarItem(node.name.text,
|
||||
return getNavigationBarItem(!node.name ? "default": node.name.text ,
|
||||
ts.ScriptElementKind.functionElement,
|
||||
getNodeModifiers(node),
|
||||
[getNodeSpan(node)],
|
||||
@@ -396,14 +433,14 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createSourceFileItem(node: SourceFile): ts.NavigationBarItem {
|
||||
var childItems = getItemsWorker(getChildNodes(node.statements), createChildItem);
|
||||
let childItems = getItemsWorker(getChildNodes(node.statements), createChildItem);
|
||||
|
||||
if (childItems === undefined || childItems.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
hasGlobalNode = true;
|
||||
var rootName = isExternalModule(node)
|
||||
let rootName = isExternalModule(node)
|
||||
? "\"" + escapeString(getBaseFileName(removeFileExtension(normalizePath(node.fileName)))) + "\""
|
||||
: "<global>"
|
||||
|
||||
@@ -415,26 +452,28 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createClassItem(node: ClassDeclaration): ts.NavigationBarItem {
|
||||
var childItems: NavigationBarItem[];
|
||||
let childItems: NavigationBarItem[];
|
||||
|
||||
if (node.members) {
|
||||
var constructor = <ConstructorDeclaration>forEach(node.members, member => {
|
||||
let constructor = <ConstructorDeclaration>forEach(node.members, member => {
|
||||
return member.kind === SyntaxKind.Constructor && member;
|
||||
});
|
||||
|
||||
// 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[] = removeDynamicallyNamedProperties(node);
|
||||
let 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);
|
||||
childItems = getItemsWorker(sortNodes(nodes), createChildItem);
|
||||
}
|
||||
|
||||
var nodeName = !node.name ? "default" : node.name.text;
|
||||
|
||||
return getNavigationBarItem(
|
||||
node.name.text,
|
||||
nodeName,
|
||||
ts.ScriptElementKind.classElement,
|
||||
getNodeModifiers(node),
|
||||
[getNodeSpan(node)],
|
||||
@@ -443,7 +482,7 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createEnumItem(node: EnumDeclaration): ts.NavigationBarItem {
|
||||
var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem);
|
||||
let childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem);
|
||||
return getNavigationBarItem(
|
||||
node.name.text,
|
||||
ts.ScriptElementKind.enumElement,
|
||||
@@ -454,7 +493,7 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
function createIterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
|
||||
var childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem);
|
||||
let childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem);
|
||||
return getNavigationBarItem(
|
||||
node.name.text,
|
||||
ts.ScriptElementKind.interfaceElement,
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
module ts {
|
||||
export module OutliningElementsCollector {
|
||||
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
|
||||
var elements: OutliningSpan[] = [];
|
||||
var collapseText = "...";
|
||||
let elements: OutliningSpan[] = [];
|
||||
let collapseText = "...";
|
||||
|
||||
function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean) {
|
||||
if (hintSpanNode && startElement && endElement) {
|
||||
var span: OutliningSpan = {
|
||||
let span: OutliningSpan = {
|
||||
textSpan: createTextSpanFromBounds(startElement.pos, endElement.end),
|
||||
hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end),
|
||||
bannerText: collapseText,
|
||||
@@ -35,8 +35,8 @@ module ts {
|
||||
return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction;
|
||||
}
|
||||
|
||||
var depth = 0;
|
||||
var maxDepth = 20;
|
||||
let depth = 0;
|
||||
let maxDepth = 20;
|
||||
function walk(n: Node): void {
|
||||
if (depth > maxDepth) {
|
||||
return;
|
||||
@@ -44,9 +44,9 @@ module ts {
|
||||
switch (n.kind) {
|
||||
case SyntaxKind.Block:
|
||||
if (!isFunctionBlock(n)) {
|
||||
var parent = n.parent;
|
||||
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
let parent = n.parent;
|
||||
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
|
||||
// Check if the block is standalone, or 'attached' to some parent statement.
|
||||
// If the latter, we want to collaps the block, but consider its hint span
|
||||
@@ -66,13 +66,13 @@ module ts {
|
||||
|
||||
if (parent.kind === SyntaxKind.TryStatement) {
|
||||
// Could be the try-block, or the finally-block.
|
||||
var tryStatement = <TryStatement>parent;
|
||||
let tryStatement = <TryStatement>parent;
|
||||
if (tryStatement.tryBlock === n) {
|
||||
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
else if (tryStatement.finallyBlock === n) {
|
||||
var finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
|
||||
let finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
|
||||
if (finallyKeyword) {
|
||||
addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
@@ -84,7 +84,7 @@ module ts {
|
||||
|
||||
// Block was a standalone block. In this case we want to only collapse
|
||||
// the span of the block, independent of any parent span.
|
||||
var span = createTextSpanFromBounds(n.getStart(), n.end);
|
||||
let span = createTextSpanFromBounds(n.getStart(), n.end);
|
||||
elements.push({
|
||||
textSpan: span,
|
||||
hintSpan: span,
|
||||
@@ -95,23 +95,25 @@ module ts {
|
||||
}
|
||||
// Fallthrough.
|
||||
|
||||
case SyntaxKind.ModuleBlock:
|
||||
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
case SyntaxKind.ModuleBlock: {
|
||||
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
var openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
var closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
case SyntaxKind.CaseBlock: {
|
||||
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
|
||||
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
var openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
|
||||
var closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
|
||||
let openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
|
||||
let closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
|
||||
addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -112,13 +112,13 @@ module ts {
|
||||
// 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[]> = {};
|
||||
let 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);
|
||||
let fullPatternSegment = createSegment(pattern);
|
||||
let dotSeparatedSegments = pattern.split(".").map(p => createSegment(p.trim()));
|
||||
let invalidPattern = dotSeparatedSegments.length === 0 || forEach(dotSeparatedSegments, segmentIsInvalid);
|
||||
|
||||
return {
|
||||
getMatches,
|
||||
@@ -147,7 +147,7 @@ module ts {
|
||||
// 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));
|
||||
let candidateMatch = matchSegment(candidate, lastOrUndefined(dotSeparatedSegments));
|
||||
if (!candidateMatch) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -164,16 +164,16 @@ module ts {
|
||||
|
||||
// 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;
|
||||
let totalMatch = candidateMatch;
|
||||
|
||||
for (var i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1;
|
||||
for (let i = dotSeparatedSegments.length - 2, j = candidateContainers.length - 1;
|
||||
i >= 0;
|
||||
i--, j--) {
|
||||
|
||||
var segment = dotSeparatedSegments[i];
|
||||
var containerName = candidateContainers[j];
|
||||
let segment = dotSeparatedSegments[i];
|
||||
let containerName = candidateContainers[j];
|
||||
|
||||
var containerMatch = matchSegment(containerName, segment);
|
||||
let containerMatch = matchSegment(containerName, segment);
|
||||
if (!containerMatch) {
|
||||
// This container didn't match the pattern piece. So there's no match at all.
|
||||
return undefined;
|
||||
@@ -196,7 +196,7 @@ module ts {
|
||||
}
|
||||
|
||||
function matchTextChunk(candidate: string, chunk: TextChunk, punctuationStripped: boolean): PatternMatch {
|
||||
var index = indexOfIgnoringCase(candidate, chunk.textLowerCase);
|
||||
let 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
|
||||
@@ -210,7 +210,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
var isLowercase = chunk.isLowerCase;
|
||||
let isLowercase = chunk.isLowerCase;
|
||||
if (isLowercase) {
|
||||
if (index > 0) {
|
||||
// c) If the part is entirely lowercase, then check if it is contained anywhere in the
|
||||
@@ -220,9 +220,8 @@ module ts {
|
||||
// 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]
|
||||
let wordSpans = getWordSpans(candidate);
|
||||
for (let span of wordSpans) {
|
||||
if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) {
|
||||
return createPatternMatch(PatternMatchKind.substring, punctuationStripped,
|
||||
/*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false));
|
||||
@@ -242,8 +241,8 @@ module ts {
|
||||
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);
|
||||
let candidateParts = getWordSpans(candidate);
|
||||
let camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false);
|
||||
if (camelCaseWeight !== undefined) {
|
||||
return createPatternMatch(PatternMatchKind.camelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight);
|
||||
}
|
||||
@@ -274,8 +273,8 @@ module ts {
|
||||
}
|
||||
|
||||
function containsSpaceOrAsterisk(text: string): boolean {
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
var ch = text.charCodeAt(i);
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
let ch = text.charCodeAt(i);
|
||||
if (ch === CharacterCodes.space || ch === CharacterCodes.asterisk) {
|
||||
return true;
|
||||
}
|
||||
@@ -293,7 +292,7 @@ module ts {
|
||||
// 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);
|
||||
let match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false);
|
||||
if (match) {
|
||||
return [match];
|
||||
}
|
||||
@@ -336,14 +335,12 @@ module ts {
|
||||
//
|
||||
// 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];
|
||||
let subWordTextChunks = segment.subWordTextChunks;
|
||||
let matches: PatternMatch[] = undefined;
|
||||
|
||||
for (let subWordTextChunk of subWordTextChunks) {
|
||||
// Try to match the candidate with this word
|
||||
var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true);
|
||||
let result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true);
|
||||
if (!result) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -356,8 +353,8 @@ module ts {
|
||||
}
|
||||
|
||||
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;
|
||||
let patternPartStart = patternSpan ? patternSpan.start : 0;
|
||||
let patternPartLength = patternSpan ? patternSpan.length : pattern.length;
|
||||
|
||||
if (patternPartLength > candidateSpan.length) {
|
||||
// Pattern part is longer than the candidate part. There can never be a match.
|
||||
@@ -365,18 +362,18 @@ module ts {
|
||||
}
|
||||
|
||||
if (ignoreCase) {
|
||||
for (var i = 0; i < patternPartLength; i++) {
|
||||
var ch1 = pattern.charCodeAt(patternPartStart + i);
|
||||
var ch2 = candidate.charCodeAt(candidateSpan.start + i);
|
||||
for (let i = 0; i < patternPartLength; i++) {
|
||||
let ch1 = pattern.charCodeAt(patternPartStart + i);
|
||||
let 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);
|
||||
for (let i = 0; i < patternPartLength; i++) {
|
||||
let ch1 = pattern.charCodeAt(patternPartStart + i);
|
||||
let ch2 = candidate.charCodeAt(candidateSpan.start + i);
|
||||
if (ch1 !== ch2) {
|
||||
return false;
|
||||
}
|
||||
@@ -387,23 +384,23 @@ module ts {
|
||||
}
|
||||
|
||||
function tryCamelCaseMatch(candidate: string, candidateParts: TextSpan[], chunk: TextChunk, ignoreCase: boolean): number {
|
||||
var chunkCharacterSpans = chunk.characterSpans;
|
||||
let 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;
|
||||
let currentCandidate = 0;
|
||||
let currentChunkSpan = 0;
|
||||
let firstMatch: number = undefined;
|
||||
let 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;
|
||||
let weight = 0;
|
||||
|
||||
// Was this contiguous?
|
||||
if (contiguous) {
|
||||
@@ -422,15 +419,15 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var candidatePart = candidateParts[currentCandidate];
|
||||
var gotOneMatchThisCandidate = false;
|
||||
let candidatePart = candidateParts[currentCandidate];
|
||||
let 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];
|
||||
let chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan];
|
||||
|
||||
if (gotOneMatchThisCandidate) {
|
||||
// We've already gotten one pattern part match in this candidate. We will
|
||||
@@ -474,7 +471,7 @@ module ts {
|
||||
|
||||
// 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
|
||||
// match is a camel case match, the relative weights of the 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 {
|
||||
@@ -540,7 +537,7 @@ module ts {
|
||||
|
||||
// TODO: find a way to determine this for any unicode characters in a
|
||||
// non-allocating manner.
|
||||
var str = String.fromCharCode(ch);
|
||||
let str = String.fromCharCode(ch);
|
||||
return str === str.toUpperCase();
|
||||
}
|
||||
|
||||
@@ -557,12 +554,12 @@ module ts {
|
||||
|
||||
// TODO: find a way to determine this for any unicode characters in a
|
||||
// non-allocating manner.
|
||||
var str = String.fromCharCode(ch);
|
||||
let str = String.fromCharCode(ch);
|
||||
return str === str.toLowerCase();
|
||||
}
|
||||
|
||||
function containsUpperCaseLetter(string: string): boolean {
|
||||
for (var i = 0, n = string.length; i < n; i++) {
|
||||
for (let i = 0, n = string.length; i < n; i++) {
|
||||
if (isUpperCaseLetter(string.charCodeAt(i))) {
|
||||
return true;
|
||||
}
|
||||
@@ -572,7 +569,7 @@ module ts {
|
||||
}
|
||||
|
||||
function startsWith(string: string, search: string) {
|
||||
for (var i = 0, n = search.length; i < n; i++) {
|
||||
for (let i = 0, n = search.length; i < n; i++) {
|
||||
if (string.charCodeAt(i) !== search.charCodeAt(i)) {
|
||||
return false;
|
||||
}
|
||||
@@ -583,7 +580,7 @@ module ts {
|
||||
|
||||
// Assumes 'value' is already lowercase.
|
||||
function indexOfIgnoringCase(string: string, value: string): number {
|
||||
for (var i = 0, n = string.length - value.length; i <= n; i++) {
|
||||
for (let i = 0, n = string.length - value.length; i <= n; i++) {
|
||||
if (startsWithIgnoringCase(string, value, i)) {
|
||||
return i;
|
||||
}
|
||||
@@ -594,9 +591,9 @@ module ts {
|
||||
|
||||
// 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);
|
||||
for (let i = 0, n = value.length; i < n; i++) {
|
||||
let ch1 = toLowerCase(string.charCodeAt(i + start));
|
||||
let ch2 = value.charCodeAt(i);
|
||||
|
||||
if (ch1 !== ch2) {
|
||||
return false;
|
||||
@@ -631,12 +628,12 @@ module ts {
|
||||
}
|
||||
|
||||
function breakPatternIntoTextChunks(pattern: string): TextChunk[] {
|
||||
var result: TextChunk[] = [];
|
||||
var wordStart = 0;
|
||||
var wordLength = 0;
|
||||
let result: TextChunk[] = [];
|
||||
let wordStart = 0;
|
||||
let wordLength = 0;
|
||||
|
||||
for (var i = 0; i < pattern.length; i++) {
|
||||
var ch = pattern.charCodeAt(i);
|
||||
for (let i = 0; i < pattern.length; i++) {
|
||||
let ch = pattern.charCodeAt(i);
|
||||
if (isWordChar(ch)) {
|
||||
if (wordLength++ === 0) {
|
||||
wordStart = i;
|
||||
@@ -658,7 +655,7 @@ module ts {
|
||||
}
|
||||
|
||||
function createTextChunk(text: string): TextChunk {
|
||||
var textLowerCase = text.toLowerCase();
|
||||
let textLowerCase = text.toLowerCase();
|
||||
return {
|
||||
text,
|
||||
textLowerCase,
|
||||
@@ -676,15 +673,15 @@ module ts {
|
||||
}
|
||||
|
||||
function breakIntoSpans(identifier: string, word: boolean): TextSpan[] {
|
||||
var result: TextSpan[] = [];
|
||||
let 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));
|
||||
let wordStart = 0;
|
||||
for (let i = 1, n = identifier.length; i < n; i++) {
|
||||
let lastIsDigit = isDigit(identifier.charCodeAt(i - 1));
|
||||
let currentIsDigit = isDigit(identifier.charCodeAt(i));
|
||||
|
||||
var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i);
|
||||
var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart);
|
||||
let hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i);
|
||||
let hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart);
|
||||
|
||||
if (charIsPunctuation(identifier.charCodeAt(i - 1)) ||
|
||||
charIsPunctuation(identifier.charCodeAt(i)) ||
|
||||
@@ -739,8 +736,8 @@ module ts {
|
||||
}
|
||||
|
||||
function isAllPunctuation(identifier: string, start: number, end: number): boolean {
|
||||
for (var i = start; i < end; i++) {
|
||||
var ch = identifier.charCodeAt(i);
|
||||
for (let i = start; i < end; i++) {
|
||||
let 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.$) {
|
||||
@@ -761,8 +758,8 @@ module ts {
|
||||
// etc.
|
||||
if (index != wordStart &&
|
||||
index + 1 < identifier.length) {
|
||||
var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
|
||||
var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1));
|
||||
let currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
|
||||
let nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1));
|
||||
|
||||
if (currentIsUpper && nextIsLower) {
|
||||
// We have a transition from an upper to a lower letter here. But we only
|
||||
@@ -773,7 +770,7 @@ module ts {
|
||||
// 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++) {
|
||||
for (let i = wordStart; i < index; i++) {
|
||||
if (!isUpperCaseLetter(identifier.charCodeAt(i))) {
|
||||
return false;
|
||||
}
|
||||
@@ -788,8 +785,8 @@ module ts {
|
||||
}
|
||||
|
||||
function transitionFromLowerToUpper(identifier: string, word: boolean, index: number): boolean {
|
||||
var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1));
|
||||
var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
|
||||
let lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1));
|
||||
let 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
|
||||
@@ -804,7 +801,7 @@ module ts {
|
||||
// on characters would be: A M
|
||||
//
|
||||
// We break the search string on characters. But we break the symbol name on words.
|
||||
var transition = word
|
||||
let 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
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user