Merge branch 'master' into es6Import

Conflicts:
	src/compiler/diagnosticInformationMap.generated.ts
	src/compiler/diagnosticMessages.json
	src/compiler/emitter.ts
	tests/baselines/reference/APISample_compile.js
	tests/baselines/reference/APISample_compile.types
	tests/baselines/reference/APISample_linter.js
	tests/baselines/reference/APISample_linter.types
	tests/baselines/reference/APISample_transform.js
	tests/baselines/reference/APISample_transform.types
	tests/baselines/reference/APISample_watcher.js
	tests/baselines/reference/APISample_watcher.types
	tests/baselines/reference/recursiveClassReferenceTest.js.map
	tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt
This commit is contained in:
Anders Hejlsberg
2015-02-23 11:15:56 -08:00
1703 changed files with 67723 additions and 19564 deletions
+1
View File
@@ -44,3 +44,4 @@ scripts/ior.js
scripts/*.js.map
coverage/
internal/
**/.DS_Store
+33 -5
View File
@@ -8,6 +8,7 @@ var child_process = require("child_process");
// Variables
var compilerDirectory = "src/compiler/";
var servicesDirectory = "src/services/";
var serverDirectory = "src/server/";
var harnessDirectory = "src/harness/";
var libraryDirectory = "src/lib/";
var scriptsDirectory = "scripts/";
@@ -64,8 +65,10 @@ var servicesSources = [
return path.join(compilerDirectory, f);
}).concat([
"breakpoints.ts",
"navigateTo.ts",
"navigationBar.ts",
"outliningElementsCollector.ts",
"patternMatcher.ts",
"services.ts",
"shims.ts",
"signatureHelp.ts",
@@ -90,6 +93,16 @@ var servicesSources = [
return path.join(servicesDirectory, f);
}));
var serverSources = [
"node.d.ts",
"editorServices.ts",
"protocol.d.ts",
"session.ts",
"server.ts"
].map(function (f) {
return path.join(serverDirectory, f);
});
var definitionsRoots = [
"compiler/types.d.ts",
"compiler/scanner.d.ts",
@@ -127,9 +140,17 @@ var harnessSources = [
"incrementalParser.ts",
"services/colorization.ts",
"services/documentRegistry.ts",
"services/preProcessFile.ts"
"services/preProcessFile.ts",
"services/patternMatcher.ts"
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
"protocol.d.ts",
"session.ts",
"client.ts",
"editorServices.ts",
].map(function (f) {
return path.join(serverDirectory, f);
}));
var librarySourceMap = [
@@ -327,6 +348,7 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
/*prefixes*/ [copyright],
/*useBuiltCompiler*/ true,
@@ -336,7 +358,10 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
/*preserveConstEnums*/ true,
/*keepComments*/ false,
/*noResolve*/ false,
/*stripInternal*/ false);
/*stripInternal*/ false,
/*callback*/ function () {
jake.cpR(servicesFile, nodePackageFile, {silent: true});
});
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
@@ -378,9 +403,12 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright
jake.rmRf(tempDirPath, {silent: true});
});
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
// Local target to build the compiler and services
desc("Builds the full compiler and services");
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile]);
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile]);
// Local target to build only tsc.js
desc("Builds only the compiler");
@@ -435,7 +463,7 @@ task("generate-spec", [specMd])
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
desc("Makes a new LKG out of the built js files");
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
var expectedFiles = [tscFile, servicesFile, nodeDefinitionsFile, standaloneDefinitionsFile, internalNodeDefinitionsFile, internalStandaloneDefinitionsFile].concat(libraryTargets);
var expectedFiles = [tscFile, servicesFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, internalNodeDefinitionsFile, internalStandaloneDefinitionsFile].concat(libraryTargets);
var missingFiles = expectedFiles.filter(function (f) {
return !fs.existsSync(f);
});
@@ -542,7 +570,7 @@ task("runtests", ["tests", builtLocalDirectory], function() {
}
if (tests && tests.toLocaleLowerCase() === "rwc") {
testTimeout = 50000;
testTimeout = 100000;
}
colors = process.env.colors || process.env.color
+39 -39
View File
@@ -1164,7 +1164,7 @@ interface ArrayConstructor {
}
declare var Array: ArrayConstructor;
declare type PropertyKey = string | number | Symbol;
declare type PropertyKey = string | number | symbol;
interface Symbol {
/** Returns a string representation of an object. */
@@ -1173,7 +1173,7 @@ interface Symbol {
/** Returns the primitive value of the specified object. */
valueOf(): Object;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface SymbolConstructor {
@@ -1186,21 +1186,21 @@ interface SymbolConstructor {
* Returns a new unique Symbol value.
* @param description Description of the new Symbol object.
*/
(description?: string|number): Symbol;
(description?: string|number): symbol;
/**
* Returns a Symbol object from the global symbol registry matching the given key if found.
* Otherwise, returns a new symbol with this key.
* @param key key to search for.
*/
for(key: string): Symbol;
for(key: string): symbol;
/**
* Returns a key from the global symbol registry matching the given Symbol if found.
* Otherwise, returns a undefined.
* @param sym Symbol to find the key for.
*/
keyFor(sym: Symbol): string;
keyFor(sym: symbol): string;
// Well-known Symbols
@@ -1208,42 +1208,42 @@ interface SymbolConstructor {
* A method that determines if a constructor object recognizes an object as one of the
* constructors instances. Called by the semantics of the instanceof operator.
*/
hasInstance: Symbol;
hasInstance: symbol;
/**
* A Boolean value that if true indicates that an object should flatten to its array elements
* by Array.prototype.concat.
*/
isConcatSpreadable: Symbol;
isConcatSpreadable: symbol;
/**
* A Boolean value that if true indicates that an object may be used as a regular expression.
*/
isRegExp: Symbol;
isRegExp: symbol;
/**
* A method that returns the default iterator for an object.Called by the semantics of the
* for-of statement.
*/
iterator: Symbol;
iterator: symbol;
/**
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
* abstract operation.
*/
toPrimitive: Symbol;
toPrimitive: symbol;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built- in method Object.prototype.toString.
*/
toStringTag: Symbol;
toStringTag: symbol;
/**
* An Object whose own property names are property names that are excluded from the with
* environment bindings of the associated objects.
*/
unscopables: Symbol;
unscopables: symbol;
}
declare var Symbol: SymbolConstructor;
@@ -1274,7 +1274,7 @@ interface ObjectConstructor {
* Returns an array of all symbol properties found directly on object o.
* @param o Object to retrieve the symbols from.
*/
getOwnPropertySymbols(o: any): Symbol[];
getOwnPropertySymbols(o: any): symbol[];
/**
* Returns true if the values are the same value, false otherwise.
@@ -1396,7 +1396,7 @@ interface ArrayLike<T> {
interface Array<T> {
/** Iterator */
// [Symbol.iterator] (): Iterator<T>;
[Symbol.iterator] (): Iterator<T>;
/**
* Returns an array of key, value pairs for every entry in the array
@@ -1495,7 +1495,7 @@ interface ArrayConstructor {
interface String {
/** Iterator */
// [Symbol.iterator] (): Iterator<string>;
[Symbol.iterator] (): Iterator<string>;
/**
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
@@ -1613,12 +1613,12 @@ interface IteratorResult<T> {
}
interface Iterator<T> {
//[Symbol.iterator](): Iterator<T>;
[Symbol.iterator](): Iterator<T>;
next(): IteratorResult<T>;
}
interface Iterable<T> {
//[Symbol.iterator](): Iterator<T>;
[Symbol.iterator](): Iterator<T>;
}
interface GeneratorFunction extends Function {
@@ -1640,7 +1640,7 @@ interface Generator<T> extends Iterator<T> {
next(value?: any): IteratorResult<T>;
throw (exception: any): IteratorResult<T>;
return (value: T): IteratorResult<T>;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface Math {
@@ -1754,11 +1754,11 @@ interface Math {
*/
cbrt(x: number): number;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface RegExp {
// [Symbol.isRegExp]: boolean;
[Symbol.isRegExp]: boolean;
/**
* Matches a string with a regular expression, and returns an array containing the results of
@@ -1815,8 +1815,8 @@ interface Map<K, V> {
set(key: K, value?: V): Map<K, V>;
size: number;
values(): Iterator<V>;
// [Symbol.iterator]():Iterator<[K,V]>;
// [Symbol.toStringTag]: string;
[Symbol.iterator]():Iterator<[K,V]>;
[Symbol.toStringTag]: string;
}
interface MapConstructor {
@@ -1832,7 +1832,7 @@ interface WeakMap<K, V> {
get(key: K): V;
has(key: K): boolean;
set(key: K, value?: V): WeakMap<K, V>;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface WeakMapConstructor {
@@ -1852,8 +1852,8 @@ interface Set<T> {
keys(): Iterator<T>;
size: number;
values(): Iterator<T>;
// [Symbol.iterator]():Iterator<T>;
// [Symbol.toStringTag]: string;
[Symbol.iterator]():Iterator<T>;
[Symbol.toStringTag]: string;
}
interface SetConstructor {
@@ -1868,7 +1868,7 @@ interface WeakSet<T> {
clear(): void;
delete(value: T): boolean;
has(value: T): boolean;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface WeakSetConstructor {
@@ -1879,7 +1879,7 @@ interface WeakSetConstructor {
declare var WeakSet: WeakSetConstructor;
interface JSON {
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
/**
@@ -1899,7 +1899,7 @@ interface ArrayBuffer {
*/
slice(begin: number, end?: number): ArrayBuffer;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface ArrayBufferConstructor {
@@ -2036,7 +2036,7 @@ interface DataView {
*/
setUint32(byteOffset: number, value: number, littleEndian: boolean): void;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface DataViewConstructor {
@@ -2303,7 +2303,7 @@ interface Int8Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Int8ArrayConstructor {
@@ -2593,7 +2593,7 @@ interface Uint8Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint8ArrayConstructor {
@@ -2883,7 +2883,7 @@ interface Uint8ClampedArray {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint8ClampedArrayConstructor {
@@ -3173,7 +3173,7 @@ interface Int16Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Int16ArrayConstructor {
@@ -3463,7 +3463,7 @@ interface Uint16Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint16ArrayConstructor {
@@ -3753,7 +3753,7 @@ interface Int32Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Int32ArrayConstructor {
@@ -4043,7 +4043,7 @@ interface Uint32Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint32ArrayConstructor {
@@ -4333,7 +4333,7 @@ interface Float32Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Float32ArrayConstructor {
@@ -4623,7 +4623,7 @@ interface Float64Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Float64ArrayConstructor {
@@ -4687,7 +4687,7 @@ declare var Reflect: {
getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
getPrototypeOf(target: any): any;
has(target: any, propertyKey: string): boolean;
has(target: any, propertyKey: Symbol): boolean;
has(target: any, propertyKey: symbol): boolean;
isExtensible(target: any): boolean;
ownKeys(target: any): Array<PropertyKey>;
preventExtensions(target: any): boolean;
+39 -39
View File
@@ -1164,7 +1164,7 @@ interface ArrayConstructor {
}
declare var Array: ArrayConstructor;
declare type PropertyKey = string | number | Symbol;
declare type PropertyKey = string | number | symbol;
interface Symbol {
/** Returns a string representation of an object. */
@@ -1173,7 +1173,7 @@ interface Symbol {
/** Returns the primitive value of the specified object. */
valueOf(): Object;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface SymbolConstructor {
@@ -1186,21 +1186,21 @@ interface SymbolConstructor {
* Returns a new unique Symbol value.
* @param description Description of the new Symbol object.
*/
(description?: string|number): Symbol;
(description?: string|number): symbol;
/**
* Returns a Symbol object from the global symbol registry matching the given key if found.
* Otherwise, returns a new symbol with this key.
* @param key key to search for.
*/
for(key: string): Symbol;
for(key: string): symbol;
/**
* Returns a key from the global symbol registry matching the given Symbol if found.
* Otherwise, returns a undefined.
* @param sym Symbol to find the key for.
*/
keyFor(sym: Symbol): string;
keyFor(sym: symbol): string;
// Well-known Symbols
@@ -1208,42 +1208,42 @@ interface SymbolConstructor {
* A method that determines if a constructor object recognizes an object as one of the
* constructors instances. Called by the semantics of the instanceof operator.
*/
hasInstance: Symbol;
hasInstance: symbol;
/**
* A Boolean value that if true indicates that an object should flatten to its array elements
* by Array.prototype.concat.
*/
isConcatSpreadable: Symbol;
isConcatSpreadable: symbol;
/**
* A Boolean value that if true indicates that an object may be used as a regular expression.
*/
isRegExp: Symbol;
isRegExp: symbol;
/**
* A method that returns the default iterator for an object.Called by the semantics of the
* for-of statement.
*/
iterator: Symbol;
iterator: symbol;
/**
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
* abstract operation.
*/
toPrimitive: Symbol;
toPrimitive: symbol;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built- in method Object.prototype.toString.
*/
toStringTag: Symbol;
toStringTag: symbol;
/**
* An Object whose own property names are property names that are excluded from the with
* environment bindings of the associated objects.
*/
unscopables: Symbol;
unscopables: symbol;
}
declare var Symbol: SymbolConstructor;
@@ -1274,7 +1274,7 @@ interface ObjectConstructor {
* Returns an array of all symbol properties found directly on object o.
* @param o Object to retrieve the symbols from.
*/
getOwnPropertySymbols(o: any): Symbol[];
getOwnPropertySymbols(o: any): symbol[];
/**
* Returns true if the values are the same value, false otherwise.
@@ -1396,7 +1396,7 @@ interface ArrayLike<T> {
interface Array<T> {
/** Iterator */
// [Symbol.iterator] (): Iterator<T>;
[Symbol.iterator] (): Iterator<T>;
/**
* Returns an array of key, value pairs for every entry in the array
@@ -1495,7 +1495,7 @@ interface ArrayConstructor {
interface String {
/** Iterator */
// [Symbol.iterator] (): Iterator<string>;
[Symbol.iterator] (): Iterator<string>;
/**
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
@@ -1613,12 +1613,12 @@ interface IteratorResult<T> {
}
interface Iterator<T> {
//[Symbol.iterator](): Iterator<T>;
[Symbol.iterator](): Iterator<T>;
next(): IteratorResult<T>;
}
interface Iterable<T> {
//[Symbol.iterator](): Iterator<T>;
[Symbol.iterator](): Iterator<T>;
}
interface GeneratorFunction extends Function {
@@ -1640,7 +1640,7 @@ interface Generator<T> extends Iterator<T> {
next(value?: any): IteratorResult<T>;
throw (exception: any): IteratorResult<T>;
return (value: T): IteratorResult<T>;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface Math {
@@ -1754,11 +1754,11 @@ interface Math {
*/
cbrt(x: number): number;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface RegExp {
// [Symbol.isRegExp]: boolean;
[Symbol.isRegExp]: boolean;
/**
* Matches a string with a regular expression, and returns an array containing the results of
@@ -1815,8 +1815,8 @@ interface Map<K, V> {
set(key: K, value?: V): Map<K, V>;
size: number;
values(): Iterator<V>;
// [Symbol.iterator]():Iterator<[K,V]>;
// [Symbol.toStringTag]: string;
[Symbol.iterator]():Iterator<[K,V]>;
[Symbol.toStringTag]: string;
}
interface MapConstructor {
@@ -1832,7 +1832,7 @@ interface WeakMap<K, V> {
get(key: K): V;
has(key: K): boolean;
set(key: K, value?: V): WeakMap<K, V>;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface WeakMapConstructor {
@@ -1852,8 +1852,8 @@ interface Set<T> {
keys(): Iterator<T>;
size: number;
values(): Iterator<T>;
// [Symbol.iterator]():Iterator<T>;
// [Symbol.toStringTag]: string;
[Symbol.iterator]():Iterator<T>;
[Symbol.toStringTag]: string;
}
interface SetConstructor {
@@ -1868,7 +1868,7 @@ interface WeakSet<T> {
clear(): void;
delete(value: T): boolean;
has(value: T): boolean;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface WeakSetConstructor {
@@ -1879,7 +1879,7 @@ interface WeakSetConstructor {
declare var WeakSet: WeakSetConstructor;
interface JSON {
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
/**
@@ -1899,7 +1899,7 @@ interface ArrayBuffer {
*/
slice(begin: number, end?: number): ArrayBuffer;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface ArrayBufferConstructor {
@@ -2036,7 +2036,7 @@ interface DataView {
*/
setUint32(byteOffset: number, value: number, littleEndian: boolean): void;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface DataViewConstructor {
@@ -2303,7 +2303,7 @@ interface Int8Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Int8ArrayConstructor {
@@ -2593,7 +2593,7 @@ interface Uint8Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint8ArrayConstructor {
@@ -2883,7 +2883,7 @@ interface Uint8ClampedArray {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint8ClampedArrayConstructor {
@@ -3173,7 +3173,7 @@ interface Int16Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Int16ArrayConstructor {
@@ -3463,7 +3463,7 @@ interface Uint16Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint16ArrayConstructor {
@@ -3753,7 +3753,7 @@ interface Int32Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Int32ArrayConstructor {
@@ -4043,7 +4043,7 @@ interface Uint32Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint32ArrayConstructor {
@@ -4333,7 +4333,7 @@ interface Float32Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Float32ArrayConstructor {
@@ -4623,7 +4623,7 @@ interface Float64Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Float64ArrayConstructor {
@@ -4687,7 +4687,7 @@ declare var Reflect: {
getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
getPrototypeOf(target: any): any;
has(target: any, propertyKey: string): boolean;
has(target: any, propertyKey: Symbol): boolean;
has(target: any, propertyKey: symbol): boolean;
isExtensible(target: any): boolean;
ownKeys(target: any): Array<PropertyKey>;
preventExtensions(target: any): boolean;
+5312 -4414
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./tsserver.js')
+142 -107
View File
@@ -142,110 +142,113 @@ declare module "typescript" {
NumberKeyword = 117,
SetKeyword = 118,
StringKeyword = 119,
TypeKeyword = 120,
QualifiedName = 121,
ComputedPropertyName = 122,
TypeParameter = 123,
Parameter = 124,
PropertySignature = 125,
PropertyDeclaration = 126,
MethodSignature = 127,
MethodDeclaration = 128,
Constructor = 129,
GetAccessor = 130,
SetAccessor = 131,
CallSignature = 132,
ConstructSignature = 133,
IndexSignature = 134,
TypeReference = 135,
FunctionType = 136,
ConstructorType = 137,
TypeQuery = 138,
TypeLiteral = 139,
ArrayType = 140,
TupleType = 141,
UnionType = 142,
ParenthesizedType = 143,
ObjectBindingPattern = 144,
ArrayBindingPattern = 145,
BindingElement = 146,
ArrayLiteralExpression = 147,
ObjectLiteralExpression = 148,
PropertyAccessExpression = 149,
ElementAccessExpression = 150,
CallExpression = 151,
NewExpression = 152,
TaggedTemplateExpression = 153,
TypeAssertionExpression = 154,
ParenthesizedExpression = 155,
FunctionExpression = 156,
ArrowFunction = 157,
DeleteExpression = 158,
TypeOfExpression = 159,
VoidExpression = 160,
PrefixUnaryExpression = 161,
PostfixUnaryExpression = 162,
BinaryExpression = 163,
ConditionalExpression = 164,
TemplateExpression = 165,
YieldExpression = 166,
SpreadElementExpression = 167,
OmittedExpression = 168,
TemplateSpan = 169,
Block = 170,
VariableStatement = 171,
EmptyStatement = 172,
ExpressionStatement = 173,
IfStatement = 174,
DoStatement = 175,
WhileStatement = 176,
ForStatement = 177,
ForInStatement = 178,
ContinueStatement = 179,
BreakStatement = 180,
ReturnStatement = 181,
WithStatement = 182,
SwitchStatement = 183,
LabeledStatement = 184,
ThrowStatement = 185,
TryStatement = 186,
DebuggerStatement = 187,
VariableDeclaration = 188,
VariableDeclarationList = 189,
FunctionDeclaration = 190,
ClassDeclaration = 191,
InterfaceDeclaration = 192,
TypeAliasDeclaration = 193,
EnumDeclaration = 194,
ModuleDeclaration = 195,
ModuleBlock = 196,
ImportDeclaration = 197,
ExportAssignment = 198,
ExternalModuleReference = 199,
CaseClause = 200,
DefaultClause = 201,
HeritageClause = 202,
CatchClause = 203,
PropertyAssignment = 204,
ShorthandPropertyAssignment = 205,
EnumMember = 206,
SourceFile = 207,
SyntaxList = 208,
Count = 209,
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 = 120,
LastKeyword = 122,
FirstFutureReservedWord = 101,
LastFutureReservedWord = 109,
FirstTypeNode = 135,
LastTypeNode = 143,
FirstTypeNode = 137,
LastTypeNode = 145,
FirstPunctuation = 14,
LastPunctuation = 63,
FirstToken = 0,
LastToken = 120,
LastToken = 122,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@@ -254,7 +257,7 @@ declare module "typescript" {
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 121,
FirstNode = 123,
}
const enum NodeFlags {
Export = 1,
@@ -487,7 +490,7 @@ declare module "typescript" {
}
interface BinaryExpression extends Expression {
left: Expression;
operator: SyntaxKind;
operatorToken: Node;
right: Expression;
}
interface ConditionalExpression extends Expression {
@@ -585,6 +588,10 @@ declare module "typescript" {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface ForOfStatement extends IterationStatement {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface BreakOrContinueStatement extends Statement {
label?: Identifier;
}
@@ -686,7 +693,10 @@ declare module "typescript" {
endOfFileToken: Node;
fileName: string;
text: string;
amdDependencies: string[];
amdDependencies: {
path: string;
name: string;
}[];
amdModuleName: string;
referencedFiles: FileReference[];
hasNoDefaultLib: boolean;
@@ -991,8 +1001,9 @@ declare module "typescript" {
ObjectLiteral = 131072,
ContainsUndefinedOrNull = 262144,
ContainsObjectLiteral = 524288,
Intrinsic = 127,
Primitive = 510,
ESSymbol = 1048576,
Intrinsic = 1048703,
Primitive = 1049086,
StringLike = 258,
NumberLike = 132,
ObjectType = 48128,
@@ -1278,6 +1289,7 @@ declare module "typescript" {
equals = 61,
exclamation = 33,
greaterThan = 62,
hash = 35,
lessThan = 60,
minus = 45,
openBrace = 123,
@@ -1344,8 +1356,8 @@ declare module "typescript" {
}
function tokenToString(t: SyntaxKind): string;
function computeLineStarts(text: string): number[];
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getLineStarts(sourceFile: SourceFile): number[];
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
line: number;
@@ -1367,7 +1379,7 @@ declare module "typescript" {
function createNode(kind: SyntaxKind): Node;
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
function modifierToFlag(token: SyntaxKind): NodeFlags;
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
function isEvalOrArgumentsIdentifier(node: Node): boolean;
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
function isLeftHandSideExpression(expr: Expression): boolean;
@@ -1429,9 +1441,9 @@ declare module "typescript" {
scriptSnapshot: IScriptSnapshot;
nameTable: Map<string>;
getNamedDeclarations(): Declaration[];
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionFromLineAndCharacter(line: number, character: number): number;
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
/**
@@ -1493,7 +1505,7 @@ declare module "typescript" {
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string): NavigateToItem[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
@@ -1568,6 +1580,7 @@ declare module "typescript" {
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number | string;
}
interface DefinitionInfo {
fileName: string;
@@ -1701,6 +1714,9 @@ declare module "typescript" {
InMultiLineCommentTrivia = 1,
InSingleQuoteStringLiteral = 2,
InDoubleQuoteStringLiteral = 3,
InTemplateHeadOrNoSubstitutionTemplate = 4,
InTemplateMiddleOrTail = 5,
InTemplateSubstitutionPosition = 6,
}
enum TokenClass {
Punctuation = 0,
@@ -1722,7 +1738,26 @@ declare module "typescript" {
classification: TokenClass;
}
interface Classifier {
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
}
/**
* The document registry represents a store of SourceFile objects that can be shared between
@@ -1858,7 +1893,7 @@ declare module "typescript" {
}
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
var disableIncrementalParsing: boolean;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
function createDocumentRegistry(): DocumentRegistry;
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
+30159
View File
File diff suppressed because one or more lines are too long
+142 -107
View File
@@ -142,110 +142,113 @@ declare module ts {
NumberKeyword = 117,
SetKeyword = 118,
StringKeyword = 119,
TypeKeyword = 120,
QualifiedName = 121,
ComputedPropertyName = 122,
TypeParameter = 123,
Parameter = 124,
PropertySignature = 125,
PropertyDeclaration = 126,
MethodSignature = 127,
MethodDeclaration = 128,
Constructor = 129,
GetAccessor = 130,
SetAccessor = 131,
CallSignature = 132,
ConstructSignature = 133,
IndexSignature = 134,
TypeReference = 135,
FunctionType = 136,
ConstructorType = 137,
TypeQuery = 138,
TypeLiteral = 139,
ArrayType = 140,
TupleType = 141,
UnionType = 142,
ParenthesizedType = 143,
ObjectBindingPattern = 144,
ArrayBindingPattern = 145,
BindingElement = 146,
ArrayLiteralExpression = 147,
ObjectLiteralExpression = 148,
PropertyAccessExpression = 149,
ElementAccessExpression = 150,
CallExpression = 151,
NewExpression = 152,
TaggedTemplateExpression = 153,
TypeAssertionExpression = 154,
ParenthesizedExpression = 155,
FunctionExpression = 156,
ArrowFunction = 157,
DeleteExpression = 158,
TypeOfExpression = 159,
VoidExpression = 160,
PrefixUnaryExpression = 161,
PostfixUnaryExpression = 162,
BinaryExpression = 163,
ConditionalExpression = 164,
TemplateExpression = 165,
YieldExpression = 166,
SpreadElementExpression = 167,
OmittedExpression = 168,
TemplateSpan = 169,
Block = 170,
VariableStatement = 171,
EmptyStatement = 172,
ExpressionStatement = 173,
IfStatement = 174,
DoStatement = 175,
WhileStatement = 176,
ForStatement = 177,
ForInStatement = 178,
ContinueStatement = 179,
BreakStatement = 180,
ReturnStatement = 181,
WithStatement = 182,
SwitchStatement = 183,
LabeledStatement = 184,
ThrowStatement = 185,
TryStatement = 186,
DebuggerStatement = 187,
VariableDeclaration = 188,
VariableDeclarationList = 189,
FunctionDeclaration = 190,
ClassDeclaration = 191,
InterfaceDeclaration = 192,
TypeAliasDeclaration = 193,
EnumDeclaration = 194,
ModuleDeclaration = 195,
ModuleBlock = 196,
ImportDeclaration = 197,
ExportAssignment = 198,
ExternalModuleReference = 199,
CaseClause = 200,
DefaultClause = 201,
HeritageClause = 202,
CatchClause = 203,
PropertyAssignment = 204,
ShorthandPropertyAssignment = 205,
EnumMember = 206,
SourceFile = 207,
SyntaxList = 208,
Count = 209,
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 = 120,
LastKeyword = 122,
FirstFutureReservedWord = 101,
LastFutureReservedWord = 109,
FirstTypeNode = 135,
LastTypeNode = 143,
FirstTypeNode = 137,
LastTypeNode = 145,
FirstPunctuation = 14,
LastPunctuation = 63,
FirstToken = 0,
LastToken = 120,
LastToken = 122,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@@ -254,7 +257,7 @@ declare module ts {
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 121,
FirstNode = 123,
}
const enum NodeFlags {
Export = 1,
@@ -487,7 +490,7 @@ declare module ts {
}
interface BinaryExpression extends Expression {
left: Expression;
operator: SyntaxKind;
operatorToken: Node;
right: Expression;
}
interface ConditionalExpression extends Expression {
@@ -585,6 +588,10 @@ declare module ts {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface ForOfStatement extends IterationStatement {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface BreakOrContinueStatement extends Statement {
label?: Identifier;
}
@@ -686,7 +693,10 @@ declare module ts {
endOfFileToken: Node;
fileName: string;
text: string;
amdDependencies: string[];
amdDependencies: {
path: string;
name: string;
}[];
amdModuleName: string;
referencedFiles: FileReference[];
hasNoDefaultLib: boolean;
@@ -991,8 +1001,9 @@ declare module ts {
ObjectLiteral = 131072,
ContainsUndefinedOrNull = 262144,
ContainsObjectLiteral = 524288,
Intrinsic = 127,
Primitive = 510,
ESSymbol = 1048576,
Intrinsic = 1048703,
Primitive = 1049086,
StringLike = 258,
NumberLike = 132,
ObjectType = 48128,
@@ -1278,6 +1289,7 @@ declare module ts {
equals = 61,
exclamation = 33,
greaterThan = 62,
hash = 35,
lessThan = 60,
minus = 45,
openBrace = 123,
@@ -1344,8 +1356,8 @@ declare module ts {
}
function tokenToString(t: SyntaxKind): string;
function computeLineStarts(text: string): number[];
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getLineStarts(sourceFile: SourceFile): number[];
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
line: number;
@@ -1367,7 +1379,7 @@ declare module ts {
function createNode(kind: SyntaxKind): Node;
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
function modifierToFlag(token: SyntaxKind): NodeFlags;
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
function isEvalOrArgumentsIdentifier(node: Node): boolean;
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
function isLeftHandSideExpression(expr: Expression): boolean;
@@ -1429,9 +1441,9 @@ declare module ts {
scriptSnapshot: IScriptSnapshot;
nameTable: Map<string>;
getNamedDeclarations(): Declaration[];
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionFromLineAndCharacter(line: number, character: number): number;
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
/**
@@ -1493,7 +1505,7 @@ declare module ts {
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string): NavigateToItem[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
@@ -1568,6 +1580,7 @@ declare module ts {
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number | string;
}
interface DefinitionInfo {
fileName: string;
@@ -1701,6 +1714,9 @@ declare module ts {
InMultiLineCommentTrivia = 1,
InSingleQuoteStringLiteral = 2,
InDoubleQuoteStringLiteral = 3,
InTemplateHeadOrNoSubstitutionTemplate = 4,
InTemplateMiddleOrTail = 5,
InTemplateSubstitutionPosition = 6,
}
enum TokenClass {
Punctuation = 0,
@@ -1722,7 +1738,26 @@ declare module ts {
classification: TokenClass;
}
interface Classifier {
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
}
/**
* The document registry represents a store of SourceFile objects that can be shared between
@@ -1858,7 +1893,7 @@ declare module ts {
}
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
var disableIncrementalParsing: boolean;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
function createDocumentRegistry(): DocumentRegistry;
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
+4385 -2854
View File
File diff suppressed because it is too large Load Diff
+22 -2
View File
@@ -159,6 +159,7 @@ declare module ts {
function getFullWidth(node: Node): number;
function containsParseError(node: Node): boolean;
function getSourceFileOfNode(node: Node): SourceFile;
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
function nodePosToString(node: Node): string;
function getStartPosOfNode(node: Node): number;
function nodeIsMissing(node: Node): boolean;
@@ -216,6 +217,26 @@ declare module ts {
function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult;
function isKeyword(token: SyntaxKind): boolean;
function isTrivia(token: SyntaxKind): boolean;
/**
* A declaration has a dynamic name if both of the following are true:
* 1. The declaration has a computed property name
* 2. The computed name is *not* expressed as Symbol.<name>, where name
* is a property of the Symbol constructor that denotes a built in
* Symbol.
*/
function hasDynamicName(declaration: Declaration): boolean;
/**
* Checks if the expression is of the form:
* Symbol.name
* where Symbol is literally the word "Symbol", and name is any identifierName
*/
function isWellKnownSymbolSyntactically(node: Expression): boolean;
function getPropertyNameForPropertyNameNode(name: DeclarationName): string;
function getPropertyNameForKnownSymbolName(symbolName: string): string;
/**
* Includes the word "Symbol" with unicode escapes
*/
function isESSymbolIdentifier(node: Node): boolean;
function isModifier(token: SyntaxKind): boolean;
function textSpanEnd(span: TextSpan): number;
function textSpanIsEmpty(span: TextSpan): boolean;
@@ -255,8 +276,7 @@ declare module ts {
list: Node;
}
function getEndLinePosition(line: number, sourceFile: SourceFile): number;
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
function getStartLinePositionForPosition(position: number, sourceFile: SourceFile): number;
function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number;
function rangeContainsRange(r1: TextRange, r2: TextRange): boolean;
function startEndContainsRange(start: number, end: number, range: TextRange): boolean;
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
+22 -2
View File
@@ -159,6 +159,7 @@ declare module "typescript" {
function getFullWidth(node: Node): number;
function containsParseError(node: Node): boolean;
function getSourceFileOfNode(node: Node): SourceFile;
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
function nodePosToString(node: Node): string;
function getStartPosOfNode(node: Node): number;
function nodeIsMissing(node: Node): boolean;
@@ -216,6 +217,26 @@ declare module "typescript" {
function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult;
function isKeyword(token: SyntaxKind): boolean;
function isTrivia(token: SyntaxKind): boolean;
/**
* A declaration has a dynamic name if both of the following are true:
* 1. The declaration has a computed property name
* 2. The computed name is *not* expressed as Symbol.<name>, where name
* is a property of the Symbol constructor that denotes a built in
* Symbol.
*/
function hasDynamicName(declaration: Declaration): boolean;
/**
* Checks if the expression is of the form:
* Symbol.name
* where Symbol is literally the word "Symbol", and name is any identifierName
*/
function isWellKnownSymbolSyntactically(node: Expression): boolean;
function getPropertyNameForPropertyNameNode(name: DeclarationName): string;
function getPropertyNameForKnownSymbolName(symbolName: string): string;
/**
* Includes the word "Symbol" with unicode escapes
*/
function isESSymbolIdentifier(node: Node): boolean;
function isModifier(token: SyntaxKind): boolean;
function textSpanEnd(span: TextSpan): number;
function textSpanIsEmpty(span: TextSpan): boolean;
@@ -255,8 +276,7 @@ declare module "typescript" {
list: Node;
}
function getEndLinePosition(line: number, sourceFile: SourceFile): number;
function getStartPositionOfLine(line: number, sourceFile: SourceFile): number;
function getStartLinePositionForPosition(position: number, sourceFile: SourceFile): number;
function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number;
function rangeContainsRange(r1: TextRange, r2: TextRange): boolean;
function startEndContainsRange(start: number, end: number, range: TextRange): boolean;
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
+3 -2
View File
@@ -25,9 +25,10 @@
"url": "https://github.com/Microsoft/TypeScript.git"
},
"preferGlobal": true,
"main": "./bin/typescriptServices.js",
"main": "./bin/typescript.js",
"bin": {
"tsc": "./bin/tsc"
"tsc": "./bin/tsc",
"tsserver": "./bin/tsserver"
},
"engines": {
"node": ">=0.8.0"
+49
View File
@@ -0,0 +1,49 @@
<#
.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
Note: If you get security errors, try running powershell as an Administrator and with the "-executionPolicy remoteSigned" switch
.PARAMETER vsVersion
Set to "12" for Dev12 (VS2013) or "14" (the default) for Dev14 (VS2015)
.PARAMETER enableDevMode
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"
#>
Param(
[int]$vsVersion = 14,
[switch]$enableDevMode,
[string]$tsScript
)
$vsRegKey = "HKCU:\Software\Microsoft\VisualStudio\${vsVersion}.0"
$tsRegKey = "${vsRegKey}\TypeScriptLanguageService"
if($enableDevMode -ne $true -and $tsScript -eq ""){
Throw "You must either enable language service debugging (-enableDevMode), set a custom script (-tsScript), or both"
}
if(!(Test-Path $vsRegKey)){
Throw "Visual Studio ${vsVersion} is not installed"
}
if(!(Test-Path $tsRegKey)){
# Create the TypeScript subkey if it doesn't exist
New-Item -path $tsRegKey
}
if($tsScript -ne ""){
if(!(Test-Path $tsScript)){
Throw "Could not locate the TypeScript language service script at ${tsScript}"
}
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}"
}
+18 -13
View File
@@ -51,17 +51,6 @@ module ts {
}
}
/**
* A declaration has a dynamic name if both of the following are true:
* 1. The declaration has a computed property name
* 2. The computed name is *not* expressed as Symbol.<name>, where name
* is a property of the Symbol constructor that denotes a built in
* Symbol.
*/
export function hasDynamicName(declaration: Declaration): boolean {
return declaration.name && declaration.name.kind === SyntaxKind.ComputedPropertyName;
}
export function bindSourceFile(file: SourceFile): void {
var start = new Date().getTime();
bindSourceFileWorker(file);
@@ -98,13 +87,18 @@ module ts {
if (symbolKind & SymbolFlags.Value && !symbol.valueDeclaration) symbol.valueDeclaration = node;
}
// Should not be called on a declaration with a computed property name.
// Should not be called on a declaration with a computed property name,
// unless it is a well known Symbol.
function getDeclarationName(node: Declaration): string {
if (node.name) {
if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) {
return '"' + (<LiteralExpression>node.name).text + '"';
}
Debug.assert(!hasDynamicName(node));
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
var nameExpression = (<ComputedPropertyName>node.name).expression;
Debug.assert(isWellKnownSymbolSyntactically(nameExpression));
return getPropertyNameForKnownSymbolName((<PropertyAccessExpression>nameExpression).name.text);
}
return (<Identifier | LiteralExpression>node.name).text;
}
switch (node.kind) {
@@ -501,9 +495,20 @@ module ts {
break;
}
case SyntaxKind.Block:
// do not treat function block a block-scope container
// all block-scope locals that reside in this block should go to the function locals.
// Otherwise this won't be considered as redeclaration of a block scoped local:
// function foo() {
// let x;
// var 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));
break;
case SyntaxKind.CatchClause:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.SwitchStatement:
bindChildren(node, 0, /*isBlockScopeContainer*/ true);
break;
+382 -131
View File
File diff suppressed because it is too large Load Diff
@@ -123,12 +123,12 @@ module ts {
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." },
yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." },
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." },
Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in an ambient context." },
Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in class property declarations." },
A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." },
A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." },
Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." },
Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in method overloads." },
Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces." },
Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in type literals." },
A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." },
A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." },
A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." },
A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: DiagnosticCategory.Error, key: "A comma expression is not allowed in a computed property name." },
extends_clause_already_seen: { code: 1172, category: DiagnosticCategory.Error, key: "'extends' clause already seen." },
extends_clause_must_precede_implements_clause: { code: 1173, category: DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause." },
@@ -147,10 +147,13 @@ module ts {
Merge_conflict_marker_encountered: { code: 1185, category: DiagnosticCategory.Error, key: "Merge conflict marker encountered." },
A_rest_element_cannot_have_an_initializer: { code: 1186, category: DiagnosticCategory.Error, key: "A rest element cannot have an initializer." },
A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." },
An_import_declaration_cannot_have_modifiers: { code: 1188, category: DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." },
External_module_0_has_no_default_export_or_export_assignment: { code: 1189, category: DiagnosticCategory.Error, key: "External module '{0}' has no default export or export assignment." },
An_export_declaration_cannot_have_modifiers: { code: 1190, category: DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." },
Export_declarations_are_not_permitted_in_an_internal_module: { code: 1191, category: DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." },
Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: { code: 1188, category: DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...of' statement." },
The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: { code: 1189, category: DiagnosticCategory.Error, key: "The variable declaration of a 'for...in' statement cannot have an initializer." },
The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: { code: 1190, category: DiagnosticCategory.Error, key: "The variable declaration of a 'for...of' statement cannot have an initializer." },
An_import_declaration_cannot_have_modifiers: { code: 1191, category: DiagnosticCategory.Error, key: "An import declaration cannot have modifiers." },
External_module_0_has_no_default_export_or_export_assignment: { code: 1192, category: DiagnosticCategory.Error, key: "External module '{0}' has no default export or export assignment." },
An_export_declaration_cannot_have_modifiers: { code: 1193, category: DiagnosticCategory.Error, key: "An export declaration cannot have modifiers." },
Export_declarations_are_not_permitted_in_an_internal_module: { code: 1194, category: DiagnosticCategory.Error, key: "Export declarations are not permitted in an internal module." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@@ -170,7 +173,7 @@ module ts {
Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: DiagnosticCategory.Error, key: "Global type '{0}' must be a class or interface type." },
Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: DiagnosticCategory.Error, key: "Global type '{0}' must have {1} type parameter(s)." },
Cannot_find_global_type_0: { code: 2318, category: DiagnosticCategory.Error, key: "Cannot find global type '{0}'." },
Named_properties_0_of_types_1_and_2_are_not_identical: { code: 2319, category: DiagnosticCategory.Error, key: "Named properties '{0}' of types '{1}' and '{2}' are not identical." },
Named_property_0_of_types_1_and_2_are_not_identical: { code: 2319, category: DiagnosticCategory.Error, key: "Named property '{0}' of types '{1}' and '{2}' are not identical." },
Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." },
Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: DiagnosticCategory.Error, key: "Excessive stack depth comparing types '{0}' and '{1}'." },
Type_0_is_not_assignable_to_type_1: { code: 2322, category: DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." },
@@ -192,7 +195,7 @@ module ts {
Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" },
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
An_index_expression_argument_must_be_of_type_string_number_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', or 'any'." },
An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
@@ -208,7 +211,7 @@ module ts {
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." },
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: DiagnosticCategory.Error, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." },
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: DiagnosticCategory.Error, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." },
The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number: { code: 2360, category: DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'." },
The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: DiagnosticCategory.Error, key: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." },
The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: DiagnosticCategory.Error, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" },
The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: DiagnosticCategory.Error, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." },
The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: DiagnosticCategory.Error, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." },
@@ -303,12 +306,27 @@ module ts {
Type_0_is_not_an_array_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type." },
A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" },
A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." },
A_computed_property_name_must_be_of_type_string_number_or_any: { code: 2464, category: DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', or 'any'." },
A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: DiagnosticCategory.Error, key: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." },
this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a computed property name." },
super_cannot_be_referenced_in_a_computed_property_name: { code: 2466, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in a computed property name." },
A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2466, category: DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." },
Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2468, category: DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." },
Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2469, category: DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" },
A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: { code: 2467, category: DiagnosticCategory.Error, key: "A computed property name cannot reference a type parameter from its containing type." },
Cannot_find_global_value_0: { code: 2468, category: DiagnosticCategory.Error, key: "Cannot find global value '{0}'." },
The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." },
Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." },
A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." },
Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2472, category: DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." },
Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." },
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." },
const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." },
A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 2476, category: DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." },
const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 2477, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." },
const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 2478, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." },
Property_0_does_not_exist_on_const_enum_1: { code: 2479, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." },
let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." },
Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: DiagnosticCategory.Error, key: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." },
for_of_statements_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 2482, category: DiagnosticCategory.Error, key: "'for...of' statements are only available when targeting ECMAScript 6 or higher." },
The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot use a type annotation." },
Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: DiagnosticCategory.Error, key: "Export declaration conflicts with exported declaration of '{0}'" },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -378,14 +396,6 @@ 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}'." },
Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." },
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." },
const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 4084, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." },
A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 4085, category: DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal." },
const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 4086, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." },
const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 4087, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." },
Property_0_does_not_exist_on_const_enum_1: { code: 4088, 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: 4089, category: DiagnosticCategory.Error, key: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." },
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}" },
@@ -462,5 +472,6 @@ module ts {
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." },
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." },
The_arguments_object_cannot_be_referenced_in_an_arrow_function_Consider_using_a_standard_function_expression: { code: 9002, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression." },
for_of_statements_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'for...of' statements are not currently supported." },
};
}
+93 -49
View File
@@ -483,11 +483,11 @@
"category": "Error",
"code": 1164
},
"Computed property names are not allowed in an ambient context.": {
"A computed property name in an ambient context must directly refer to a built-in symbol.": {
"category": "Error",
"code": 1165
},
"Computed property names are not allowed in class property declarations.": {
"A computed property name in a class property declaration must directly refer to a built-in symbol.": {
"category": "Error",
"code": 1166
},
@@ -495,15 +495,15 @@
"category": "Error",
"code": 1167
},
"Computed property names are not allowed in method overloads.": {
"A computed property name in a method overload must directly refer to a built-in symbol.": {
"category": "Error",
"code": 1168
},
"Computed property names are not allowed in interfaces.": {
"A computed property name in an interface must directly refer to a built-in symbol.": {
"category": "Error",
"code": 1169
},
"Computed property names are not allowed in type literals.": {
"A computed property name in a type literal must directly refer to a built-in symbol.": {
"category": "Error",
"code": 1170
},
@@ -579,22 +579,34 @@
"category": "Error",
"code": 1187
},
"An import declaration cannot have modifiers.": {
"Only a single variable declaration is allowed in a 'for...of' statement.": {
"category": "Error",
"code": 1188
},
"External module '{0}' has no default export or export assignment.": {
"The variable declaration of a 'for...in' statement cannot have an initializer.": {
"category": "Error",
"code": 1189
},
"An export declaration cannot have modifiers.": {
"The variable declaration of a 'for...of' statement cannot have an initializer.": {
"category": "Error",
"code": 1190
},
"Export declarations are not permitted in an internal module.": {
"An import declaration cannot have modifiers.": {
"category": "Error",
"code": 1191
},
"External module '{0}' has no default export or export assignment.": {
"category": "Error",
"code": 1192
},
"An export declaration cannot have modifiers.": {
"category": "Error",
"code": 1193
},
"Export declarations are not permitted in an internal module.": {
"category": "Error",
"code": 1194
},
"Duplicate identifier '{0}'.": {
"category": "Error",
@@ -672,7 +684,7 @@
"category": "Error",
"code": 2318
},
"Named properties '{0}' of types '{1}' and '{2}' are not identical.": {
"Named property '{0}' of types '{1}' and '{2}' are not identical.": {
"category": "Error",
"code": 2319
},
@@ -760,7 +772,7 @@
"category": "Error",
"code": 2341
},
"An index expression argument must be of type 'string', 'number', or 'any'.": {
"An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.": {
"category": "Error",
"code": 2342
},
@@ -824,7 +836,7 @@
"category": "Error",
"code": 2359
},
"The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'.": {
"The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'.": {
"category": "Error",
"code": 2360
},
@@ -1204,7 +1216,7 @@
"category": "Error",
"code": 2463
},
"A computed property name must be of type 'string', 'number', or 'any'.": {
"A computed property name must be of type 'string', 'number', 'symbol', or 'any'.": {
"category": "Error",
"code": 2464
},
@@ -1218,16 +1230,76 @@
},
"A computed property name cannot reference a type parameter from its containing type.": {
"category": "Error",
"code": 2466
"code": 2467
},
"Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher.": {
"Cannot find global value '{0}'.": {
"category": "Error",
"code": 2468
},
"Export declaration conflicts with exported declaration of '{0}'": {
"The '{0}' operator cannot be applied to type 'symbol'.": {
"category": "Error",
"code": 2469
},
"'Symbol' reference does not refer to the global Symbol constructor object.": {
"category": "Error",
"code": 2470
},
"A computed property name of the form '{0}' must be of type 'symbol'.": {
"category": "Error",
"code": 2471
},
"Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher.": {
"category": "Error",
"code": 2472
},
"Enum declarations must all be const or non-const.": {
"category": "Error",
"code": 2473
},
"In 'const' enum declarations member initializer must be constant expression.": {
"category": "Error",
"code": 2474
},
"'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.": {
"category": "Error",
"code": 2475
},
"A const enum member can only be accessed using a string literal.": {
"category": "Error",
"code": 2476
},
"'const' enum member initializer was evaluated to a non-finite value.": {
"category": "Error",
"code": 2477
},
"'const' enum member initializer was evaluated to disallowed value 'NaN'.": {
"category": "Error",
"code": 2478
},
"Property '{0}' does not exist on 'const' enum '{1}'.": {
"category": "Error",
"code": 2479
},
"'let' is not allowed to be used as a name in 'let' or 'const' declarations.": {
"category": "Error",
"code": 2480
},
"Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'.": {
"category": "Error",
"code": 2481
},
"'for...of' statements are only available when targeting ECMAScript 6 or higher.": {
"category": "Error",
"code": 2482
},
"The left-hand side of a 'for...of' statement cannot use a type annotation.": {
"category": "Error",
"code": 2483
},
"Export declaration conflicts with exported declaration of '{0}'": {
"category": "Error",
"code": 2484
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
@@ -1504,39 +1576,7 @@
"Exported type alias '{0}' has or is using private name '{1}'.": {
"category": "Error",
"code": 4081
},
"Enum declarations must all be const or non-const.": {
"category": "Error",
"code": 4082
},
"In 'const' enum declarations member initializer must be constant expression.": {
"category": "Error",
"code": 4083
},
"'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.": {
"category": "Error",
"code": 4084
},
"A const enum member can only be accessed using a string literal.": {
"category": "Error",
"code": 4085
},
"'const' enum member initializer was evaluated to a non-finite value.": {
"category": "Error",
"code": 4086
},
"'const' enum member initializer was evaluated to disallowed value 'NaN'.": {
"category": "Error",
"code": 4087
},
"Property '{0}' does not exist on 'const' enum '{1}'.": {
"category": "Error",
"code": 4088
},
"'let' is not allowed to be used as a name in 'let' or 'const' declarations.": {
"category": "Error",
"code": 4089
},
},
"The current host does not support the '{0}' option.": {
"category": "Error",
"code": 5001
@@ -1841,5 +1881,9 @@
"The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression.": {
"category": "Error",
"code": 9002
},
"'for...of' statements are not currently supported.": {
"category": "Error",
"code": 9003
}
}
+586 -162
View File
File diff suppressed because it is too large Load Diff
+80 -39
View File
@@ -152,6 +152,7 @@ module ts {
return visitNode(cbNode, (<PostfixUnaryExpression>node).operand);
case SyntaxKind.BinaryExpression:
return visitNode(cbNode, (<BinaryExpression>node).left) ||
visitNode(cbNode, (<BinaryExpression>node).operatorToken) ||
visitNode(cbNode, (<BinaryExpression>node).right);
case SyntaxKind.ConditionalExpression:
return visitNode(cbNode, (<ConditionalExpression>node).condition) ||
@@ -191,6 +192,10 @@ module ts {
return visitNode(cbNode, (<ForInStatement>node).initializer) ||
visitNode(cbNode, (<ForInStatement>node).expression) ||
visitNode(cbNode, (<ForInStatement>node).statement);
case SyntaxKind.ForOfStatement:
return visitNode(cbNode, (<ForOfStatement>node).initializer) ||
visitNode(cbNode, (<ForOfStatement>node).expression) ||
visitNode(cbNode, (<ForOfStatement>node).statement);
case SyntaxKind.ContinueStatement:
case SyntaxKind.BreakStatement:
return visitNode(cbNode, (<BreakOrContinueStatement>node).label);
@@ -1329,6 +1334,12 @@ module ts {
return undefined;
}
function parseTokenNode<T extends Node>(): T {
var node = <T>createNode(token);
nextToken();
return finishNode(node);
}
function canParseSemicolon() {
// If there's a real semicolon, then we can always parse it out.
if (token === SyntaxKind.SemicolonToken) {
@@ -1625,8 +1636,8 @@ module ts {
}
// in the case where we're parsing the variable declarator of a 'for-in' statement, we
// are done if we see an 'in' keyword in front of us.
if (token === SyntaxKind.InKeyword) {
// are done if we see an 'in' keyword in front of us. Same with for-of
if (isInOrOfKeyword(token)) {
return true;
}
@@ -1904,6 +1915,7 @@ module ts {
case SyntaxKind.BreakStatement:
case SyntaxKind.ContinueStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.WithStatement:
@@ -2106,14 +2118,6 @@ module ts {
return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
}
function parseTokenNode<T extends Node>(): T {
var node = <T>createNode(token);
nextToken();
return finishNode(node);
}
function parseTemplateExpression(): TemplateExpression {
var template = <TemplateExpression>createNode(SyntaxKind.TemplateExpression);
@@ -2620,6 +2624,7 @@ module ts {
case SyntaxKind.StringKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
// If these are followed by a dot, then parse these out as a dotted type reference instead.
var node = tryParse(parseKeywordAndNoDot);
return node || parseTypeReference();
@@ -2644,6 +2649,7 @@ module ts {
case SyntaxKind.StringKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.TypeOfKeyword:
case SyntaxKind.OpenBraceToken:
@@ -2821,8 +2827,9 @@ module ts {
// Expression[in] , AssignmentExpression[in]
var expr = parseAssignmentExpressionOrHigher();
while (parseOptional(SyntaxKind.CommaToken)) {
expr = makeBinaryExpression(expr, SyntaxKind.CommaToken, parseAssignmentExpressionOrHigher());
var operatorToken: Node;
while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) {
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher());
}
return expr;
}
@@ -2901,9 +2908,7 @@ module ts {
// Note: we call reScanGreaterToken so that we get an appropriately merged token
// for cases like > > = becoming >>=
if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) {
var operator = token;
nextToken();
return makeBinaryExpression(expr, operator, parseAssignmentExpressionOrHigher());
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher());
}
// It wasn't an assignment or a lambda. This is a conditional expression:
@@ -3186,6 +3191,10 @@ module ts {
return parseBinaryExpressionRest(precedence, leftOperand);
}
function isInOrOfKeyword(t: SyntaxKind) {
return t === SyntaxKind.InKeyword || t === SyntaxKind.OfKeyword;
}
function parseBinaryExpressionRest(precedence: number, leftOperand: Expression): Expression {
while (true) {
// We either have a binary operator here, or we're finished. We call
@@ -3203,9 +3212,7 @@ module ts {
break;
}
var operator = token;
nextToken();
leftOperand = makeBinaryExpression(leftOperand, operator, parseBinaryExpressionOrHigher(newPrecedence));
leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence));
}
return leftOperand;
@@ -3261,10 +3268,10 @@ module ts {
return -1;
}
function makeBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression): BinaryExpression {
function makeBinaryExpression(left: Expression, operatorToken: Node, right: Expression): BinaryExpression {
var node = <BinaryExpression>createNode(SyntaxKind.BinaryExpression, left.pos);
node.left = left;
node.operator = operator;
node.operatorToken = operatorToken;
node.right = right;
return finishNode(node);
}
@@ -3815,7 +3822,7 @@ module ts {
return finishNode(node);
}
function parseForOrForInStatement(): Statement {
function parseForOrForInOrForOfStatement(): Statement {
var pos = getNodePos();
parseExpected(SyntaxKind.ForKeyword);
parseExpected(SyntaxKind.OpenParenToken);
@@ -3823,21 +3830,27 @@ module ts {
var initializer: VariableDeclarationList | Expression = undefined;
if (token !== SyntaxKind.SemicolonToken) {
if (token === SyntaxKind.VarKeyword || token === SyntaxKind.LetKeyword || token === SyntaxKind.ConstKeyword) {
initializer = parseVariableDeclarationList(/*disallowIn:*/ true);
initializer = parseVariableDeclarationList(/*inForStatementInitializer:*/ true);
}
else {
initializer = disallowInAnd(parseExpression);
}
}
var forOrForInStatement: IterationStatement;
var forOrForInOrForOfStatement: IterationStatement;
if (parseOptional(SyntaxKind.InKeyword)) {
var forInStatement = <ForInStatement>createNode(SyntaxKind.ForInStatement, pos);
forInStatement.initializer = initializer;
forInStatement.expression = allowInAnd(parseExpression);
parseExpected(SyntaxKind.CloseParenToken);
forOrForInStatement = forInStatement;
forOrForInOrForOfStatement = forInStatement;
}
else {
else if (parseOptional(SyntaxKind.OfKeyword)) {
var forOfStatement = <ForOfStatement>createNode(SyntaxKind.ForOfStatement, pos);
forOfStatement.initializer = initializer;
forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher);
parseExpected(SyntaxKind.CloseParenToken);
forOrForInOrForOfStatement = forOfStatement;
} else {
var forStatement = <ForStatement>createNode(SyntaxKind.ForStatement, pos);
forStatement.initializer = initializer;
parseExpected(SyntaxKind.SemicolonToken);
@@ -3849,12 +3862,12 @@ module ts {
forStatement.iterator = allowInAnd(parseExpression);
}
parseExpected(SyntaxKind.CloseParenToken);
forOrForInStatement = forStatement;
forOrForInOrForOfStatement = forStatement;
}
forOrForInStatement.statement = parseStatement();
forOrForInOrForOfStatement.statement = parseStatement();
return finishNode(forOrForInStatement);
return finishNode(forOrForInOrForOfStatement);
}
function parseBreakOrContinueStatement(kind: SyntaxKind): BreakOrContinueStatement {
@@ -4100,7 +4113,7 @@ module ts {
case SyntaxKind.WhileKeyword:
return parseWhileStatement();
case SyntaxKind.ForKeyword:
return parseForOrForInStatement();
return parseForOrForInOrForOfStatement();
case SyntaxKind.ContinueKeyword:
return parseBreakOrContinueStatement(SyntaxKind.ContinueStatement);
case SyntaxKind.BreakKeyword:
@@ -4242,11 +4255,13 @@ module ts {
var node = <VariableDeclaration>createNode(SyntaxKind.VariableDeclaration);
node.name = parseIdentifierOrPattern();
node.type = parseTypeAnnotation();
node.initializer = parseInitializer(/*inParameter*/ false);
if (!isInOrOfKeyword(token)) {
node.initializer = parseInitializer(/*inParameter*/ false);
}
return finishNode(node);
}
function parseVariableDeclarationList(disallowIn: boolean): VariableDeclarationList {
function parseVariableDeclarationList(inForStatementInitializer: boolean): VariableDeclarationList {
var node = <VariableDeclarationList>createNode(SyntaxKind.VariableDeclarationList);
switch (token) {
@@ -4263,20 +4278,39 @@ module ts {
}
nextToken();
var savedDisallowIn = inDisallowInContext();
setDisallowInContext(disallowIn);
node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration);
// The user may have written the following:
//
// for (var of X) { }
//
// In this case, we want to parse an empty declaration list, and then parse 'of'
// as a keyword. The reason this is not automatic is that 'of' is a valid identifier.
// So we need to look ahead to determine if 'of' should be treated as a keyword in
// this context.
// The checker will then give an error that there is an empty declaration list.
if (token === SyntaxKind.OfKeyword && lookAhead(canFollowContextualOfKeyword)) {
node.declarations = createMissingList<VariableDeclaration>();
}
else {
var savedDisallowIn = inDisallowInContext();
setDisallowInContext(inForStatementInitializer);
setDisallowInContext(savedDisallowIn);
node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration);
setDisallowInContext(savedDisallowIn);
}
return finishNode(node);
}
function canFollowContextualOfKeyword(): boolean {
return nextTokenIsIdentifier() && nextToken() === SyntaxKind.CloseParenToken;
}
function parseVariableStatement(fullStart: number, modifiers: ModifiersArray): VariableStatement {
var node = <VariableStatement>createNode(SyntaxKind.VariableStatement, fullStart);
setModifiers(node, modifiers);
node.declarationList = parseVariableDeclarationList(/*disallowIn:*/ false);
node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer:*/ false);
parseSemicolon();
return finishNode(node);
}
@@ -4935,7 +4969,7 @@ module ts {
function processReferenceComments(sourceFile: SourceFile): void {
var triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, sourceText);
var referencedFiles: FileReference[] = [];
var amdDependencies: string[] = [];
var amdDependencies: {path: string; name: string}[] = [];
var amdModuleName: string;
// Keep scanning all the leading trivia in the file until we get to something that
@@ -4975,10 +5009,17 @@ module ts {
amdModuleName = amdModuleNameMatchResult[2];
}
var amdDependencyRegEx = /^\/\/\/\s*<amd-dependency\s+path\s*=\s*('|")(.+?)\1/gim;
var amdDependencyRegEx = /^\/\/\/\s*<amd-dependency\s/gim;
var pathRegex = /\spath\s*=\s*('|")(.+?)\1/gim;
var nameRegex = /\sname\s*=\s*('|")(.+?)\1/gim;
var amdDependencyMatchResult = amdDependencyRegEx.exec(comment);
if (amdDependencyMatchResult) {
amdDependencies.push(amdDependencyMatchResult[2]);
var pathMatchResult = pathRegex.exec(comment);
var nameMatchResult = nameRegex.exec(comment);
if (pathMatchResult) {
var amdDependency = {path: pathMatchResult[2], name: nameMatchResult ? nameMatchResult[2] : undefined };
amdDependencies.push(amdDependency);
}
}
}
}
+11 -9
View File
@@ -84,6 +84,7 @@ module ts {
"string": SyntaxKind.StringKeyword,
"super": SyntaxKind.SuperKeyword,
"switch": SyntaxKind.SwitchKeyword,
"symbol": SyntaxKind.SymbolKeyword,
"this": SyntaxKind.ThisKeyword,
"throw": SyntaxKind.ThrowKeyword,
"true": SyntaxKind.TrueKeyword,
@@ -95,6 +96,7 @@ module ts {
"while": SyntaxKind.WhileKeyword,
"with": SyntaxKind.WithKeyword,
"yield": SyntaxKind.YieldKeyword,
"of": SyntaxKind.OfKeyword,
"{": SyntaxKind.OpenBraceToken,
"}": SyntaxKind.CloseBraceToken,
"(": SyntaxKind.OpenParenToken,
@@ -225,7 +227,7 @@ module ts {
return false;
}
function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget) {
/* @internal */ export function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget) {
return languageVersion >= ScriptTarget.ES5 ?
lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
lookupInUnicodeMap(code, unicodeES3IdentifierStart);
@@ -280,13 +282,13 @@ module ts {
return result;
}
export function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number {
return computePositionFromLineAndCharacter(getLineStarts(sourceFile), line, character);
export function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number {
return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character);
}
export function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number {
Debug.assert(line > 0 && line <= lineStarts.length);
return lineStarts[line - 1] + character - 1;
export function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number {
Debug.assert(line >= 0 && line < lineStarts.length);
return lineStarts[line] + character;
}
export function getLineStarts(sourceFile: SourceFile): number[] {
@@ -300,11 +302,11 @@ module ts {
// the binary search returns the negative value of the next line start
// e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20
// then the search will return -2
lineNumber = (~lineNumber) - 1;
lineNumber = ~lineNumber - 1;
}
return {
line: lineNumber + 1,
character: position - lineStarts[lineNumber] + 1
line: lineNumber,
character: position - lineStarts[lineNumber]
};
}
+5 -5
View File
@@ -72,7 +72,7 @@ module ts {
function countLines(program: Program): number {
var count = 0;
forEach(program.getSourceFiles(), file => {
count += getLineAndCharacterOfPosition(file, file.end).line;
count += getLineStarts(file).length;
});
return count;
}
@@ -88,11 +88,11 @@ module ts {
if (diagnostic.file) {
var loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
output += diagnostic.file.fileName + "(" + loc.line + "," + loc.character + "): ";
output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `;
}
var category = DiagnosticCategory[diagnostic.category].toLowerCase();
output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) + sys.newLine;
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`;
sys.write(output);
}
@@ -332,7 +332,7 @@ module ts {
var program = createProgram(fileNames, compilerOptions, compilerHost);
var exitStatus = compileProgram();
var end = start - new Date().getTime();
var end = new Date().getTime() - start;
if (compilerOptions.listFiles) {
forEach(program.getSourceFiles(), file => {
@@ -357,7 +357,7 @@ module ts {
reportTimeStatistic("Bind time", ts.bindTime);
reportTimeStatistic("Check time", ts.checkTime);
reportTimeStatistic("Emit time", ts.emitTime);
reportTimeStatistic("Total time", start - end);
reportTimeStatistic("Total time", end);
}
return { program, exitStatus };
+16 -7
View File
@@ -142,8 +142,9 @@ module ts {
NumberKeyword,
SetKeyword,
StringKeyword,
SymbolKeyword,
TypeKeyword,
OfKeyword, // LastKeyword and LastToken
// Parse tree nodes
// Names
@@ -212,6 +213,7 @@ module ts {
WhileStatement,
ForStatement,
ForInStatement,
ForOfStatement,
ContinueStatement,
BreakStatement,
ReturnStatement,
@@ -269,7 +271,7 @@ module ts {
FirstReservedWord = BreakKeyword,
LastReservedWord = WithKeyword,
FirstKeyword = BreakKeyword,
LastKeyword = TypeKeyword,
LastKeyword = OfKeyword,
FirstFutureReservedWord = ImplementsKeyword,
LastFutureReservedWord = YieldKeyword,
FirstTypeNode = TypeReference,
@@ -277,7 +279,7 @@ module ts {
FirstPunctuation = OpenBraceToken,
LastPunctuation = CaretEqualsToken,
FirstToken = Unknown,
LastToken = TypeKeyword,
LastToken = OfKeyword,
FirstTriviaToken = SingleLineCommentTrivia,
LastTriviaToken = ConflictMarkerTrivia,
FirstLiteralToken = NumericLiteral,
@@ -631,7 +633,7 @@ module ts {
export interface BinaryExpression extends Expression {
left: Expression;
operator: SyntaxKind;
operatorToken: Node;
right: Expression;
}
@@ -762,6 +764,11 @@ module ts {
expression: Expression;
}
export interface ForOfStatement extends IterationStatement {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
export interface BreakOrContinueStatement extends Statement {
label?: Identifier;
}
@@ -945,7 +952,7 @@ module ts {
fileName: string;
text: string;
amdDependencies: string[];
amdDependencies: {path: string; name: string}[];
amdModuleName: string;
referencedFiles: FileReference[];
@@ -1359,9 +1366,10 @@ module ts {
ObjectLiteral = 0x00020000, // Originates in an object literal
ContainsUndefinedOrNull = 0x00040000, // Type is or contains Undefined or Null type
ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type
ESSymbol = 0x00100000, // Type of symbol primitive introduced in ES6
Intrinsic = Any | String | Number | Boolean | Void | Undefined | Null,
Primitive = String | Number | Boolean | Void | Undefined | Null | StringLiteral | Enum,
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
Primitive = String | Number | Boolean | ESSymbol | Void | Undefined | Null | StringLiteral | Enum,
StringLike = String | StringLiteral,
NumberLike = Number | Enum,
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
@@ -1699,6 +1707,7 @@ module ts {
equals = 0x3D, // =
exclamation = 0x21, // !
greaterThan = 0x3E, // >
hash = 0x23, // #
lessThan = 0x3C, // <
minus = 0x2D, // -
openBrace = 0x7B, // {
+58 -2
View File
@@ -105,11 +105,16 @@ module ts {
return <SourceFile>node;
}
export function getStartPositionOfLine(line: number, sourceFile: SourceFile): number {
Debug.assert(line >= 0);
return getLineStarts(sourceFile)[line];
}
// This is a useful function for debugging purposes.
export function nodePosToString(node: Node): string {
var file = getSourceFileOfNode(node);
var loc = getLineAndCharacterOfPosition(file, node.pos);
return file.fileName + "(" + loc.line + "," + loc.character + ")";
return `${ file.fileName }(${ loc.line + 1 },${ loc.character + 1 })`;
}
export function getStartPosOfNode(node: Node): number {
@@ -349,6 +354,7 @@ module ts {
case SyntaxKind.WhileStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.WithStatement:
case SyntaxKind.SwitchStatement:
case SyntaxKind.CaseClause:
@@ -566,7 +572,8 @@ module ts {
forStatement.condition === node ||
forStatement.iterator === node;
case SyntaxKind.ForInStatement:
var forInStatement = <ForInStatement>parent;
case SyntaxKind.ForOfStatement:
var forInStatement = <ForInStatement | ForOfStatement>parent;
return (forInStatement.initializer === node && forInStatement.initializer.kind !== SyntaxKind.VariableDeclarationList) ||
forInStatement.expression === node;
case SyntaxKind.TypeAssertionExpression:
@@ -713,6 +720,7 @@ module ts {
case SyntaxKind.ExpressionStatement:
case SyntaxKind.EmptyStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.IfStatement:
case SyntaxKind.LabeledStatement:
@@ -836,6 +844,54 @@ module ts {
return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken;
}
/**
* A declaration has a dynamic name if both of the following are true:
* 1. The declaration has a computed property name
* 2. The computed name is *not* expressed as Symbol.<name>, where name
* is a property of the Symbol constructor that denotes a built in
* Symbol.
*/
export function hasDynamicName(declaration: Declaration): boolean {
return declaration.name &&
declaration.name.kind === SyntaxKind.ComputedPropertyName &&
!isWellKnownSymbolSyntactically((<ComputedPropertyName>declaration.name).expression);
}
/**
* Checks if the expression is of the form:
* Symbol.name
* where Symbol is literally the word "Symbol", and name is any identifierName
*/
export function isWellKnownSymbolSyntactically(node: Expression): boolean {
return node.kind === SyntaxKind.PropertyAccessExpression && isESSymbolIdentifier((<PropertyAccessExpression>node).expression);
}
export function getPropertyNameForPropertyNameNode(name: DeclarationName): string {
if (name.kind === SyntaxKind.Identifier || name.kind === SyntaxKind.StringLiteral || name.kind === SyntaxKind.NumericLiteral) {
return (<Identifier | LiteralExpression>name).text;
}
if (name.kind === SyntaxKind.ComputedPropertyName) {
var nameExpression = (<ComputedPropertyName>name).expression;
if (isWellKnownSymbolSyntactically(nameExpression)) {
var rightHandSideName = (<PropertyAccessExpression>nameExpression).name.text;
return getPropertyNameForKnownSymbolName(rightHandSideName);
}
}
return undefined;
}
export function getPropertyNameForKnownSymbolName(symbolName: string): string {
return "__@" + symbolName;
}
/**
* Includes the word "Symbol" with unicode escapes
*/
export function isESSymbolIdentifier(node: Node): boolean {
return node.kind === SyntaxKind.Identifier && (<Identifier>node).text === "Symbol";
}
export function isModifier(token: SyntaxKind): boolean {
switch (token) {
case SyntaxKind.PublicKeyword:
+25 -28
View File
@@ -282,6 +282,8 @@ module FourSlash {
return new Harness.LanguageService.NativeLanugageServiceAdapter(cancellationToken, compilationOptions);
case FourSlashTestType.Shims:
return new Harness.LanguageService.ShimLanugageServiceAdapter(cancellationToken, compilationOptions);
case FourSlashTestType.Server:
return new Harness.LanguageService.ServerLanugageServiceAdapter(cancellationToken, compilationOptions);
default:
throw new Error("Unknown FourSlash test type: ");
}
@@ -396,7 +398,7 @@ module FourSlash {
var lineStarts = ts.computeLineStarts(this.getFileContent(this.activeFile.fileName));
var lineCharPos = ts.computeLineAndCharacterOfPosition(lineStarts, pos);
this.scenarioActions.push('<MoveCaretToLineAndChar LineNumber="' + lineCharPos.line + '" CharNumber="' + lineCharPos.character + '" />');
this.scenarioActions.push(`<MoveCaretToLineAndChar LineNumber=${ lineCharPos.line + 1 } CharNumber=${ lineCharPos.character + 1 } />`);
}
public moveCaretRight(count = 1) {
@@ -418,6 +420,9 @@ module FourSlash {
this.activeFile = fileToOpen;
var fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), '').substr(1);
this.scenarioActions.push('<OpenFile FileName="" SrcFileId="' + fileName + '" FileId="' + fileName + '" />');
// Let the host know that this file is now open
this.languageServiceAdapterHost.openFile(fileToOpen.fileName);
}
public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) {
@@ -1927,7 +1932,7 @@ module FourSlash {
}
var missingItem = { name: name, kind: kind };
this.raiseError('verifyGetScriptLexicalStructureListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items) + ')');
this.raiseError('verifyGetScriptLexicalStructureListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items, null, " ") + ')');
}
private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) {
@@ -2010,39 +2015,31 @@ module FourSlash {
// Get the text of the entire line the caret is currently at
private getCurrentLineContent() {
// The current caret position (in line/col terms)
var line = this.getCurrentCaretFilePosition().line;
// The line/col of the start of this line
var pos = this.languageServiceAdapterHost.lineColToPosition(this.activeFile.fileName, line, 1);
// The index of the current file
var text = this.getFileContent(this.activeFile.fileName)
// The text from the start of the line to the end of the file
var text = this.getFileContent(this.activeFile.fileName).substring(pos);
var pos = this.currentCaretPosition;
var startPos = pos, endPos = pos;
// Truncate to the first newline
var newlinePos = text.indexOf('\n');
if (newlinePos === -1) {
return text;
}
else {
if (text.charAt(newlinePos - 1) === '\r') {
newlinePos--;
while (startPos > 0) {
var ch = text.charCodeAt(startPos - 1);
if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) {
break;
}
return text.substr(0, newlinePos);
}
}
private getCurrentCaretFilePosition() {
var result = this.languageServiceAdapterHost.positionToZeroBasedLineCol(this.activeFile.fileName, this.currentCaretPosition);
if (result.line >= 0) {
result.line++;
startPos--;
}
if (result.character >= 0) {
result.character++;
while (endPos < text.length) {
var ch = text.charCodeAt(endPos);
if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) {
break;
}
endPos++;
}
return result;
return text.substring(startPos, endPos);
}
private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string) {
@@ -2120,7 +2117,7 @@ module FourSlash {
}
private getLineColStringAtPosition(position: number) {
var pos = this.languageServiceAdapterHost.positionToZeroBasedLineCol(this.activeFile.fileName, position);
var pos = this.languageServiceAdapterHost.positionToLineAndCharacter(this.activeFile.fileName, position);
return 'line ' + (pos.line + 1) + ', col ' + pos.character;
}
+6 -1
View File
@@ -4,7 +4,8 @@
const enum FourSlashTestType {
Native,
Shims
Shims,
Server
}
class FourSlashRunner extends RunnerBase {
@@ -22,6 +23,10 @@ class FourSlashRunner extends RunnerBase {
this.basePath = 'tests/cases/fourslash/shims';
this.testSuiteName = 'fourslash-shims';
break;
case FourSlashTestType.Server:
this.basePath = 'tests/cases/fourslash/server';
this.testSuiteName = 'fourslash-server';
break;
}
}
+16 -12
View File
@@ -16,14 +16,15 @@
/// <reference path='..\services\services.ts' />
/// <reference path='..\services\shims.ts' />
/// <reference path='..\server\session.ts' />
/// <reference path='..\server\client.ts' />
/// <reference path='..\server\node.d.ts' />
/// <reference path='external\mocha.d.ts'/>
/// <reference path='external\chai.d.ts'/>
/// <reference path='sourceMapRecorder.ts'/>
/// <reference path='runnerbase.ts'/>
declare var require: any;
declare var process: any;
var Buffer = require('buffer').Buffer;
var Buffer: BufferConstructor = require('buffer').Buffer;
// this will work in the browser via browserify
var _chai: typeof chai = require('chai');
@@ -795,9 +796,12 @@ module Harness {
}
}
export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget) {
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ true);
Utils.assertInvariants(result, /*parent:*/ undefined);
export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, assertInvariants = true) {
// Only set the parent nodes if we're asserting invariants. We don't need them otherwise.
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ assertInvariants);
if (assertInvariants) {
Utils.assertInvariants(result, /*parent:*/ undefined);
}
return result;
}
@@ -805,7 +809,6 @@ module Harness {
export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
// Cache these between executions so we don't have to re-parse them for every test
export var fourslashFileName = 'fourslash.ts';
export var fourslashSourceFile: ts.SourceFile;
@@ -926,7 +929,8 @@ module Harness {
settingsCallback?: (settings: ts.CompilerOptions) => void,
options?: ts.CompilerOptions,
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
currentDirectory?: string) {
currentDirectory?: string,
assertInvariants = true) {
options = options || { noResolve: false };
options.target = options.target || ts.ScriptTarget.ES3;
@@ -1074,7 +1078,7 @@ module Harness {
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);
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, options.target, assertInvariants);
}
};
inputFiles.forEach(register);
@@ -1181,13 +1185,13 @@ module Harness {
}
export function getMinimalDiagnostic(err: ts.Diagnostic): HarnessDiagnostic {
var errorLineInfo = err.file ? err.file.getLineAndCharacterFromPosition(err.start) : { line: 0, character: 0 };
var errorLineInfo = err.file ? err.file.getLineAndCharacterOfPosition(err.start) : { line: -1, character: -1 };
return {
fileName: err.file && err.file.fileName,
start: err.start,
end: err.start + err.length,
line: errorLineInfo.line,
character: errorLineInfo.character,
line: errorLineInfo.line + 1,
character: errorLineInfo.character + 1,
message: ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine),
category: ts.DiagnosticCategory[err.category].toLowerCase(),
code: err.code
+163 -37
View File
@@ -1,5 +1,6 @@
/// <reference path='..\services\services.ts' />
/// <reference path='..\services\shims.ts' />
/// <reference path='..\server\client.ts' />
/// <reference path='harness.ts' />
module Harness.LanguageService {
@@ -23,18 +24,18 @@ module Harness.LanguageService {
this.version++;
}
public editContent(minChar: number, limChar: number, newText: string): void {
public editContent(start: number, end: number, newText: string): void {
// Apply edits
var prefix = this.content.substring(0, minChar);
var prefix = this.content.substring(0, start);
var middle = newText;
var suffix = this.content.substring(limChar);
var suffix = this.content.substring(end);
this.setContent(prefix + middle + suffix);
// Store edit range + new length of script
this.editRanges.push({
length: this.content.length,
textChangeRange: ts.createTextChangeRange(
ts.createTextSpanFromBounds(minChar, limChar), newText.length)
ts.createTextSpanFromBounds(start, end), newText.length)
});
// Update version #
@@ -145,52 +146,28 @@ module Harness.LanguageService {
this.fileNameToScript[fileName] = new ScriptInfo(fileName, content);
}
public updateScript(fileName: string, content: string) {
public editScript(fileName: string, start: number, end: number, newText: string) {
var script = this.getScriptInfo(fileName);
if (script !== null) {
script.updateContent(content);
return;
}
this.addScript(fileName, content);
}
public editScript(fileName: string, minChar: number, limChar: number, newText: string) {
var script = this.getScriptInfo(fileName);
if (script !== null) {
script.editContent(minChar, limChar, newText);
script.editContent(start, end, newText);
return;
}
throw new Error("No script with name '" + fileName + "'");
}
/**
* @param line 1 based index
* @param col 1 based index
*/
public lineColToPosition(fileName: string, line: number, col: number): number {
var script: ScriptInfo = this.fileNameToScript[fileName];
assert.isNotNull(script);
assert.isTrue(line >= 1);
assert.isTrue(col >= 1);
return ts.computePositionFromLineAndCharacter(script.lineMap, line, col);
public openFile(fileName: string): void {
}
/**
* @param line 0 based index
* @param col 0 based index
*/
public positionToZeroBasedLineCol(fileName: string, position: number): ts.LineAndCharacter {
public positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter {
var script: ScriptInfo = this.fileNameToScript[fileName];
assert.isNotNull(script);
var result = ts.computeLineAndCharacterOfPosition(script.lineMap, position);
assert.isTrue(result.line >= 1);
assert.isTrue(result.character >= 1);
return { line: result.line - 1, character: result.character - 1 };
return ts.computeLineAndCharacterOfPosition(script.lineMap, position);
}
}
@@ -236,10 +213,8 @@ module Harness.LanguageService {
getFilenames(): string[] { return this.nativeHost.getFilenames(); }
getScriptInfo(fileName: string): ScriptInfo { return this.nativeHost.getScriptInfo(fileName); }
addScript(fileName: string, content: string): void { this.nativeHost.addScript(fileName, content); }
updateScript(fileName: string, content: string): void { return this.nativeHost.updateScript(fileName, content); }
editScript(fileName: string, minChar: number, limChar: number, newText: string): void { this.nativeHost.editScript(fileName, minChar, limChar, newText); }
lineColToPosition(fileName: string, line: number, col: number): number { return this.nativeHost.lineColToPosition(fileName, line, col); }
positionToZeroBasedLineCol(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToZeroBasedLineCol(fileName, position); }
editScript(fileName: string, start: number, end: number, newText: string): void { this.nativeHost.editScript(fileName, start, end, newText); }
positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToLineAndCharacter(fileName, position); }
getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); }
getCancellationToken(): ts.CancellationToken { return this.nativeHost.getCancellationToken(); }
@@ -442,5 +417,156 @@ module Harness.LanguageService {
return convertResult;
}
}
// Server adapter
class SessionClientHost extends NativeLanguageServiceHost implements ts.server.SessionClientHost {
private client: ts.server.SessionClient;
constructor(cancellationToken: ts.CancellationToken, settings: ts.CompilerOptions) {
super(cancellationToken, settings);
}
onMessage(message: string): void {
}
writeMessage(message: string): void {
}
setClient(client: ts.server.SessionClient) {
this.client = client;
}
openFile(fileName: string): void {
super.openFile(fileName);
this.client.openFile(fileName);
}
editScript(fileName: string, start: number, end: number, newText: string) {
super.editScript(fileName, start, end, newText);
this.client.changeFile(fileName, start, end, newText);
}
}
class SessionServerHost implements ts.server.ServerHost, ts.server.Logger {
args: string[] = [];
newLine: string;
useCaseSensitiveFileNames: boolean = false;
constructor(private host: NativeLanguageServiceHost) {
this.newLine = this.host.getNewLine();
}
onMessage(message: string): void {
}
writeMessage(message: string): void {
}
write(message: string): void {
this.writeMessage(message);
}
readFile(fileName: string): string {
if (fileName.indexOf(Harness.Compiler.defaultLibFileName) >= 0) {
fileName = Harness.Compiler.defaultLibFileName;
}
var snapshot = this.host.getScriptSnapshot(fileName);
return snapshot && snapshot.getText(0, snapshot.getLength());
}
writeFile(name: string, text: string, writeByteOrderMark: boolean): void {
}
resolvePath(path: string): string {
return path;
}
fileExists(path: string): boolean {
return !!this.host.getScriptSnapshot(path);
}
directoryExists(path: string): boolean {
return false;
}
getExecutingFilePath(): string {
return "";
}
exit(exitCode: number): void {
}
createDirectory(directoryName: string): void {
throw new Error("Not Implemented Yet.");
}
getCurrentDirectory(): string {
return this.host.getCurrentDirectory();
}
readDirectory(path: string, extension?: string): string[] {
throw new Error("Not implemented Yet.");
}
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
return { close() { } };
}
close(): void {
}
info(message: string): void {
return this.host.log(message);
}
msg(message: string) {
return this.host.log(message);
}
endGroup(): void {
}
perftrc(message: string): void {
return this.host.log(message);
}
startGroup(): void {
}
}
export class ServerLanugageServiceAdapter implements LanguageServiceAdapter {
private host: SessionClientHost;
private client: ts.server.SessionClient;
constructor(cancellationToken?: ts.CancellationToken, options?: ts.CompilerOptions) {
// This is the main host that tests use to direct tests
var clientHost = new SessionClientHost(cancellationToken, options);
var client = new ts.server.SessionClient(clientHost);
// This host is just a proxy for the clientHost, it uses the client
// host to answer server queries about files on disk
var serverHost = new SessionServerHost(clientHost);
var server = new ts.server.Session(serverHost, serverHost);
// Fake the connection between the client and the server
serverHost.writeMessage = client.onMessage.bind(client);
clientHost.writeMessage = server.onMessage.bind(server);
// Wire the client to the host to get notifications when a file is open
// or edited.
clientHost.setClient(client);
// Set the properties
this.client = client;
this.host = clientHost;
}
getHost() { return this.host; }
getLanguageService(): ts.LanguageService { return this.client; }
getClassifier(): ts.Classifier { throw new Error("getClassifier is not available using the server interface."); }
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); }
}
}
+4
View File
@@ -66,6 +66,9 @@ if (testConfigFile !== '') {
case 'fourslash-shims':
runners.push(new FourSlashRunner(FourSlashTestType.Shims));
break;
case 'fourslash-server':
runners.push(new FourSlashRunner(FourSlashTestType.Server));
break;
case 'fourslash-generated':
runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native));
break;
@@ -95,6 +98,7 @@ if (runners.length === 0) {
// language services
runners.push(new FourSlashRunner(FourSlashTestType.Native));
runners.push(new FourSlashRunner(FourSlashTestType.Shims));
runners.push(new FourSlashRunner(FourSlashTestType.Server));
//runners.push(new GeneratedFourslashRunner());
}
+2 -1
View File
@@ -90,7 +90,8 @@ module RWC {
/*settingsCallback*/ undefined, opts.options,
// Since all Rwc json file specified current directory in its json file, we need to pass this information to compilerHost
// so that when the host is asked for current directory, it should give the value from json rather than from process
currentDirectory);
currentDirectory,
/*assertInvariants:*/ false);
});
function getHarnessCompilerInputUnit(fileName: string) {
+5 -3
View File
@@ -85,15 +85,17 @@ class TypeWriterWalker {
private log(node: ts.Node, type: ts.Type): void {
var actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterFromPosition(actualPos);
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos);
var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
// If we got an unknown type, we temporarily want to fall back to just pretending the name
// (source text) of the node is the type. This is to align with the old typeWriter to make
// baseline comparisons easier. In the long term, we will want to just call typeToString
this.results.push({
line: lineAndCharacter.line - 1,
column: lineAndCharacter.character,
line: lineAndCharacter.line,
// todo(cyrusn): Not sure why column is one-based for type-writer. But I'm preserving
// that behavior to prevent having a lot of baselines to fix up.
column: lineAndCharacter.character + 1,
syntaxKind: node.kind,
sourceText: sourceText,
type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.WriteOwnNameForAnyLike)
+39 -39
View File
@@ -1,4 +1,4 @@
declare type PropertyKey = string | number | Symbol;
declare type PropertyKey = string | number | symbol;
interface Symbol {
/** Returns a string representation of an object. */
@@ -7,7 +7,7 @@ interface Symbol {
/** Returns the primitive value of the specified object. */
valueOf(): Object;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface SymbolConstructor {
@@ -20,21 +20,21 @@ interface SymbolConstructor {
* Returns a new unique Symbol value.
* @param description Description of the new Symbol object.
*/
(description?: string|number): Symbol;
(description?: string|number): symbol;
/**
* Returns a Symbol object from the global symbol registry matching the given key if found.
* Otherwise, returns a new symbol with this key.
* @param key key to search for.
*/
for(key: string): Symbol;
for(key: string): symbol;
/**
* Returns a key from the global symbol registry matching the given Symbol if found.
* Otherwise, returns a undefined.
* @param sym Symbol to find the key for.
*/
keyFor(sym: Symbol): string;
keyFor(sym: symbol): string;
// Well-known Symbols
@@ -42,42 +42,42 @@ interface SymbolConstructor {
* A method that determines if a constructor object recognizes an object as one of the
* constructors instances. Called by the semantics of the instanceof operator.
*/
hasInstance: Symbol;
hasInstance: symbol;
/**
* A Boolean value that if true indicates that an object should flatten to its array elements
* by Array.prototype.concat.
*/
isConcatSpreadable: Symbol;
isConcatSpreadable: symbol;
/**
* A Boolean value that if true indicates that an object may be used as a regular expression.
*/
isRegExp: Symbol;
isRegExp: symbol;
/**
* A method that returns the default iterator for an object.Called by the semantics of the
* for-of statement.
*/
iterator: Symbol;
iterator: symbol;
/**
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
* abstract operation.
*/
toPrimitive: Symbol;
toPrimitive: symbol;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built- in method Object.prototype.toString.
*/
toStringTag: Symbol;
toStringTag: symbol;
/**
* An Object whose own property names are property names that are excluded from the with
* environment bindings of the associated objects.
*/
unscopables: Symbol;
unscopables: symbol;
}
declare var Symbol: SymbolConstructor;
@@ -108,7 +108,7 @@ interface ObjectConstructor {
* Returns an array of all symbol properties found directly on object o.
* @param o Object to retrieve the symbols from.
*/
getOwnPropertySymbols(o: any): Symbol[];
getOwnPropertySymbols(o: any): symbol[];
/**
* Returns true if the values are the same value, false otherwise.
@@ -230,7 +230,7 @@ interface ArrayLike<T> {
interface Array<T> {
/** Iterator */
// [Symbol.iterator] (): Iterator<T>;
[Symbol.iterator] (): Iterator<T>;
/**
* Returns an array of key, value pairs for every entry in the array
@@ -329,7 +329,7 @@ interface ArrayConstructor {
interface String {
/** Iterator */
// [Symbol.iterator] (): Iterator<string>;
[Symbol.iterator] (): Iterator<string>;
/**
* Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point
@@ -447,12 +447,12 @@ interface IteratorResult<T> {
}
interface Iterator<T> {
//[Symbol.iterator](): Iterator<T>;
[Symbol.iterator](): Iterator<T>;
next(): IteratorResult<T>;
}
interface Iterable<T> {
//[Symbol.iterator](): Iterator<T>;
[Symbol.iterator](): Iterator<T>;
}
interface GeneratorFunction extends Function {
@@ -474,7 +474,7 @@ interface Generator<T> extends Iterator<T> {
next(value?: any): IteratorResult<T>;
throw (exception: any): IteratorResult<T>;
return (value: T): IteratorResult<T>;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface Math {
@@ -588,11 +588,11 @@ interface Math {
*/
cbrt(x: number): number;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface RegExp {
// [Symbol.isRegExp]: boolean;
[Symbol.isRegExp]: boolean;
/**
* Matches a string with a regular expression, and returns an array containing the results of
@@ -649,8 +649,8 @@ interface Map<K, V> {
set(key: K, value?: V): Map<K, V>;
size: number;
values(): Iterator<V>;
// [Symbol.iterator]():Iterator<[K,V]>;
// [Symbol.toStringTag]: string;
[Symbol.iterator]():Iterator<[K,V]>;
[Symbol.toStringTag]: string;
}
interface MapConstructor {
@@ -666,7 +666,7 @@ interface WeakMap<K, V> {
get(key: K): V;
has(key: K): boolean;
set(key: K, value?: V): WeakMap<K, V>;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface WeakMapConstructor {
@@ -686,8 +686,8 @@ interface Set<T> {
keys(): Iterator<T>;
size: number;
values(): Iterator<T>;
// [Symbol.iterator]():Iterator<T>;
// [Symbol.toStringTag]: string;
[Symbol.iterator]():Iterator<T>;
[Symbol.toStringTag]: string;
}
interface SetConstructor {
@@ -702,7 +702,7 @@ interface WeakSet<T> {
clear(): void;
delete(value: T): boolean;
has(value: T): boolean;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface WeakSetConstructor {
@@ -713,7 +713,7 @@ interface WeakSetConstructor {
declare var WeakSet: WeakSetConstructor;
interface JSON {
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
/**
@@ -733,7 +733,7 @@ interface ArrayBuffer {
*/
slice(begin: number, end?: number): ArrayBuffer;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface ArrayBufferConstructor {
@@ -870,7 +870,7 @@ interface DataView {
*/
setUint32(byteOffset: number, value: number, littleEndian: boolean): void;
// [Symbol.toStringTag]: string;
[Symbol.toStringTag]: string;
}
interface DataViewConstructor {
@@ -1137,7 +1137,7 @@ interface Int8Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Int8ArrayConstructor {
@@ -1427,7 +1427,7 @@ interface Uint8Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint8ArrayConstructor {
@@ -1717,7 +1717,7 @@ interface Uint8ClampedArray {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint8ClampedArrayConstructor {
@@ -2007,7 +2007,7 @@ interface Int16Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Int16ArrayConstructor {
@@ -2297,7 +2297,7 @@ interface Uint16Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint16ArrayConstructor {
@@ -2587,7 +2587,7 @@ interface Int32Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Int32ArrayConstructor {
@@ -2877,7 +2877,7 @@ interface Uint32Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Uint32ArrayConstructor {
@@ -3167,7 +3167,7 @@ interface Float32Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Float32ArrayConstructor {
@@ -3457,7 +3457,7 @@ interface Float64Array {
values(): Iterator<number>;
[index: number]: number;
// [Symbol.iterator] (): Iterator<number>;
[Symbol.iterator] (): Iterator<number>;
}
interface Float64ArrayConstructor {
@@ -3521,7 +3521,7 @@ declare var Reflect: {
getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
getPrototypeOf(target: any): any;
has(target: any, propertyKey: string): boolean;
has(target: any, propertyKey: Symbol): boolean;
has(target: any, propertyKey: symbol): boolean;
isExtensible(target: any): boolean;
ownKeys(target: any): Array<PropertyKey>;
preventExtensions(target: any): boolean;
+494
View File
@@ -0,0 +1,494 @@
/// <reference path="session.ts" />
module ts.server {
export interface SessionClientHost extends LanguageServiceHost {
writeMessage(message: string): void;
}
interface CompletionEntry extends CompletionInfo {
fileName: string;
position: number;
}
interface RenameEntry extends RenameInfo {
fileName: string;
position: number;
locations: RenameLocation[];
findInStrings: boolean;
findInComments: boolean;
}
export class SessionClient implements LanguageService {
private sequence: number = 0;
private fileMapping: ts.Map<string> = {};
private lineMaps: ts.Map<number[]> = {};
private messages: string[] = [];
private lastRenameEntry: RenameEntry;
constructor(private host: SessionClientHost) {
}
public onMessage(message: string): void {
this.messages.push(message);
}
private writeMessage(message: string): void {
this.host.writeMessage(message);
}
private getLineMap(fileName: string): number[] {
var lineMap = ts.lookUp(this.lineMaps, fileName);
if (!lineMap) {
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
lineMap = this.lineMaps[fileName] = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength()));
}
return lineMap;
}
private lineColToPosition(fileName: string, lineCol: protocol.Location): number {
return ts.computePositionOfLineAndCharacter(this.getLineMap(fileName), lineCol.line - 1, lineCol.col - 1);
}
private positionToOneBasedLineCol(fileName: string, position: number): protocol.Location {
var lineCol = ts.computeLineAndCharacterOfPosition(this.getLineMap(fileName), position);
return {
line: lineCol.line + 1,
col: lineCol.character + 1
};
}
private convertCodeEditsToTextChange(fileName: string, codeEdit: protocol.CodeEdit): ts.TextChange {
var start = this.lineColToPosition(fileName, codeEdit.start);
var end = this.lineColToPosition(fileName, codeEdit.end);
return {
span: ts.createTextSpanFromBounds(start, end),
newText: codeEdit.newText
};
}
private processRequest<T extends protocol.Request>(command: string, arguments?: any): T {
var request: protocol.Request = {
seq: this.sequence++,
type: "request",
command: command,
arguments: arguments
};
this.writeMessage(JSON.stringify(request));
return <T>request;
}
private processResponse<T extends protocol.Response>(request: protocol.Request): T {
var lastMessage = this.messages.shift();
Debug.assert(!!lastMessage, "Did not recieve any responses.");
// Read the content length
var contentLengthPrefix = "Content-Length: ";
var lines = lastMessage.split("\r\n");
Debug.assert(lines.length >= 2, "Malformed response: Expected 3 lines in the response.");
var contentLengthText = lines[0];
Debug.assert(contentLengthText.indexOf(contentLengthPrefix) === 0, "Malformed response: Response text did not contain content-length header.");
var contentLength = parseInt(contentLengthText.substring(contentLengthPrefix.length));
// Read the body
var responseBody = lines[2];
// Verify content length
Debug.assert(responseBody.length + 1 === contentLength, "Malformed response: Content length did not match the response's body length.");
try {
var response: T = JSON.parse(responseBody);
}
catch (e) {
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error detailes: " + e.message);
}
// verify the sequence numbers
Debug.assert(response.request_seq === request.seq, "Malformed response: response sequance number did not match request sequence number.");
// unmarshal errors
if (!response.success) {
throw new Error("Error " + response.message);
}
Debug.assert(!!response.body, "Malformed response: Unexpected empty response body.");
return response;
}
openFile(fileName: string): void {
var args: protocol.FileRequestArgs = { file: fileName };
this.processRequest(CommandNames.Open, args);
}
closeFile(fileName: string): void {
var args: protocol.FileRequestArgs = { file: fileName };
this.processRequest(CommandNames.Close, args);
}
changeFile(fileName: string, start: number, end: number, newText: string): void {
// clear the line map after an edit
this.lineMaps[fileName] = undefined;
var lineCol = this.positionToOneBasedLineCol(fileName, start);
var endLineCol = this.positionToOneBasedLineCol(fileName, end);
var args: protocol.ChangeRequestArgs = {
file: fileName,
line: lineCol.line,
col: lineCol.col,
endLine: endLineCol.line,
endCol: endLineCol.col,
insertString: newText
};
this.processRequest(CommandNames.Change, args);
}
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
var lineCol = this.positionToOneBasedLineCol(fileName, position);
var args: protocol.FileLocationRequestArgs = {
file: fileName,
line: lineCol.line,
col: lineCol.col
};
var request = this.processRequest<protocol.QuickInfoRequest>(CommandNames.Quickinfo, args);
var response = this.processResponse<protocol.QuickInfoResponse>(request);
var start = this.lineColToPosition(fileName, response.body.start);
var end = this.lineColToPosition(fileName, response.body.end);
return {
kind: response.body.kind,
kindModifiers: response.body.kindModifiers,
textSpan: ts.createTextSpanFromBounds(start, end),
displayParts: [{ kind: "text", text: response.body.displayString }],
documentation: [{ kind: "text", text: response.body.documentation }]
};
}
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo {
var lineCol = this.positionToOneBasedLineCol(fileName, position);
var args: protocol.CompletionsRequestArgs = {
file: fileName,
line: lineCol.line,
col: lineCol.col,
prefix: undefined
};
var request = this.processRequest<protocol.CompletionsRequest>(CommandNames.Completions, args);
var response = this.processResponse<protocol.CompletionsResponse>(request);
return {
isMemberCompletion: false,
isNewIdentifierLocation: false,
entries: response.body,
fileName: fileName,
position: position
};
}
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails {
var lineCol = this.positionToOneBasedLineCol(fileName, position);
var args: protocol.CompletionDetailsRequestArgs = {
file: fileName,
line: lineCol.line,
col: lineCol.col,
entryNames: [entryName]
};
var request = this.processRequest<protocol.CompletionDetailsRequest>(CommandNames.CompletionDetails, args);
var response = this.processResponse<protocol.CompletionDetailsResponse>(request);
Debug.assert(response.body.length == 1, "Unexpected length of completion details response body.");
return response.body[0];
}
getNavigateToItems(searchTerm: string): NavigateToItem[] {
var args: protocol.NavtoRequestArgs = {
searchTerm,
file: this.host.getScriptFileNames()[0]
};
var request = this.processRequest<protocol.NavtoRequest>(CommandNames.Navto, args);
var response = this.processResponse<protocol.NavtoResponse>(request);
return response.body.map(entry => {
var fileName = entry.file;
var start = this.lineColToPosition(fileName, entry.start);
var end = this.lineColToPosition(fileName, entry.end);
return {
name: entry.name,
containerName: entry.containerName || "",
containerKind: entry.containerKind || "",
kind: entry.kind,
kindModifiers: entry.kindModifiers,
matchKind: entry.matchKind,
fileName: fileName,
textSpan: ts.createTextSpanFromBounds(start, end)
};
});
}
getFormattingEditsForRange(fileName: string, start: number, end: number, options: ts.FormatCodeOptions): ts.TextChange[] {
var startLineCol = this.positionToOneBasedLineCol(fileName, start);
var endLineCol = this.positionToOneBasedLineCol(fileName, end);
var args: protocol.FormatRequestArgs = {
file: fileName,
line: startLineCol.line,
col: startLineCol.col,
endLine: endLineCol.line,
endCol: endLineCol.col,
};
// TODO: handle FormatCodeOptions
var request = this.processRequest<protocol.FormatRequest>(CommandNames.Format, args);
var response = this.processResponse<protocol.FormatResponse>(request);
return response.body.map(entry=> this.convertCodeEditsToTextChange(fileName, entry));
}
getFormattingEditsForDocument(fileName: string, options: ts.FormatCodeOptions): ts.TextChange[] {
return this.getFormattingEditsForRange(fileName, 0, this.host.getScriptSnapshot(fileName).getLength(), options);
}
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): ts.TextChange[] {
var lineCol = this.positionToOneBasedLineCol(fileName, position);
var args: protocol.FormatOnKeyRequestArgs = {
file: fileName,
line: lineCol.line,
col: lineCol.col,
key: key
};
// TODO: handle FormatCodeOptions
var request = this.processRequest<protocol.FormatOnKeyRequest>(CommandNames.Formatonkey, args);
var response = this.processResponse<protocol.FormatResponse>(request);
return response.body.map(entry=> this.convertCodeEditsToTextChange(fileName, entry));
}
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
var lineCol = this.positionToOneBasedLineCol(fileName, position);
var args: protocol.FileLocationRequestArgs = {
file: fileName,
line: lineCol.line,
col: lineCol.col,
};
var request = this.processRequest<protocol.DefinitionRequest>(CommandNames.Definition, args);
var response = this.processResponse<protocol.DefinitionResponse>(request);
return response.body.map(entry => {
var fileName = entry.file;
var start = this.lineColToPosition(fileName, entry.start);
var end = this.lineColToPosition(fileName, entry.end);
return {
containerKind: "",
containerName: "",
fileName: fileName,
textSpan: ts.createTextSpanFromBounds(start, end),
kind: "",
name: ""
};
});
}
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
var lineCol = this.positionToOneBasedLineCol(fileName, position);
var args: protocol.FileLocationRequestArgs = {
file: fileName,
line: lineCol.line,
col: lineCol.col,
};
var request = this.processRequest<protocol.ReferencesRequest>(CommandNames.References, args);
var response = this.processResponse<protocol.ReferencesResponse>(request);
return response.body.refs.map(entry => {
var fileName = entry.file;
var start = this.lineColToPosition(fileName, entry.start);
var end = this.lineColToPosition(fileName, entry.end);
return {
fileName: fileName,
textSpan: ts.createTextSpanFromBounds(start, end),
isWriteAccess: entry.isWriteAccess,
};
});
}
getEmitOutput(fileName: string): EmitOutput {
throw new Error("Not Implemented Yet.");
}
getSyntacticDiagnostics(fileName: string): Diagnostic[] {
throw new Error("Not Implemented Yet.");
}
getSemanticDiagnostics(fileName: string): Diagnostic[] {
throw new Error("Not Implemented Yet.");
}
getCompilerOptionsDiagnostics(): Diagnostic[] {
throw new Error("Not Implemented Yet.");
}
getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo {
var lineCol = this.positionToOneBasedLineCol(fileName, position);
var args: protocol.RenameRequestArgs = {
file: fileName,
line: lineCol.line,
col: lineCol.col,
findInStrings,
findInComments
};
var request = this.processRequest<protocol.RenameRequest>(CommandNames.Rename, args);
var response = this.processResponse<protocol.RenameResponse>(request);
var locations: RenameLocation[] = [];
response.body.locs.map((entry: protocol.SpanGroup) => {
var fileName = entry.file;
entry.locs.map((loc: protocol.TextSpan) => {
var start = this.lineColToPosition(fileName, loc.start);
var end = this.lineColToPosition(fileName, loc.end);
locations.push({
textSpan: ts.createTextSpanFromBounds(start, end),
fileName: fileName
});
});
});
return this.lastRenameEntry = {
canRename: response.body.info.canRename,
displayName: response.body.info.displayName,
fullDisplayName: response.body.info.fullDisplayName,
kind: response.body.info.kind,
kindModifiers: response.body.info.kindModifiers,
localizedErrorMessage: response.body.info.localizedErrorMessage,
triggerSpan: ts.createTextSpanFromBounds(position, position),
fileName: fileName,
position: position,
findInStrings: findInStrings,
findInComments: findInComments,
locations: locations
};
}
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] {
if (!this.lastRenameEntry ||
this.lastRenameEntry.fileName !== fileName ||
this.lastRenameEntry.position !== position ||
this.lastRenameEntry.findInStrings != findInStrings ||
this.lastRenameEntry.findInComments != findInComments) {
this.getRenameInfo(fileName, position, findInStrings, findInComments);
}
return this.lastRenameEntry.locations;
}
decodeNavigationBarItems(items: protocol.NavigationBarItem[], fileName: string): NavigationBarItem[] {
if (!items) {
return [];
}
return items.map(item => ({
text: item.text,
kind: item.kind,
kindModifiers: item.kindModifiers || "",
spans: item.spans.map(span=> createTextSpanFromBounds(this.lineColToPosition(fileName, span.start), this.lineColToPosition(fileName, span.end))),
childItems: this.decodeNavigationBarItems(item.childItems, fileName),
indent: 0,
bolded: false,
grayed: false
}));
}
getNavigationBarItems(fileName: string): NavigationBarItem[] {
var args: protocol.FileRequestArgs = {
file: fileName
};
var request = this.processRequest<protocol.NavBarRequest>(CommandNames.NavBar, args);
var response = this.processResponse<protocol.NavBarResponse>(request);
return this.decodeNavigationBarItems(response.body, fileName);
}
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
throw new Error("Not Implemented Yet.");
}
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan {
throw new Error("Not Implemented Yet.");
}
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
throw new Error("Not Implemented Yet.");
}
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
throw new Error("Not Implemented Yet.");
}
getOutliningSpans(fileName: string): OutliningSpan[] {
throw new Error("Not Implemented Yet.");
}
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] {
throw new Error("Not Implemented Yet.");
}
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] {
var lineCol = this.positionToOneBasedLineCol(fileName, position);
var args: protocol.FileLocationRequestArgs = {
file: fileName,
line: lineCol.line,
col: lineCol.col,
};
var request = this.processRequest<protocol.BraceRequest>(CommandNames.Brace, args);
var response = this.processResponse<protocol.BraceResponse>(request);
return response.body.map(entry => {
var start = this.lineColToPosition(fileName, entry.start);
var end = this.lineColToPosition(fileName, entry.end);
return {
start: start,
length: end - start,
};
});
}
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number {
throw new Error("Not Implemented Yet.");
}
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
throw new Error("Not Implemented Yet.");
}
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
throw new Error("Not Implemented Yet.");
}
getProgram(): Program {
throw new Error("SourceFile objects are not serializable through the server protocol.");
}
getSourceFile(fileName: string): SourceFile {
throw new Error("SourceFile objects are not serializable through the server protocol.");
}
cleanupSemanticCache(): void {
throw new Error("cleanupSemanticCache is not available through the server layer.");
}
dispose(): void {
throw new Error("dispose is not available through the server layer.");
}
}
}
File diff suppressed because it is too large Load Diff
+677
View File
@@ -0,0 +1,677 @@
// Type definitions for Node.js v0.10.1
// Project: http://nodejs.org/
// Definitions by: Microsoft TypeScript <http://typescriptlang.org>, DefinitelyTyped <https://github.com/borisyankov/DefinitelyTyped>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/************************************************
* *
* Node.js v0.10.1 API *
* *
************************************************/
/************************************************
* *
* GLOBAL *
* *
************************************************/
declare var process: NodeJS.Process;
declare var global: any;
declare var __filename: string;
declare var __dirname: string;
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
declare function clearTimeout(timeoutId: NodeJS.Timer): void;
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
declare function clearInterval(intervalId: NodeJS.Timer): void;
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
declare function clearImmediate(immediateId: any): void;
declare var require: {
(id: string): any;
resolve(id: string): string;
cache: any;
extensions: any;
main: any;
};
declare var module: {
exports: any;
require(id: string): any;
id: string;
filename: string;
loaded: boolean;
parent: any;
children: any[];
};
// Same as module.exports
declare var exports: any;
declare var SlowBuffer: {
new (str: string, encoding?: string): Buffer;
new (size: number): Buffer;
new (size: Uint8Array): Buffer;
new (array: any[]): Buffer;
prototype: Buffer;
isBuffer(obj: any): boolean;
byteLength(string: string, encoding?: string): number;
concat(list: Buffer[], totalLength?: number): Buffer;
};
// Buffer class
interface Buffer extends NodeBuffer { }
interface BufferConstructor {
new (str: string, encoding ?: string): Buffer;
new (size: number): Buffer;
new (size: Uint8Array): Buffer;
new (array: any[]): Buffer;
prototype: Buffer;
isBuffer(obj: any): boolean;
byteLength(string: string, encoding ?: string): number;
concat(list: Buffer[], totalLength ?: number): Buffer;
}
declare var Buffer: BufferConstructor;
/************************************************
* *
* GLOBAL INTERFACES *
* *
************************************************/
declare module NodeJS {
export interface ErrnoException extends Error {
errno?: any;
code?: string;
path?: string;
syscall?: string;
}
export interface EventEmitter {
addListener(event: string, listener: Function): EventEmitter;
on(event: string, listener: Function): EventEmitter;
once(event: string, listener: Function): EventEmitter;
removeListener(event: string, listener: Function): EventEmitter;
removeAllListeners(event?: string): EventEmitter;
setMaxListeners(n: number): void;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
}
export interface ReadableStream extends EventEmitter {
readable: boolean;
read(size?: number): any;
setEncoding(encoding: string): void;
pause(): void;
resume(): void;
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends WritableStream>(destination?: T): void;
unshift(chunk: string): void;
unshift(chunk: Buffer): void;
wrap(oldStream: ReadableStream): ReadableStream;
}
export interface WritableStream extends EventEmitter {
writable: boolean;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
end(): void;
end(buffer: Buffer, cb?: Function): void;
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
}
export interface ReadWriteStream extends ReadableStream, WritableStream { }
export interface Process extends EventEmitter {
stdout: WritableStream;
stderr: WritableStream;
stdin: ReadableStream;
argv: string[];
execPath: string;
abort(): void;
chdir(directory: string): void;
cwd(): string;
env: any;
exit(code?: number): void;
getgid(): number;
setgid(id: number): void;
setgid(id: string): void;
getuid(): number;
setuid(id: number): void;
setuid(id: string): void;
version: string;
versions: {
http_parser: string;
node: string;
v8: string;
ares: string;
uv: string;
zlib: string;
openssl: string;
};
config: {
target_defaults: {
cflags: any[];
default_configuration: string;
defines: string[];
include_dirs: string[];
libraries: string[];
};
variables: {
clang: number;
host_arch: string;
node_install_npm: boolean;
node_install_waf: boolean;
node_prefix: string;
node_shared_openssl: boolean;
node_shared_v8: boolean;
node_shared_zlib: boolean;
node_use_dtrace: boolean;
node_use_etw: boolean;
node_use_openssl: boolean;
target_arch: string;
v8_no_strict_aliasing: number;
v8_use_snapshot: boolean;
visibility: string;
};
};
kill(pid: number, signal?: string): void;
pid: number;
title: string;
arch: string;
platform: string;
memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; };
nextTick(callback: Function): void;
umask(mask?: number): number;
uptime(): number;
hrtime(time?: number[]): number[];
// Worker
send? (message: any, sendHandle?: any): void;
}
export interface Timer {
ref(): void;
unref(): void;
}
}
/**
* @deprecated
*/
interface NodeBuffer {
[index: number]: number;
write(string: string, offset?: number, length?: number, encoding?: string): number;
toString(encoding?: string, start?: number, end?: number): string;
toJSON(): any;
length: number;
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
slice(start?: number, end?: number): Buffer;
readUInt8(offset: number, noAsset?: boolean): number;
readUInt16LE(offset: number, noAssert?: boolean): number;
readUInt16BE(offset: number, noAssert?: boolean): number;
readUInt32LE(offset: number, noAssert?: boolean): number;
readUInt32BE(offset: number, noAssert?: boolean): number;
readInt8(offset: number, noAssert?: boolean): number;
readInt16LE(offset: number, noAssert?: boolean): number;
readInt16BE(offset: number, noAssert?: boolean): number;
readInt32LE(offset: number, noAssert?: boolean): number;
readInt32BE(offset: number, noAssert?: boolean): number;
readFloatLE(offset: number, noAssert?: boolean): number;
readFloatBE(offset: number, noAssert?: boolean): number;
readDoubleLE(offset: number, noAssert?: boolean): number;
readDoubleBE(offset: number, noAssert?: boolean): number;
writeUInt8(value: number, offset: number, noAssert?: boolean): void;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): void;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): void;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): void;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): void;
writeInt8(value: number, offset: number, noAssert?: boolean): void;
writeInt16LE(value: number, offset: number, noAssert?: boolean): void;
writeInt16BE(value: number, offset: number, noAssert?: boolean): void;
writeInt32LE(value: number, offset: number, noAssert?: boolean): void;
writeInt32BE(value: number, offset: number, noAssert?: boolean): void;
writeFloatLE(value: number, offset: number, noAssert?: boolean): void;
writeFloatBE(value: number, offset: number, noAssert?: boolean): void;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): void;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): void;
fill(value: any, offset?: number, end?: number): void;
}
declare module NodeJS {
export interface Path {
normalize(p: string): string;
join(...paths: any[]): string;
resolve(...pathSegments: any[]): string;
relative(from: string, to: string): string;
dirname(p: string): string;
basename(p: string, ext?: string): string;
extname(p: string): string;
sep: string;
}
}
declare module NodeJS {
export interface ReadLineInstance extends EventEmitter {
setPrompt(prompt: string, length: number): void;
prompt(preserveCursor?: boolean): void;
question(query: string, callback: Function): void;
pause(): void;
resume(): void;
close(): void;
write(data: any, key?: any): void;
}
export interface ReadLineOptions {
input: NodeJS.ReadableStream;
output: NodeJS.WritableStream;
completer?: Function;
terminal?: boolean;
}
export interface ReadLine {
createInterface(options: ReadLineOptions): ReadLineInstance;
}
}
declare module NodeJS {
module events {
export class EventEmitter implements NodeJS.EventEmitter {
static listenerCount(emitter: EventEmitter, event: string): number;
addListener(event: string, listener: Function): EventEmitter;
on(event: string, listener: Function): EventEmitter;
once(event: string, listener: Function): EventEmitter;
removeListener(event: string, listener: Function): EventEmitter;
removeAllListeners(event?: string): EventEmitter;
setMaxListeners(n: number): void;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
}
}
}
declare module NodeJS {
module stream {
export interface Stream extends events.EventEmitter {
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
}
export interface ReadableOptions {
highWaterMark?: number;
encoding?: string;
objectMode?: boolean;
}
export class Readable extends events.EventEmitter implements NodeJS.ReadableStream {
readable: boolean;
constructor(opts?: ReadableOptions);
_read(size: number): void;
read(size?: number): any;
setEncoding(encoding: string): void;
pause(): void;
resume(): void;
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
unshift(chunk: string): void;
unshift(chunk: Buffer): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean;
}
export interface WritableOptions {
highWaterMark?: number;
decodeStrings?: boolean;
}
export class Writable extends events.EventEmitter implements NodeJS.WritableStream {
writable: boolean;
constructor(opts?: WritableOptions);
_write(data: Buffer, encoding: string, callback: Function): void;
_write(data: string, encoding: string, callback: Function): void;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
end(): void;
end(buffer: Buffer, cb?: Function): void;
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
}
export interface DuplexOptions extends ReadableOptions, WritableOptions {
allowHalfOpen?: boolean;
}
// Note: Duplex extends both Readable and Writable.
export class Duplex extends Readable implements NodeJS.ReadWriteStream {
writable: boolean;
constructor(opts?: DuplexOptions);
_write(data: Buffer, encoding: string, callback: Function): void;
_write(data: string, encoding: string, callback: Function): void;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
end(): void;
end(buffer: Buffer, cb?: Function): void;
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
}
export interface TransformOptions extends ReadableOptions, WritableOptions { }
// Note: Transform lacks the _read and _write methods of Readable/Writable.
export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream {
readable: boolean;
writable: boolean;
constructor(opts?: TransformOptions);
_transform(chunk: Buffer, encoding: string, callback: Function): void;
_transform(chunk: string, encoding: string, callback: Function): void;
_flush(callback: Function): void;
read(size?: number): any;
setEncoding(encoding: string): void;
pause(): void;
resume(): void;
pipe<T extends NodeJS.WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends NodeJS.WritableStream>(destination?: T): void;
unshift(chunk: string): void;
unshift(chunk: Buffer): void;
wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
push(chunk: any, encoding?: string): boolean;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
end(): void;
end(buffer: Buffer, cb?: Function): void;
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
}
export class PassThrough extends Transform { }
}
}
declare module NodeJS {
module fs {
interface Stats {
isFile(): boolean;
isDirectory(): boolean;
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isSymbolicLink(): boolean;
isFIFO(): boolean;
isSocket(): boolean;
dev: number;
ino: number;
mode: number;
nlink: number;
uid: number;
gid: number;
rdev: number;
size: number;
blksize: number;
blocks: number;
atime: Date;
mtime: Date;
ctime: Date;
}
interface FSWatcher extends events.EventEmitter {
close(): void;
}
export interface ReadStream extends stream.Readable { }
export interface WriteStream extends stream.Writable { }
export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function renameSync(oldPath: string, newPath: string): void;
export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function truncateSync(path: string, len?: number): void;
export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function ftruncateSync(fd: number, len?: number): void;
export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function chownSync(path: string, uid: number, gid: number): void;
export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function fchownSync(fd: number, uid: number, gid: number): void;
export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function lchownSync(path: string, uid: number, gid: number): void;
export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function chmodSync(path: string, mode: number): void;
export function chmodSync(path: string, mode: string): void;
export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function fchmodSync(fd: number, mode: number): void;
export function fchmodSync(fd: number, mode: string): void;
export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function lchmodSync(path: string, mode: number): void;
export function lchmodSync(path: string, mode: string): void;
export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function statSync(path: string): Stats;
export function lstatSync(path: string): Stats;
export function fstatSync(fd: number): Stats;
export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function linkSync(srcpath: string, dstpath: string): void;
export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function symlinkSync(srcpath: string, dstpath: string, type?: string): void;
export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void;
export function readlinkSync(path: string): string;
export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
export function realpath(path: string, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
export function realpathSync(path: string, cache?: { [path: string]: string }): string;
export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function unlinkSync(path: string): void;
export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function rmdirSync(path: string): void;
export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function mkdirSync(path: string, mode?: number): void;
export function mkdirSync(path: string, mode?: string): void;
export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void;
export function readdirSync(path: string): string[];
export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function closeSync(fd: number): void;
export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
export function openSync(path: string, flags: string, mode?: number): number;
export function openSync(path: string, flags: string, mode?: string): number;
export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function utimesSync(path: string, atime: number, mtime: number): void;
export function utimesSync(path: string, atime: Date, mtime: Date): void;
export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function futimesSync(fd: number, atime: number, mtime: number): void;
export function futimesSync(fd: number, atime: Date, mtime: Date): void;
export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
export function fsyncSync(fd: number): void;
export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
export function readFileSync(filename: string, encoding: string): string;
export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string;
export function readFileSync(filename: string, options?: { flag?: string; }): Buffer;
export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void;
export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void;
export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void;
export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher;
export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher;
export function exists(path: string, callback?: (exists: boolean) => void): void;
export function existsSync(path: string): boolean;
export function createReadStream(path: string, options?: {
flags?: string;
encoding?: string;
fd?: string;
mode?: number;
bufferSize?: number;
}): ReadStream;
export function createReadStream(path: string, options?: {
flags?: string;
encoding?: string;
fd?: string;
mode?: string;
bufferSize?: number;
}): ReadStream;
export function createWriteStream(path: string, options?: {
flags?: string;
encoding?: string;
string?: string;
}): WriteStream;
}
}
declare module NodeJS {
module path {
export function normalize(p: string): string;
export function join(...paths: any[]): string;
export function resolve(...pathSegments: any[]): string;
export function relative(from: string, to: string): string;
export function dirname(p: string): string;
export function basename(p: string, ext?: string): string;
export function extname(p: string): string;
export var sep: string;
}
}
declare module NodeJS {
module _debugger {
export interface Packet {
raw: string;
headers: string[];
body: Message;
}
export interface Message {
seq: number;
type: string;
}
export interface RequestInfo {
command: string;
arguments: any;
}
export interface Request extends Message, RequestInfo {
}
export interface Event extends Message {
event: string;
body?: any;
}
export interface Response extends Message {
request_seq: number;
success: boolean;
/** Contains error message if success == false. */
message?: string;
/** Contains message body if success == true. */
body?: any;
}
export interface BreakpointMessageBody {
type: string;
target: number;
line: number;
}
export class Protocol {
res: Packet;
state: string;
execute(data: string): void;
serialize(rq: Request): string;
onResponse: (pkt: Packet) => void;
}
export var NO_FRAME: number;
export var port: number;
export interface ScriptDesc {
name: string;
id: number;
isNative?: boolean;
handle?: number;
type: string;
lineOffset?: number;
columnOffset?: number;
lineCount?: number;
}
export interface Breakpoint {
id: number;
scriptId: number;
script: ScriptDesc;
line: number;
condition?: string;
scriptReq?: string;
}
export interface RequestHandler {
(err: boolean, body: Message, res: Packet): void;
request_seq?: number;
}
export interface ResponseBodyHandler {
(err: boolean, body?: any): void;
request_seq?: number;
}
export interface ExceptionInfo {
text: string;
}
export interface BreakResponse {
script?: ScriptDesc;
exception?: ExceptionInfo;
sourceLine: number;
sourceLineText: string;
sourceColumn: number;
}
export function SourceInfo(body: BreakResponse): string;
export class Client extends events.EventEmitter {
protocol: Protocol;
scripts: ScriptDesc[];
handles: ScriptDesc[];
breakpoints: Breakpoint[];
currentSourceLine: number;
currentSourceColumn: number;
currentSourceLineText: string;
currentFrame: number;
currentScript: string;
connect(port: number, host: string): void;
req(req: any, cb: RequestHandler): void;
reqFrameEval(code: string, frame: number, cb: RequestHandler): void;
mirrorObject(obj: any, depth: number, cb: ResponseBodyHandler): void;
setBreakpoint(rq: BreakpointMessageBody, cb: RequestHandler): void;
clearBreakpoint(rq: Request, cb: RequestHandler): void;
listbreakpoints(cb: RequestHandler): void;
reqSource(from: number, to: number, cb: RequestHandler): void;
reqScripts(cb: any): void;
reqContinue(cb: RequestHandler): void;
}
}
}
+823
View File
@@ -0,0 +1,823 @@
/**
* Declaration module describing the TypeScript Server protocol
*/
declare module ts.server.protocol {
/**
* A TypeScript Server message
*/
export interface Message {
/**
* Sequence number of the message
*/
seq: number;
/**
* One of "request", "response", or "event"
*/
type: string;
}
/**
* Client-initiated request message
*/
export interface Request extends Message {
/**
* The command to execute
*/
command: string;
/**
* Object containing arguments for the command
*/
arguments?: any;
}
/**
* Server-initiated event message
*/
export interface Event extends Message {
/**
* Name of event
*/
event: string;
/**
* Event-specific information
*/
body?: any;
}
/**
* Response by server to client request message.
*/
export interface Response extends Message {
/**
* Sequence number of the request message.
*/
request_seq: number;
/**
* Outcome of the request.
*/
success: boolean;
/**
* The command requested.
*/
command: string;
/**
* Contains error message if success == false.
*/
message?: string;
/**
* Contains message body if success == true.
*/
body?: any;
}
/**
* Arguments for FileRequest messages.
*/
export interface FileRequestArgs {
/**
* The file for the request (absolute pathname required).
*/
file: string;
}
/**
* Request whose sole parameter is a file name.
*/
export interface FileRequest extends Request {
arguments: FileRequestArgs;
}
/**
* Instances of this interface specify a location in a source file:
* (file, line, col), where line and column are 1-based.
*/
export interface FileLocationRequestArgs extends FileRequestArgs {
/**
* The line number for the request (1-based).
*/
line: number;
/**
* The column for the request (1-based).
*/
col: number;
}
/**
* A request whose arguments specify a file location (file, line, col).
*/
export interface FileLocationRequest extends FileRequest {
arguments: FileLocationRequestArgs;
}
/**
* Go to definition request; value of command field is
* "definition". Return response giving the file locations that
* define the symbol found in file at location line, col.
*/
export interface DefinitionRequest extends FileLocationRequest {
}
/**
* Location in source code expressed as (one-based) line and column.
*/
export interface Location {
line: number;
col: number;
}
/**
* Object found in response messages defining a span of text in source code.
*/
export interface TextSpan {
/**
* First character of the definition.
*/
start: Location;
/**
* One character past last character of the definition.
*/
end: Location;
}
/**
* Object found in response messages defining a span of text in a specific source file.
*/
export interface FileSpan extends TextSpan {
/**
* File containing text span.
*/
file: string;
}
/**
* Definition response message. Gives text range for definition.
*/
export interface DefinitionResponse extends Response {
body?: FileSpan[];
}
/**
* Find references request; value of command field is
* "references". Return response giving the file locations that
* reference the symbol found in file at location line, col.
*/
export interface ReferencesRequest extends FileLocationRequest {
}
export interface ReferencesResponseItem extends FileSpan {
/** Text of line containing the reference. Including this
* with the response avoids latency of editor loading files
* to show text of reference line (the server already has
* loaded the referencing files).
*/
lineText: string;
/**
* True if reference is a write location, false otherwise.
*/
isWriteAccess: boolean;
}
/**
* The body of a "references" response message.
*/
export interface ReferencesResponseBody {
/**
* The file locations referencing the symbol.
*/
refs: ReferencesResponseItem[];
/**
* The name of the symbol.
*/
symbolName: string;
/**
* The start column of the symbol (on the line provided by the references request).
*/
symbolStartCol: number;
/**
* The full display name of the symbol.
*/
symbolDisplayString: string;
}
/**
* Response to "references" request.
*/
export interface ReferencesResponse extends Response {
body?: ReferencesResponseBody;
}
export interface RenameRequestArgs extends FileLocationRequestArgs {
findInComments?: boolean;
findInStrings?: boolean;
}
/**
* Rename request; value of command field is "rename". Return
* response giving the file locations that reference the symbol
* found in file at location line, col. Also return full display
* name of the symbol so that client can print it unambiguously.
*/
export interface RenameRequest extends FileLocationRequest {
arguments: RenameRequestArgs;
}
/**
* Information about the item to be renamed.
*/
export interface RenameInfo {
/**
* True if item can be renamed.
*/
canRename: boolean;
/**
* Error message if item can not be renamed.
*/
localizedErrorMessage?: string;
/**
* Display name of the item to be renamed.
*/
displayName: string;
/**
* Full display name of item to be renamed.
*/
fullDisplayName: string;
/**
* The items's kind (such as 'className' or 'parameterName' or plain 'text').
*/
kind: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
kindModifiers: string;
}
/**
* A group of text spans, all in 'file'.
*/
export interface SpanGroup {
/** The file to which the spans apply */
file: string;
/** The text spans in this group */
locs: TextSpan[];
}
export interface RenameResponseBody {
/**
* Information about the item to be renamed.
*/
info: RenameInfo;
/**
* An array of span groups (one per file) that refer to the item to be renamed.
*/
locs: SpanGroup[];
}
/**
* Rename response message.
*/
export interface RenameResponse extends Response {
body?: RenameResponseBody;
}
/**
* Open request; value of command field is "open". Notify the
* server that the client has file open. The server will not
* monitor the filesystem for changes in this file and will assume
* that the client is updating the server (using the change and/or
* reload messages) when the file changes. Server does not currently
* send a response to an open request.
*/
export interface OpenRequest extends FileRequest {
}
/**
* Close request; value of command field is "close". Notify the
* server that the client has closed a previously open file. If
* file is still referenced by open files, the server will resume
* monitoring the filesystem for changes to file. Server does not
* currently send a response to a close request.
*/
export interface CloseRequest extends FileRequest {
}
/**
* Quickinfo request; value of command field is
* "quickinfo". Return response giving a quick type and
* documentation string for the symbol found in file at location
* line, col.
*/
export interface QuickInfoRequest extends FileLocationRequest {
}
/**
* Body of QuickInfoResponse.
*/
export interface QuickInfoResponseBody {
/**
* The symbol's kind (such as 'className' or 'parameterName' or plain 'text').
*/
kind: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
kindModifiers: string;
/**
* Starting file location of symbol.
*/
start: Location;
/**
* One past last character of symbol.
*/
end: Location;
/**
* Type and kind of symbol.
*/
displayString: string;
/**
* Documentation associated with symbol.
*/
documentation: string;
}
/**
* Quickinfo response message.
*/
export interface QuickInfoResponse extends Response {
body?: QuickInfoResponseBody;
}
/**
* Arguments for format messages.
*/
export interface FormatRequestArgs extends FileLocationRequestArgs {
/**
* Last line of range for which to format text in file.
*/
endLine: number;
/**
* Last column of range for which to format text in file.
*/
endCol: number;
}
/**
* Format request; value of command field is "format". Return
* response giving zero or more edit instructions. The edit
* instructions will be sorted in file order. Applying the edit
* instructions in reverse to file will result in correctly
* reformatted text.
*/
export interface FormatRequest extends FileLocationRequest {
arguments: FormatRequestArgs;
}
/**
* Object found in response messages defining an editing
* instruction for a span of text in source code. The effect of
* this instruction is to replace the text starting at start and
* ending one character before end with newText. For an insertion,
* the text span is empty. For a deletion, newText is empty.
*/
export interface CodeEdit {
/**
* First character of the text span to edit.
*/
start: Location;
/**
* One character past last character of the text span to edit.
*/
end: Location;
/**
* Replace the span defined above with this string (may be
* the empty string).
*/
newText: string;
}
/**
* Format and format on key response message.
*/
export interface FormatResponse extends Response {
body?: CodeEdit[];
}
/**
* Arguments for format on key messages.
*/
export interface FormatOnKeyRequestArgs extends FileLocationRequestArgs {
/**
* Key pressed (';', '\n', or '}').
*/
key: string;
}
/**
* Format on key request; value of command field is
* "formatonkey". Given file location and key typed (as string),
* return response giving zero or more edit instructions. The
* edit instructions will be sorted in file order. Applying the
* edit instructions in reverse to file will result in correctly
* reformatted text.
*/
export interface FormatOnKeyRequest extends FileLocationRequest {
arguments: FormatOnKeyRequestArgs;
}
/**
* Arguments for completions messages.
*/
export interface CompletionsRequestArgs extends FileLocationRequestArgs {
/**
* Optional prefix to apply to possible completions.
*/
prefix?: string;
}
/**
* Completions request; value of command field is "completions".
* Given a file location (file, line, col) and a prefix (which may
* be the empty string), return the possible completions that
* begin with prefix.
*/
export interface CompletionsRequest extends FileLocationRequest {
arguments: CompletionsRequestArgs;
}
/**
* Arguments for completion details request.
*/
export interface CompletionDetailsRequestArgs extends FileLocationRequestArgs {
/**
* Names of one or more entries for which to obtain details.
*/
entryNames: string[];
}
/**
* Completion entry details request; value of command field is
* "completionEntryDetails". Given a file location (file, line,
* col) and an array of completion entry names return more
* detailed information for each completion entry.
*/
export interface CompletionDetailsRequest extends FileLocationRequest {
arguments: CompletionDetailsRequestArgs;
}
/**
* Part of a symbol description.
*/
export interface SymbolDisplayPart {
/**
* Text of an item describing the symbol.
*/
text: string;
/**
* The symbol's kind (such as 'className' or 'parameterName' or plain 'text').
*/
kind: string;
}
/**
* An item found in a completion response.
*/
export interface CompletionEntry {
/**
* The symbol's name.
*/
name: string;
/**
* The symbol's kind (such as 'className' or 'parameterName').
*/
kind: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
kindModifiers: string;
}
/**
* Additional completion entry details, available on demand
*/
export interface CompletionEntryDetails extends CompletionEntry {
/**
* Display parts of the symbol (similar to quick info).
*/
displayParts: SymbolDisplayPart[];
/**
* Documentation strings for the symbol.
*/
documentation: SymbolDisplayPart[];
}
export interface CompletionsResponse extends Response {
body?: CompletionEntry[];
}
export interface CompletionDetailsResponse extends Response {
body?: CompletionEntryDetails[];
}
/**
* Arguments for geterr messages.
*/
export interface GeterrRequestArgs {
/**
* List of file names for which to compute compiler errors.
* The files will be checked in list order.
*/
files: string[];
/**
* Delay in milliseconds to wait before starting to compute
* errors for the files in the file list
*/
delay: number;
}
/**
* Geterr request; value of command field is "geterr". Wait for
* delay milliseconds and then, if during the wait no change or
* reload messages have arrived for the first file in the files
* list, get the syntactic errors for the file, field requests,
* and then get the semantic errors for the file. Repeat with a
* smaller delay for each subsequent file on the files list. Best
* practice for an editor is to send a file list containing each
* file that is currently visible, in most-recently-used order.
*/
export interface GeterrRequest extends Request {
arguments: GeterrRequestArgs;
}
/**
* Item of diagnostic information found in a DiagnosticEvent message.
*/
export interface Diagnostic {
/**
* Starting file location at which text appies.
*/
start: Location;
/**
* The last file location at which the text applies.
*/
end: Location;
/**
* Text of diagnostic message.
*/
text: string;
}
export interface DiagnosticEventBody {
/**
* The file for which diagnostic information is reported.
*/
file: string;
/**
* An array of diagnostic information items.
*/
diagnostics: Diagnostic[];
}
/**
* Event message for "syntaxDiag" and "semanticDiag" event types.
* These events provide syntactic and semantic errors for a file.
*/
export interface DiagnosticEvent extends Event {
body?: DiagnosticEventBody;
}
/**
* Arguments for reload request.
*/
export interface ReloadRequestArgs extends FileRequestArgs {
/**
* Name of temporary file from which to reload file
* contents. May be same as file.
*/
tmpfile: string;
}
/**
* Reload request message; value of command field is "reload".
* Reload contents of file with name given by the 'file' argument
* from temporary file with name given by the 'tmpfile' argument.
* The two names can be identical.
*/
export interface ReloadRequest extends FileRequest {
arguments: ReloadRequestArgs;
}
/**
* Response to "reload" request. This is just an acknowledgement, so
* no body field is required.
*/
export interface ReloadResponse extends Response {
}
/**
* Arguments for saveto request.
*/
export interface SavetoRequestArgs extends FileRequestArgs {
/**
* Name of temporary file into which to save server's view of
* file contents.
*/
tmpfile: string;
}
/**
* Saveto request message; value of command field is "saveto".
* For debugging purposes, save to a temporaryfile (named by
* argument 'tmpfile') the contents of file named by argument
* 'file'. The server does not currently send a response to a
* "saveto" request.
*/
export interface SavetoRequest extends FileRequest {
arguments: SavetoRequestArgs;
}
/**
* Arguments for navto request message.
*/
export interface NavtoRequestArgs extends FileRequestArgs {
/**
* Search term to navigate to from current location; term can
* be '.*' or an identifier prefix.
*/
searchTerm: string;
}
/**
* Navto request message; value of command field is "navto".
* Return list of objects giving file locations and symbols that
* match the search term given in argument 'searchTerm'. The
* context for the search is given by the named file.
*/
export interface NavtoRequest extends FileRequest {
arguments: NavtoRequestArgs;
}
/**
* An item found in a navto response.
*/
export interface NavtoItem {
/**
* The symbol's name.
*/
name: string;
/**
* The symbol's kind (such as 'className' or 'parameterName').
*/
kind: string;
/**
* exact, substring, or prefix.
*/
matchKind?: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
kindModifiers?: string;
/**
* The file in which the symbol is found.
*/
file: string;
/**
* The location within file at which the symbol is found.
*/
start: Location;
/**
* One past the last character of the symbol.
*/
end: Location;
/**
* Name of symbol's container symbol (if any); for example,
* the class name if symbol is a class member.
*/
containerName?: string;
/**
* Kind of symbol's container symbol (if any).
*/
containerKind?: string;
}
/**
* Navto response message. Body is an array of navto items. Each
* item gives a symbol that matched the search term.
*/
export interface NavtoResponse extends Response {
body?: NavtoItem[];
}
/**
* Arguments for change request message.
*/
export interface ChangeRequestArgs extends FormatRequestArgs {
/**
* Optional string to insert at location (file, line, col).
*/
insertString?: string;
}
/**
* Change request message; value of command field is "change".
* Update the server's view of the file named by argument 'file'.
* Server does not currently send a response to a change request.
*/
export interface ChangeRequest extends FileLocationRequest {
arguments: ChangeRequestArgs;
}
/**
* Response to "brace" request.
*/
export interface BraceResponse extends Response {
body?: TextSpan[];
}
/**
* Brace matching request; value of command field is "brace".
* Return response giving the file locations of matching braces
* found in file at location line, col.
*/
export interface BraceRequest extends FileLocationRequest {
}
/**
* NavBar itesm request; value of command field is "navbar".
* Return response giving the list of navigation bar entries
* extracted from the requested file.
*/
export interface NavBarRequest extends FileRequest {
}
export interface NavigationBarItem {
/**
* The item's display text.
*/
text: string;
/**
* The symbol's kind (such as 'className' or 'parameterName').
*/
kind: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
kindModifiers?: string;
/**
* The definition locations of the item.
*/
spans: TextSpan[];
/**
* Optional children.
*/
childItems?: NavigationBarItem[];
}
export interface NavBarResponse extends Response {
body?: NavigationBarItem[];
}
}
+219
View File
@@ -0,0 +1,219 @@
/// <reference path="node.d.ts" />
/// <reference path="session.ts" />
module ts.server {
var nodeproto: typeof NodeJS._debugger = require('_debugger');
var readline: NodeJS.ReadLine = require('readline');
var path: NodeJS.Path = require('path');
var fs: typeof NodeJS.fs = require('fs');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false,
});
class Logger implements ts.server.Logger {
fd = -1;
seq = 0;
inGroup = false;
firstInGroup = true;
constructor(public logFilename: string) {
}
static padStringRight(str: string, padding: string) {
return (str + padding).slice(0, padding.length);
}
close() {
if (this.fd >= 0) {
fs.close(this.fd);
}
}
perftrc(s: string) {
this.msg(s, "Perf");
}
info(s: string) {
this.msg(s, "Info");
}
startGroup() {
this.inGroup = true;
this.firstInGroup = true;
}
endGroup() {
this.inGroup = false;
this.seq++;
this.firstInGroup = true;
}
msg(s: string, type = "Err") {
if (this.fd < 0) {
this.fd = fs.openSync(this.logFilename, "w");
}
if (this.fd >= 0) {
s = s + "\n";
var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
if (this.firstInGroup) {
s = prefix + s;
this.firstInGroup = false;
}
if (!this.inGroup) {
this.seq++;
this.firstInGroup = true;
}
var buf = new Buffer(s);
fs.writeSync(this.fd, buf, 0, buf.length, null);
}
}
}
interface WatchedFile {
fileName: string;
callback: (fileName: string) => void;
mtime: Date;
}
class WatchedFileSet {
private watchedFiles: WatchedFile[] = [];
private nextFileToCheck = 0;
private watchTimer: NodeJS.Timer;
private static fileDeleted = 34;
// average async stat takes about 30 microseconds
// set chunk size to do 30 files in < 1 millisecond
constructor(public interval = 2500, public chunkSize = 30) {
}
private static copyListRemovingItem<T>(item: T, list: T[]) {
var copiedList: T[] = [];
for (var i = 0, len = list.length; i < len; i++) {
if (list[i] != item) {
copiedList.push(list[i]);
}
}
return copiedList;
}
private static getModifiedTime(fileName: string): Date {
return fs.statSync(fileName).mtime;
}
private poll(checkedIndex: number) {
var watchedFile = this.watchedFiles[checkedIndex];
if (!watchedFile) {
return;
}
fs.stat(watchedFile.fileName,(err, stats) => {
if (err) {
var msg = err.message;
if (err.errno) {
msg += " errno: " + err.errno.toString();
}
if (err.errno == WatchedFileSet.fileDeleted) {
watchedFile.callback(watchedFile.fileName);
}
}
else if (watchedFile.mtime.getTime() != stats.mtime.getTime()) {
watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName);
watchedFile.callback(watchedFile.fileName);
}
});
}
// this implementation uses polling and
// stat due to inconsistencies of fs.watch
// and efficiency of stat on modern filesystems
private startWatchTimer() {
this.watchTimer = setInterval(() => {
var count = 0;
var nextToCheck = this.nextFileToCheck;
var firstCheck = -1;
while ((count < this.chunkSize) && (nextToCheck != firstCheck)) {
this.poll(nextToCheck);
if (firstCheck < 0) {
firstCheck = nextToCheck;
}
nextToCheck++;
if (nextToCheck === this.watchedFiles.length) {
nextToCheck = 0;
}
count++;
}
this.nextFileToCheck = nextToCheck;
}, this.interval);
}
addFile(fileName: string, callback: (fileName: string) => void ): WatchedFile {
var file: WatchedFile = {
fileName,
callback,
mtime: WatchedFileSet.getModifiedTime(fileName)
};
this.watchedFiles.push(file);
if (this.watchedFiles.length === 1) {
this.startWatchTimer();
}
return file;
}
removeFile(file: WatchedFile) {
this.watchedFiles = WatchedFileSet.copyListRemovingItem(file, this.watchedFiles);
}
}
class IOSession extends Session {
constructor(host: ServerHost, logger: ts.server.Logger) {
super(host, logger);
}
listen() {
rl.on('line',(input: string) => {
var message = input.trim();
this.onMessage(message);
});
rl.on('close',() => {
this.projectService.closeLog();
this.projectService.log("Exiting...");
process.exit(0);
});
}
}
// This places log file in the directory containing editorServices.js
// TODO: check that this location is writable
var logger = new Logger(__dirname + "/.log" + process.pid.toString());
// REVIEW: for now this implementation uses polling.
// The advantage of polling is that it works reliably
// on all os and with network mounted files.
// For 90 referenced files, the average time to detect
// changes is 2*msInterval (by default 5 seconds).
// The overhead of this is .04 percent (1/2500) with
// average pause of < 1 millisecond (and max
// pause less than 1.5 milliseconds); question is
// do we anticipate reference sets in the 100s and
// do we care about waiting 10-20 seconds to detect
// changes for large reference sets? If so, do we want
// to increase the chunk size or decrease the interval
// time dynamically to match the large reference set?
var watchedFileSet = new WatchedFileSet();
ts.sys.watchFile = function (fileName, callback) {
var watchedFile = watchedFileSet.addFile(fileName, callback);
return {
close: () => watchedFileSet.removeFile(watchedFile)
}
};
// Start listening
new IOSession(ts.sys, logger).listen();
}
+801
View File
@@ -0,0 +1,801 @@
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\services\services.ts" />
/// <reference path="node.d.ts" />
/// <reference path="protocol.d.ts" />
/// <reference path="editorServices.ts" />
module ts.server {
var spaceCache = [" ", " ", " ", " "];
interface StackTraceError extends Error {
stack?: string;
}
function generateSpaces(n: number): string {
if (!spaceCache[n]) {
var strBuilder = "";
for (var i = 0; i < n; i++) {
strBuilder += " ";
}
spaceCache[n] = strBuilder;
}
return spaceCache[n];
}
interface FileStart {
file: string;
start: ILineInfo;
}
function compareNumber(a: number, b: number) {
if (a < b) {
return -1;
}
else if (a == b) {
return 0;
}
else return 1;
}
function compareFileStart(a: FileStart, b: FileStart) {
if (a.file < b.file) {
return -1;
}
else if (a.file == b.file) {
var n = compareNumber(a.start.line, b.start.line);
if (n == 0) {
return compareNumber(a.start.col, b.start.col);
}
else return n;
}
else {
return 1;
}
}
function sortNavItems(items: ts.NavigateToItem[]) {
return items.sort((a, b) => {
if (a.matchKind < b.matchKind) {
return -1;
}
else if (a.matchKind == b.matchKind) {
var lowa = a.name.toLowerCase();
var lowb = b.name.toLowerCase();
if (lowa < lowb) {
return -1;
}
else if (lowa == lowb) {
return 0;
}
else {
return 1;
}
}
else {
return 1;
}
})
}
function formatDiag(fileName: string, project: Project, diag: ts.Diagnostic) {
return {
start: project.compilerService.host.positionToLineCol(fileName, diag.start),
end: project.compilerService.host.positionToLineCol(fileName, diag.start + diag.length),
text: ts.flattenDiagnosticMessageText(diag.messageText, "\n")
};
}
interface PendingErrorCheck {
fileName: string;
project: Project;
}
function allEditsBeforePos(edits: ts.TextChange[], pos: number) {
for (var i = 0, len = edits.length; i < len; i++) {
if (ts.textSpanEnd(edits[i].span) >= pos) {
return false;
}
}
return true;
}
export module CommandNames {
export var Change = "change";
export var Close = "close";
export var Completions = "completions";
export var CompletionDetails = "completionEntryDetails";
export var Definition = "definition";
export var Format = "format";
export var Formatonkey = "formatonkey";
export var Geterr = "geterr";
export var NavBar = "navbar";
export var Navto = "navto";
export var Open = "open";
export var Quickinfo = "quickinfo";
export var References = "references";
export var Reload = "reload";
export var Rename = "rename";
export var Saveto = "saveto";
export var Brace = "brace";
export var Unknown = "unknown";
}
module Errors {
export var NoProject = new Error("No Project.");
export var NoContent = new Error("No Content.");
}
export interface ServerHost extends ts.System {
}
export class Session {
projectService: ProjectService;
pendingOperation = false;
fileHash: ts.Map<number> = {};
nextFileId = 1;
errorTimer: NodeJS.Timer;
immediateId: any;
changeSeq = 0;
constructor(private host: ServerHost, private logger: Logger) {
this.projectService = new ProjectService(host, logger);
}
logError(err: Error, cmd: string) {
var typedErr = <StackTraceError>err;
var msg = "Exception on executing command " + cmd;
if (typedErr.message) {
msg += ":\n" + typedErr.message;
if (typedErr.stack) {
msg += "\n" + typedErr.stack;
}
}
this.projectService.log(msg);
}
sendLineToClient(line: string) {
this.host.write(line + this.host.newLine);
}
send(msg: NodeJS._debugger.Message) {
var json = JSON.stringify(msg);
this.sendLineToClient('Content-Length: ' + (1 + Buffer.byteLength(json, 'utf8')) +
'\r\n\r\n' + json);
}
event(info: any, eventName: string) {
var ev: NodeJS._debugger.Event = {
seq: 0,
type: "event",
event: eventName,
body: info,
};
this.send(ev);
}
response(info: any, cmdName: string, reqSeq = 0, errorMsg?: string) {
var res: protocol.Response = {
seq: 0,
type: "response",
command: cmdName,
request_seq: reqSeq,
success: !errorMsg,
}
if (!errorMsg) {
res.body = info;
}
else {
res.message = errorMsg;
}
this.send(res);
}
output(body: any, commandName: string, requestSequence = 0, errorMessage?: string) {
this.response(body, commandName, requestSequence, errorMessage);
}
semanticCheck(file: string, project: Project) {
var diags = project.compilerService.languageService.getSemanticDiagnostics(file);
if (diags) {
var bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag");
}
}
syntacticCheck(file: string, project: Project) {
var diags = project.compilerService.languageService.getSyntacticDiagnostics(file);
if (diags) {
var bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag");
}
}
errorCheck(file: string, project: Project) {
this.syntacticCheck(file, project);
this.semanticCheck(file, project);
}
updateErrorCheck(checkList: PendingErrorCheck[], seq: number,
matchSeq: (seq: number) => boolean, ms = 1500, followMs = 200) {
if (followMs > ms) {
followMs = ms;
}
if (this.errorTimer) {
clearTimeout(this.errorTimer);
}
if (this.immediateId) {
clearImmediate(this.immediateId);
this.immediateId = undefined;
}
var index = 0;
var checkOne = () => {
if (matchSeq(seq)) {
var checkSpec = checkList[index++];
if (checkSpec.project.getSourceFileFromName(checkSpec.fileName)) {
this.syntacticCheck(checkSpec.fileName, checkSpec.project);
this.immediateId = setImmediate(() => {
this.semanticCheck(checkSpec.fileName, checkSpec.project);
this.immediateId = undefined;
if (checkList.length > index) {
this.errorTimer = setTimeout(checkOne, followMs);
}
else {
this.errorTimer = undefined;
}
});
}
}
}
if ((checkList.length > index) && (matchSeq(seq))) {
this.errorTimer = setTimeout(checkOne, ms);
}
}
getDefinition(line: number, col: number, fileName: string): protocol.FileSpan[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var position = compilerService.host.lineColToPosition(file, line, col);
var definitions = compilerService.languageService.getDefinitionAtPosition(file, position);
if (!definitions) {
throw Errors.NoContent;
}
return definitions.map(def => ({
file: def.fileName,
start: compilerService.host.positionToLineCol(def.fileName, def.textSpan.start),
end: compilerService.host.positionToLineCol(def.fileName, ts.textSpanEnd(def.textSpan))
}));
}
getRenameLocations(line: number, col: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var position = compilerService.host.lineColToPosition(file, line, col);
var renameInfo = compilerService.languageService.getRenameInfo(file, position);
if (!renameInfo) {
throw Errors.NoContent;
}
if (!renameInfo.canRename) {
return {
info: renameInfo,
locs: []
};
}
var renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments);
if (!renameLocations) {
throw Errors.NoContent;
}
var bakedRenameLocs = renameLocations.map(location => (<protocol.FileSpan>{
file: location.fileName,
start: compilerService.host.positionToLineCol(location.fileName, location.textSpan.start),
end: compilerService.host.positionToLineCol(location.fileName, ts.textSpanEnd(location.textSpan)),
})).sort((a, b) => {
if (a.file < b.file) {
return -1;
}
else if (a.file > b.file) {
return 1;
}
else {
// reverse sort assuming no overlap
if (a.start.line < b.start.line) {
return 1;
}
else if (a.start.line > b.start.line) {
return -1;
}
else {
return b.start.col - a.start.col;
}
}
}).reduce<protocol.SpanGroup[]>((accum: protocol.SpanGroup[], cur: protocol.FileSpan) => {
var curFileAccum: protocol.SpanGroup;
if (accum.length > 0) {
curFileAccum = accum[accum.length - 1];
if (curFileAccum.file != cur.file) {
curFileAccum = undefined;
}
}
if (!curFileAccum) {
curFileAccum = { file: cur.file, locs: [] };
accum.push(curFileAccum);
}
curFileAccum.locs.push({ start: cur.start, end: cur.end });
return accum;
}, []);
return { info: renameInfo, locs: bakedRenameLocs };
}
getReferences(line: number, col: number, fileName: string): protocol.ReferencesResponseBody {
// TODO: get all projects for this file; report refs for all projects deleting duplicates
// can avoid duplicates by eliminating same ref file from subsequent projects
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var position = compilerService.host.lineColToPosition(file, line, col);
var references = compilerService.languageService.getReferencesAtPosition(file, position);
if (!references) {
throw Errors.NoContent;
}
var nameInfo = compilerService.languageService.getQuickInfoAtPosition(file, position);
if (!nameInfo) {
throw Errors.NoContent;
}
var displayString = ts.displayPartsToString(nameInfo.displayParts);
var nameSpan = nameInfo.textSpan;
var nameColStart = compilerService.host.positionToLineCol(file, nameSpan.start).col;
var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan));
var bakedRefs: protocol.ReferencesResponseItem[] = references.map((ref) => {
var start = compilerService.host.positionToLineCol(ref.fileName, ref.textSpan.start);
var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1);
var snap = compilerService.host.getScriptSnapshot(ref.fileName);
var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, "");
return {
file: ref.fileName,
start: start,
lineText: lineText,
end: compilerService.host.positionToLineCol(ref.fileName, ts.textSpanEnd(ref.textSpan)),
isWriteAccess: ref.isWriteAccess
};
}).sort(compareFileStart);
return {
refs: bakedRefs,
symbolName: nameText,
symbolStartCol: nameColStart,
symbolDisplayString: displayString
};
}
openClientFile(fileName: string) {
var file = ts.normalizePath(fileName);
this.projectService.openClientFile(file);
}
getQuickInfo(line: number, col: number, fileName: string): protocol.QuickInfoResponseBody {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var position = compilerService.host.lineColToPosition(file, line, col);
var quickInfo = compilerService.languageService.getQuickInfoAtPosition(file, position);
if (!quickInfo) {
throw Errors.NoContent;
}
var displayString = ts.displayPartsToString(quickInfo.displayParts);
var docString = ts.displayPartsToString(quickInfo.documentation);
return {
kind: quickInfo.kind,
kindModifiers: quickInfo.kindModifiers,
start: compilerService.host.positionToLineCol(file, quickInfo.textSpan.start),
end: compilerService.host.positionToLineCol(file, ts.textSpanEnd(quickInfo.textSpan)),
displayString: displayString,
documentation: docString,
};
}
getFormattingEditsForRange(line: number, col: number, endLine: number, endCol: number, fileName: string): protocol.CodeEdit[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var startPosition = compilerService.host.lineColToPosition(file, line, col);
var endPosition = compilerService.host.lineColToPosition(file, endLine, endCol);
// TODO: avoid duplicate code (with formatonkey)
var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition, compilerService.formatCodeOptions);
if (!edits) {
throw Errors.NoContent;
}
return edits.map((edit) => {
return {
start: compilerService.host.positionToLineCol(file, edit.span.start),
end: compilerService.host.positionToLineCol(file, ts.textSpanEnd(edit.span)),
newText: edit.newText ? edit.newText : ""
};
});
}
getFormattingEditsAfterKeystroke(line: number, col: number, key: string, fileName: string): protocol.CodeEdit[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var position = compilerService.host.lineColToPosition(file, line, col);
var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key,
compilerService.formatCodeOptions);
if ((key == "\n") && ((!edits) || (edits.length == 0) || allEditsBeforePos(edits, position))) {
// TODO: get these options from host
var editorOptions: ts.EditorOptions = {
IndentSize: 4,
TabSize: 4,
NewLineCharacter: "\n",
ConvertTabsToSpaces: true,
};
var indentPosition = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions);
var spaces = generateSpaces(indentPosition);
if (indentPosition > 0) {
edits.push({ span: ts.createTextSpanFromBounds(position, position), newText: spaces });
}
}
if (!edits) {
throw Errors.NoContent;
}
return edits.map((edit) => {
return {
start: compilerService.host.positionToLineCol(file,
edit.span.start),
end: compilerService.host.positionToLineCol(file,
ts.textSpanEnd(edit.span)),
newText: edit.newText ? edit.newText : ""
};
});
}
getCompletions(line: number, col: number, prefix: string, fileName: string): protocol.CompletionEntry[] {
if (!prefix) {
prefix = "";
}
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var position = compilerService.host.lineColToPosition(file, line, col);
var completions = compilerService.languageService.getCompletionsAtPosition(file, position);
if (!completions) {
throw Errors.NoContent;
}
return completions.entries.reduce((result: protocol.CompletionEntry[], entry: ts.CompletionEntry) => {
if (completions.isMemberCompletion || entry.name.indexOf(prefix) == 0) {
result.push(entry);
}
return result;
}, []);
}
getCompletionEntryDetails(line: number, col: number,
entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var position = compilerService.host.lineColToPosition(file, line, col);
return entryNames.reduce((accum: protocol.CompletionEntryDetails[], entryName: string) => {
var details = compilerService.languageService.getCompletionEntryDetails(file, position, entryName);
if (details) {
accum.push(details);
}
return accum;
}, []);
}
getDiagnostics(delay: number, fileNames: string[]) {
var checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => {
fileName = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(fileName);
if (project) {
accum.push({ fileName, project });
}
return accum;
}, []);
if (checkList.length > 0) {
this.updateErrorCheck(checkList, this.changeSeq,(n) => n == this.changeSeq, delay)
}
}
change(line: number, col: number, endLine: number, endCol: number, insertString: string, fileName: string) {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (project) {
var compilerService = project.compilerService;
var start = compilerService.host.lineColToPosition(file, line, col);
var end = compilerService.host.lineColToPosition(file, endLine, endCol);
if (start >= 0) {
compilerService.host.editScript(file, start, end, insertString);
this.changeSeq++;
}
}
}
reload(fileName: string, tempFileName: string, reqSeq = 0) {
var file = ts.normalizePath(fileName);
var tmpfile = ts.normalizePath(tempFileName);
var project = this.projectService.getProjectForFile(file);
if (project) {
this.changeSeq++;
// make sure no changes happen before this one is finished
project.compilerService.host.reloadScript(file, tmpfile,() => {
this.output(undefined, CommandNames.Reload, reqSeq);
});
}
}
saveToTmp(fileName: string, tempFileName: string) {
var file = ts.normalizePath(fileName);
var tmpfile = ts.normalizePath(tempFileName);
var project = this.projectService.getProjectForFile(file);
if (project) {
project.compilerService.host.saveTo(file, tmpfile);
}
}
closeClientFile(fileName: string) {
var file = ts.normalizePath(fileName);
this.projectService.closeClientFile(file);
}
decorateNavigationBarItem(project: Project, fileName: string, items: ts.NavigationBarItem[]): protocol.NavigationBarItem[] {
if (!items) {
return undefined;
}
var compilerService = project.compilerService;
return items.map(item => ({
text: item.text,
kind: item.kind,
kindModifiers: item.kindModifiers,
spans: item.spans.map(span => ({
start: compilerService.host.positionToLineCol(fileName, span.start),
end: compilerService.host.positionToLineCol(fileName, ts.textSpanEnd(span))
})),
childItems: this.decorateNavigationBarItem(project, fileName, item.childItems)
}));
}
getNavigationBarItems(fileName: string): protocol.NavigationBarItem[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var items = compilerService.languageService.getNavigationBarItems(file);
if (!items) {
throw Errors.NoContent;
}
return this.decorateNavigationBarItem(project, fileName, items);
}
getNavigateToItems(searchTerm: string, fileName: string): protocol.NavtoItem[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var navItems = sortNavItems(compilerService.languageService.getNavigateToItems(searchTerm));
if (!navItems) {
throw Errors.NoContent;
}
return navItems.map((navItem) => {
var start = compilerService.host.positionToLineCol(navItem.fileName, navItem.textSpan.start);
var end = compilerService.host.positionToLineCol(navItem.fileName, ts.textSpanEnd(navItem.textSpan));
var bakedItem: protocol.NavtoItem = {
name: navItem.name,
kind: navItem.kind,
file: navItem.fileName,
start: start,
end: end,
};
if (navItem.kindModifiers && (navItem.kindModifiers != "")) {
bakedItem.kindModifiers = navItem.kindModifiers;
}
if (navItem.matchKind != 'none') {
bakedItem.matchKind = navItem.matchKind;
}
if (navItem.containerName && (navItem.containerName.length > 0)) {
bakedItem.containerName = navItem.containerName;
}
if (navItem.containerKind && (navItem.containerKind.length > 0)) {
bakedItem.containerKind = navItem.containerKind;
}
return bakedItem;
});
}
getBraceMatching(line: number, col: number, fileName: string): protocol.TextSpan[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var position = compilerService.host.lineColToPosition(file, line, col);
var spans = compilerService.languageService.getBraceMatchingAtPosition(file, position);
if (!spans) {
throw Errors.NoContent;
}
return spans.map(span => ({
start: compilerService.host.positionToLineCol(file, span.start),
end: compilerService.host.positionToLineCol(file, span.start + span.length)
}));
}
onMessage(message: string) {
try {
var request = <protocol.Request>JSON.parse(message);
var response: any;
switch (request.command) {
case CommandNames.Definition: {
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
response = this.getDefinition(defArgs.line, defArgs.col, defArgs.file);
break;
}
case CommandNames.References: {
var refArgs = <protocol.FileLocationRequestArgs>request.arguments;
response = this.getReferences(refArgs.line, refArgs.col, refArgs.file);
break;
}
case CommandNames.Rename: {
var renameArgs = <protocol.RenameRequestArgs>request.arguments;
response = this.getRenameLocations(renameArgs.line, renameArgs.col, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings);
break;
}
case CommandNames.Open: {
var openArgs = <protocol.FileRequestArgs>request.arguments;
this.openClientFile(openArgs.file);
break;
}
case CommandNames.Quickinfo: {
var quickinfoArgs = <protocol.FileLocationRequestArgs>request.arguments;
response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.col, quickinfoArgs.file);
break;
}
case CommandNames.Format: {
var formatArgs = <protocol.FormatRequestArgs>request.arguments;
response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.col, formatArgs.endLine, formatArgs.endCol, formatArgs.file);
break;
}
case CommandNames.Formatonkey: {
var formatOnKeyArgs = <protocol.FormatOnKeyRequestArgs>request.arguments;
response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.col, formatOnKeyArgs.key, formatOnKeyArgs.file);
break;
}
case CommandNames.Completions: {
var completionsArgs = <protocol.CompletionsRequestArgs>request.arguments;
response = this.getCompletions(request.arguments.line, request.arguments.col, completionsArgs.prefix, request.arguments.file);
break;
}
case CommandNames.CompletionDetails: {
var completionDetailsArgs = <protocol.CompletionDetailsRequestArgs>request.arguments;
response = this.getCompletionEntryDetails(request.arguments.line, request.arguments.col, completionDetailsArgs.entryNames,
request.arguments.file);
break;
}
case CommandNames.Geterr: {
var geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files);
break;
}
case CommandNames.Change: {
var changeArgs = <protocol.ChangeRequestArgs>request.arguments;
this.change(changeArgs.line, changeArgs.col, changeArgs.endLine, changeArgs.endCol,
changeArgs.insertString, changeArgs.file);
break;
}
case CommandNames.Reload: {
var reloadArgs = <protocol.ReloadRequestArgs>request.arguments;
this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq);
break;
}
case CommandNames.Saveto: {
var savetoArgs = <protocol.SavetoRequestArgs>request.arguments;
this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile);
break;
}
case CommandNames.Close: {
var closeArgs = <protocol.FileRequestArgs>request.arguments;
this.closeClientFile(closeArgs.file);
break;
}
case CommandNames.Navto: {
var navtoArgs = <protocol.NavtoRequestArgs>request.arguments;
response = this.getNavigateToItems(navtoArgs.searchTerm, navtoArgs.file);
break;
}
case CommandNames.Brace: {
var braceArguments = <protocol.FileLocationRequestArgs>request.arguments;
response = this.getBraceMatching(braceArguments.line, braceArguments.col, braceArguments.file);
break;
}
case CommandNames.NavBar: {
var navBarArgs = <protocol.FileRequestArgs>request.arguments;
response = this.getNavigationBarItems(navBarArgs.file);
break;
}
default: {
this.projectService.log("Unrecognized JSON command: " + message);
this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command);
break;
}
}
if (response) {
this.output(response, request.command, request.seq);
}
} catch (err) {
if (err instanceof OperationCanceledException) {
// Handle cancellation exceptions
}
this.logError(err, message);
this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message);
}
}
}
}
+11 -8
View File
@@ -14,17 +14,17 @@ module ts.BreakpointResolver {
}
var tokenAtLocation = getTokenAtPosition(sourceFile, position);
var lineOfPosition = sourceFile.getLineAndCharacterFromPosition(position).line;
if (sourceFile.getLineAndCharacterFromPosition(tokenAtLocation.getStart()).line > lineOfPosition) {
var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) {
// Get previous token if the token is returned starts on new line
// eg: var x =10; |--- curser is here
// eg: var x =10; |--- cursor is here
// var y = 10;
// token at position will return var keyword on second line as the token but we would like to use
// token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line
tokenAtLocation = findPrecedingToken(tokenAtLocation.pos, sourceFile);
// Its a blank line
if (!tokenAtLocation || sourceFile.getLineAndCharacterFromPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
return undefined;
}
}
@@ -42,7 +42,7 @@ module ts.BreakpointResolver {
}
function spanInNodeIfStartsOnSameLine(node: Node, otherwiseOnNode?: Node): TextSpan {
if (node && lineOfPosition === sourceFile.getLineAndCharacterFromPosition(node.getStart()).line) {
if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) {
return spanInNode(node);
}
return spanInNode(otherwiseOnNode);
@@ -69,7 +69,7 @@ module ts.BreakpointResolver {
return textSpan(node);
}
if (node.parent.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>node.parent).operator === SyntaxKind.CommaToken) {
if (node.parent.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>node.parent).operatorToken.kind === SyntaxKind.CommaToken) {
// if this is comma expression, the breakpoint is possible in this expression
return textSpan(node);
}
@@ -151,8 +151,9 @@ module ts.BreakpointResolver {
return spanInForStatement(<ForStatement>node);
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
// span on for (a in ...)
return textSpan(node, findNextToken((<ForInStatement>node).expression, node));
return textSpan(node, findNextToken((<ForInStatement | ForOfStatement>node).expression, node));
case SyntaxKind.SwitchStatement:
// span on switch(...)
@@ -261,7 +262,8 @@ module ts.BreakpointResolver {
function spanInVariableDeclaration(variableDeclaration: VariableDeclaration): TextSpan {
// If declaration of for in statement, just set the span in parent
if (variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement) {
if (variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement ||
variableDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement) {
return spanInNode(variableDeclaration.parent.parent);
}
@@ -362,6 +364,7 @@ module ts.BreakpointResolver {
case SyntaxKind.WhileStatement:
case SyntaxKind.IfStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
// Set span on previous token if it starts on same line otherwise on the first statement of the block
+19 -19
View File
@@ -67,8 +67,8 @@ module ts.formatting {
}
export function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
var line = sourceFile.getLineAndCharacterFromPosition(position).line;
if (line === 1) {
var line = sourceFile.getLineAndCharacterOfPosition(position).line;
if (line === 0) {
return [];
}
// get the span for the previous\current line
@@ -100,7 +100,7 @@ module ts.formatting {
export function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
// format from the beginning of the line
var span = {
pos: getStartLinePositionForPosition(start, sourceFile),
pos: getLineStartPositionForPosition(start, sourceFile),
end: end
};
return formatSpan(span, sourceFile, options, rulesProvider, FormattingRequestKind.FormatSelection);
@@ -112,7 +112,7 @@ module ts.formatting {
return [];
}
var span = {
pos: getStartLinePositionForPosition(parent.getStart(sourceFile), sourceFile),
pos: getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile),
end: parent.end
};
return formatSpan(span, sourceFile, options, rulesProvider, requestKind);
@@ -283,7 +283,7 @@ module ts.formatting {
var previousLine = Constants.Unknown;
var childKind = SyntaxKind.Unknown;
while (n) {
var line = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)).line;
var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
if (previousLine !== Constants.Unknown && line !== previousLine) {
break;
}
@@ -327,7 +327,7 @@ module ts.formatting {
formattingScanner.advance();
if (formattingScanner.isOnToken()) {
var startLine = sourceFile.getLineAndCharacterFromPosition(enclosingNode.getStart(sourceFile)).line;
var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
processNode(enclosingNode, enclosingNode, startLine, initialIndentation, delta);
}
@@ -357,8 +357,8 @@ module ts.formatting {
}
}
else {
var startLine = sourceFile.getLineAndCharacterFromPosition(startPos).line;
var startLinePosition = getStartLinePositionForPosition(startPos, sourceFile);
var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line;
var startLinePosition = getLineStartPositionForPosition(startPos, sourceFile);
var column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options);
if (startLine !== parentStartLine || startPos === column) {
return column
@@ -521,7 +521,7 @@ module ts.formatting {
var childStartPos = child.getStart(sourceFile);
var childStart = sourceFile.getLineAndCharacterFromPosition(childStartPos);
var childStart = sourceFile.getLineAndCharacterOfPosition(childStartPos);
// if child is a list item - try to get its indentation
var childIndentationAmount = Constants.Unknown;
@@ -594,7 +594,7 @@ module ts.formatting {
}
else if (tokenInfo.token.kind === listStartToken) {
// consume list start token
startLine = sourceFile.getLineAndCharacterFromPosition(tokenInfo.token.pos).line;
startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
var indentation =
computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, startLine);
@@ -641,7 +641,7 @@ module ts.formatting {
var lineAdded: boolean;
var isTokenInRange = rangeContainsRange(originalRange, currentTokenInfo.token);
var tokenStart = sourceFile.getLineAndCharacterFromPosition(currentTokenInfo.token.pos);
var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
if (isTokenInRange) {
var rangeHasError = rangeContainsError(currentTokenInfo.token);
// save prevStartLine since processRange will overwrite this value with current ones
@@ -674,7 +674,7 @@ module ts.formatting {
continue;
}
var triviaStartLine = sourceFile.getLineAndCharacterFromPosition(triviaItem.pos).line;
var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line;
switch (triviaItem.kind) {
case SyntaxKind.MultiLineCommentTrivia:
var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
@@ -712,7 +712,7 @@ module ts.formatting {
for (var i = 0, len = trivia.length; i < len; ++i) {
var triviaItem = trivia[i];
if (isComment(triviaItem.kind) && rangeContainsRange(originalRange, triviaItem)) {
var triviaItemStart = sourceFile.getLineAndCharacterFromPosition(triviaItem.pos);
var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos);
processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation);
}
}
@@ -729,7 +729,7 @@ module ts.formatting {
if (!rangeHasError && !previousRangeHasError) {
if (!previousRange) {
// trim whitespaces starting from the beginning of the span up to the current line
var originalStart = sourceFile.getLineAndCharacterFromPosition(originalRange.pos);
var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos);
trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line);
}
else {
@@ -807,18 +807,18 @@ module ts.formatting {
recordReplace(pos, 0, indentationString);
}
else {
var tokenStart = sourceFile.getLineAndCharacterFromPosition(pos);
if (indentation !== tokenStart.character - 1) {
var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
if (indentation !== tokenStart.character) {
var startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
recordReplace(startLinePosition, tokenStart.character - 1, indentationString);
recordReplace(startLinePosition, tokenStart.character, indentationString);
}
}
}
function indentMultilineComment(commentRange: TextRange, indentation: number, firstLineIsIndented: boolean) {
// split comment in lines
var startLine = sourceFile.getLineAndCharacterFromPosition(commentRange.pos).line;
var endLine = sourceFile.getLineAndCharacterFromPosition(commentRange.end).line;
var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line;
var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line;
if (startLine === endLine) {
if (!firstLineIsIndented) {
+6 -6
View File
@@ -71,8 +71,8 @@ module ts.formatting {
public TokensAreOnSameLine(): boolean {
if (this.tokensAreOnSameLine === undefined) {
var startLine = this.sourceFile.getLineAndCharacterFromPosition(this.currentTokenSpan.pos).line;
var endLine = this.sourceFile.getLineAndCharacterFromPosition(this.nextTokenSpan.pos).line;
var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line;
var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line;
this.tokensAreOnSameLine = (startLine == endLine);
}
@@ -96,8 +96,8 @@ module ts.formatting {
}
private NodeIsOnOneLine(node: Node): boolean {
var startLine = this.sourceFile.getLineAndCharacterFromPosition(node.getStart(this.sourceFile)).line;
var endLine = this.sourceFile.getLineAndCharacterFromPosition(node.getEnd()).line;
var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line;
var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
return startLine == endLine;
}
@@ -105,8 +105,8 @@ module ts.formatting {
var openBrace = findChildOfKind(node, SyntaxKind.OpenBraceToken, this.sourceFile);
var closeBrace = findChildOfKind(node, SyntaxKind.CloseBraceToken, this.sourceFile);
if (openBrace && closeBrace) {
var startLine = this.sourceFile.getLineAndCharacterFromPosition(openBrace.getEnd()).line;
var endLine = this.sourceFile.getLineAndCharacterFromPosition(closeBrace.getStart(this.sourceFile)).line;
var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line;
var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line;
return startLine === endLine;
}
return false;
+11 -12
View File
@@ -93,17 +93,16 @@ module ts.formatting {
savedPos = scanner.getStartPos();
}
function shouldRescanGreaterThanToken(container: Node): boolean {
if (container.kind !== SyntaxKind.BinaryExpression) {
return false;
}
switch ((<BinaryExpression>container).operator) {
case SyntaxKind.GreaterThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
case SyntaxKind.GreaterThanGreaterThanToken:
return true;
function shouldRescanGreaterThanToken(node: Node): boolean {
if (node) {
switch (node.kind) {
case SyntaxKind.GreaterThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
case SyntaxKind.GreaterThanGreaterThanToken:
return true;
}
}
return false;
@@ -164,7 +163,7 @@ module ts.formatting {
if (expectedScanAction === ScanAction.RescanGreaterThanToken && currentToken === SyntaxKind.GreaterThanToken) {
currentToken = scanner.reScanGreaterToken();
Debug.assert((<BinaryExpression>n).operator === currentToken);
Debug.assert(n.kind === currentToken);
lastScanAction = ScanAction.RescanGreaterThanToken;
}
else if (expectedScanAction === ScanAction.RescanSlashToken && startsWithSlashToken(currentToken)) {
+4
View File
@@ -464,6 +464,9 @@ module ts.formatting {
// "in" keyword in for (var x in []) { }
case SyntaxKind.ForInStatement:
return context.currentTokenSpan.kind === SyntaxKind.InKeyword || context.nextTokenSpan.kind === SyntaxKind.InKeyword;
// Technically, "of" is not a binary operator, but format it the same way as "in"
case SyntaxKind.ForOfStatement:
return context.currentTokenSpan.kind === SyntaxKind.OfKeyword || context.nextTokenSpan.kind === SyntaxKind.OfKeyword;
}
return false;
}
@@ -592,6 +595,7 @@ module ts.formatting {
case SyntaxKind.SwitchStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.TryStatement:
case SyntaxKind.DoStatement:
+8 -8
View File
@@ -24,7 +24,7 @@ module ts.formatting {
return 0;
}
var lineAtPosition = sourceFile.getLineAndCharacterFromPosition(position).line;
var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
if (precedingToken.kind === SyntaxKind.CommaToken && precedingToken.parent.kind !== SyntaxKind.BinaryExpression) {
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
@@ -74,7 +74,7 @@ module ts.formatting {
}
export function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number {
var start = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile));
var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options);
}
@@ -135,10 +135,10 @@ module ts.formatting {
function getParentStart(parent: Node, child: Node, sourceFile: SourceFile): LineAndCharacter {
var containingList = getContainingList(child, sourceFile);
if (containingList) {
return sourceFile.getLineAndCharacterFromPosition(containingList.pos);
return sourceFile.getLineAndCharacterOfPosition(containingList.pos);
}
return sourceFile.getLineAndCharacterFromPosition(parent.getStart(sourceFile));
return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile));
}
/*
@@ -204,7 +204,7 @@ module ts.formatting {
}
function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter {
return sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile));
return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
}
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean {
@@ -279,7 +279,6 @@ module ts.formatting {
}
}
function deriveActualIndentationFromList(list: Node[], index: number, sourceFile: SourceFile, options: EditorOptions): number {
Debug.assert(index >= 0 && index < list.length);
var node = list[index];
@@ -292,7 +291,7 @@ module ts.formatting {
continue;
}
// skip list items that ends on the same line with the current list element
var prevEndLine = sourceFile.getLineAndCharacterFromPosition(list[i].end).line;
var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line;
if (prevEndLine !== lineAndCharacter.line) {
return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options);
}
@@ -303,7 +302,7 @@ module ts.formatting {
}
function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter: LineAndCharacter, sourceFile: SourceFile, options: EditorOptions): number {
var lineStart = sourceFile.getPositionFromLineAndCharacter(lineAndCharacter.line, 1);
var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options);
}
@@ -359,6 +358,7 @@ module ts.formatting {
case SyntaxKind.DoStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.IfStatement:
case SyntaxKind.FunctionDeclaration:
+2 -2
View File
@@ -126,7 +126,7 @@ module ts.formatting {
static AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([SyntaxKind.MultiLineCommentTrivia]));
static Keywords = TokenRange.FromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword);
static BinaryOperators = TokenRange.FromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator);
static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword]);
static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword]);
static UnaryPrefixOperators = TokenRange.FromTokens([SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken]);
static UnaryPrefixExpressions = TokenRange.FromTokens([SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
static UnaryPreincrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
@@ -134,7 +134,7 @@ module ts.formatting {
static UnaryPredecrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
static UnaryPostdecrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword]);
static Comments = TokenRange.FromTokens([SyntaxKind.SingleLineCommentTrivia, SyntaxKind.MultiLineCommentTrivia]);
static TypeNames = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.NumberKeyword, SyntaxKind.StringKeyword, SyntaxKind.BooleanKeyword, SyntaxKind.VoidKeyword, SyntaxKind.AnyKeyword]);
static TypeNames = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.NumberKeyword, SyntaxKind.StringKeyword, SyntaxKind.BooleanKeyword, SyntaxKind.SymbolKeyword, SyntaxKind.VoidKeyword, SyntaxKind.AnyKeyword]);
}
}
}
+117
View File
@@ -0,0 +1,117 @@
module ts.NavigateTo {
type RawNavigateToItem = { name: string; fileName: string; matchKind: MatchKind; declaration: Declaration };
enum MatchKind {
none = 0,
exact = 1,
substring = 2,
prefix = 3
}
export function getNavigateToItems(program: Program, cancellationToken: CancellationTokenObject, searchValue: string, maxResultCount: number): NavigateToItem[]{
// Split search value in terms array
var terms = searchValue.split(" ");
// default NavigateTo approach: if search term contains only lower-case chars - use case-insensitive search, otherwise switch to case-sensitive version
var searchTerms = map(terms, t => ({ caseSensitive: hasAnyUpperCaseCharacter(t), term: t }));
var rawItems: RawNavigateToItem[] = [];
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
forEach(program.getSourceFiles(), sourceFile => {
cancellationToken.throwIfCancellationRequested();
var fileName = sourceFile.fileName;
var declarations = sourceFile.getNamedDeclarations();
for (var i = 0, n = declarations.length; i < n; i++) {
var declaration = declarations[i];
// TODO(jfreeman): Skip this declaration if it has a computed name
var name = (<Identifier>declaration.name).text;
var matchKind = getMatchKind(searchTerms, name);
if (matchKind !== MatchKind.none) {
rawItems.push({ name, fileName, matchKind, declaration });
}
}
});
rawItems.sort(compareNavigateToItems);
if (maxResultCount !== undefined) {
rawItems = rawItems.slice(0, maxResultCount);
}
var items = map(rawItems, createNavigateToItem);
return items;
// This means "compare in a case insensitive manner."
var baseSensitivity: Intl.CollatorOptions = { sensitivity: "base" };
function compareNavigateToItems(i1: RawNavigateToItem, i2: RawNavigateToItem) {
// TODO(cyrusn): get the gamut of comparisons that VS already uses here.
// Right now we just sort by kind first, and then by name of the item.
// We first sort case insensitively. So "Aaa" will come before "bar".
// Then we sort case sensitively, so "aaa" will come before "Aaa".
return i1.matchKind - i2.matchKind ||
i1.name.localeCompare(i2.name, undefined, baseSensitivity) ||
i1.name.localeCompare(i2.name);
}
function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem {
var declaration = rawItem.declaration;
var container = <Declaration>getContainerNode(declaration);
return {
name: rawItem.name,
kind: getNodeKind(declaration),
kindModifiers: getNodeModifiers(declaration),
matchKind: MatchKind[rawItem.matchKind],
fileName: rawItem.fileName,
textSpan: createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()),
// TODO(jfreeman): What should be the containerName when the container has a computed name?
containerName: container && container.name ? (<Identifier>container.name).text : "",
containerKind: container && container.name ? getNodeKind(container) : ""
};
}
function hasAnyUpperCaseCharacter(s: string): boolean {
for (var i = 0, n = s.length; i < n; i++) {
var c = s.charCodeAt(i);
if ((CharacterCodes.A <= c && c <= CharacterCodes.Z) ||
(c >= CharacterCodes.maxAsciiCharacter && s.charAt(i).toLocaleLowerCase() !== s.charAt(i))) {
return true;
}
}
return false;
}
function getMatchKind(searchTerms: { caseSensitive: boolean; term: string }[], name: string): MatchKind {
var matchKind = MatchKind.none;
if (name) {
for (var j = 0, n = searchTerms.length; j < n; j++) {
var searchTerm = searchTerms[j];
var nameToSearch = searchTerm.caseSensitive ? name : name.toLocaleLowerCase();
// in case of case-insensitive search searchTerm.term will already be lower-cased
var index = nameToSearch.indexOf(searchTerm.term);
if (index < 0) {
// Didn't match.
return MatchKind.none;
}
var termKind = MatchKind.substring;
if (index === 0) {
// here we know that match occur at the beginning of the string.
// if search term and declName has the same length - we have an exact match, otherwise declName have longer length and this will be prefix match
termKind = name.length === searchTerm.term.length ? MatchKind.exact : MatchKind.prefix;
}
// Update our match kind if we don't have one, or if this match is better.
if (matchKind === MatchKind.none || termKind < matchKind) {
matchKind = termKind;
}
}
}
return matchKind;
}
}
}
+11 -5
View File
@@ -97,8 +97,7 @@ module ts.NavigationBar {
function sortNodes(nodes: Node[]): Node[] {
return nodes.slice(0).sort((n1: Declaration, n2: Declaration) => {
if (n1.name && n2.name) {
// TODO(jfreeman): How do we sort declarations with computed names?
return (<Identifier>n1.name).text.localeCompare((<Identifier>n2.name).text);
return getPropertyNameForPropertyNameNode(n1.name).localeCompare(getPropertyNameForPropertyNameNode(n2.name));
}
else if (n1.name) {
return 1;
@@ -426,7 +425,7 @@ module ts.NavigationBar {
// Add the constructor parameters in as children of the class (for property parameters).
// Note that *all* parameters will be added to the nodes array, but parameters that
// are not properties will be filtered out later by createChildItem.
var nodes: Node[] = removeComputedProperties(node);
var nodes: Node[] = removeDynamicallyNamedProperties(node);
if (constructor) {
nodes.push.apply(nodes, constructor.parameters);
}
@@ -455,7 +454,7 @@ module ts.NavigationBar {
}
function createIterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem);
var childItems = getItemsWorker(sortNodes(removeDynamicallyNamedProperties(node)), createChildItem);
return getNavigationBarItem(
node.name.text,
ts.ScriptElementKind.interfaceElement,
@@ -466,10 +465,17 @@ module ts.NavigationBar {
}
}
function removeComputedProperties(node: ClassDeclaration | InterfaceDeclaration | EnumDeclaration): Declaration[] {
function removeComputedProperties(node: EnumDeclaration): Declaration[] {
return filter<Declaration>(node.members, member => member.name === undefined || member.name.kind !== SyntaxKind.ComputedPropertyName);
}
/**
* Like removeComputedProperties, but retains the properties with well known symbol names
*/
function removeDynamicallyNamedProperties(node: ClassDeclaration | InterfaceDeclaration): Declaration[]{
return filter<Declaration>(node.members, member => !hasDynamicName(member));
}
function getInnermostModule(node: ModuleDeclaration): ModuleDeclaration {
while (node.body.kind === SyntaxKind.ModuleDeclaration) {
node = <ModuleDeclaration>node.body;
@@ -61,6 +61,7 @@ module ts {
// to be the entire span of the parent.
if (parent.kind === SyntaxKind.DoStatement ||
parent.kind === SyntaxKind.ForInStatement ||
parent.kind === SyntaxKind.ForOfStatement ||
parent.kind === SyntaxKind.ForStatement ||
parent.kind === SyntaxKind.IfStatement ||
parent.kind === SyntaxKind.WhileStatement ||
+813
View File
@@ -0,0 +1,813 @@
module ts {
// Note(cyrusn): this enum is ordered from strongest match type to weakest match type.
export enum PatternMatchKind {
Exact,
Prefix,
Substring,
CamelCase
}
// Information about a match made by the pattern matcher between a candidate and the
// search pattern.
export interface PatternMatch {
// What kind of match this was. Exact matches are better than prefix matches which are
// better than substring matches which are better than CamelCase matches.
kind: PatternMatchKind;
// If this was a camel case match, how strong the match is. Higher number means
// it was a better match.
camelCaseWeight?: number;
// If this was a match where all constituent parts of the candidate and search pattern
// matched case sensitively or case insensitively. Case sensitive matches of the kind
// are better matches than insensitive matches.
isCaseSensitive: boolean;
// Whether or not this match occurred with the punctuation from the search pattern stripped
// out or not. Matches without the punctuation stripped are better than ones with punctuation
// stripped.
punctuationStripped: boolean;
}
// The pattern matcher maintains an internal cache of information as it is used. Therefore,
// you should not keep it around forever and should get and release the matcher appropriately
// once you no longer need it.
export interface PatternMatcher {
// Used to match a candidate against the last segment of a possibly dotted pattern. This
// is useful as a quick check to prevent having to compute a container before calling
// "getMatches".
//
// For example, if the search pattern is "ts.c.SK" and the candidate is "SyntaxKind", then
// this will return a successful match, having only tested "SK" against "SyntaxKind". At
// that point a call can be made to 'getMatches("SyntaxKind", "ts.compiler")', with the
// work to create 'ts.compiler' only being done once the first match succeeded.
getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[];
// Fully checks a candidate, with an dotted container, against the search pattern.
// The candidate must match the last part of the search pattern, and the dotted container
// must match the preceding segments of the pattern.
getMatches(candidate: string, dottedContainer: string): PatternMatch[];
// Whether or not the pattern contained dots or not. Clients can use this to determine
// If they should call getMatches, or if getMatchesForLastSegmentOfPattern is sufficient.
patternContainsDots: boolean;
}
// First we break up the pattern given by dots. Each portion of the pattern between the
// dots is a 'Segment'. The 'Segment' contains information about the entire section of
// text between the dots, as well as information about any individual 'Words' that we
// can break the segment into. A 'Word' is simply a contiguous sequence of characters
// that can appear in a typescript identifier. So "GetKeyword" would be one word, while
// "Get Keyword" would be two words. Once we have the individual 'words', we break those
// into constituent 'character spans' of interest. For example, while 'UIElement' is one
// word, it make character spans corresponding to "U", "I" and "Element". These spans
// are then used when doing camel cased matches against candidate patterns.
interface Segment {
// Information about the entire piece of text between the dots. For example, if the
// text between the dots is 'GetKeyword', then TotalTextChunk.Text will be 'GetKeyword' and
// TotalTextChunk.CharacterSpans will correspond to 'Get', 'Keyword'.
totalTextChunk: TextChunk;
// Information about the subwords compromising the total word. For example, if the
// text between the dots is 'GetFoo KeywordBar', then the subwords will be 'GetFoo'
// and 'KeywordBar'. Those individual words will have CharacterSpans of ('Get' and
// 'Foo') and('Keyword' and 'Bar') respectively.
subWordTextChunks: TextChunk[];
}
// Information about a chunk of text from the pattern. The chunk is a piece of text, with
// cached information about the character spans within in. Character spans are used for
// camel case matching.
interface TextChunk {
// The text of the chunk. This should be a contiguous sequence of character that could
// occur in a symbol name.
text: string;
// The text of a chunk in lower case. Cached because it is needed often to check for
// case insensitive matches.
textLowerCase: string;
// Whether or not this chunk is entirely lowercase. We have different rules when searching
// for something entirely lowercase or not.
isLowerCase: boolean;
// The spans in this text chunk that we think are of interest and should be matched
// independently. For example, if the chunk is for "UIElement" the the spans of interest
// correspond to "U", "I" and "Element". If "UIElement" isn't found as an exaxt, prefix.
// or substring match, then the character spans will be used to attempt a camel case match.
characterSpans: TextSpan[];
}
function createPatternMatch(kind: PatternMatchKind, punctuationStripped: boolean, isCaseSensitive: boolean, camelCaseWeight?: number): PatternMatch {
return {
kind,
punctuationStripped,
isCaseSensitive,
camelCaseWeight
};
}
export function createPatternMatcher(pattern: string): PatternMatcher {
// We'll often see the same candidate string many times when searching (For example, when
// we see the name of a module that is used everywhere, or the name of an overload). As
// such, we cache the information we compute about the candidate for the life of this
// pattern matcher so we don't have to compute it multiple times.
var stringToWordSpans: Map<TextSpan[]> = {};
pattern = pattern.trim();
var fullPatternSegment = createSegment(pattern);
var dotSeparatedSegments = pattern.split(".").map(p => createSegment(p.trim()));
var invalidPattern = dotSeparatedSegments.length === 0 || forEach(dotSeparatedSegments, segmentIsInvalid);
return {
getMatches,
getMatchesForLastSegmentOfPattern,
patternContainsDots: dotSeparatedSegments.length > 1
};
// Quick checks so we can bail out when asked to match a candidate.
function skipMatch(candidate: string) {
return invalidPattern || !candidate;
}
function getMatchesForLastSegmentOfPattern(candidate: string): PatternMatch[] {
if (skipMatch(candidate)) {
return undefined;
}
return matchSegment(candidate, lastOrUndefined(dotSeparatedSegments));
}
function getMatches(candidate: string, dottedContainer: string): PatternMatch[] {
if (skipMatch(candidate)) {
return undefined;
}
// First, check that the last part of the dot separated pattern matches the name of the
// candidate. If not, then there's no point in proceeding and doing the more
// expensive work.
var candidateMatch = matchSegment(candidate, lastOrUndefined(dotSeparatedSegments));
if (!candidateMatch) {
return undefined;
}
dottedContainer = dottedContainer || "";
var containerParts = dottedContainer.split(".");
// -1 because the last part was checked against the name, and only the rest
// of the parts are checked against the container.
if (dotSeparatedSegments.length - 1 > containerParts.length) {
// There weren't enough container parts to match against the pattern parts.
// So this definitely doesn't match.
return null;
}
// So far so good. Now break up the container for the candidate and check if all
// the dotted parts match up correctly.
var totalMatch = candidateMatch;
for (var i = dotSeparatedSegments.length - 2, j = containerParts.length - 1;
i >= 0;
i--, j--) {
var segment = dotSeparatedSegments[i];
var containerName = containerParts[j];
var containerMatch = matchSegment(containerName, segment);
if (!containerMatch) {
// This container didn't match the pattern piece. So there's no match at all.
return undefined;
}
addRange(totalMatch, containerMatch);
}
// Success, this symbol's full name matched against the dotted name the user was asking
// about.
return totalMatch;
}
function getWordSpans(word: string): TextSpan[] {
if (!hasProperty(stringToWordSpans, word)) {
stringToWordSpans[word] = breakIntoWordSpans(word);
}
return stringToWordSpans[word];
}
function matchTextChunk(candidate: string, chunk: TextChunk, punctuationStripped: boolean): PatternMatch {
var index = indexOfIgnoringCase(candidate, chunk.textLowerCase);
if (index === 0) {
if (chunk.text.length === candidate.length) {
// a) Check if the part matches the candidate entirely, in an case insensitive or
// sensitive manner. If it does, return that there was an exact match.
return createPatternMatch(PatternMatchKind.Exact, punctuationStripped, /*isCaseSensitive:*/ candidate === chunk.text);
}
else {
// b) Check if the part is a prefix of the candidate, in a case insensitive or sensitive
// manner. If it does, return that there was a prefix match.
return createPatternMatch(PatternMatchKind.Prefix, punctuationStripped, /*isCaseSensitive:*/ startsWith(candidate, chunk.text));
}
}
var isLowercase = chunk.isLowerCase;
if (isLowercase) {
if (index > 0) {
// c) If the part is entirely lowercase, then check if it is contained anywhere in the
// candidate in a case insensitive manner. If so, return that there was a substring
// match.
//
// Note: We only have a substring match if the lowercase part is prefix match of some
// word part. That way we don't match something like 'Class' when the user types 'a'.
// But we would match 'FooAttribute' (since 'Attribute' starts with 'a').
var wordSpans = getWordSpans(candidate);
for (var i = 0, n = wordSpans.length; i < n; i++) {
var span = wordSpans[i]
if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) {
return createPatternMatch(PatternMatchKind.Substring, punctuationStripped,
/*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false));
}
}
}
}
else {
// d) If the part was not entirely lowercase, then check if it is contained in the
// candidate in a case *sensitive* manner. If so, return that there was a substring
// match.
if (candidate.indexOf(chunk.text) > 0) {
return createPatternMatch(PatternMatchKind.Substring, punctuationStripped, /*isCaseSensitive:*/ true);
}
}
if (!isLowercase) {
// e) If the part was not entirely lowercase, then attempt a camel cased match as well.
if (chunk.characterSpans.length > 0) {
var candidateParts = getWordSpans(candidate);
var camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ false);
if (camelCaseWeight !== undefined) {
return createPatternMatch(PatternMatchKind.CamelCase, punctuationStripped, /*isCaseSensitive:*/ true, /*camelCaseWeight:*/ camelCaseWeight);
}
camelCaseWeight = tryCamelCaseMatch(candidate, candidateParts, chunk, /*ignoreCase:*/ true);
if (camelCaseWeight !== undefined) {
return createPatternMatch(PatternMatchKind.CamelCase, punctuationStripped, /*isCaseSensitive:*/ false, /*camelCaseWeight:*/ camelCaseWeight);
}
}
}
if (isLowercase) {
// f) Is the pattern a substring of the candidate starting on one of the candidate's word boundaries?
// We could check every character boundary start of the candidate for the pattern. However, that's
// an m * n operation in the wost case. Instead, find the first instance of the pattern
// substring, and see if it starts on a capital letter. It seems unlikely that the user will try to
// filter the list based on a substring that starts on a capital letter and also with a lowercase one.
// (Pattern: fogbar, Candidate: quuxfogbarFogBar).
if (chunk.text.length < candidate.length) {
if (index > 0 && isUpperCaseLetter(candidate.charCodeAt(index))) {
return createPatternMatch(PatternMatchKind.Substring, punctuationStripped, /*isCaseSensitive:*/ false);
}
}
}
return undefined;
}
function containsSpaceOrAsterisk(text: string): boolean {
for (var i = 0; i < text.length; i++) {
var ch = text.charCodeAt(i);
if (ch === CharacterCodes.space || ch === CharacterCodes.asterisk) {
return true;
}
}
return false;
}
function matchSegment(candidate: string, segment: Segment): PatternMatch[] {
// First check if the segment matches as is. This is also useful if the segment contains
// characters we would normally strip when splitting into parts that we also may want to
// match in the candidate. For example if the segment is "@int" and the candidate is
// "@int", then that will show up as an exact match here.
//
// Note: if the segment contains a space or an asterisk then we must assume that it's a
// multi-word segment.
if (!containsSpaceOrAsterisk(segment.totalTextChunk.text)) {
var match = matchTextChunk(candidate, segment.totalTextChunk, /*punctuationStripped:*/ false);
if (match) {
return [match];
}
}
// The logic for pattern matching is now as follows:
//
// 1) Break the segment passed in into words. Breaking is rather simple and a
// good way to think about it that if gives you all the individual alphanumeric words
// of the pattern.
//
// 2) For each word try to match the word against the candidate value.
//
// 3) Matching is as follows:
//
// a) Check if the word matches the candidate entirely, in an case insensitive or
// sensitive manner. If it does, return that there was an exact match.
//
// b) Check if the word is a prefix of the candidate, in a case insensitive or
// sensitive manner. If it does, return that there was a prefix match.
//
// c) If the word is entirely lowercase, then check if it is contained anywhere in the
// candidate in a case insensitive manner. If so, return that there was a substring
// match.
//
// Note: We only have a substring match if the lowercase part is prefix match of
// some word part. That way we don't match something like 'Class' when the user
// types 'a'. But we would match 'FooAttribute' (since 'Attribute' starts with
// 'a').
//
// d) If the word was not entirely lowercase, then check if it is contained in the
// candidate in a case *sensitive* manner. If so, return that there was a substring
// match.
//
// e) If the word was not entirely lowercase, then attempt a camel cased match as
// well.
//
// f) The word is all lower case. Is it a case insensitive substring of the candidate starting
// on a part boundary of the candidate?
//
// Only if all words have some sort of match is the pattern considered matched.
var subWordTextChunks = segment.subWordTextChunks;
var matches: PatternMatch[] = undefined;
for (var i = 0, n = subWordTextChunks.length; i < n; i++) {
var subWordTextChunk = subWordTextChunks[i];
// Try to match the candidate with this word
var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true);
if (!result) {
return undefined;
}
matches = matches || [];
matches.push(result);
}
return matches;
}
function partStartsWith(candidate: string, candidateSpan: TextSpan, pattern: string, ignoreCase: boolean, patternSpan?: TextSpan): boolean {
var patternPartStart = patternSpan ? patternSpan.start : 0;
var patternPartLength = patternSpan ? patternSpan.length : pattern.length;
if (patternPartLength > candidateSpan.length) {
// Pattern part is longer than the candidate part. There can never be a match.
return false;
}
if (ignoreCase) {
for (var i = 0; i < patternPartLength; i++) {
var ch1 = pattern.charCodeAt(patternPartStart + i);
var ch2 = candidate.charCodeAt(candidateSpan.start + i);
if (toLowerCase(ch1) !== toLowerCase(ch2)) {
return false;
}
}
}
else {
for (var i = 0; i < patternPartLength; i++) {
var ch1 = pattern.charCodeAt(patternPartStart + i);
var ch2 = candidate.charCodeAt(candidateSpan.start + i);
if (ch1 !== ch2) {
return false;
}
}
}
return true;
}
function tryCamelCaseMatch(candidate: string, candidateParts: TextSpan[], chunk: TextChunk, ignoreCase: boolean): number {
var chunkCharacterSpans = chunk.characterSpans;
// Note: we may have more pattern parts than candidate parts. This is because multiple
// pattern parts may match a candidate part. For example "SiUI" against "SimpleUI".
// We'll have 3 pattern parts Si/U/I against two candidate parts Simple/UI. However, U
// and I will both match in UI.
var currentCandidate = 0;
var currentChunkSpan = 0;
var firstMatch: number = undefined;
var contiguous: boolean = undefined;
while (true) {
// Let's consider our termination cases
if (currentChunkSpan === chunkCharacterSpans.length) {
// We did match! We shall assign a weight to this
var weight = 0;
// Was this contiguous?
if (contiguous) {
weight += 1;
}
// Did we start at the beginning of the candidate?
if (firstMatch === 0) {
weight += 2;
}
return weight;
}
else if (currentCandidate === candidateParts.length) {
// No match, since we still have more of the pattern to hit
return undefined;
}
var candidatePart = candidateParts[currentCandidate];
var gotOneMatchThisCandidate = false;
// Consider the case of matching SiUI against SimpleUIElement. The candidate parts
// will be Simple/UI/Element, and the pattern parts will be Si/U/I. We'll match 'Si'
// against 'Simple' first. Then we'll match 'U' against 'UI'. However, we want to
// still keep matching pattern parts against that candidate part.
for (; currentChunkSpan < chunkCharacterSpans.length; currentChunkSpan++) {
var chunkCharacterSpan = chunkCharacterSpans[currentChunkSpan];
if (gotOneMatchThisCandidate) {
// We've already gotten one pattern part match in this candidate. We will
// only continue trying to consumer pattern parts if the last part and this
// part are both upper case.
if (!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan - 1].start)) ||
!isUpperCaseLetter(chunk.text.charCodeAt(chunkCharacterSpans[currentChunkSpan].start))) {
break;
}
}
if (!partStartsWith(candidate, candidatePart, chunk.text, ignoreCase, chunkCharacterSpan)) {
break;
}
gotOneMatchThisCandidate = true;
firstMatch = firstMatch === undefined ? currentCandidate : firstMatch;
// If we were contiguous, then keep that value. If we weren't, then keep that
// value. If we don't know, then set the value to 'true' as an initial match is
// obviously contiguous.
contiguous = contiguous === undefined ? true : contiguous;
candidatePart = createTextSpan(candidatePart.start + chunkCharacterSpan.length, candidatePart.length - chunkCharacterSpan.length);
}
// Check if we matched anything at all. If we didn't, then we need to unset the
// contiguous bit if we currently had it set.
// If we haven't set the bit yet, then that means we haven't matched anything so
// far, and we don't want to change that.
if (!gotOneMatchThisCandidate && contiguous !== undefined) {
contiguous = false;
}
// Move onto the next candidate.
currentCandidate++;
}
}
}
// Helper function to compare two matches to determine which is better. Matches are first
// ordered by kind (so all prefix matches always beat all substring matches). Then, if the
// match is a camel case match, the relative weights of hte match are used to determine
// which is better (with a greater weight being better). Then if the match is of the same
// type, then a case sensitive match is considered better than an insensitive one.
function patternMatchCompareTo(match1: PatternMatch, match2: PatternMatch): number {
return compareType(match1, match2) ||
compareCamelCase(match1, match2) ||
compareCase(match1, match2) ||
comparePunctuation(match1, match2);
}
function comparePunctuation(result1: PatternMatch, result2: PatternMatch) {
// Consider a match to be better if it was successful without stripping punctuation
// versus a match that had to strip punctuation to succeed.
if (result1.punctuationStripped !== result2.punctuationStripped) {
return result1.punctuationStripped ? 1 : -1;
}
return 0;
}
function compareCase(result1: PatternMatch, result2: PatternMatch) {
if (result1.isCaseSensitive !== result2.isCaseSensitive) {
return result1.isCaseSensitive ? -1 : 1;
}
return 0;
}
function compareType(result1: PatternMatch, result2: PatternMatch) {
return result1.kind - result2.kind;
}
function compareCamelCase(result1: PatternMatch, result2: PatternMatch) {
if (result1.kind === PatternMatchKind.CamelCase && result2.kind === PatternMatchKind.CamelCase) {
// Swap the values here. If result1 has a higher weight, then we want it to come
// first.
return result2.camelCaseWeight - result1.camelCaseWeight;
}
return 0;
}
function createSegment(text: string): Segment {
return {
totalTextChunk: createTextChunk(text),
subWordTextChunks: breakPatternIntoTextChunks(text)
}
}
// A segment is considered invalid if we couldn't find any words in it.
function segmentIsInvalid(segment: Segment) {
return segment.subWordTextChunks.length === 0;
}
function isUpperCaseLetter(ch: number) {
// Fast check for the ascii range.
if (ch >= CharacterCodes.A && ch <= CharacterCodes.Z) {
return true;
}
if (ch < CharacterCodes.maxAsciiCharacter || !isUnicodeIdentifierStart(ch, ScriptTarget.Latest)) {
return false;
}
// TODO: find a way to determine this for any unicode characters in a
// non-allocating manner.
var str = String.fromCharCode(ch);
return str === str.toUpperCase();
}
function isLowerCaseLetter(ch: number) {
// Fast check for the ascii range.
if (ch >= CharacterCodes.a && ch <= CharacterCodes.z) {
return true;
}
if (ch < CharacterCodes.maxAsciiCharacter || !isUnicodeIdentifierStart(ch, ScriptTarget.Latest)) {
return false;
}
// TODO: find a way to determine this for any unicode characters in a
// non-allocating manner.
var str = String.fromCharCode(ch);
return str === str.toLowerCase();
}
function containsUpperCaseLetter(string: string): boolean {
for (var i = 0, n = string.length; i < n; i++) {
if (isUpperCaseLetter(string.charCodeAt(i))) {
return true;
}
}
return false;
}
function startsWith(string: string, search: string) {
for (var i = 0, n = search.length; i < n; i++) {
if (string.charCodeAt(i) !== search.charCodeAt(i)) {
return false;
}
}
return true;
}
// Assumes 'value' is already lowercase.
function indexOfIgnoringCase(string: string, value: string): number {
for (var i = 0, n = string.length - value.length; i <= n; i++) {
if (startsWithIgnoringCase(string, value, i)) {
return i;
}
}
return -1;
}
// Assumes 'value' is already lowercase.
function startsWithIgnoringCase(string: string, value: string, start: number): boolean {
for (var i = 0, n = value.length; i < n; i++) {
var ch1 = toLowerCase(string.charCodeAt(i + start));
var ch2 = value.charCodeAt(i);
if (ch1 !== ch2) {
return false;
}
}
return true;
}
function toLowerCase(ch: number): number {
// Fast convert for the ascii range.
if (ch >= CharacterCodes.A && ch <= CharacterCodes.Z) {
return CharacterCodes.a + (ch - CharacterCodes.A);
}
if (ch < CharacterCodes.maxAsciiCharacter) {
return ch;
}
// TODO: find a way to compute this for any unicode characters in a
// non-allocating manner.
return String.fromCharCode(ch).toLowerCase().charCodeAt(0);
}
function isDigit(ch: number) {
// TODO(cyrusn): Find a way to support this for unicode digits.
return ch >= CharacterCodes._0 && ch <= CharacterCodes._9;
}
function isWordChar(ch: number) {
return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === CharacterCodes._ || ch === CharacterCodes.$;
}
function breakPatternIntoTextChunks(pattern: string): TextChunk[] {
var result: TextChunk[] = [];
var wordStart = 0;
var wordLength = 0;
for (var i = 0; i < pattern.length; i++) {
var ch = pattern.charCodeAt(i);
if (isWordChar(ch)) {
if (wordLength++ === 0) {
wordStart = i;
}
}
else {
if (wordLength > 0) {
result.push(createTextChunk(pattern.substr(wordStart, wordLength)));
wordLength = 0;
}
}
}
if (wordLength > 0) {
result.push(createTextChunk(pattern.substr(wordStart, wordLength)));
}
return result;
}
function createTextChunk(text: string): TextChunk {
var textLowerCase = text.toLowerCase();
return {
text,
textLowerCase,
isLowerCase: text === textLowerCase,
characterSpans: breakIntoCharacterSpans(text)
}
}
/* @internal */ export function breakIntoCharacterSpans(identifier: string): TextSpan[] {
return breakIntoSpans(identifier, /*word:*/ false);
}
/* @internal */ export function breakIntoWordSpans(identifier: string): TextSpan[] {
return breakIntoSpans(identifier, /*word:*/ true);
}
function breakIntoSpans(identifier: string, word: boolean): TextSpan[] {
var result: TextSpan[] = [];
var wordStart = 0;
for (var i = 1, n = identifier.length; i < n; i++) {
var lastIsDigit = isDigit(identifier.charCodeAt(i - 1));
var currentIsDigit = isDigit(identifier.charCodeAt(i));
var hasTransitionFromLowerToUpper = transitionFromLowerToUpper(identifier, word, i);
var hasTransitionFromUpperToLower = transitionFromUpperToLower(identifier, word, i, wordStart);
if (charIsPunctuation(identifier.charCodeAt(i - 1)) ||
charIsPunctuation(identifier.charCodeAt(i)) ||
lastIsDigit != currentIsDigit ||
hasTransitionFromLowerToUpper ||
hasTransitionFromUpperToLower) {
if (!isAllPunctuation(identifier, wordStart, i)) {
result.push(createTextSpan(wordStart, i - wordStart));
}
wordStart = i;
}
}
if (!isAllPunctuation(identifier, wordStart, identifier.length)) {
result.push(createTextSpan(wordStart, identifier.length - wordStart));
}
return result;
}
function charIsPunctuation(ch: number) {
switch (ch) {
case CharacterCodes.exclamation:
case CharacterCodes.doubleQuote:
case CharacterCodes.hash:
case CharacterCodes.percent:
case CharacterCodes.ampersand:
case CharacterCodes.singleQuote:
case CharacterCodes.openParen:
case CharacterCodes.closeParen:
case CharacterCodes.asterisk:
case CharacterCodes.comma:
case CharacterCodes.minus:
case CharacterCodes.dot:
case CharacterCodes.slash:
case CharacterCodes.colon:
case CharacterCodes.semicolon:
case CharacterCodes.question:
case CharacterCodes.at:
case CharacterCodes.openBracket:
case CharacterCodes.backslash:
case CharacterCodes.closeBracket:
case CharacterCodes._:
case CharacterCodes.openBrace:
case CharacterCodes.closeBrace:
return true;
}
return false;
}
function isAllPunctuation(identifier: string, start: number, end: number): boolean {
for (var i = start; i < end; i++) {
var ch = identifier.charCodeAt(i);
// We don't consider _ or $ as punctuation as there may be things with that name.
if (!charIsPunctuation(ch) || ch === CharacterCodes._ || ch === CharacterCodes.$) {
return false;
}
}
return true;
}
function transitionFromUpperToLower(identifier: string, word: boolean, index: number, wordStart: number): boolean {
if (word) {
// Cases this supports:
// 1) IDisposable -> I, Disposable
// 2) UIElement -> UI, Element
// 3) HTMLDocument -> HTML, Document
//
// etc.
if (index != wordStart &&
index + 1 < identifier.length) {
var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
var nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1));
if (currentIsUpper && nextIsLower) {
// We have a transition from an upper to a lower letter here. But we only
// want to break if all the letters that preceded are uppercase. i.e. if we
// have "Foo" we don't want to break that into "F, oo". But if we have
// "IFoo" or "UIFoo", then we want to break that into "I, Foo" and "UI,
// Foo". i.e. the last uppercase letter belongs to the lowercase letters
// that follows. Note: this will make the following not split properly:
// "HELLOthere". However, these sorts of names do not show up in .Net
// programs.
for (var i = wordStart; i < index; i++) {
if (!isUpperCaseLetter(identifier.charCodeAt(i))) {
return false;
}
}
return true;
}
}
}
return false;
}
function transitionFromLowerToUpper(identifier: string, word: boolean, index: number): boolean {
var lastIsUpper = isUpperCaseLetter(identifier.charCodeAt(index - 1));
var currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
// See if the casing indicates we're starting a new word. Note: if we're breaking on
// words, then just seeing an upper case character isn't enough. Instead, it has to
// be uppercase and the previous character can't be uppercase.
//
// For example, breaking "AddMetadata" on words would make: Add Metadata
//
// on characters would be: A dd M etadata
//
// Break "AM" on words would be: AM
//
// on characters would be: A M
//
// We break the search string on characters. But we break the symbol name on words.
var transition = word
? (currentIsUpper && !lastIsUpper)
: currentIsUpper;
return transition;
}
}
+224 -190
View File
@@ -2,14 +2,15 @@
/// <reference path='breakpoints.ts' />
/// <reference path='outliningElementsCollector.ts' />
/// <reference path='navigateTo.ts' />
/// <reference path='navigationBar.ts' />
/// <reference path='patternMatcher.ts' />
/// <reference path='signatureHelp.ts' />
/// <reference path='utilities.ts' />
/// <reference path='formatting\formatting.ts' />
/// <reference path='formatting\smartIndenter.ts' />
module ts {
export var servicesVersion = "0.4"
export interface Node {
@@ -61,9 +62,9 @@ module ts {
scriptSnapshot: IScriptSnapshot;
nameTable: Map<string>;
getNamedDeclarations(): Declaration[];
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionFromLineAndCharacter(line: number, character: number): number;
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
@@ -612,7 +613,7 @@ module ts {
}
if (paramHelpStringMargin === undefined) {
paramHelpStringMargin = sourceFile.getLineAndCharacterFromPosition(firstLineParamHelpStringPos).character - 1;
paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character;
}
// Now consume white spaces max
@@ -725,7 +726,7 @@ module ts {
public statements: NodeArray<Statement>;
public endOfFileToken: Node;
public amdDependencies: string[];
public amdDependencies: {name: string; path: string}[];
public amdModuleName: string;
public referencedFiles: FileReference[];
@@ -750,16 +751,16 @@ module ts {
return updateSourceFile(this, newText, textChangeRange);
}
public getLineAndCharacterFromPosition(position: number): LineAndCharacter {
return getLineAndCharacterOfPosition(this, position);
public getLineAndCharacterOfPosition(position: number): LineAndCharacter {
return ts.getLineAndCharacterOfPosition(this, position);
}
public getLineStarts(): number[] {
return getLineStarts(this);
}
public getPositionFromLineAndCharacter(line: number, character: number): number {
return getPositionFromLineAndCharacter(this, line, character);
public getPositionOfLineAndCharacter(line: number, character: number): number {
return ts.getPositionOfLineAndCharacter(this, line, character);
}
public getNamedDeclarations() {
@@ -900,7 +901,7 @@ module ts {
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string): NavigateToItem[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
@@ -991,6 +992,7 @@ module ts {
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number| string;
}
export interface DefinitionInfo {
@@ -1143,6 +1145,9 @@ module ts {
InMultiLineCommentTrivia,
InSingleQuoteStringLiteral,
InDoubleQuoteStringLiteral,
InTemplateHeadOrNoSubstitutionTemplate,
InTemplateMiddleOrTail,
InTemplateSubstitutionPosition,
}
export enum TokenClass {
@@ -1168,7 +1173,26 @@ module ts {
}
export interface Classifier {
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
}
/**
@@ -1355,13 +1379,6 @@ module ts {
public static typeAlias = "type alias name";
}
enum MatchKind {
none = 0,
exact = 1,
substring = 2,
prefix = 3
}
/// Language Service
interface CompletionSession {
@@ -1969,6 +1986,62 @@ module ts {
});
}
/* @internal */ export function getContainerNode(node: Node): Node {
while (true) {
node = node.parent;
if (!node) {
return undefined;
}
switch (node.kind) {
case SyntaxKind.SourceFile:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ModuleDeclaration:
return node;
}
}
}
/* @internal */ export function getNodeKind(node: Node): string {
switch (node.kind) {
case SyntaxKind.ModuleDeclaration: return ScriptElementKind.moduleElement;
case SyntaxKind.ClassDeclaration: return ScriptElementKind.classElement;
case SyntaxKind.InterfaceDeclaration: return ScriptElementKind.interfaceElement;
case SyntaxKind.TypeAliasDeclaration: return ScriptElementKind.typeElement;
case SyntaxKind.EnumDeclaration: return ScriptElementKind.enumElement;
case SyntaxKind.VariableDeclaration:
return isConst(node)
? ScriptElementKind.constElement
: isLet(node)
? ScriptElementKind.letElement
: ScriptElementKind.variableElement;
case SyntaxKind.FunctionDeclaration: return ScriptElementKind.functionElement;
case SyntaxKind.GetAccessor: return ScriptElementKind.memberGetAccessorElement;
case SyntaxKind.SetAccessor: return ScriptElementKind.memberSetAccessorElement;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
return ScriptElementKind.memberFunctionElement;
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
return ScriptElementKind.memberVariableElement;
case SyntaxKind.IndexSignature: return ScriptElementKind.indexSignatureElement;
case SyntaxKind.ConstructSignature: return ScriptElementKind.constructSignatureElement;
case SyntaxKind.CallSignature: return ScriptElementKind.callSignatureElement;
case SyntaxKind.Constructor: return ScriptElementKind.constructorImplementationElement;
case SyntaxKind.TypeParameter: return ScriptElementKind.typeParameterElement;
case SyntaxKind.EnumMember: return ScriptElementKind.variableElement;
case SyntaxKind.Parameter: return (node.flags & NodeFlags.AccessibilityModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
}
return ScriptElementKind.unknown;
}
export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry()): LanguageService {
var syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host);
var ruleProvider: formatting.RulesProvider;
@@ -2699,29 +2772,6 @@ module ts {
}
}
function getContainerNode(node: Node): Node {
while (true) {
node = node.parent;
if (!node) {
return undefined;
}
switch (node.kind) {
case SyntaxKind.SourceFile:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ModuleDeclaration:
return node;
}
}
}
// TODO(drosen): use contextual SemanticMeaning.
function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker, location: Node): string {
var flags = symbol.getFlags();
@@ -2808,39 +2858,6 @@ module ts {
return ScriptElementKind.unknown;
}
function getNodeKind(node: Node): string {
switch (node.kind) {
case SyntaxKind.ModuleDeclaration: return ScriptElementKind.moduleElement;
case SyntaxKind.ClassDeclaration: return ScriptElementKind.classElement;
case SyntaxKind.InterfaceDeclaration: return ScriptElementKind.interfaceElement;
case SyntaxKind.TypeAliasDeclaration: return ScriptElementKind.typeElement;
case SyntaxKind.EnumDeclaration: return ScriptElementKind.enumElement;
case SyntaxKind.VariableDeclaration:
return isConst(node)
? ScriptElementKind.constElement
: isLet(node)
? ScriptElementKind.letElement
: ScriptElementKind.variableElement;
case SyntaxKind.FunctionDeclaration: return ScriptElementKind.functionElement;
case SyntaxKind.GetAccessor: return ScriptElementKind.memberGetAccessorElement;
case SyntaxKind.SetAccessor: return ScriptElementKind.memberSetAccessorElement;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
return ScriptElementKind.memberFunctionElement;
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
return ScriptElementKind.memberVariableElement;
case SyntaxKind.IndexSignature: return ScriptElementKind.indexSignatureElement;
case SyntaxKind.ConstructSignature: return ScriptElementKind.constructSignatureElement;
case SyntaxKind.CallSignature: return ScriptElementKind.callSignatureElement;
case SyntaxKind.Constructor: return ScriptElementKind.constructorImplementationElement;
case SyntaxKind.TypeParameter: return ScriptElementKind.typeParameterElement;
case SyntaxKind.EnumMember: return ScriptElementKind.variableElement;
case SyntaxKind.Parameter: return (node.flags & NodeFlags.AccessibilityModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
}
return ScriptElementKind.unknown;
}
function getSymbolModifiers(symbol: Symbol): string {
return symbol && symbol.declarations && symbol.declarations.length > 0
? getNodeModifiers(symbol.declarations[0])
@@ -3419,7 +3436,9 @@ module ts {
}
break;
case SyntaxKind.ForKeyword:
if (hasKind(node.parent, SyntaxKind.ForStatement) || hasKind(node.parent, SyntaxKind.ForInStatement)) {
if (hasKind(node.parent, SyntaxKind.ForStatement) ||
hasKind(node.parent, SyntaxKind.ForInStatement) ||
hasKind(node.parent, SyntaxKind.ForOfStatement)) {
return getLoopBreakContinueOccurrences(<IterationStatement>node.parent);
}
break;
@@ -3696,6 +3715,7 @@ module ts {
switch (owner.kind) {
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.DoStatement:
case SyntaxKind.WhileStatement:
return getLoopBreakContinueOccurrences(<IterationStatement>owner)
@@ -3740,6 +3760,7 @@ module ts {
// Fall through.
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.DoStatement:
if (!statement.label || isLabeledBy(node, statement.label.text)) {
@@ -4627,7 +4648,7 @@ module ts {
return true;
}
else if (parent.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>parent).left === node) {
var operator = (<BinaryExpression>parent).operator;
var operator = (<BinaryExpression>parent).operatorToken.kind;
return SyntaxKind.FirstAssignment <= operator && operator <= SyntaxKind.LastAssignment;
}
}
@@ -4636,89 +4657,10 @@ module ts {
}
/// NavigateTo
function getNavigateToItems(searchValue: string): NavigateToItem[] {
function getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[] {
synchronizeHostData();
// Split search value in terms array
var terms = searchValue.split(" ");
// default NavigateTo approach: if search term contains only lower-case chars - use case-insensitive search, otherwise switch to case-sensitive version
var searchTerms = map(terms, t => ({ caseSensitive: hasAnyUpperCaseCharacter(t), term: t }));
var items: NavigateToItem[] = [];
// Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
forEach(program.getSourceFiles(), sourceFile => {
cancellationToken.throwIfCancellationRequested();
var fileName = sourceFile.fileName;
var declarations = sourceFile.getNamedDeclarations();
for (var i = 0, n = declarations.length; i < n; i++) {
var declaration = declarations[i];
// TODO(jfreeman): Skip this declaration if it has a computed name
var name = (<Identifier>declaration.name).text;
var matchKind = getMatchKind(searchTerms, name);
if (matchKind !== MatchKind.none) {
var container = <Declaration>getContainerNode(declaration);
items.push({
name: name,
kind: getNodeKind(declaration),
kindModifiers: getNodeModifiers(declaration),
matchKind: MatchKind[matchKind],
fileName: fileName,
textSpan: createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()),
// TODO(jfreeman): What should be the containerName when the container has a computed name?
containerName: container && container.name ? (<Identifier>container.name).text : "",
containerKind: container && container.name ? getNodeKind(container) : ""
});
}
}
});
return items;
function hasAnyUpperCaseCharacter(s: string): boolean {
for (var i = 0, n = s.length; i < n; i++) {
var c = s.charCodeAt(i);
if ((CharacterCodes.A <= c && c <= CharacterCodes.Z) ||
(c >= CharacterCodes.maxAsciiCharacter && s.charAt(i).toLocaleLowerCase() !== s.charAt(i))) {
return true;
}
}
return false;
}
function getMatchKind(searchTerms: { caseSensitive: boolean; term: string }[], name: string): MatchKind {
var matchKind = MatchKind.none;
if (name) {
for (var j = 0, n = searchTerms.length; j < n; j++) {
var searchTerm = searchTerms[j];
var nameToSearch = searchTerm.caseSensitive ? name : name.toLocaleLowerCase();
// in case of case-insensitive search searchTerm.term will already be lower-cased
var index = nameToSearch.indexOf(searchTerm.term);
if (index < 0) {
// Didn't match.
return MatchKind.none;
}
var termKind = MatchKind.substring;
if (index === 0) {
// here we know that match occur at the beginning of the string.
// if search term and declName has the same length - we have an exact match, otherwise declName have longer length and this will be prefix match
termKind = name.length === searchTerm.term.length ? MatchKind.exact : MatchKind.prefix;
}
// Update our match kind if we don't have one, or if this match is better.
if (matchKind === MatchKind.none || termKind < matchKind) {
matchKind = termKind;
}
}
}
return matchKind;
}
return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount);
}
function containErrors(diagnostics: Diagnostic[]): boolean {
@@ -5518,11 +5460,13 @@ module ts {
var declarations = symbol.getDeclarations();
if (declarations && declarations.length > 0) {
// Disallow rename for elements that are defined in the standard TypeScript library.
var defaultLibFile = getDefaultLibFileName(host.getCompilationSettings());
for (var i = 0; i < declarations.length; i++) {
var sourceFile = declarations[i].getSourceFile();
if (sourceFile && endsWith(sourceFile.fileName, defaultLibFile)) {
return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key));
var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings());
if (defaultLibFileName) {
for (var i = 0; i < declarations.length; i++) {
var sourceFile = declarations[i].getSourceFile();
if (sourceFile && getCanonicalFileName(ts.normalizePath(sourceFile.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) {
return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key));
}
}
}
@@ -5544,10 +5488,6 @@ module ts {
return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_this_element.key));
function endsWith(string: string, value: string): boolean {
return string.lastIndexOf(value) + value.length === string.length;
}
function getRenameInfoError(localizedErrorMessage: string): RenameInfo {
return {
canRename: false,
@@ -5617,6 +5557,28 @@ module ts {
noRegexTable[SyntaxKind.TrueKeyword] = true;
noRegexTable[SyntaxKind.FalseKeyword] = true;
// Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact)
// classification on template strings. Because of the context free nature of templates,
// the only precise way to classify a template portion would be by propagating the stack across
// lines, just as we do with the end-of-line state. However, this is a burden for implementers,
// and the behavior is entirely subsumed by the syntactic classifier anyway, so we instead
// flatten any nesting when the template stack is non-empty and encode it in the end-of-line state.
// Situations in which this fails are
// 1) When template strings are nested across different lines:
// `hello ${ `world
// ` }`
//
// Where on the second line, you will get the closing of a template,
// a closing curly, and a new template.
//
// 2) When substitution expressions have curly braces and the curly brace falls on the next line:
// `hello ${ () => {
// return "world" } } `
//
// Where on the second line, you will get the 'return' keyword,
// a string literal, and a template end consisting of '} } `'.
var templateStack: SyntaxKind[] = [];
function isAccessibilityModifier(kind: SyntaxKind) {
switch (kind) {
case SyntaxKind.PublicKeyword:
@@ -5636,7 +5598,7 @@ module ts {
keyword2 === SyntaxKind.ConstructorKeyword ||
keyword2 === SyntaxKind.StaticKeyword) {
// Allow things like "public get", "public constructor" and "public static".
// Allow things like "public get", "public constructor" and "public static".
// These are all legal.
return true;
}
@@ -5650,13 +5612,19 @@ module ts {
// if there are more cases we want the classifier to be better at.
return true;
}
// 'classifyKeywordsInGenerics' should be 'true' when a syntactic classifier is not present.
function getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult {
// If there is a syntactic classifier ('syntacticClassifierAbsent' is false),
// we will be more conservative in order to avoid conflicting with the syntactic classifier.
function getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult {
var offset = 0;
var token = SyntaxKind.Unknown;
var lastNonTriviaToken = SyntaxKind.Unknown;
// Empty out the template stack for reuse.
while (templateStack.length > 0) {
templateStack.pop();
}
// If we're in a string literal, then prepend: "\
// (and a newline). That way when we lex we'll think we're still in a string literal.
//
@@ -5675,6 +5643,17 @@ module ts {
text = "/*\n" + text;
offset = 3;
break;
case EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate:
text = "`\n" + text;
offset = 2;
break;
case EndOfLineState.InTemplateMiddleOrTail:
text = "}\n" + text;
offset = 2;
// fallthrough
case EndOfLineState.InTemplateSubstitutionPosition:
templateStack.push(SyntaxKind.TemplateHead);
break;
}
scanner.setText(text);
@@ -5715,36 +5694,70 @@ module ts {
}
}
else if (lastNonTriviaToken === SyntaxKind.DotToken && isKeyword(token)) {
token = SyntaxKind.Identifier;
token = SyntaxKind.Identifier;
}
else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) {
// We have two keywords in a row. Only treat the second as a keyword if
// it's a sequence that could legally occur in the language. Otherwise
// treat it as an identifier. This way, if someone writes "private var"
// we recognize that 'var' is actually an identifier here.
token = SyntaxKind.Identifier;
// We have two keywords in a row. Only treat the second as a keyword if
// it's a sequence that could legally occur in the language. Otherwise
// treat it as an identifier. This way, if someone writes "private var"
// we recognize that 'var' is actually an identifier here.
token = SyntaxKind.Identifier;
}
else if (lastNonTriviaToken === SyntaxKind.Identifier &&
token === SyntaxKind.LessThanToken) {
// Could be the start of something generic. Keep track of that by bumping
// up the current count of generic contexts we may be in.
angleBracketStack++;
// Could be the start of something generic. Keep track of that by bumping
// up the current count of generic contexts we may be in.
angleBracketStack++;
}
else if (token === SyntaxKind.GreaterThanToken && angleBracketStack > 0) {
// If we think we're currently in something generic, then mark that that
// generic entity is complete.
angleBracketStack--;
// If we think we're currently in something generic, then mark that that
// generic entity is complete.
angleBracketStack--;
}
else if (token === SyntaxKind.AnyKeyword ||
token === SyntaxKind.StringKeyword ||
token === SyntaxKind.NumberKeyword ||
token === SyntaxKind.BooleanKeyword) {
if (angleBracketStack > 0 && !classifyKeywordsInGenerics) {
// If it looks like we're could be in something generic, don't classify this
// as a keyword. We may just get overwritten by the syntactic classifier,
// causing a noisy experience for the user.
token = SyntaxKind.Identifier;
}
token === SyntaxKind.BooleanKeyword ||
token === SyntaxKind.SymbolKeyword) {
if (angleBracketStack > 0 && !syntacticClassifierAbsent) {
// If it looks like we're could be in something generic, don't classify this
// as a keyword. We may just get overwritten by the syntactic classifier,
// causing a noisy experience for the user.
token = SyntaxKind.Identifier;
}
}
else if (token === SyntaxKind.TemplateHead) {
templateStack.push(token);
}
else if (token === SyntaxKind.OpenBraceToken) {
// If we don't have anything on the template stack,
// then we aren't trying to keep track of a previously scanned template head.
if (templateStack.length > 0) {
templateStack.push(token);
}
}
else if (token === SyntaxKind.CloseBraceToken) {
// If we don't have anything on the template stack,
// then we aren't trying to keep track of a previously scanned template head.
if (templateStack.length > 0) {
var lastTemplateStackToken = lastOrUndefined(templateStack);
if (lastTemplateStackToken === SyntaxKind.TemplateHead) {
token = scanner.reScanTemplateToken();
// Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us.
if (token === SyntaxKind.TemplateTail) {
templateStack.pop();
}
else {
Debug.assert(token === SyntaxKind.TemplateMiddle, "Should have been a template middle. Was " + token);
}
}
else {
Debug.assert(lastTemplateStackToken === SyntaxKind.OpenBraceToken, "Should have been an open brace. Was: " + token);
templateStack.pop();
}
}
}
lastNonTriviaToken = token;
@@ -5789,6 +5802,22 @@ module ts {
result.finalLexState = EndOfLineState.InMultiLineCommentTrivia;
}
}
else if (isTemplateLiteralKind(token)) {
if (scanner.isUnterminated()) {
if (token === SyntaxKind.TemplateTail) {
result.finalLexState = EndOfLineState.InTemplateMiddleOrTail;
}
else if (token === SyntaxKind.NoSubstitutionTemplateLiteral) {
result.finalLexState = EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate;
}
else {
Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token);
}
}
}
else if (templateStack.length > 0 && lastOrUndefined(templateStack) === SyntaxKind.TemplateHead) {
result.finalLexState = EndOfLineState.InTemplateSubstitutionPosition;
}
}
}
@@ -5844,7 +5873,8 @@ module ts {
case SyntaxKind.EqualsToken:
case SyntaxKind.CommaToken:
return true;
default: return false;
default:
return false;
}
}
@@ -5889,9 +5919,13 @@ module ts {
case SyntaxKind.SingleLineCommentTrivia:
return TokenClass.Comment;
case SyntaxKind.WhitespaceTrivia:
case SyntaxKind.NewLineTrivia:
return TokenClass.Whitespace;
case SyntaxKind.Identifier:
default:
if (isTemplateLiteralKind(token)) {
return TokenClass.StringLiteral;
}
return TokenClass.Identifier;
}
}
+6 -9
View File
@@ -138,7 +138,7 @@ module ts {
* Returns a JSON-encoded value of the type:
* { name: string; kind: string; kindModifiers: string; containerName: string; containerKind: string; matchKind: string; fileName: string; textSpan: { start: number; length: number}; } [] = [];
*/
getNavigateToItems(searchValue: string): string;
getNavigateToItems(searchValue: string, maxResultCount?: number): string;
/**
* Returns a JSON-encoded value of the type:
@@ -165,7 +165,7 @@ module ts {
}
export interface ClassifierShim extends Shim {
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): string;
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string;
}
export interface CoreServicesShim extends Shim {
@@ -274,10 +274,7 @@ module ts {
}
public getDefaultLibFileName(options: CompilerOptions): string {
// Shim the API changes for 1.5 release. This should be removed once
// TypeScript 1.5 has shipped.
return "";
//return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
}
}
@@ -631,11 +628,11 @@ module ts {
/// NAVIGATE TO
/** Return a list of symbols that are interesting to navigate to */
public getNavigateToItems(searchValue: string): string {
public getNavigateToItems(searchValue: string, maxResultCount?: number): string {
return this.forwardJSONCall(
"getNavigateToItems('" + searchValue + "')",
"getNavigateToItems('" + searchValue + "', " + maxResultCount+ ")",
() => {
var items = this.languageService.getNavigateToItems(searchValue);
var items = this.languageService.getNavigateToItems(searchValue, maxResultCount);
return items;
});
}
+2 -2
View File
@@ -295,8 +295,8 @@ module ts.SignatureHelp {
var tagExpression = <TaggedTemplateExpression>templateExpression.parent;
Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression);
// If we're just after a template tail, don't show signature help.
if (node.kind === SyntaxKind.TemplateTail && position >= node.getEnd() && !(<LiteralExpression>node).isUnterminated) {
// If we're just after a template tail, don't show signature help.
if (node.kind === SyntaxKind.TemplateTail && !isInsideTemplateLiteral(<LiteralExpression>node, position)) {
return undefined;
}
+6 -12
View File
@@ -6,12 +6,11 @@ module ts {
}
export function getEndLinePosition(line: number, sourceFile: SourceFile): number {
Debug.assert(line >= 1);
Debug.assert(line >= 0);
var lineStarts = sourceFile.getLineStarts();
// lines returned by SourceFile.getLineAndCharacterForPosition are 1-based
var lineIndex = line - 1;
if (lineIndex === lineStarts.length - 1) {
var lineIndex = line;
if (lineIndex + 1 === lineStarts.length) {
// last line - return EOF
return sourceFile.text.length - 1;
}
@@ -32,15 +31,10 @@ module ts {
}
}
export function getStartPositionOfLine(line: number, sourceFile: SourceFile): number {
Debug.assert(line >= 1);
return sourceFile.getLineStarts()[line - 1];
}
export function getStartLinePositionForPosition(position: number, sourceFile: SourceFile): number {
export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number {
var lineStarts = sourceFile.getLineStarts();
var line = sourceFile.getLineAndCharacterFromPosition(position).line;
return lineStarts[line - 1];
var line = sourceFile.getLineAndCharacterOfPosition(position).line;
return lineStarts[line];
}
export function rangeContainsRange(r1: TextRange, r2: TextRange): boolean {
+1 -3
View File
@@ -30,9 +30,7 @@ var Board = (function () {
function Board() {
}
Board.prototype.allShipsSunk = function () {
return this.ships.every(function (val) {
return val.isSunk;
});
return this.ships.every(function (val) { return val.isSunk; });
};
return Board;
})();
+154 -121
View File
@@ -21,8 +21,8 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
allDiagnostics.forEach(diagnostic => {
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
});
var exitCode = emitResult.emitSkipped ? 1 : 0;
@@ -181,118 +181,121 @@ declare module "typescript" {
NumberKeyword = 119,
SetKeyword = 120,
StringKeyword = 121,
TypeKeyword = 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,
ContinueStatement = 181,
BreakStatement = 182,
ReturnStatement = 183,
WithStatement = 184,
SwitchStatement = 185,
LabeledStatement = 186,
ThrowStatement = 187,
TryStatement = 188,
DebuggerStatement = 189,
VariableDeclaration = 190,
VariableDeclarationList = 191,
FunctionDeclaration = 192,
ClassDeclaration = 193,
InterfaceDeclaration = 194,
TypeAliasDeclaration = 195,
EnumDeclaration = 196,
ModuleDeclaration = 197,
ModuleBlock = 198,
ImportEqualsDeclaration = 199,
ImportDeclaration = 200,
ImportClause = 201,
NamespaceImport = 202,
NamedImports = 203,
ImportSpecifier = 204,
ExportAssignment = 205,
ExportDeclaration = 206,
NamedExports = 207,
ExportSpecifier = 208,
ExternalModuleReference = 209,
CaseClause = 210,
DefaultClause = 211,
HeritageClause = 212,
CatchClause = 213,
PropertyAssignment = 214,
ShorthandPropertyAssignment = 215,
EnumMember = 216,
SourceFile = 217,
SyntaxList = 218,
Count = 219,
SymbolKeyword = 122,
TypeKeyword = 123,
OfKeyword = 124,
QualifiedName = 125,
ComputedPropertyName = 126,
TypeParameter = 127,
Parameter = 128,
PropertySignature = 129,
PropertyDeclaration = 130,
MethodSignature = 131,
MethodDeclaration = 132,
Constructor = 133,
GetAccessor = 134,
SetAccessor = 135,
CallSignature = 136,
ConstructSignature = 137,
IndexSignature = 138,
TypeReference = 139,
FunctionType = 140,
ConstructorType = 141,
TypeQuery = 142,
TypeLiteral = 143,
ArrayType = 144,
TupleType = 145,
UnionType = 146,
ParenthesizedType = 147,
ObjectBindingPattern = 148,
ArrayBindingPattern = 149,
BindingElement = 150,
ArrayLiteralExpression = 151,
ObjectLiteralExpression = 152,
PropertyAccessExpression = 153,
ElementAccessExpression = 154,
CallExpression = 155,
NewExpression = 156,
TaggedTemplateExpression = 157,
TypeAssertionExpression = 158,
ParenthesizedExpression = 159,
FunctionExpression = 160,
ArrowFunction = 161,
DeleteExpression = 162,
TypeOfExpression = 163,
VoidExpression = 164,
PrefixUnaryExpression = 165,
PostfixUnaryExpression = 166,
BinaryExpression = 167,
ConditionalExpression = 168,
TemplateExpression = 169,
YieldExpression = 170,
SpreadElementExpression = 171,
OmittedExpression = 172,
TemplateSpan = 173,
Block = 174,
VariableStatement = 175,
EmptyStatement = 176,
ExpressionStatement = 177,
IfStatement = 178,
DoStatement = 179,
WhileStatement = 180,
ForStatement = 181,
ForInStatement = 182,
ForOfStatement = 183,
ContinueStatement = 184,
BreakStatement = 185,
ReturnStatement = 186,
WithStatement = 187,
SwitchStatement = 188,
LabeledStatement = 189,
ThrowStatement = 190,
TryStatement = 191,
DebuggerStatement = 192,
VariableDeclaration = 193,
VariableDeclarationList = 194,
FunctionDeclaration = 195,
ClassDeclaration = 196,
InterfaceDeclaration = 197,
TypeAliasDeclaration = 198,
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
LastReservedWord = 100,
FirstKeyword = 65,
LastKeyword = 122,
LastKeyword = 124,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 137,
LastTypeNode = 145,
FirstTypeNode = 139,
LastTypeNode = 147,
FirstPunctuation = 14,
LastPunctuation = 63,
FirstToken = 0,
LastToken = 122,
LastToken = 124,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@@ -301,7 +304,7 @@ declare module "typescript" {
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 123,
FirstNode = 125,
}
const enum NodeFlags {
Export = 1,
@@ -534,7 +537,7 @@ declare module "typescript" {
}
interface BinaryExpression extends Expression {
left: Expression;
operator: SyntaxKind;
operatorToken: Node;
right: Expression;
}
interface ConditionalExpression extends Expression {
@@ -632,6 +635,10 @@ declare module "typescript" {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface ForOfStatement extends IterationStatement {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface BreakOrContinueStatement extends Statement {
label?: Identifier;
}
@@ -762,7 +769,10 @@ declare module "typescript" {
endOfFileToken: Node;
fileName: string;
text: string;
amdDependencies: string[];
amdDependencies: {
path: string;
name: string;
}[];
amdModuleName: string;
referencedFiles: FileReference[];
hasNoDefaultLib: boolean;
@@ -1070,8 +1080,9 @@ declare module "typescript" {
ObjectLiteral = 131072,
ContainsUndefinedOrNull = 262144,
ContainsObjectLiteral = 524288,
Intrinsic = 127,
Primitive = 510,
ESSymbol = 1048576,
Intrinsic = 1048703,
Primitive = 1049086,
StringLike = 258,
NumberLike = 132,
ObjectType = 48128,
@@ -1357,6 +1368,7 @@ declare module "typescript" {
equals = 61,
exclamation = 33,
greaterThan = 62,
hash = 35,
lessThan = 60,
minus = 45,
openBrace = 123,
@@ -1423,8 +1435,8 @@ declare module "typescript" {
}
function tokenToString(t: SyntaxKind): string;
function computeLineStarts(text: string): number[];
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getLineStarts(sourceFile: SourceFile): number[];
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
line: number;
@@ -1508,9 +1520,9 @@ declare module "typescript" {
scriptSnapshot: IScriptSnapshot;
nameTable: Map<string>;
getNamedDeclarations(): Declaration[];
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionFromLineAndCharacter(line: number, character: number): number;
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
/**
@@ -1572,7 +1584,7 @@ declare module "typescript" {
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string): NavigateToItem[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
@@ -1647,6 +1659,7 @@ declare module "typescript" {
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number | string;
}
interface DefinitionInfo {
fileName: string;
@@ -1780,6 +1793,9 @@ declare module "typescript" {
InMultiLineCommentTrivia = 1,
InSingleQuoteStringLiteral = 2,
InDoubleQuoteStringLiteral = 3,
InTemplateHeadOrNoSubstitutionTemplate = 4,
InTemplateMiddleOrTail = 5,
InTemplateSubstitutionPosition = 6,
}
enum TokenClass {
Punctuation = 0,
@@ -1801,7 +1817,26 @@ declare module "typescript" {
classification: TokenClass;
}
interface Classifier {
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
}
/**
* The document registry represents a store of SourceFile objects that can be shared between
@@ -1963,8 +1998,8 @@ function compile(fileNames, options) {
var emitResult = program.emit();
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
allDiagnostics.forEach(function (diagnostic) {
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
console.log(diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL));
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
console.log(diagnostic.file.fileName + " (" + (lineChar.line + 1) + "," + (lineChar.character + 1) + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL));
});
var exitCode = emitResult.emitSkipped ? 1 : 0;
console.log("Process exiting with code '" + exitCode + "'.");
@@ -1972,8 +2007,6 @@ function compile(fileNames, options) {
}
exports.compile = compile;
compile(process.argv.slice(2), {
noEmitOnError: true,
noImplicitAny: true,
target: 1 /* ES5 */,
module: 1 /* CommonJS */
noEmitOnError: true, noImplicitAny: true,
target: 1 /* ES5 */, module: 1 /* CommonJS */
});
+200 -131
View File
@@ -56,27 +56,27 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
>diagnostics : ts.Diagnostic[]
allDiagnostics.forEach(diagnostic => {
>allDiagnostics.forEach(diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); }) : void
>allDiagnostics.forEach(diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); }) : void
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>allDiagnostics : ts.Diagnostic[]
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); } : (diagnostic: ts.Diagnostic) => void
>diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); } : (diagnostic: ts.Diagnostic) => void
>diagnostic : ts.Diagnostic
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
>lineChar : ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start) : ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.start : number
>diagnostic : ts.Diagnostic
>start : number
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
>console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`) : any
console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
>console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`) : any
>console.log : any
>console : any
>log : any
@@ -85,9 +85,11 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>fileName : string
>lineChar.line + 1 : number
>lineChar.line : number
>lineChar : ts.LineAndCharacter
>line : number
>lineChar.character + 1 : number
>lineChar.character : number
>lineChar : ts.LineAndCharacter
>character : number
@@ -559,298 +561,307 @@ declare module "typescript" {
StringKeyword = 121,
>StringKeyword : SyntaxKind
TypeKeyword = 122,
SymbolKeyword = 122,
>SymbolKeyword : SyntaxKind
TypeKeyword = 123,
>TypeKeyword : SyntaxKind
QualifiedName = 123,
OfKeyword = 124,
>OfKeyword : SyntaxKind
QualifiedName = 125,
>QualifiedName : SyntaxKind
ComputedPropertyName = 124,
ComputedPropertyName = 126,
>ComputedPropertyName : SyntaxKind
TypeParameter = 125,
TypeParameter = 127,
>TypeParameter : SyntaxKind
Parameter = 126,
Parameter = 128,
>Parameter : SyntaxKind
PropertySignature = 127,
PropertySignature = 129,
>PropertySignature : SyntaxKind
PropertyDeclaration = 128,
PropertyDeclaration = 130,
>PropertyDeclaration : SyntaxKind
MethodSignature = 129,
MethodSignature = 131,
>MethodSignature : SyntaxKind
MethodDeclaration = 130,
MethodDeclaration = 132,
>MethodDeclaration : SyntaxKind
Constructor = 131,
Constructor = 133,
>Constructor : SyntaxKind
GetAccessor = 132,
GetAccessor = 134,
>GetAccessor : SyntaxKind
SetAccessor = 133,
SetAccessor = 135,
>SetAccessor : SyntaxKind
CallSignature = 134,
CallSignature = 136,
>CallSignature : SyntaxKind
ConstructSignature = 135,
ConstructSignature = 137,
>ConstructSignature : SyntaxKind
IndexSignature = 136,
IndexSignature = 138,
>IndexSignature : SyntaxKind
TypeReference = 137,
TypeReference = 139,
>TypeReference : SyntaxKind
FunctionType = 138,
FunctionType = 140,
>FunctionType : SyntaxKind
ConstructorType = 139,
ConstructorType = 141,
>ConstructorType : SyntaxKind
TypeQuery = 140,
TypeQuery = 142,
>TypeQuery : SyntaxKind
TypeLiteral = 141,
TypeLiteral = 143,
>TypeLiteral : SyntaxKind
ArrayType = 142,
ArrayType = 144,
>ArrayType : SyntaxKind
TupleType = 143,
TupleType = 145,
>TupleType : SyntaxKind
UnionType = 144,
UnionType = 146,
>UnionType : SyntaxKind
ParenthesizedType = 145,
ParenthesizedType = 147,
>ParenthesizedType : SyntaxKind
ObjectBindingPattern = 146,
ObjectBindingPattern = 148,
>ObjectBindingPattern : SyntaxKind
ArrayBindingPattern = 147,
ArrayBindingPattern = 149,
>ArrayBindingPattern : SyntaxKind
BindingElement = 148,
BindingElement = 150,
>BindingElement : SyntaxKind
ArrayLiteralExpression = 149,
ArrayLiteralExpression = 151,
>ArrayLiteralExpression : SyntaxKind
ObjectLiteralExpression = 150,
ObjectLiteralExpression = 152,
>ObjectLiteralExpression : SyntaxKind
PropertyAccessExpression = 151,
PropertyAccessExpression = 153,
>PropertyAccessExpression : SyntaxKind
ElementAccessExpression = 152,
ElementAccessExpression = 154,
>ElementAccessExpression : SyntaxKind
CallExpression = 153,
CallExpression = 155,
>CallExpression : SyntaxKind
NewExpression = 154,
NewExpression = 156,
>NewExpression : SyntaxKind
TaggedTemplateExpression = 155,
TaggedTemplateExpression = 157,
>TaggedTemplateExpression : SyntaxKind
TypeAssertionExpression = 156,
TypeAssertionExpression = 158,
>TypeAssertionExpression : SyntaxKind
ParenthesizedExpression = 157,
ParenthesizedExpression = 159,
>ParenthesizedExpression : SyntaxKind
FunctionExpression = 158,
FunctionExpression = 160,
>FunctionExpression : SyntaxKind
ArrowFunction = 159,
ArrowFunction = 161,
>ArrowFunction : SyntaxKind
DeleteExpression = 160,
DeleteExpression = 162,
>DeleteExpression : SyntaxKind
TypeOfExpression = 161,
TypeOfExpression = 163,
>TypeOfExpression : SyntaxKind
VoidExpression = 162,
VoidExpression = 164,
>VoidExpression : SyntaxKind
PrefixUnaryExpression = 163,
PrefixUnaryExpression = 165,
>PrefixUnaryExpression : SyntaxKind
PostfixUnaryExpression = 164,
PostfixUnaryExpression = 166,
>PostfixUnaryExpression : SyntaxKind
BinaryExpression = 165,
BinaryExpression = 167,
>BinaryExpression : SyntaxKind
ConditionalExpression = 166,
ConditionalExpression = 168,
>ConditionalExpression : SyntaxKind
TemplateExpression = 167,
TemplateExpression = 169,
>TemplateExpression : SyntaxKind
YieldExpression = 168,
YieldExpression = 170,
>YieldExpression : SyntaxKind
SpreadElementExpression = 169,
SpreadElementExpression = 171,
>SpreadElementExpression : SyntaxKind
OmittedExpression = 170,
OmittedExpression = 172,
>OmittedExpression : SyntaxKind
TemplateSpan = 171,
TemplateSpan = 173,
>TemplateSpan : SyntaxKind
Block = 172,
Block = 174,
>Block : SyntaxKind
VariableStatement = 173,
VariableStatement = 175,
>VariableStatement : SyntaxKind
EmptyStatement = 174,
EmptyStatement = 176,
>EmptyStatement : SyntaxKind
ExpressionStatement = 175,
ExpressionStatement = 177,
>ExpressionStatement : SyntaxKind
IfStatement = 176,
IfStatement = 178,
>IfStatement : SyntaxKind
DoStatement = 177,
DoStatement = 179,
>DoStatement : SyntaxKind
WhileStatement = 178,
WhileStatement = 180,
>WhileStatement : SyntaxKind
ForStatement = 179,
ForStatement = 181,
>ForStatement : SyntaxKind
ForInStatement = 180,
ForInStatement = 182,
>ForInStatement : SyntaxKind
ContinueStatement = 181,
ForOfStatement = 183,
>ForOfStatement : SyntaxKind
ContinueStatement = 184,
>ContinueStatement : SyntaxKind
BreakStatement = 182,
BreakStatement = 185,
>BreakStatement : SyntaxKind
ReturnStatement = 183,
ReturnStatement = 186,
>ReturnStatement : SyntaxKind
WithStatement = 184,
WithStatement = 187,
>WithStatement : SyntaxKind
SwitchStatement = 185,
SwitchStatement = 188,
>SwitchStatement : SyntaxKind
LabeledStatement = 186,
LabeledStatement = 189,
>LabeledStatement : SyntaxKind
ThrowStatement = 187,
ThrowStatement = 190,
>ThrowStatement : SyntaxKind
TryStatement = 188,
TryStatement = 191,
>TryStatement : SyntaxKind
DebuggerStatement = 189,
DebuggerStatement = 192,
>DebuggerStatement : SyntaxKind
VariableDeclaration = 190,
VariableDeclaration = 193,
>VariableDeclaration : SyntaxKind
VariableDeclarationList = 191,
VariableDeclarationList = 194,
>VariableDeclarationList : SyntaxKind
FunctionDeclaration = 192,
FunctionDeclaration = 195,
>FunctionDeclaration : SyntaxKind
ClassDeclaration = 193,
ClassDeclaration = 196,
>ClassDeclaration : SyntaxKind
InterfaceDeclaration = 194,
InterfaceDeclaration = 197,
>InterfaceDeclaration : SyntaxKind
TypeAliasDeclaration = 195,
TypeAliasDeclaration = 198,
>TypeAliasDeclaration : SyntaxKind
EnumDeclaration = 196,
EnumDeclaration = 199,
>EnumDeclaration : SyntaxKind
ModuleDeclaration = 197,
ModuleDeclaration = 200,
>ModuleDeclaration : SyntaxKind
ModuleBlock = 198,
ModuleBlock = 201,
>ModuleBlock : SyntaxKind
ImportEqualsDeclaration = 199,
ImportEqualsDeclaration = 202,
>ImportEqualsDeclaration : SyntaxKind
ImportDeclaration = 200,
ImportDeclaration = 203,
>ImportDeclaration : SyntaxKind
ImportClause = 201,
ImportClause = 204,
>ImportClause : SyntaxKind
NamespaceImport = 202,
NamespaceImport = 205,
>NamespaceImport : SyntaxKind
NamedImports = 203,
NamedImports = 206,
>NamedImports : SyntaxKind
ImportSpecifier = 204,
ImportSpecifier = 207,
>ImportSpecifier : SyntaxKind
ExportAssignment = 205,
ExportAssignment = 208,
>ExportAssignment : SyntaxKind
ExportDeclaration = 206,
ExportDeclaration = 209,
>ExportDeclaration : SyntaxKind
NamedExports = 207,
NamedExports = 210,
>NamedExports : SyntaxKind
ExportSpecifier = 208,
ExportSpecifier = 211,
>ExportSpecifier : SyntaxKind
ExternalModuleReference = 209,
ExternalModuleReference = 212,
>ExternalModuleReference : SyntaxKind
CaseClause = 210,
CaseClause = 213,
>CaseClause : SyntaxKind
DefaultClause = 211,
DefaultClause = 214,
>DefaultClause : SyntaxKind
HeritageClause = 212,
HeritageClause = 215,
>HeritageClause : SyntaxKind
CatchClause = 213,
CatchClause = 216,
>CatchClause : SyntaxKind
PropertyAssignment = 214,
PropertyAssignment = 217,
>PropertyAssignment : SyntaxKind
ShorthandPropertyAssignment = 215,
ShorthandPropertyAssignment = 218,
>ShorthandPropertyAssignment : SyntaxKind
EnumMember = 216,
EnumMember = 219,
>EnumMember : SyntaxKind
SourceFile = 217,
SourceFile = 220,
>SourceFile : SyntaxKind
SyntaxList = 218,
SyntaxList = 221,
>SyntaxList : SyntaxKind
Count = 219,
Count = 222,
>Count : SyntaxKind
FirstAssignment = 52,
@@ -868,7 +879,7 @@ declare module "typescript" {
FirstKeyword = 65,
>FirstKeyword : SyntaxKind
LastKeyword = 122,
LastKeyword = 124,
>LastKeyword : SyntaxKind
FirstFutureReservedWord = 103,
@@ -877,10 +888,10 @@ declare module "typescript" {
LastFutureReservedWord = 111,
>LastFutureReservedWord : SyntaxKind
FirstTypeNode = 137,
FirstTypeNode = 139,
>FirstTypeNode : SyntaxKind
LastTypeNode = 145,
LastTypeNode = 147,
>LastTypeNode : SyntaxKind
FirstPunctuation = 14,
@@ -892,7 +903,7 @@ declare module "typescript" {
FirstToken = 0,
>FirstToken : SyntaxKind
LastToken = 122,
LastToken = 124,
>LastToken : SyntaxKind
FirstTriviaToken = 2,
@@ -919,7 +930,7 @@ declare module "typescript" {
LastBinaryOperator = 63,
>LastBinaryOperator : SyntaxKind
FirstNode = 123,
FirstNode = 125,
>FirstNode : SyntaxKind
}
const enum NodeFlags {
@@ -1606,9 +1617,9 @@ declare module "typescript" {
>left : Expression
>Expression : Expression
operator: SyntaxKind;
>operator : SyntaxKind
>SyntaxKind : SyntaxKind
operatorToken: Node;
>operatorToken : Node
>Node : Node
right: Expression;
>right : Expression
@@ -1900,6 +1911,19 @@ declare module "typescript" {
expression: Expression;
>expression : Expression
>Expression : Expression
}
interface ForOfStatement extends IterationStatement {
>ForOfStatement : ForOfStatement
>IterationStatement : IterationStatement
initializer: VariableDeclarationList | Expression;
>initializer : Expression | VariableDeclarationList
>VariableDeclarationList : VariableDeclarationList
>Expression : Expression
expression: Expression;
>expression : Expression
>Expression : Expression
}
interface BreakOrContinueStatement extends Statement {
@@ -2318,9 +2342,16 @@ declare module "typescript" {
text: string;
>text : string
amdDependencies: string[];
>amdDependencies : string[]
amdDependencies: {
>amdDependencies : { path: string; name: string; }[]
path: string;
>path : string
name: string;
>name : string
}[];
amdModuleName: string;
>amdModuleName : string
@@ -3447,10 +3478,13 @@ declare module "typescript" {
ContainsObjectLiteral = 524288,
>ContainsObjectLiteral : TypeFlags
Intrinsic = 127,
ESSymbol = 1048576,
>ESSymbol : TypeFlags
Intrinsic = 1048703,
>Intrinsic : TypeFlags
Primitive = 510,
Primitive = 1049086,
>Primitive : TypeFlags
StringLike = 258,
@@ -4292,6 +4326,9 @@ declare module "typescript" {
greaterThan = 62,
>greaterThan : CharacterCodes
hash = 35,
>hash : CharacterCodes
lessThan = 60,
>lessThan : CharacterCodes
@@ -4497,15 +4534,15 @@ declare module "typescript" {
>computeLineStarts : (text: string) => number[]
>text : string
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
>sourceFile : SourceFile
>SourceFile : SourceFile
>line : number
>character : number
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
>lineStarts : number[]
>line : number
>character : number
@@ -4864,16 +4901,16 @@ declare module "typescript" {
>getNamedDeclarations : () => Declaration[]
>Declaration : Declaration
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
>pos : number
>LineAndCharacter : LineAndCharacter
getLineStarts(): number[];
>getLineStarts : () => number[]
getPositionFromLineAndCharacter(line: number, character: number): number;
>getPositionFromLineAndCharacter : (line: number, character: number) => number
getPositionOfLineAndCharacter(line: number, character: number): number;
>getPositionOfLineAndCharacter : (line: number, character: number) => number
>line : number
>character : number
@@ -5090,9 +5127,10 @@ declare module "typescript" {
>position : number
>ReferenceEntry : ReferenceEntry
getNavigateToItems(searchValue: string): NavigateToItem[];
>getNavigateToItems : (searchValue: string) => NavigateToItem[]
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
>getNavigateToItems : (searchValue: string, maxResultCount?: number) => NavigateToItem[]
>searchValue : string
>maxResultCount : number
>NavigateToItem : NavigateToItem
getNavigationBarItems(fileName: string): NavigationBarItem[];
@@ -5331,6 +5369,9 @@ declare module "typescript" {
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
>PlaceOpenBraceOnNewLineForControlBlocks : boolean
[s: string]: boolean | number | string;
>s : string
}
interface DefinitionInfo {
>DefinitionInfo : DefinitionInfo
@@ -5668,6 +5709,15 @@ declare module "typescript" {
InDoubleQuoteStringLiteral = 3,
>InDoubleQuoteStringLiteral : EndOfLineState
InTemplateHeadOrNoSubstitutionTemplate = 4,
>InTemplateHeadOrNoSubstitutionTemplate : EndOfLineState
InTemplateMiddleOrTail = 5,
>InTemplateMiddleOrTail : EndOfLineState
InTemplateSubstitutionPosition = 6,
>InTemplateSubstitutionPosition : EndOfLineState
}
enum TokenClass {
>TokenClass : TokenClass
@@ -5723,12 +5773,31 @@ declare module "typescript" {
interface Classifier {
>Classifier : Classifier
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
>getClassificationsForLine : (text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean) => ClassificationResult
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
>getClassificationsForLine : (text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean) => ClassificationResult
>text : string
>lexState : EndOfLineState
>EndOfLineState : EndOfLineState
>classifyKeywordsInGenerics : boolean
>syntacticClassifierAbsent : boolean
>ClassificationResult : ClassificationResult
}
/**
+164 -128
View File
@@ -39,7 +39,7 @@ export function delint(sourceFile: ts.SourceFile) {
break;
case ts.SyntaxKind.BinaryExpression:
var op = (<ts.BinaryExpression>node).operator;
var op = (<ts.BinaryExpression>node).operatorToken.kind;
if (op === ts.SyntaxKind.EqualsEqualsToken || op === ts.SyntaxKind.ExclamationEqualsToken) {
report(node, "Use '===' and '!=='.")
@@ -51,8 +51,8 @@ export function delint(sourceFile: ts.SourceFile) {
}
function report(node: ts.Node, message: string) {
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`)
var lineChar = sourceFile.getLineAndCharacterOfPosition(node.getStart());
console.log(`${sourceFile.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${message}`)
}
}
@@ -212,118 +212,121 @@ declare module "typescript" {
NumberKeyword = 119,
SetKeyword = 120,
StringKeyword = 121,
TypeKeyword = 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,
ContinueStatement = 181,
BreakStatement = 182,
ReturnStatement = 183,
WithStatement = 184,
SwitchStatement = 185,
LabeledStatement = 186,
ThrowStatement = 187,
TryStatement = 188,
DebuggerStatement = 189,
VariableDeclaration = 190,
VariableDeclarationList = 191,
FunctionDeclaration = 192,
ClassDeclaration = 193,
InterfaceDeclaration = 194,
TypeAliasDeclaration = 195,
EnumDeclaration = 196,
ModuleDeclaration = 197,
ModuleBlock = 198,
ImportEqualsDeclaration = 199,
ImportDeclaration = 200,
ImportClause = 201,
NamespaceImport = 202,
NamedImports = 203,
ImportSpecifier = 204,
ExportAssignment = 205,
ExportDeclaration = 206,
NamedExports = 207,
ExportSpecifier = 208,
ExternalModuleReference = 209,
CaseClause = 210,
DefaultClause = 211,
HeritageClause = 212,
CatchClause = 213,
PropertyAssignment = 214,
ShorthandPropertyAssignment = 215,
EnumMember = 216,
SourceFile = 217,
SyntaxList = 218,
Count = 219,
SymbolKeyword = 122,
TypeKeyword = 123,
OfKeyword = 124,
QualifiedName = 125,
ComputedPropertyName = 126,
TypeParameter = 127,
Parameter = 128,
PropertySignature = 129,
PropertyDeclaration = 130,
MethodSignature = 131,
MethodDeclaration = 132,
Constructor = 133,
GetAccessor = 134,
SetAccessor = 135,
CallSignature = 136,
ConstructSignature = 137,
IndexSignature = 138,
TypeReference = 139,
FunctionType = 140,
ConstructorType = 141,
TypeQuery = 142,
TypeLiteral = 143,
ArrayType = 144,
TupleType = 145,
UnionType = 146,
ParenthesizedType = 147,
ObjectBindingPattern = 148,
ArrayBindingPattern = 149,
BindingElement = 150,
ArrayLiteralExpression = 151,
ObjectLiteralExpression = 152,
PropertyAccessExpression = 153,
ElementAccessExpression = 154,
CallExpression = 155,
NewExpression = 156,
TaggedTemplateExpression = 157,
TypeAssertionExpression = 158,
ParenthesizedExpression = 159,
FunctionExpression = 160,
ArrowFunction = 161,
DeleteExpression = 162,
TypeOfExpression = 163,
VoidExpression = 164,
PrefixUnaryExpression = 165,
PostfixUnaryExpression = 166,
BinaryExpression = 167,
ConditionalExpression = 168,
TemplateExpression = 169,
YieldExpression = 170,
SpreadElementExpression = 171,
OmittedExpression = 172,
TemplateSpan = 173,
Block = 174,
VariableStatement = 175,
EmptyStatement = 176,
ExpressionStatement = 177,
IfStatement = 178,
DoStatement = 179,
WhileStatement = 180,
ForStatement = 181,
ForInStatement = 182,
ForOfStatement = 183,
ContinueStatement = 184,
BreakStatement = 185,
ReturnStatement = 186,
WithStatement = 187,
SwitchStatement = 188,
LabeledStatement = 189,
ThrowStatement = 190,
TryStatement = 191,
DebuggerStatement = 192,
VariableDeclaration = 193,
VariableDeclarationList = 194,
FunctionDeclaration = 195,
ClassDeclaration = 196,
InterfaceDeclaration = 197,
TypeAliasDeclaration = 198,
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
LastReservedWord = 100,
FirstKeyword = 65,
LastKeyword = 122,
LastKeyword = 124,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 137,
LastTypeNode = 145,
FirstTypeNode = 139,
LastTypeNode = 147,
FirstPunctuation = 14,
LastPunctuation = 63,
FirstToken = 0,
LastToken = 122,
LastToken = 124,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@@ -332,7 +335,7 @@ declare module "typescript" {
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 123,
FirstNode = 125,
}
const enum NodeFlags {
Export = 1,
@@ -565,7 +568,7 @@ declare module "typescript" {
}
interface BinaryExpression extends Expression {
left: Expression;
operator: SyntaxKind;
operatorToken: Node;
right: Expression;
}
interface ConditionalExpression extends Expression {
@@ -663,6 +666,10 @@ declare module "typescript" {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface ForOfStatement extends IterationStatement {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface BreakOrContinueStatement extends Statement {
label?: Identifier;
}
@@ -793,7 +800,10 @@ declare module "typescript" {
endOfFileToken: Node;
fileName: string;
text: string;
amdDependencies: string[];
amdDependencies: {
path: string;
name: string;
}[];
amdModuleName: string;
referencedFiles: FileReference[];
hasNoDefaultLib: boolean;
@@ -1101,8 +1111,9 @@ declare module "typescript" {
ObjectLiteral = 131072,
ContainsUndefinedOrNull = 262144,
ContainsObjectLiteral = 524288,
Intrinsic = 127,
Primitive = 510,
ESSymbol = 1048576,
Intrinsic = 1048703,
Primitive = 1049086,
StringLike = 258,
NumberLike = 132,
ObjectType = 48128,
@@ -1388,6 +1399,7 @@ declare module "typescript" {
equals = 61,
exclamation = 33,
greaterThan = 62,
hash = 35,
lessThan = 60,
minus = 45,
openBrace = 123,
@@ -1454,8 +1466,8 @@ declare module "typescript" {
}
function tokenToString(t: SyntaxKind): string;
function computeLineStarts(text: string): number[];
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getLineStarts(sourceFile: SourceFile): number[];
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
line: number;
@@ -1539,9 +1551,9 @@ declare module "typescript" {
scriptSnapshot: IScriptSnapshot;
nameTable: Map<string>;
getNamedDeclarations(): Declaration[];
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionFromLineAndCharacter(line: number, character: number): number;
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
/**
@@ -1603,7 +1615,7 @@ declare module "typescript" {
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string): NavigateToItem[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
@@ -1678,6 +1690,7 @@ declare module "typescript" {
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number | string;
}
interface DefinitionInfo {
fileName: string;
@@ -1811,6 +1824,9 @@ declare module "typescript" {
InMultiLineCommentTrivia = 1,
InSingleQuoteStringLiteral = 2,
InDoubleQuoteStringLiteral = 3,
InTemplateHeadOrNoSubstitutionTemplate = 4,
InTemplateMiddleOrTail = 5,
InTemplateSubstitutionPosition = 6,
}
enum TokenClass {
Punctuation = 0,
@@ -1832,7 +1848,26 @@ declare module "typescript" {
classification: TokenClass;
}
interface Classifier {
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
}
/**
* The document registry represents a store of SourceFile objects that can be shared between
@@ -1993,25 +2028,26 @@ function delint(sourceFile) {
delintNode(sourceFile);
function delintNode(node) {
switch (node.kind) {
case 179 /* ForStatement */:
case 180 /* ForInStatement */:
case 178 /* WhileStatement */:
case 177 /* DoStatement */:
if (node.statement.kind !== 172 /* Block */) {
case 181 /* ForStatement */:
case 182 /* ForInStatement */:
case 180 /* WhileStatement */:
case 179 /* DoStatement */:
if (node.statement.kind !== 174 /* Block */) {
report(node, "A looping statement's contents should be wrapped in a block body.");
}
break;
case 176 /* IfStatement */:
case 178 /* IfStatement */:
var ifStatement = node;
if (ifStatement.thenStatement.kind !== 172 /* Block */) {
if (ifStatement.thenStatement.kind !== 174 /* Block */) {
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
}
if (ifStatement.elseStatement && ifStatement.elseStatement.kind !== 172 /* Block */ && ifStatement.elseStatement.kind !== 176 /* IfStatement */) {
if (ifStatement.elseStatement &&
ifStatement.elseStatement.kind !== 174 /* Block */ && ifStatement.elseStatement.kind !== 178 /* IfStatement */) {
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
}
break;
case 165 /* BinaryExpression */:
var op = node.operator;
case 167 /* BinaryExpression */:
var op = node.operatorToken.kind;
if (op === 28 /* EqualsEqualsToken */ || op === 29 /* ExclamationEqualsToken */) {
report(node, "Use '===' and '!=='.");
}
@@ -2020,8 +2056,8 @@ function delint(sourceFile) {
ts.forEachChild(node, delintNode);
}
function report(node, message) {
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
console.log(sourceFile.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + message);
var lineChar = sourceFile.getLineAndCharacterOfPosition(node.getStart());
console.log(sourceFile.fileName + " (" + (lineChar.line + 1) + "," + (lineChar.character + 1) + "): " + message);
}
}
exports.delint = delint;
+203 -132
View File
@@ -173,15 +173,17 @@ export function delint(sourceFile: ts.SourceFile) {
>SyntaxKind : typeof ts.SyntaxKind
>BinaryExpression : ts.SyntaxKind
var op = (<ts.BinaryExpression>node).operator;
var op = (<ts.BinaryExpression>node).operatorToken.kind;
>op : ts.SyntaxKind
>(<ts.BinaryExpression>node).operator : ts.SyntaxKind
>(<ts.BinaryExpression>node).operatorToken.kind : ts.SyntaxKind
>(<ts.BinaryExpression>node).operatorToken : ts.Node
>(<ts.BinaryExpression>node) : ts.BinaryExpression
><ts.BinaryExpression>node : ts.BinaryExpression
>ts : unknown
>BinaryExpression : ts.BinaryExpression
>node : ts.Node
>operator : ts.SyntaxKind
>operatorToken : ts.Node
>kind : ts.SyntaxKind
if (op === ts.SyntaxKind.EqualsEqualsToken || op === ts.SyntaxKind.ExclamationEqualsToken) {
>op === ts.SyntaxKind.EqualsEqualsToken || op === ts.SyntaxKind.ExclamationEqualsToken : boolean
@@ -224,28 +226,30 @@ export function delint(sourceFile: ts.SourceFile) {
>Node : ts.Node
>message : string
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
var lineChar = sourceFile.getLineAndCharacterOfPosition(node.getStart());
>lineChar : ts.LineAndCharacter
>sourceFile.getLineAndCharacterFromPosition(node.getStart()) : ts.LineAndCharacter
>sourceFile.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
>sourceFile.getLineAndCharacterOfPosition(node.getStart()) : ts.LineAndCharacter
>sourceFile.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>sourceFile : ts.SourceFile
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>node.getStart() : number
>node.getStart : (sourceFile?: ts.SourceFile) => number
>node : ts.Node
>getStart : (sourceFile?: ts.SourceFile) => number
console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`)
>console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`) : any
console.log(`${sourceFile.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${message}`)
>console.log(`${sourceFile.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${message}`) : any
>console.log : any
>console : any
>log : any
>sourceFile.fileName : string
>sourceFile : ts.SourceFile
>fileName : string
>lineChar.line + 1 : number
>lineChar.line : number
>lineChar : ts.LineAndCharacter
>line : number
>lineChar.character + 1 : number
>lineChar.character : number
>lineChar : ts.LineAndCharacter
>character : number
@@ -703,298 +707,307 @@ declare module "typescript" {
StringKeyword = 121,
>StringKeyword : SyntaxKind
TypeKeyword = 122,
SymbolKeyword = 122,
>SymbolKeyword : SyntaxKind
TypeKeyword = 123,
>TypeKeyword : SyntaxKind
QualifiedName = 123,
OfKeyword = 124,
>OfKeyword : SyntaxKind
QualifiedName = 125,
>QualifiedName : SyntaxKind
ComputedPropertyName = 124,
ComputedPropertyName = 126,
>ComputedPropertyName : SyntaxKind
TypeParameter = 125,
TypeParameter = 127,
>TypeParameter : SyntaxKind
Parameter = 126,
Parameter = 128,
>Parameter : SyntaxKind
PropertySignature = 127,
PropertySignature = 129,
>PropertySignature : SyntaxKind
PropertyDeclaration = 128,
PropertyDeclaration = 130,
>PropertyDeclaration : SyntaxKind
MethodSignature = 129,
MethodSignature = 131,
>MethodSignature : SyntaxKind
MethodDeclaration = 130,
MethodDeclaration = 132,
>MethodDeclaration : SyntaxKind
Constructor = 131,
Constructor = 133,
>Constructor : SyntaxKind
GetAccessor = 132,
GetAccessor = 134,
>GetAccessor : SyntaxKind
SetAccessor = 133,
SetAccessor = 135,
>SetAccessor : SyntaxKind
CallSignature = 134,
CallSignature = 136,
>CallSignature : SyntaxKind
ConstructSignature = 135,
ConstructSignature = 137,
>ConstructSignature : SyntaxKind
IndexSignature = 136,
IndexSignature = 138,
>IndexSignature : SyntaxKind
TypeReference = 137,
TypeReference = 139,
>TypeReference : SyntaxKind
FunctionType = 138,
FunctionType = 140,
>FunctionType : SyntaxKind
ConstructorType = 139,
ConstructorType = 141,
>ConstructorType : SyntaxKind
TypeQuery = 140,
TypeQuery = 142,
>TypeQuery : SyntaxKind
TypeLiteral = 141,
TypeLiteral = 143,
>TypeLiteral : SyntaxKind
ArrayType = 142,
ArrayType = 144,
>ArrayType : SyntaxKind
TupleType = 143,
TupleType = 145,
>TupleType : SyntaxKind
UnionType = 144,
UnionType = 146,
>UnionType : SyntaxKind
ParenthesizedType = 145,
ParenthesizedType = 147,
>ParenthesizedType : SyntaxKind
ObjectBindingPattern = 146,
ObjectBindingPattern = 148,
>ObjectBindingPattern : SyntaxKind
ArrayBindingPattern = 147,
ArrayBindingPattern = 149,
>ArrayBindingPattern : SyntaxKind
BindingElement = 148,
BindingElement = 150,
>BindingElement : SyntaxKind
ArrayLiteralExpression = 149,
ArrayLiteralExpression = 151,
>ArrayLiteralExpression : SyntaxKind
ObjectLiteralExpression = 150,
ObjectLiteralExpression = 152,
>ObjectLiteralExpression : SyntaxKind
PropertyAccessExpression = 151,
PropertyAccessExpression = 153,
>PropertyAccessExpression : SyntaxKind
ElementAccessExpression = 152,
ElementAccessExpression = 154,
>ElementAccessExpression : SyntaxKind
CallExpression = 153,
CallExpression = 155,
>CallExpression : SyntaxKind
NewExpression = 154,
NewExpression = 156,
>NewExpression : SyntaxKind
TaggedTemplateExpression = 155,
TaggedTemplateExpression = 157,
>TaggedTemplateExpression : SyntaxKind
TypeAssertionExpression = 156,
TypeAssertionExpression = 158,
>TypeAssertionExpression : SyntaxKind
ParenthesizedExpression = 157,
ParenthesizedExpression = 159,
>ParenthesizedExpression : SyntaxKind
FunctionExpression = 158,
FunctionExpression = 160,
>FunctionExpression : SyntaxKind
ArrowFunction = 159,
ArrowFunction = 161,
>ArrowFunction : SyntaxKind
DeleteExpression = 160,
DeleteExpression = 162,
>DeleteExpression : SyntaxKind
TypeOfExpression = 161,
TypeOfExpression = 163,
>TypeOfExpression : SyntaxKind
VoidExpression = 162,
VoidExpression = 164,
>VoidExpression : SyntaxKind
PrefixUnaryExpression = 163,
PrefixUnaryExpression = 165,
>PrefixUnaryExpression : SyntaxKind
PostfixUnaryExpression = 164,
PostfixUnaryExpression = 166,
>PostfixUnaryExpression : SyntaxKind
BinaryExpression = 165,
BinaryExpression = 167,
>BinaryExpression : SyntaxKind
ConditionalExpression = 166,
ConditionalExpression = 168,
>ConditionalExpression : SyntaxKind
TemplateExpression = 167,
TemplateExpression = 169,
>TemplateExpression : SyntaxKind
YieldExpression = 168,
YieldExpression = 170,
>YieldExpression : SyntaxKind
SpreadElementExpression = 169,
SpreadElementExpression = 171,
>SpreadElementExpression : SyntaxKind
OmittedExpression = 170,
OmittedExpression = 172,
>OmittedExpression : SyntaxKind
TemplateSpan = 171,
TemplateSpan = 173,
>TemplateSpan : SyntaxKind
Block = 172,
Block = 174,
>Block : SyntaxKind
VariableStatement = 173,
VariableStatement = 175,
>VariableStatement : SyntaxKind
EmptyStatement = 174,
EmptyStatement = 176,
>EmptyStatement : SyntaxKind
ExpressionStatement = 175,
ExpressionStatement = 177,
>ExpressionStatement : SyntaxKind
IfStatement = 176,
IfStatement = 178,
>IfStatement : SyntaxKind
DoStatement = 177,
DoStatement = 179,
>DoStatement : SyntaxKind
WhileStatement = 178,
WhileStatement = 180,
>WhileStatement : SyntaxKind
ForStatement = 179,
ForStatement = 181,
>ForStatement : SyntaxKind
ForInStatement = 180,
ForInStatement = 182,
>ForInStatement : SyntaxKind
ContinueStatement = 181,
ForOfStatement = 183,
>ForOfStatement : SyntaxKind
ContinueStatement = 184,
>ContinueStatement : SyntaxKind
BreakStatement = 182,
BreakStatement = 185,
>BreakStatement : SyntaxKind
ReturnStatement = 183,
ReturnStatement = 186,
>ReturnStatement : SyntaxKind
WithStatement = 184,
WithStatement = 187,
>WithStatement : SyntaxKind
SwitchStatement = 185,
SwitchStatement = 188,
>SwitchStatement : SyntaxKind
LabeledStatement = 186,
LabeledStatement = 189,
>LabeledStatement : SyntaxKind
ThrowStatement = 187,
ThrowStatement = 190,
>ThrowStatement : SyntaxKind
TryStatement = 188,
TryStatement = 191,
>TryStatement : SyntaxKind
DebuggerStatement = 189,
DebuggerStatement = 192,
>DebuggerStatement : SyntaxKind
VariableDeclaration = 190,
VariableDeclaration = 193,
>VariableDeclaration : SyntaxKind
VariableDeclarationList = 191,
VariableDeclarationList = 194,
>VariableDeclarationList : SyntaxKind
FunctionDeclaration = 192,
FunctionDeclaration = 195,
>FunctionDeclaration : SyntaxKind
ClassDeclaration = 193,
ClassDeclaration = 196,
>ClassDeclaration : SyntaxKind
InterfaceDeclaration = 194,
InterfaceDeclaration = 197,
>InterfaceDeclaration : SyntaxKind
TypeAliasDeclaration = 195,
TypeAliasDeclaration = 198,
>TypeAliasDeclaration : SyntaxKind
EnumDeclaration = 196,
EnumDeclaration = 199,
>EnumDeclaration : SyntaxKind
ModuleDeclaration = 197,
ModuleDeclaration = 200,
>ModuleDeclaration : SyntaxKind
ModuleBlock = 198,
ModuleBlock = 201,
>ModuleBlock : SyntaxKind
ImportEqualsDeclaration = 199,
ImportEqualsDeclaration = 202,
>ImportEqualsDeclaration : SyntaxKind
ImportDeclaration = 200,
ImportDeclaration = 203,
>ImportDeclaration : SyntaxKind
ImportClause = 201,
ImportClause = 204,
>ImportClause : SyntaxKind
NamespaceImport = 202,
NamespaceImport = 205,
>NamespaceImport : SyntaxKind
NamedImports = 203,
NamedImports = 206,
>NamedImports : SyntaxKind
ImportSpecifier = 204,
ImportSpecifier = 207,
>ImportSpecifier : SyntaxKind
ExportAssignment = 205,
ExportAssignment = 208,
>ExportAssignment : SyntaxKind
ExportDeclaration = 206,
ExportDeclaration = 209,
>ExportDeclaration : SyntaxKind
NamedExports = 207,
NamedExports = 210,
>NamedExports : SyntaxKind
ExportSpecifier = 208,
ExportSpecifier = 211,
>ExportSpecifier : SyntaxKind
ExternalModuleReference = 209,
ExternalModuleReference = 212,
>ExternalModuleReference : SyntaxKind
CaseClause = 210,
CaseClause = 213,
>CaseClause : SyntaxKind
DefaultClause = 211,
DefaultClause = 214,
>DefaultClause : SyntaxKind
HeritageClause = 212,
HeritageClause = 215,
>HeritageClause : SyntaxKind
CatchClause = 213,
CatchClause = 216,
>CatchClause : SyntaxKind
PropertyAssignment = 214,
PropertyAssignment = 217,
>PropertyAssignment : SyntaxKind
ShorthandPropertyAssignment = 215,
ShorthandPropertyAssignment = 218,
>ShorthandPropertyAssignment : SyntaxKind
EnumMember = 216,
EnumMember = 219,
>EnumMember : SyntaxKind
SourceFile = 217,
SourceFile = 220,
>SourceFile : SyntaxKind
SyntaxList = 218,
SyntaxList = 221,
>SyntaxList : SyntaxKind
Count = 219,
Count = 222,
>Count : SyntaxKind
FirstAssignment = 52,
@@ -1012,7 +1025,7 @@ declare module "typescript" {
FirstKeyword = 65,
>FirstKeyword : SyntaxKind
LastKeyword = 122,
LastKeyword = 124,
>LastKeyword : SyntaxKind
FirstFutureReservedWord = 103,
@@ -1021,10 +1034,10 @@ declare module "typescript" {
LastFutureReservedWord = 111,
>LastFutureReservedWord : SyntaxKind
FirstTypeNode = 137,
FirstTypeNode = 139,
>FirstTypeNode : SyntaxKind
LastTypeNode = 145,
LastTypeNode = 147,
>LastTypeNode : SyntaxKind
FirstPunctuation = 14,
@@ -1036,7 +1049,7 @@ declare module "typescript" {
FirstToken = 0,
>FirstToken : SyntaxKind
LastToken = 122,
LastToken = 124,
>LastToken : SyntaxKind
FirstTriviaToken = 2,
@@ -1063,7 +1076,7 @@ declare module "typescript" {
LastBinaryOperator = 63,
>LastBinaryOperator : SyntaxKind
FirstNode = 123,
FirstNode = 125,
>FirstNode : SyntaxKind
}
const enum NodeFlags {
@@ -1750,9 +1763,9 @@ declare module "typescript" {
>left : Expression
>Expression : Expression
operator: SyntaxKind;
>operator : SyntaxKind
>SyntaxKind : SyntaxKind
operatorToken: Node;
>operatorToken : Node
>Node : Node
right: Expression;
>right : Expression
@@ -2044,6 +2057,19 @@ declare module "typescript" {
expression: Expression;
>expression : Expression
>Expression : Expression
}
interface ForOfStatement extends IterationStatement {
>ForOfStatement : ForOfStatement
>IterationStatement : IterationStatement
initializer: VariableDeclarationList | Expression;
>initializer : Expression | VariableDeclarationList
>VariableDeclarationList : VariableDeclarationList
>Expression : Expression
expression: Expression;
>expression : Expression
>Expression : Expression
}
interface BreakOrContinueStatement extends Statement {
@@ -2462,9 +2488,16 @@ declare module "typescript" {
text: string;
>text : string
amdDependencies: string[];
>amdDependencies : string[]
amdDependencies: {
>amdDependencies : { path: string; name: string; }[]
path: string;
>path : string
name: string;
>name : string
}[];
amdModuleName: string;
>amdModuleName : string
@@ -3591,10 +3624,13 @@ declare module "typescript" {
ContainsObjectLiteral = 524288,
>ContainsObjectLiteral : TypeFlags
Intrinsic = 127,
ESSymbol = 1048576,
>ESSymbol : TypeFlags
Intrinsic = 1048703,
>Intrinsic : TypeFlags
Primitive = 510,
Primitive = 1049086,
>Primitive : TypeFlags
StringLike = 258,
@@ -4436,6 +4472,9 @@ declare module "typescript" {
greaterThan = 62,
>greaterThan : CharacterCodes
hash = 35,
>hash : CharacterCodes
lessThan = 60,
>lessThan : CharacterCodes
@@ -4641,15 +4680,15 @@ declare module "typescript" {
>computeLineStarts : (text: string) => number[]
>text : string
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
>sourceFile : SourceFile
>SourceFile : SourceFile
>line : number
>character : number
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
>lineStarts : number[]
>line : number
>character : number
@@ -5008,16 +5047,16 @@ declare module "typescript" {
>getNamedDeclarations : () => Declaration[]
>Declaration : Declaration
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
>pos : number
>LineAndCharacter : LineAndCharacter
getLineStarts(): number[];
>getLineStarts : () => number[]
getPositionFromLineAndCharacter(line: number, character: number): number;
>getPositionFromLineAndCharacter : (line: number, character: number) => number
getPositionOfLineAndCharacter(line: number, character: number): number;
>getPositionOfLineAndCharacter : (line: number, character: number) => number
>line : number
>character : number
@@ -5234,9 +5273,10 @@ declare module "typescript" {
>position : number
>ReferenceEntry : ReferenceEntry
getNavigateToItems(searchValue: string): NavigateToItem[];
>getNavigateToItems : (searchValue: string) => NavigateToItem[]
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
>getNavigateToItems : (searchValue: string, maxResultCount?: number) => NavigateToItem[]
>searchValue : string
>maxResultCount : number
>NavigateToItem : NavigateToItem
getNavigationBarItems(fileName: string): NavigationBarItem[];
@@ -5475,6 +5515,9 @@ declare module "typescript" {
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
>PlaceOpenBraceOnNewLineForControlBlocks : boolean
[s: string]: boolean | number | string;
>s : string
}
interface DefinitionInfo {
>DefinitionInfo : DefinitionInfo
@@ -5812,6 +5855,15 @@ declare module "typescript" {
InDoubleQuoteStringLiteral = 3,
>InDoubleQuoteStringLiteral : EndOfLineState
InTemplateHeadOrNoSubstitutionTemplate = 4,
>InTemplateHeadOrNoSubstitutionTemplate : EndOfLineState
InTemplateMiddleOrTail = 5,
>InTemplateMiddleOrTail : EndOfLineState
InTemplateSubstitutionPosition = 6,
>InTemplateSubstitutionPosition : EndOfLineState
}
enum TokenClass {
>TokenClass : TokenClass
@@ -5867,12 +5919,31 @@ declare module "typescript" {
interface Classifier {
>Classifier : Classifier
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
>getClassificationsForLine : (text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean) => ClassificationResult
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
>getClassificationsForLine : (text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean) => ClassificationResult
>text : string
>lexState : EndOfLineState
>EndOfLineState : EndOfLineState
>classifyKeywordsInGenerics : boolean
>syntacticClassifierAbsent : boolean
>ClassificationResult : ClassificationResult
}
/**
+150 -115
View File
@@ -54,7 +54,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
return {
outputs: outputs,
errors: errors.map(function (e) {
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): "
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): "
+ ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
})
};
@@ -213,118 +213,121 @@ declare module "typescript" {
NumberKeyword = 119,
SetKeyword = 120,
StringKeyword = 121,
TypeKeyword = 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,
ContinueStatement = 181,
BreakStatement = 182,
ReturnStatement = 183,
WithStatement = 184,
SwitchStatement = 185,
LabeledStatement = 186,
ThrowStatement = 187,
TryStatement = 188,
DebuggerStatement = 189,
VariableDeclaration = 190,
VariableDeclarationList = 191,
FunctionDeclaration = 192,
ClassDeclaration = 193,
InterfaceDeclaration = 194,
TypeAliasDeclaration = 195,
EnumDeclaration = 196,
ModuleDeclaration = 197,
ModuleBlock = 198,
ImportEqualsDeclaration = 199,
ImportDeclaration = 200,
ImportClause = 201,
NamespaceImport = 202,
NamedImports = 203,
ImportSpecifier = 204,
ExportAssignment = 205,
ExportDeclaration = 206,
NamedExports = 207,
ExportSpecifier = 208,
ExternalModuleReference = 209,
CaseClause = 210,
DefaultClause = 211,
HeritageClause = 212,
CatchClause = 213,
PropertyAssignment = 214,
ShorthandPropertyAssignment = 215,
EnumMember = 216,
SourceFile = 217,
SyntaxList = 218,
Count = 219,
SymbolKeyword = 122,
TypeKeyword = 123,
OfKeyword = 124,
QualifiedName = 125,
ComputedPropertyName = 126,
TypeParameter = 127,
Parameter = 128,
PropertySignature = 129,
PropertyDeclaration = 130,
MethodSignature = 131,
MethodDeclaration = 132,
Constructor = 133,
GetAccessor = 134,
SetAccessor = 135,
CallSignature = 136,
ConstructSignature = 137,
IndexSignature = 138,
TypeReference = 139,
FunctionType = 140,
ConstructorType = 141,
TypeQuery = 142,
TypeLiteral = 143,
ArrayType = 144,
TupleType = 145,
UnionType = 146,
ParenthesizedType = 147,
ObjectBindingPattern = 148,
ArrayBindingPattern = 149,
BindingElement = 150,
ArrayLiteralExpression = 151,
ObjectLiteralExpression = 152,
PropertyAccessExpression = 153,
ElementAccessExpression = 154,
CallExpression = 155,
NewExpression = 156,
TaggedTemplateExpression = 157,
TypeAssertionExpression = 158,
ParenthesizedExpression = 159,
FunctionExpression = 160,
ArrowFunction = 161,
DeleteExpression = 162,
TypeOfExpression = 163,
VoidExpression = 164,
PrefixUnaryExpression = 165,
PostfixUnaryExpression = 166,
BinaryExpression = 167,
ConditionalExpression = 168,
TemplateExpression = 169,
YieldExpression = 170,
SpreadElementExpression = 171,
OmittedExpression = 172,
TemplateSpan = 173,
Block = 174,
VariableStatement = 175,
EmptyStatement = 176,
ExpressionStatement = 177,
IfStatement = 178,
DoStatement = 179,
WhileStatement = 180,
ForStatement = 181,
ForInStatement = 182,
ForOfStatement = 183,
ContinueStatement = 184,
BreakStatement = 185,
ReturnStatement = 186,
WithStatement = 187,
SwitchStatement = 188,
LabeledStatement = 189,
ThrowStatement = 190,
TryStatement = 191,
DebuggerStatement = 192,
VariableDeclaration = 193,
VariableDeclarationList = 194,
FunctionDeclaration = 195,
ClassDeclaration = 196,
InterfaceDeclaration = 197,
TypeAliasDeclaration = 198,
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
LastReservedWord = 100,
FirstKeyword = 65,
LastKeyword = 122,
LastKeyword = 124,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 137,
LastTypeNode = 145,
FirstTypeNode = 139,
LastTypeNode = 147,
FirstPunctuation = 14,
LastPunctuation = 63,
FirstToken = 0,
LastToken = 122,
LastToken = 124,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@@ -333,7 +336,7 @@ declare module "typescript" {
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 123,
FirstNode = 125,
}
const enum NodeFlags {
Export = 1,
@@ -566,7 +569,7 @@ declare module "typescript" {
}
interface BinaryExpression extends Expression {
left: Expression;
operator: SyntaxKind;
operatorToken: Node;
right: Expression;
}
interface ConditionalExpression extends Expression {
@@ -664,6 +667,10 @@ declare module "typescript" {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface ForOfStatement extends IterationStatement {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface BreakOrContinueStatement extends Statement {
label?: Identifier;
}
@@ -794,7 +801,10 @@ declare module "typescript" {
endOfFileToken: Node;
fileName: string;
text: string;
amdDependencies: string[];
amdDependencies: {
path: string;
name: string;
}[];
amdModuleName: string;
referencedFiles: FileReference[];
hasNoDefaultLib: boolean;
@@ -1102,8 +1112,9 @@ declare module "typescript" {
ObjectLiteral = 131072,
ContainsUndefinedOrNull = 262144,
ContainsObjectLiteral = 524288,
Intrinsic = 127,
Primitive = 510,
ESSymbol = 1048576,
Intrinsic = 1048703,
Primitive = 1049086,
StringLike = 258,
NumberLike = 132,
ObjectType = 48128,
@@ -1389,6 +1400,7 @@ declare module "typescript" {
equals = 61,
exclamation = 33,
greaterThan = 62,
hash = 35,
lessThan = 60,
minus = 45,
openBrace = 123,
@@ -1455,8 +1467,8 @@ declare module "typescript" {
}
function tokenToString(t: SyntaxKind): string;
function computeLineStarts(text: string): number[];
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getLineStarts(sourceFile: SourceFile): number[];
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
line: number;
@@ -1540,9 +1552,9 @@ declare module "typescript" {
scriptSnapshot: IScriptSnapshot;
nameTable: Map<string>;
getNamedDeclarations(): Declaration[];
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionFromLineAndCharacter(line: number, character: number): number;
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
/**
@@ -1604,7 +1616,7 @@ declare module "typescript" {
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string): NavigateToItem[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
@@ -1679,6 +1691,7 @@ declare module "typescript" {
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number | string;
}
interface DefinitionInfo {
fileName: string;
@@ -1812,6 +1825,9 @@ declare module "typescript" {
InMultiLineCommentTrivia = 1,
InSingleQuoteStringLiteral = 2,
InDoubleQuoteStringLiteral = 3,
InTemplateHeadOrNoSubstitutionTemplate = 4,
InTemplateMiddleOrTail = 5,
InTemplateSubstitutionPosition = 6,
}
enum TokenClass {
Punctuation = 0,
@@ -1833,7 +1849,26 @@ declare module "typescript" {
classification: TokenClass;
}
interface Classifier {
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
}
/**
* The document registry represents a store of SourceFile objects that can be shared between
@@ -2022,7 +2057,7 @@ function transform(contents, compilerOptions) {
return {
outputs: outputs,
errors: errors.map(function (e) {
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
})
};
}
@@ -177,7 +177,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
>diagnostics : ts.Diagnostic[]
return {
>{ outputs: outputs, errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) } : { outputs: any[]; errors: string[]; }
>{ outputs: outputs, errors: errors.map(function (e) { return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) } : { outputs: any[]; errors: string[]; }
outputs: outputs,
>outputs : any[]
@@ -185,30 +185,32 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
errors: errors.map(function (e) {
>errors : string[]
>errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) : string[]
>errors.map(function (e) { return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) : string[]
>errors.map : <U>(callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[]
>errors : ts.Diagnostic[]
>map : <U>(callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[]
>function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); } : (e: ts.Diagnostic) => string
>function (e) { return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); } : (e: ts.Diagnostic) => string
>e : ts.Diagnostic
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): "
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL) : string
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " : string
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line : string
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): "
>e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL) : string
>e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " : string
>e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) : string
>e.file.fileName + "(" : string
>e.file.fileName : string
>e.file : ts.SourceFile
>e : ts.Diagnostic
>file : ts.SourceFile
>fileName : string
>e.file.getLineAndCharacterFromPosition(e.start).line : number
>e.file.getLineAndCharacterFromPosition(e.start) : ts.LineAndCharacter
>e.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
>(e.file.getLineAndCharacterOfPosition(e.start).line + 1) : number
>e.file.getLineAndCharacterOfPosition(e.start).line + 1 : number
>e.file.getLineAndCharacterOfPosition(e.start).line : number
>e.file.getLineAndCharacterOfPosition(e.start) : ts.LineAndCharacter
>e.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>e.file : ts.SourceFile
>e : ts.Diagnostic
>file : ts.SourceFile
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>e.start : number
>e : ts.Diagnostic
>start : number
@@ -655,298 +657,307 @@ declare module "typescript" {
StringKeyword = 121,
>StringKeyword : SyntaxKind
TypeKeyword = 122,
SymbolKeyword = 122,
>SymbolKeyword : SyntaxKind
TypeKeyword = 123,
>TypeKeyword : SyntaxKind
QualifiedName = 123,
OfKeyword = 124,
>OfKeyword : SyntaxKind
QualifiedName = 125,
>QualifiedName : SyntaxKind
ComputedPropertyName = 124,
ComputedPropertyName = 126,
>ComputedPropertyName : SyntaxKind
TypeParameter = 125,
TypeParameter = 127,
>TypeParameter : SyntaxKind
Parameter = 126,
Parameter = 128,
>Parameter : SyntaxKind
PropertySignature = 127,
PropertySignature = 129,
>PropertySignature : SyntaxKind
PropertyDeclaration = 128,
PropertyDeclaration = 130,
>PropertyDeclaration : SyntaxKind
MethodSignature = 129,
MethodSignature = 131,
>MethodSignature : SyntaxKind
MethodDeclaration = 130,
MethodDeclaration = 132,
>MethodDeclaration : SyntaxKind
Constructor = 131,
Constructor = 133,
>Constructor : SyntaxKind
GetAccessor = 132,
GetAccessor = 134,
>GetAccessor : SyntaxKind
SetAccessor = 133,
SetAccessor = 135,
>SetAccessor : SyntaxKind
CallSignature = 134,
CallSignature = 136,
>CallSignature : SyntaxKind
ConstructSignature = 135,
ConstructSignature = 137,
>ConstructSignature : SyntaxKind
IndexSignature = 136,
IndexSignature = 138,
>IndexSignature : SyntaxKind
TypeReference = 137,
TypeReference = 139,
>TypeReference : SyntaxKind
FunctionType = 138,
FunctionType = 140,
>FunctionType : SyntaxKind
ConstructorType = 139,
ConstructorType = 141,
>ConstructorType : SyntaxKind
TypeQuery = 140,
TypeQuery = 142,
>TypeQuery : SyntaxKind
TypeLiteral = 141,
TypeLiteral = 143,
>TypeLiteral : SyntaxKind
ArrayType = 142,
ArrayType = 144,
>ArrayType : SyntaxKind
TupleType = 143,
TupleType = 145,
>TupleType : SyntaxKind
UnionType = 144,
UnionType = 146,
>UnionType : SyntaxKind
ParenthesizedType = 145,
ParenthesizedType = 147,
>ParenthesizedType : SyntaxKind
ObjectBindingPattern = 146,
ObjectBindingPattern = 148,
>ObjectBindingPattern : SyntaxKind
ArrayBindingPattern = 147,
ArrayBindingPattern = 149,
>ArrayBindingPattern : SyntaxKind
BindingElement = 148,
BindingElement = 150,
>BindingElement : SyntaxKind
ArrayLiteralExpression = 149,
ArrayLiteralExpression = 151,
>ArrayLiteralExpression : SyntaxKind
ObjectLiteralExpression = 150,
ObjectLiteralExpression = 152,
>ObjectLiteralExpression : SyntaxKind
PropertyAccessExpression = 151,
PropertyAccessExpression = 153,
>PropertyAccessExpression : SyntaxKind
ElementAccessExpression = 152,
ElementAccessExpression = 154,
>ElementAccessExpression : SyntaxKind
CallExpression = 153,
CallExpression = 155,
>CallExpression : SyntaxKind
NewExpression = 154,
NewExpression = 156,
>NewExpression : SyntaxKind
TaggedTemplateExpression = 155,
TaggedTemplateExpression = 157,
>TaggedTemplateExpression : SyntaxKind
TypeAssertionExpression = 156,
TypeAssertionExpression = 158,
>TypeAssertionExpression : SyntaxKind
ParenthesizedExpression = 157,
ParenthesizedExpression = 159,
>ParenthesizedExpression : SyntaxKind
FunctionExpression = 158,
FunctionExpression = 160,
>FunctionExpression : SyntaxKind
ArrowFunction = 159,
ArrowFunction = 161,
>ArrowFunction : SyntaxKind
DeleteExpression = 160,
DeleteExpression = 162,
>DeleteExpression : SyntaxKind
TypeOfExpression = 161,
TypeOfExpression = 163,
>TypeOfExpression : SyntaxKind
VoidExpression = 162,
VoidExpression = 164,
>VoidExpression : SyntaxKind
PrefixUnaryExpression = 163,
PrefixUnaryExpression = 165,
>PrefixUnaryExpression : SyntaxKind
PostfixUnaryExpression = 164,
PostfixUnaryExpression = 166,
>PostfixUnaryExpression : SyntaxKind
BinaryExpression = 165,
BinaryExpression = 167,
>BinaryExpression : SyntaxKind
ConditionalExpression = 166,
ConditionalExpression = 168,
>ConditionalExpression : SyntaxKind
TemplateExpression = 167,
TemplateExpression = 169,
>TemplateExpression : SyntaxKind
YieldExpression = 168,
YieldExpression = 170,
>YieldExpression : SyntaxKind
SpreadElementExpression = 169,
SpreadElementExpression = 171,
>SpreadElementExpression : SyntaxKind
OmittedExpression = 170,
OmittedExpression = 172,
>OmittedExpression : SyntaxKind
TemplateSpan = 171,
TemplateSpan = 173,
>TemplateSpan : SyntaxKind
Block = 172,
Block = 174,
>Block : SyntaxKind
VariableStatement = 173,
VariableStatement = 175,
>VariableStatement : SyntaxKind
EmptyStatement = 174,
EmptyStatement = 176,
>EmptyStatement : SyntaxKind
ExpressionStatement = 175,
ExpressionStatement = 177,
>ExpressionStatement : SyntaxKind
IfStatement = 176,
IfStatement = 178,
>IfStatement : SyntaxKind
DoStatement = 177,
DoStatement = 179,
>DoStatement : SyntaxKind
WhileStatement = 178,
WhileStatement = 180,
>WhileStatement : SyntaxKind
ForStatement = 179,
ForStatement = 181,
>ForStatement : SyntaxKind
ForInStatement = 180,
ForInStatement = 182,
>ForInStatement : SyntaxKind
ContinueStatement = 181,
ForOfStatement = 183,
>ForOfStatement : SyntaxKind
ContinueStatement = 184,
>ContinueStatement : SyntaxKind
BreakStatement = 182,
BreakStatement = 185,
>BreakStatement : SyntaxKind
ReturnStatement = 183,
ReturnStatement = 186,
>ReturnStatement : SyntaxKind
WithStatement = 184,
WithStatement = 187,
>WithStatement : SyntaxKind
SwitchStatement = 185,
SwitchStatement = 188,
>SwitchStatement : SyntaxKind
LabeledStatement = 186,
LabeledStatement = 189,
>LabeledStatement : SyntaxKind
ThrowStatement = 187,
ThrowStatement = 190,
>ThrowStatement : SyntaxKind
TryStatement = 188,
TryStatement = 191,
>TryStatement : SyntaxKind
DebuggerStatement = 189,
DebuggerStatement = 192,
>DebuggerStatement : SyntaxKind
VariableDeclaration = 190,
VariableDeclaration = 193,
>VariableDeclaration : SyntaxKind
VariableDeclarationList = 191,
VariableDeclarationList = 194,
>VariableDeclarationList : SyntaxKind
FunctionDeclaration = 192,
FunctionDeclaration = 195,
>FunctionDeclaration : SyntaxKind
ClassDeclaration = 193,
ClassDeclaration = 196,
>ClassDeclaration : SyntaxKind
InterfaceDeclaration = 194,
InterfaceDeclaration = 197,
>InterfaceDeclaration : SyntaxKind
TypeAliasDeclaration = 195,
TypeAliasDeclaration = 198,
>TypeAliasDeclaration : SyntaxKind
EnumDeclaration = 196,
EnumDeclaration = 199,
>EnumDeclaration : SyntaxKind
ModuleDeclaration = 197,
ModuleDeclaration = 200,
>ModuleDeclaration : SyntaxKind
ModuleBlock = 198,
ModuleBlock = 201,
>ModuleBlock : SyntaxKind
ImportEqualsDeclaration = 199,
ImportEqualsDeclaration = 202,
>ImportEqualsDeclaration : SyntaxKind
ImportDeclaration = 200,
ImportDeclaration = 203,
>ImportDeclaration : SyntaxKind
ImportClause = 201,
ImportClause = 204,
>ImportClause : SyntaxKind
NamespaceImport = 202,
NamespaceImport = 205,
>NamespaceImport : SyntaxKind
NamedImports = 203,
NamedImports = 206,
>NamedImports : SyntaxKind
ImportSpecifier = 204,
ImportSpecifier = 207,
>ImportSpecifier : SyntaxKind
ExportAssignment = 205,
ExportAssignment = 208,
>ExportAssignment : SyntaxKind
ExportDeclaration = 206,
ExportDeclaration = 209,
>ExportDeclaration : SyntaxKind
NamedExports = 207,
NamedExports = 210,
>NamedExports : SyntaxKind
ExportSpecifier = 208,
ExportSpecifier = 211,
>ExportSpecifier : SyntaxKind
ExternalModuleReference = 209,
ExternalModuleReference = 212,
>ExternalModuleReference : SyntaxKind
CaseClause = 210,
CaseClause = 213,
>CaseClause : SyntaxKind
DefaultClause = 211,
DefaultClause = 214,
>DefaultClause : SyntaxKind
HeritageClause = 212,
HeritageClause = 215,
>HeritageClause : SyntaxKind
CatchClause = 213,
CatchClause = 216,
>CatchClause : SyntaxKind
PropertyAssignment = 214,
PropertyAssignment = 217,
>PropertyAssignment : SyntaxKind
ShorthandPropertyAssignment = 215,
ShorthandPropertyAssignment = 218,
>ShorthandPropertyAssignment : SyntaxKind
EnumMember = 216,
EnumMember = 219,
>EnumMember : SyntaxKind
SourceFile = 217,
SourceFile = 220,
>SourceFile : SyntaxKind
SyntaxList = 218,
SyntaxList = 221,
>SyntaxList : SyntaxKind
Count = 219,
Count = 222,
>Count : SyntaxKind
FirstAssignment = 52,
@@ -964,7 +975,7 @@ declare module "typescript" {
FirstKeyword = 65,
>FirstKeyword : SyntaxKind
LastKeyword = 122,
LastKeyword = 124,
>LastKeyword : SyntaxKind
FirstFutureReservedWord = 103,
@@ -973,10 +984,10 @@ declare module "typescript" {
LastFutureReservedWord = 111,
>LastFutureReservedWord : SyntaxKind
FirstTypeNode = 137,
FirstTypeNode = 139,
>FirstTypeNode : SyntaxKind
LastTypeNode = 145,
LastTypeNode = 147,
>LastTypeNode : SyntaxKind
FirstPunctuation = 14,
@@ -988,7 +999,7 @@ declare module "typescript" {
FirstToken = 0,
>FirstToken : SyntaxKind
LastToken = 122,
LastToken = 124,
>LastToken : SyntaxKind
FirstTriviaToken = 2,
@@ -1015,7 +1026,7 @@ declare module "typescript" {
LastBinaryOperator = 63,
>LastBinaryOperator : SyntaxKind
FirstNode = 123,
FirstNode = 125,
>FirstNode : SyntaxKind
}
const enum NodeFlags {
@@ -1702,9 +1713,9 @@ declare module "typescript" {
>left : Expression
>Expression : Expression
operator: SyntaxKind;
>operator : SyntaxKind
>SyntaxKind : SyntaxKind
operatorToken: Node;
>operatorToken : Node
>Node : Node
right: Expression;
>right : Expression
@@ -1996,6 +2007,19 @@ declare module "typescript" {
expression: Expression;
>expression : Expression
>Expression : Expression
}
interface ForOfStatement extends IterationStatement {
>ForOfStatement : ForOfStatement
>IterationStatement : IterationStatement
initializer: VariableDeclarationList | Expression;
>initializer : Expression | VariableDeclarationList
>VariableDeclarationList : VariableDeclarationList
>Expression : Expression
expression: Expression;
>expression : Expression
>Expression : Expression
}
interface BreakOrContinueStatement extends Statement {
@@ -2414,9 +2438,16 @@ declare module "typescript" {
text: string;
>text : string
amdDependencies: string[];
>amdDependencies : string[]
amdDependencies: {
>amdDependencies : { path: string; name: string; }[]
path: string;
>path : string
name: string;
>name : string
}[];
amdModuleName: string;
>amdModuleName : string
@@ -3543,10 +3574,13 @@ declare module "typescript" {
ContainsObjectLiteral = 524288,
>ContainsObjectLiteral : TypeFlags
Intrinsic = 127,
ESSymbol = 1048576,
>ESSymbol : TypeFlags
Intrinsic = 1048703,
>Intrinsic : TypeFlags
Primitive = 510,
Primitive = 1049086,
>Primitive : TypeFlags
StringLike = 258,
@@ -4388,6 +4422,9 @@ declare module "typescript" {
greaterThan = 62,
>greaterThan : CharacterCodes
hash = 35,
>hash : CharacterCodes
lessThan = 60,
>lessThan : CharacterCodes
@@ -4593,15 +4630,15 @@ declare module "typescript" {
>computeLineStarts : (text: string) => number[]
>text : string
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
>sourceFile : SourceFile
>SourceFile : SourceFile
>line : number
>character : number
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
>lineStarts : number[]
>line : number
>character : number
@@ -4960,16 +4997,16 @@ declare module "typescript" {
>getNamedDeclarations : () => Declaration[]
>Declaration : Declaration
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
>pos : number
>LineAndCharacter : LineAndCharacter
getLineStarts(): number[];
>getLineStarts : () => number[]
getPositionFromLineAndCharacter(line: number, character: number): number;
>getPositionFromLineAndCharacter : (line: number, character: number) => number
getPositionOfLineAndCharacter(line: number, character: number): number;
>getPositionOfLineAndCharacter : (line: number, character: number) => number
>line : number
>character : number
@@ -5186,9 +5223,10 @@ declare module "typescript" {
>position : number
>ReferenceEntry : ReferenceEntry
getNavigateToItems(searchValue: string): NavigateToItem[];
>getNavigateToItems : (searchValue: string) => NavigateToItem[]
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
>getNavigateToItems : (searchValue: string, maxResultCount?: number) => NavigateToItem[]
>searchValue : string
>maxResultCount : number
>NavigateToItem : NavigateToItem
getNavigationBarItems(fileName: string): NavigationBarItem[];
@@ -5427,6 +5465,9 @@ declare module "typescript" {
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
>PlaceOpenBraceOnNewLineForControlBlocks : boolean
[s: string]: boolean | number | string;
>s : string
}
interface DefinitionInfo {
>DefinitionInfo : DefinitionInfo
@@ -5764,6 +5805,15 @@ declare module "typescript" {
InDoubleQuoteStringLiteral = 3,
>InDoubleQuoteStringLiteral : EndOfLineState
InTemplateHeadOrNoSubstitutionTemplate = 4,
>InTemplateHeadOrNoSubstitutionTemplate : EndOfLineState
InTemplateMiddleOrTail = 5,
>InTemplateMiddleOrTail : EndOfLineState
InTemplateSubstitutionPosition = 6,
>InTemplateSubstitutionPosition : EndOfLineState
}
enum TokenClass {
>TokenClass : TokenClass
@@ -5819,12 +5869,31 @@ declare module "typescript" {
interface Classifier {
>Classifier : Classifier
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
>getClassificationsForLine : (text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean) => ClassificationResult
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
>getClassificationsForLine : (text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean) => ClassificationResult
>text : string
>lexState : EndOfLineState
>EndOfLineState : EndOfLineState
>classifyKeywordsInGenerics : boolean
>syntacticClassifierAbsent : boolean
>ClassificationResult : ClassificationResult
}
/**
+152 -117
View File
@@ -87,8 +87,8 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
allDiagnostics.forEach(diagnostic => {
if (diagnostic.file) {
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
}
else {
console.log(` Error: ${diagnostic.messageText}`);
@@ -250,118 +250,121 @@ declare module "typescript" {
NumberKeyword = 119,
SetKeyword = 120,
StringKeyword = 121,
TypeKeyword = 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,
ContinueStatement = 181,
BreakStatement = 182,
ReturnStatement = 183,
WithStatement = 184,
SwitchStatement = 185,
LabeledStatement = 186,
ThrowStatement = 187,
TryStatement = 188,
DebuggerStatement = 189,
VariableDeclaration = 190,
VariableDeclarationList = 191,
FunctionDeclaration = 192,
ClassDeclaration = 193,
InterfaceDeclaration = 194,
TypeAliasDeclaration = 195,
EnumDeclaration = 196,
ModuleDeclaration = 197,
ModuleBlock = 198,
ImportEqualsDeclaration = 199,
ImportDeclaration = 200,
ImportClause = 201,
NamespaceImport = 202,
NamedImports = 203,
ImportSpecifier = 204,
ExportAssignment = 205,
ExportDeclaration = 206,
NamedExports = 207,
ExportSpecifier = 208,
ExternalModuleReference = 209,
CaseClause = 210,
DefaultClause = 211,
HeritageClause = 212,
CatchClause = 213,
PropertyAssignment = 214,
ShorthandPropertyAssignment = 215,
EnumMember = 216,
SourceFile = 217,
SyntaxList = 218,
Count = 219,
SymbolKeyword = 122,
TypeKeyword = 123,
OfKeyword = 124,
QualifiedName = 125,
ComputedPropertyName = 126,
TypeParameter = 127,
Parameter = 128,
PropertySignature = 129,
PropertyDeclaration = 130,
MethodSignature = 131,
MethodDeclaration = 132,
Constructor = 133,
GetAccessor = 134,
SetAccessor = 135,
CallSignature = 136,
ConstructSignature = 137,
IndexSignature = 138,
TypeReference = 139,
FunctionType = 140,
ConstructorType = 141,
TypeQuery = 142,
TypeLiteral = 143,
ArrayType = 144,
TupleType = 145,
UnionType = 146,
ParenthesizedType = 147,
ObjectBindingPattern = 148,
ArrayBindingPattern = 149,
BindingElement = 150,
ArrayLiteralExpression = 151,
ObjectLiteralExpression = 152,
PropertyAccessExpression = 153,
ElementAccessExpression = 154,
CallExpression = 155,
NewExpression = 156,
TaggedTemplateExpression = 157,
TypeAssertionExpression = 158,
ParenthesizedExpression = 159,
FunctionExpression = 160,
ArrowFunction = 161,
DeleteExpression = 162,
TypeOfExpression = 163,
VoidExpression = 164,
PrefixUnaryExpression = 165,
PostfixUnaryExpression = 166,
BinaryExpression = 167,
ConditionalExpression = 168,
TemplateExpression = 169,
YieldExpression = 170,
SpreadElementExpression = 171,
OmittedExpression = 172,
TemplateSpan = 173,
Block = 174,
VariableStatement = 175,
EmptyStatement = 176,
ExpressionStatement = 177,
IfStatement = 178,
DoStatement = 179,
WhileStatement = 180,
ForStatement = 181,
ForInStatement = 182,
ForOfStatement = 183,
ContinueStatement = 184,
BreakStatement = 185,
ReturnStatement = 186,
WithStatement = 187,
SwitchStatement = 188,
LabeledStatement = 189,
ThrowStatement = 190,
TryStatement = 191,
DebuggerStatement = 192,
VariableDeclaration = 193,
VariableDeclarationList = 194,
FunctionDeclaration = 195,
ClassDeclaration = 196,
InterfaceDeclaration = 197,
TypeAliasDeclaration = 198,
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
ImportEqualsDeclaration = 202,
ImportDeclaration = 203,
ImportClause = 204,
NamespaceImport = 205,
NamedImports = 206,
ImportSpecifier = 207,
ExportAssignment = 208,
ExportDeclaration = 209,
NamedExports = 210,
ExportSpecifier = 211,
ExternalModuleReference = 212,
CaseClause = 213,
DefaultClause = 214,
HeritageClause = 215,
CatchClause = 216,
PropertyAssignment = 217,
ShorthandPropertyAssignment = 218,
EnumMember = 219,
SourceFile = 220,
SyntaxList = 221,
Count = 222,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
LastReservedWord = 100,
FirstKeyword = 65,
LastKeyword = 122,
LastKeyword = 124,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 137,
LastTypeNode = 145,
FirstTypeNode = 139,
LastTypeNode = 147,
FirstPunctuation = 14,
LastPunctuation = 63,
FirstToken = 0,
LastToken = 122,
LastToken = 124,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@@ -370,7 +373,7 @@ declare module "typescript" {
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 123,
FirstNode = 125,
}
const enum NodeFlags {
Export = 1,
@@ -603,7 +606,7 @@ declare module "typescript" {
}
interface BinaryExpression extends Expression {
left: Expression;
operator: SyntaxKind;
operatorToken: Node;
right: Expression;
}
interface ConditionalExpression extends Expression {
@@ -701,6 +704,10 @@ declare module "typescript" {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface ForOfStatement extends IterationStatement {
initializer: VariableDeclarationList | Expression;
expression: Expression;
}
interface BreakOrContinueStatement extends Statement {
label?: Identifier;
}
@@ -831,7 +838,10 @@ declare module "typescript" {
endOfFileToken: Node;
fileName: string;
text: string;
amdDependencies: string[];
amdDependencies: {
path: string;
name: string;
}[];
amdModuleName: string;
referencedFiles: FileReference[];
hasNoDefaultLib: boolean;
@@ -1139,8 +1149,9 @@ declare module "typescript" {
ObjectLiteral = 131072,
ContainsUndefinedOrNull = 262144,
ContainsObjectLiteral = 524288,
Intrinsic = 127,
Primitive = 510,
ESSymbol = 1048576,
Intrinsic = 1048703,
Primitive = 1049086,
StringLike = 258,
NumberLike = 132,
ObjectType = 48128,
@@ -1426,6 +1437,7 @@ declare module "typescript" {
equals = 61,
exclamation = 33,
greaterThan = 62,
hash = 35,
lessThan = 60,
minus = 45,
openBrace = 123,
@@ -1492,8 +1504,8 @@ declare module "typescript" {
}
function tokenToString(t: SyntaxKind): string;
function computeLineStarts(text: string): number[];
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
function getLineStarts(sourceFile: SourceFile): number[];
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
line: number;
@@ -1577,9 +1589,9 @@ declare module "typescript" {
scriptSnapshot: IScriptSnapshot;
nameTable: Map<string>;
getNamedDeclarations(): Declaration[];
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionFromLineAndCharacter(line: number, character: number): number;
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
/**
@@ -1641,7 +1653,7 @@ declare module "typescript" {
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string): NavigateToItem[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
@@ -1716,6 +1728,7 @@ declare module "typescript" {
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number | string;
}
interface DefinitionInfo {
fileName: string;
@@ -1849,6 +1862,9 @@ declare module "typescript" {
InMultiLineCommentTrivia = 1,
InSingleQuoteStringLiteral = 2,
InDoubleQuoteStringLiteral = 3,
InTemplateHeadOrNoSubstitutionTemplate = 4,
InTemplateMiddleOrTail = 5,
InTemplateSubstitutionPosition = 6,
}
enum TokenClass {
Punctuation = 0,
@@ -1870,7 +1886,26 @@ declare module "typescript" {
classification: TokenClass;
}
interface Classifier {
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
}
/**
* The document registry represents a store of SourceFile objects that can be shared between
@@ -2082,8 +2117,8 @@ function watch(rootFileNames, options) {
var allDiagnostics = services.getCompilerOptionsDiagnostics().concat(services.getSyntacticDiagnostics(fileName)).concat(services.getSemanticDiagnostics(fileName));
allDiagnostics.forEach(function (diagnostic) {
if (diagnostic.file) {
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
console.log(" Error " + diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
console.log(" Error " + diagnostic.file.fileName + " (" + (lineChar.line + 1) + "," + (lineChar.character + 1) + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
}
else {
console.log(" Error: " + diagnostic.messageText);
+200 -131
View File
@@ -317,11 +317,11 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
>fileName : string
allDiagnostics.forEach(diagnostic => {
>allDiagnostics.forEach(diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } }) : void
>allDiagnostics.forEach(diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } }) : void
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>allDiagnostics : ts.Diagnostic[]
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
>diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } } : (diagnostic: ts.Diagnostic) => void
>diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } } : (diagnostic: ts.Diagnostic) => void
>diagnostic : ts.Diagnostic
if (diagnostic.file) {
@@ -329,20 +329,20 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
>lineChar : ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start) : ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.file : ts.SourceFile
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
>diagnostic.start : number
>diagnostic : ts.Diagnostic
>start : number
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
>console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`) : any
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
>console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`) : any
>console.log : any
>console : any
>log : any
@@ -351,9 +351,11 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
>diagnostic : ts.Diagnostic
>file : ts.SourceFile
>fileName : string
>lineChar.line + 1 : number
>lineChar.line : number
>lineChar : ts.LineAndCharacter
>line : number
>lineChar.character + 1 : number
>lineChar.character : number
>lineChar : ts.LineAndCharacter
>character : number
@@ -828,298 +830,307 @@ declare module "typescript" {
StringKeyword = 121,
>StringKeyword : SyntaxKind
TypeKeyword = 122,
SymbolKeyword = 122,
>SymbolKeyword : SyntaxKind
TypeKeyword = 123,
>TypeKeyword : SyntaxKind
QualifiedName = 123,
OfKeyword = 124,
>OfKeyword : SyntaxKind
QualifiedName = 125,
>QualifiedName : SyntaxKind
ComputedPropertyName = 124,
ComputedPropertyName = 126,
>ComputedPropertyName : SyntaxKind
TypeParameter = 125,
TypeParameter = 127,
>TypeParameter : SyntaxKind
Parameter = 126,
Parameter = 128,
>Parameter : SyntaxKind
PropertySignature = 127,
PropertySignature = 129,
>PropertySignature : SyntaxKind
PropertyDeclaration = 128,
PropertyDeclaration = 130,
>PropertyDeclaration : SyntaxKind
MethodSignature = 129,
MethodSignature = 131,
>MethodSignature : SyntaxKind
MethodDeclaration = 130,
MethodDeclaration = 132,
>MethodDeclaration : SyntaxKind
Constructor = 131,
Constructor = 133,
>Constructor : SyntaxKind
GetAccessor = 132,
GetAccessor = 134,
>GetAccessor : SyntaxKind
SetAccessor = 133,
SetAccessor = 135,
>SetAccessor : SyntaxKind
CallSignature = 134,
CallSignature = 136,
>CallSignature : SyntaxKind
ConstructSignature = 135,
ConstructSignature = 137,
>ConstructSignature : SyntaxKind
IndexSignature = 136,
IndexSignature = 138,
>IndexSignature : SyntaxKind
TypeReference = 137,
TypeReference = 139,
>TypeReference : SyntaxKind
FunctionType = 138,
FunctionType = 140,
>FunctionType : SyntaxKind
ConstructorType = 139,
ConstructorType = 141,
>ConstructorType : SyntaxKind
TypeQuery = 140,
TypeQuery = 142,
>TypeQuery : SyntaxKind
TypeLiteral = 141,
TypeLiteral = 143,
>TypeLiteral : SyntaxKind
ArrayType = 142,
ArrayType = 144,
>ArrayType : SyntaxKind
TupleType = 143,
TupleType = 145,
>TupleType : SyntaxKind
UnionType = 144,
UnionType = 146,
>UnionType : SyntaxKind
ParenthesizedType = 145,
ParenthesizedType = 147,
>ParenthesizedType : SyntaxKind
ObjectBindingPattern = 146,
ObjectBindingPattern = 148,
>ObjectBindingPattern : SyntaxKind
ArrayBindingPattern = 147,
ArrayBindingPattern = 149,
>ArrayBindingPattern : SyntaxKind
BindingElement = 148,
BindingElement = 150,
>BindingElement : SyntaxKind
ArrayLiteralExpression = 149,
ArrayLiteralExpression = 151,
>ArrayLiteralExpression : SyntaxKind
ObjectLiteralExpression = 150,
ObjectLiteralExpression = 152,
>ObjectLiteralExpression : SyntaxKind
PropertyAccessExpression = 151,
PropertyAccessExpression = 153,
>PropertyAccessExpression : SyntaxKind
ElementAccessExpression = 152,
ElementAccessExpression = 154,
>ElementAccessExpression : SyntaxKind
CallExpression = 153,
CallExpression = 155,
>CallExpression : SyntaxKind
NewExpression = 154,
NewExpression = 156,
>NewExpression : SyntaxKind
TaggedTemplateExpression = 155,
TaggedTemplateExpression = 157,
>TaggedTemplateExpression : SyntaxKind
TypeAssertionExpression = 156,
TypeAssertionExpression = 158,
>TypeAssertionExpression : SyntaxKind
ParenthesizedExpression = 157,
ParenthesizedExpression = 159,
>ParenthesizedExpression : SyntaxKind
FunctionExpression = 158,
FunctionExpression = 160,
>FunctionExpression : SyntaxKind
ArrowFunction = 159,
ArrowFunction = 161,
>ArrowFunction : SyntaxKind
DeleteExpression = 160,
DeleteExpression = 162,
>DeleteExpression : SyntaxKind
TypeOfExpression = 161,
TypeOfExpression = 163,
>TypeOfExpression : SyntaxKind
VoidExpression = 162,
VoidExpression = 164,
>VoidExpression : SyntaxKind
PrefixUnaryExpression = 163,
PrefixUnaryExpression = 165,
>PrefixUnaryExpression : SyntaxKind
PostfixUnaryExpression = 164,
PostfixUnaryExpression = 166,
>PostfixUnaryExpression : SyntaxKind
BinaryExpression = 165,
BinaryExpression = 167,
>BinaryExpression : SyntaxKind
ConditionalExpression = 166,
ConditionalExpression = 168,
>ConditionalExpression : SyntaxKind
TemplateExpression = 167,
TemplateExpression = 169,
>TemplateExpression : SyntaxKind
YieldExpression = 168,
YieldExpression = 170,
>YieldExpression : SyntaxKind
SpreadElementExpression = 169,
SpreadElementExpression = 171,
>SpreadElementExpression : SyntaxKind
OmittedExpression = 170,
OmittedExpression = 172,
>OmittedExpression : SyntaxKind
TemplateSpan = 171,
TemplateSpan = 173,
>TemplateSpan : SyntaxKind
Block = 172,
Block = 174,
>Block : SyntaxKind
VariableStatement = 173,
VariableStatement = 175,
>VariableStatement : SyntaxKind
EmptyStatement = 174,
EmptyStatement = 176,
>EmptyStatement : SyntaxKind
ExpressionStatement = 175,
ExpressionStatement = 177,
>ExpressionStatement : SyntaxKind
IfStatement = 176,
IfStatement = 178,
>IfStatement : SyntaxKind
DoStatement = 177,
DoStatement = 179,
>DoStatement : SyntaxKind
WhileStatement = 178,
WhileStatement = 180,
>WhileStatement : SyntaxKind
ForStatement = 179,
ForStatement = 181,
>ForStatement : SyntaxKind
ForInStatement = 180,
ForInStatement = 182,
>ForInStatement : SyntaxKind
ContinueStatement = 181,
ForOfStatement = 183,
>ForOfStatement : SyntaxKind
ContinueStatement = 184,
>ContinueStatement : SyntaxKind
BreakStatement = 182,
BreakStatement = 185,
>BreakStatement : SyntaxKind
ReturnStatement = 183,
ReturnStatement = 186,
>ReturnStatement : SyntaxKind
WithStatement = 184,
WithStatement = 187,
>WithStatement : SyntaxKind
SwitchStatement = 185,
SwitchStatement = 188,
>SwitchStatement : SyntaxKind
LabeledStatement = 186,
LabeledStatement = 189,
>LabeledStatement : SyntaxKind
ThrowStatement = 187,
ThrowStatement = 190,
>ThrowStatement : SyntaxKind
TryStatement = 188,
TryStatement = 191,
>TryStatement : SyntaxKind
DebuggerStatement = 189,
DebuggerStatement = 192,
>DebuggerStatement : SyntaxKind
VariableDeclaration = 190,
VariableDeclaration = 193,
>VariableDeclaration : SyntaxKind
VariableDeclarationList = 191,
VariableDeclarationList = 194,
>VariableDeclarationList : SyntaxKind
FunctionDeclaration = 192,
FunctionDeclaration = 195,
>FunctionDeclaration : SyntaxKind
ClassDeclaration = 193,
ClassDeclaration = 196,
>ClassDeclaration : SyntaxKind
InterfaceDeclaration = 194,
InterfaceDeclaration = 197,
>InterfaceDeclaration : SyntaxKind
TypeAliasDeclaration = 195,
TypeAliasDeclaration = 198,
>TypeAliasDeclaration : SyntaxKind
EnumDeclaration = 196,
EnumDeclaration = 199,
>EnumDeclaration : SyntaxKind
ModuleDeclaration = 197,
ModuleDeclaration = 200,
>ModuleDeclaration : SyntaxKind
ModuleBlock = 198,
ModuleBlock = 201,
>ModuleBlock : SyntaxKind
ImportEqualsDeclaration = 199,
ImportEqualsDeclaration = 202,
>ImportEqualsDeclaration : SyntaxKind
ImportDeclaration = 200,
ImportDeclaration = 203,
>ImportDeclaration : SyntaxKind
ImportClause = 201,
ImportClause = 204,
>ImportClause : SyntaxKind
NamespaceImport = 202,
NamespaceImport = 205,
>NamespaceImport : SyntaxKind
NamedImports = 203,
NamedImports = 206,
>NamedImports : SyntaxKind
ImportSpecifier = 204,
ImportSpecifier = 207,
>ImportSpecifier : SyntaxKind
ExportAssignment = 205,
ExportAssignment = 208,
>ExportAssignment : SyntaxKind
ExportDeclaration = 206,
ExportDeclaration = 209,
>ExportDeclaration : SyntaxKind
NamedExports = 207,
NamedExports = 210,
>NamedExports : SyntaxKind
ExportSpecifier = 208,
ExportSpecifier = 211,
>ExportSpecifier : SyntaxKind
ExternalModuleReference = 209,
ExternalModuleReference = 212,
>ExternalModuleReference : SyntaxKind
CaseClause = 210,
CaseClause = 213,
>CaseClause : SyntaxKind
DefaultClause = 211,
DefaultClause = 214,
>DefaultClause : SyntaxKind
HeritageClause = 212,
HeritageClause = 215,
>HeritageClause : SyntaxKind
CatchClause = 213,
CatchClause = 216,
>CatchClause : SyntaxKind
PropertyAssignment = 214,
PropertyAssignment = 217,
>PropertyAssignment : SyntaxKind
ShorthandPropertyAssignment = 215,
ShorthandPropertyAssignment = 218,
>ShorthandPropertyAssignment : SyntaxKind
EnumMember = 216,
EnumMember = 219,
>EnumMember : SyntaxKind
SourceFile = 217,
SourceFile = 220,
>SourceFile : SyntaxKind
SyntaxList = 218,
SyntaxList = 221,
>SyntaxList : SyntaxKind
Count = 219,
Count = 222,
>Count : SyntaxKind
FirstAssignment = 52,
@@ -1137,7 +1148,7 @@ declare module "typescript" {
FirstKeyword = 65,
>FirstKeyword : SyntaxKind
LastKeyword = 122,
LastKeyword = 124,
>LastKeyword : SyntaxKind
FirstFutureReservedWord = 103,
@@ -1146,10 +1157,10 @@ declare module "typescript" {
LastFutureReservedWord = 111,
>LastFutureReservedWord : SyntaxKind
FirstTypeNode = 137,
FirstTypeNode = 139,
>FirstTypeNode : SyntaxKind
LastTypeNode = 145,
LastTypeNode = 147,
>LastTypeNode : SyntaxKind
FirstPunctuation = 14,
@@ -1161,7 +1172,7 @@ declare module "typescript" {
FirstToken = 0,
>FirstToken : SyntaxKind
LastToken = 122,
LastToken = 124,
>LastToken : SyntaxKind
FirstTriviaToken = 2,
@@ -1188,7 +1199,7 @@ declare module "typescript" {
LastBinaryOperator = 63,
>LastBinaryOperator : SyntaxKind
FirstNode = 123,
FirstNode = 125,
>FirstNode : SyntaxKind
}
const enum NodeFlags {
@@ -1875,9 +1886,9 @@ declare module "typescript" {
>left : Expression
>Expression : Expression
operator: SyntaxKind;
>operator : SyntaxKind
>SyntaxKind : SyntaxKind
operatorToken: Node;
>operatorToken : Node
>Node : Node
right: Expression;
>right : Expression
@@ -2169,6 +2180,19 @@ declare module "typescript" {
expression: Expression;
>expression : Expression
>Expression : Expression
}
interface ForOfStatement extends IterationStatement {
>ForOfStatement : ForOfStatement
>IterationStatement : IterationStatement
initializer: VariableDeclarationList | Expression;
>initializer : Expression | VariableDeclarationList
>VariableDeclarationList : VariableDeclarationList
>Expression : Expression
expression: Expression;
>expression : Expression
>Expression : Expression
}
interface BreakOrContinueStatement extends Statement {
@@ -2587,9 +2611,16 @@ declare module "typescript" {
text: string;
>text : string
amdDependencies: string[];
>amdDependencies : string[]
amdDependencies: {
>amdDependencies : { path: string; name: string; }[]
path: string;
>path : string
name: string;
>name : string
}[];
amdModuleName: string;
>amdModuleName : string
@@ -3716,10 +3747,13 @@ declare module "typescript" {
ContainsObjectLiteral = 524288,
>ContainsObjectLiteral : TypeFlags
Intrinsic = 127,
ESSymbol = 1048576,
>ESSymbol : TypeFlags
Intrinsic = 1048703,
>Intrinsic : TypeFlags
Primitive = 510,
Primitive = 1049086,
>Primitive : TypeFlags
StringLike = 258,
@@ -4561,6 +4595,9 @@ declare module "typescript" {
greaterThan = 62,
>greaterThan : CharacterCodes
hash = 35,
>hash : CharacterCodes
lessThan = 60,
>lessThan : CharacterCodes
@@ -4766,15 +4803,15 @@ declare module "typescript" {
>computeLineStarts : (text: string) => number[]
>text : string
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
>sourceFile : SourceFile
>SourceFile : SourceFile
>line : number
>character : number
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
>lineStarts : number[]
>line : number
>character : number
@@ -5133,16 +5170,16 @@ declare module "typescript" {
>getNamedDeclarations : () => Declaration[]
>Declaration : Declaration
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
>pos : number
>LineAndCharacter : LineAndCharacter
getLineStarts(): number[];
>getLineStarts : () => number[]
getPositionFromLineAndCharacter(line: number, character: number): number;
>getPositionFromLineAndCharacter : (line: number, character: number) => number
getPositionOfLineAndCharacter(line: number, character: number): number;
>getPositionOfLineAndCharacter : (line: number, character: number) => number
>line : number
>character : number
@@ -5359,9 +5396,10 @@ declare module "typescript" {
>position : number
>ReferenceEntry : ReferenceEntry
getNavigateToItems(searchValue: string): NavigateToItem[];
>getNavigateToItems : (searchValue: string) => NavigateToItem[]
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
>getNavigateToItems : (searchValue: string, maxResultCount?: number) => NavigateToItem[]
>searchValue : string
>maxResultCount : number
>NavigateToItem : NavigateToItem
getNavigationBarItems(fileName: string): NavigationBarItem[];
@@ -5600,6 +5638,9 @@ declare module "typescript" {
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
>PlaceOpenBraceOnNewLineForControlBlocks : boolean
[s: string]: boolean | number | string;
>s : string
}
interface DefinitionInfo {
>DefinitionInfo : DefinitionInfo
@@ -5937,6 +5978,15 @@ declare module "typescript" {
InDoubleQuoteStringLiteral = 3,
>InDoubleQuoteStringLiteral : EndOfLineState
InTemplateHeadOrNoSubstitutionTemplate = 4,
>InTemplateHeadOrNoSubstitutionTemplate : EndOfLineState
InTemplateMiddleOrTail = 5,
>InTemplateMiddleOrTail : EndOfLineState
InTemplateSubstitutionPosition = 6,
>InTemplateSubstitutionPosition : EndOfLineState
}
enum TokenClass {
>TokenClass : TokenClass
@@ -5992,12 +6042,31 @@ declare module "typescript" {
interface Classifier {
>Classifier : Classifier
getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): ClassificationResult;
>getClassificationsForLine : (text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean) => ClassificationResult
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
>getClassificationsForLine : (text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean) => ClassificationResult
>text : string
>lexState : EndOfLineState
>EndOfLineState : EndOfLineState
>classifyKeywordsInGenerics : boolean
>syntacticClassifierAbsent : boolean
>ClassificationResult : ClassificationResult
}
/**
@@ -19,9 +19,7 @@ module clodule {
var clodule = (function () {
function clodule() {
}
clodule.sfn = function (id) {
return 42;
};
clodule.sfn = function (id) { return 42; };
return clodule;
})();
var clodule;
@@ -28,16 +28,12 @@ var Point = (function () {
this.x = x;
this.y = y;
}
Point.Origin = function () {
return { x: 0, y: 0 };
}; // unexpected error here bug 840246
Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246
return Point;
})();
var Point;
(function (Point) {
function Origin() {
return null;
}
function Origin() { return null; }
Point.Origin = Origin; //expected duplicate identifier error
})(Point || (Point = {}));
var A;
@@ -47,17 +43,13 @@ var A;
this.x = x;
this.y = y;
}
Point.Origin = function () {
return { x: 0, y: 0 };
}; // unexpected error here bug 840246
Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246
return Point;
})();
A.Point = Point;
var Point;
(function (Point) {
function Origin() {
return "";
}
function Origin() { return ""; }
Point.Origin = Origin; //expected duplicate identifier error
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
@@ -28,16 +28,12 @@ var Point = (function () {
this.x = x;
this.y = y;
}
Point.Origin = function () {
return { x: 0, y: 0 };
};
Point.Origin = function () { return { x: 0, y: 0 }; };
return Point;
})();
var Point;
(function (Point) {
function Origin() {
return "";
} // not an error, since not exported
function Origin() { return ""; } // not an error, since not exported
})(Point || (Point = {}));
var A;
(function (A) {
@@ -46,16 +42,12 @@ var A;
this.x = x;
this.y = y;
}
Point.Origin = function () {
return { x: 0, y: 0 };
};
Point.Origin = function () { return { x: 0, y: 0 }; };
return Point;
})();
A.Point = Point;
var Point;
(function (Point) {
function Origin() {
return "";
} // not an error since not exported
function Origin() { return ""; } // not an error since not exported
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
@@ -0,0 +1,16 @@
tests/cases/conformance/Symbols/ES5SymbolProperty1.ts(7,6): error TS2471: A computed property name of the form 'Symbol.foo' must be of type 'symbol'.
==== tests/cases/conformance/Symbols/ES5SymbolProperty1.ts (1 errors) ====
interface SymbolConstructor {
foo: string;
}
var Symbol: SymbolConstructor;
var obj = {
[Symbol.foo]: 0
~~~~~~~~~~
!!! error TS2471: A computed property name of the form 'Symbol.foo' must be of type 'symbol'.
}
obj[Symbol.foo];
@@ -0,0 +1,19 @@
//// [ES5SymbolProperty1.ts]
interface SymbolConstructor {
foo: string;
}
var Symbol: SymbolConstructor;
var obj = {
[Symbol.foo]: 0
}
obj[Symbol.foo];
//// [ES5SymbolProperty1.js]
var Symbol;
var obj = (_a = {}, _a[Symbol.foo] =
0,
_a);
obj[Symbol.foo];
var _a;
@@ -0,0 +1,19 @@
tests/cases/conformance/Symbols/ES5SymbolProperty2.ts(5,10): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
tests/cases/conformance/Symbols/ES5SymbolProperty2.ts(10,11): error TS2304: Cannot find name 'Symbol'.
==== tests/cases/conformance/Symbols/ES5SymbolProperty2.ts (2 errors) ====
module M {
var Symbol;
export class C {
[Symbol.iterator]() { }
~~~~~~~~~~~~~~~
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
}
(new C)[Symbol.iterator];
}
(new M.C)[Symbol.iterator];
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
@@ -0,0 +1,26 @@
//// [ES5SymbolProperty2.ts]
module M {
var Symbol;
export class C {
[Symbol.iterator]() { }
}
(new C)[Symbol.iterator];
}
(new M.C)[Symbol.iterator];
//// [ES5SymbolProperty2.js]
var M;
(function (M) {
var Symbol;
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
M.C = C;
(new C)[Symbol.iterator];
})(M || (M = {}));
(new M.C)[Symbol.iterator];
@@ -0,0 +1,13 @@
tests/cases/conformance/Symbols/ES5SymbolProperty3.ts(4,6): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
==== tests/cases/conformance/Symbols/ES5SymbolProperty3.ts (1 errors) ====
var Symbol;
class C {
[Symbol.iterator]() { }
~~~~~~~~~~~~~~~
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
}
(new C)[Symbol.iterator]
@@ -0,0 +1,18 @@
//// [ES5SymbolProperty3.ts]
var Symbol;
class C {
[Symbol.iterator]() { }
}
(new C)[Symbol.iterator]
//// [ES5SymbolProperty3.js]
var Symbol;
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
(new C)[Symbol.iterator];
@@ -0,0 +1,13 @@
tests/cases/conformance/Symbols/ES5SymbolProperty4.ts(4,6): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
==== tests/cases/conformance/Symbols/ES5SymbolProperty4.ts (1 errors) ====
var Symbol: { iterator: string };
class C {
[Symbol.iterator]() { }
~~~~~~~~~~~~~~~
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
}
(new C)[Symbol.iterator]
@@ -0,0 +1,18 @@
//// [ES5SymbolProperty4.ts]
var Symbol: { iterator: string };
class C {
[Symbol.iterator]() { }
}
(new C)[Symbol.iterator]
//// [ES5SymbolProperty4.js]
var Symbol;
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
(new C)[Symbol.iterator];
@@ -0,0 +1,13 @@
tests/cases/conformance/Symbols/ES5SymbolProperty5.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/conformance/Symbols/ES5SymbolProperty5.ts (1 errors) ====
var Symbol: { iterator: symbol };
class C {
[Symbol.iterator]() { }
}
(new C)[Symbol.iterator](0) // Should error
~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
@@ -0,0 +1,18 @@
//// [ES5SymbolProperty5.ts]
var Symbol: { iterator: symbol };
class C {
[Symbol.iterator]() { }
}
(new C)[Symbol.iterator](0) // Should error
//// [ES5SymbolProperty5.js]
var Symbol;
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
(new C)[Symbol.iterator](0); // Should error
@@ -0,0 +1,14 @@
tests/cases/conformance/Symbols/ES5SymbolProperty6.ts(2,6): error TS2304: Cannot find name 'Symbol'.
tests/cases/conformance/Symbols/ES5SymbolProperty6.ts(5,9): error TS2304: Cannot find name 'Symbol'.
==== tests/cases/conformance/Symbols/ES5SymbolProperty6.ts (2 errors) ====
class C {
[Symbol.iterator]() { }
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
}
(new C)[Symbol.iterator]
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
@@ -0,0 +1,15 @@
//// [ES5SymbolProperty6.ts]
class C {
[Symbol.iterator]() { }
}
(new C)[Symbol.iterator]
//// [ES5SymbolProperty6.js]
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
(new C)[Symbol.iterator];
@@ -0,0 +1,13 @@
tests/cases/conformance/Symbols/ES5SymbolProperty7.ts(4,6): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
==== tests/cases/conformance/Symbols/ES5SymbolProperty7.ts (1 errors) ====
var Symbol: { iterator: any };
class C {
[Symbol.iterator]() { }
~~~~~~~~~~~~~~~
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
}
(new C)[Symbol.iterator]
@@ -0,0 +1,18 @@
//// [ES5SymbolProperty7.ts]
var Symbol: { iterator: any };
class C {
[Symbol.iterator]() { }
}
(new C)[Symbol.iterator]
//// [ES5SymbolProperty7.js]
var Symbol;
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
return C;
})();
(new C)[Symbol.iterator];
@@ -0,0 +1,7 @@
//// [ES5SymbolType1.ts]
var s: symbol;
s.toString();
//// [ES5SymbolType1.js]
var s;
s.toString();
@@ -0,0 +1,10 @@
=== tests/cases/conformance/Symbols/ES5SymbolType1.ts ===
var s: symbol;
>s : symbol
s.toString();
>s.toString() : string
>s.toString : () => string
>s : symbol
>toString : () => string
@@ -1,12 +1,9 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,12): error TS2304: Cannot find name 'yield'.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,20): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (3 errors) ====
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (2 errors) ====
var v = { [yield]: foo }
~~~~~~~
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
~~~~~
!!! error TS2304: Cannot find name 'yield'.
~~~
@@ -2,4 +2,7 @@
var v = { [yield]: foo }
//// [FunctionDeclaration8_es6.js]
var v = { [yield]: foo };
var v = (_a = {}, _a[yield] =
foo,
_a);
var _a;
@@ -1,15 +1,12 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,14): error TS9000: 'yield' expressions are not currently supported.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (3 errors) ====
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (2 errors) ====
function * foo() {
~
!!! error TS9001: Generators are not currently supported.
var v = { [yield]: foo }
~~~~~~~
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
}
@@ -5,5 +5,8 @@ function * foo() {
//// [FunctionDeclaration9_es6.js]
function foo() {
var v = { []: foo };
var v = (_a = {}, _a[] =
foo,
_a);
var _a;
}
@@ -2,5 +2,4 @@
var v = { * }
//// [FunctionPropertyAssignments4_es6.js]
var v = { : function () {
} };
var v = { : function () { } };
@@ -1,13 +1,10 @@
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (3 errors) ====
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ====
var v = { *[foo()]() { } }
~
!!! error TS9001: Generators are not currently supported.
~~~~~~~
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
~~~
!!! error TS2304: Cannot find name 'foo'.
@@ -2,4 +2,6 @@
var v = { *[foo()]() { } }
//// [FunctionPropertyAssignments5_es6.js]
var v = { [foo()]: function () { } };
var v = (_a = {}, _a[foo()] = function () { },
_a);
var _a;
@@ -7,5 +7,6 @@ var v = { * foo() {
//// [YieldExpression10_es6.js]
var v = { foo: function () {
;
} };
;
}
};
@@ -2,6 +2,4 @@
function* foo() { yield }
//// [YieldExpression13_es6.js]
function foo() {
;
}
function foo() { ; }
@@ -2,6 +2,4 @@
var v = { get foo() { yield foo; } }
//// [YieldExpression17_es6.js]
var v = { get foo() {
;
} };
var v = { get foo() { ; } };
@@ -52,9 +52,7 @@ var C = (function () {
}
C.privateMethod = function () { };
Object.defineProperty(C, "privateGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -65,9 +63,7 @@ var C = (function () {
});
C.protectedMethod = function () { };
Object.defineProperty(C, "protectedGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -78,9 +74,7 @@ var C = (function () {
});
C.publicMethod = function () { };
Object.defineProperty(C, "publicGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -97,9 +91,7 @@ var D = (function () {
}
D.privateMethod = function () { };
Object.defineProperty(D, "privateGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -110,9 +102,7 @@ var D = (function () {
});
D.protectedMethod = function () { };
Object.defineProperty(D, "protectedGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -123,9 +113,7 @@ var D = (function () {
});
D.publicMethod = function () { };
Object.defineProperty(D, "publicGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -142,9 +130,7 @@ var E = (function () {
}
E.prototype.method = function () { };
Object.defineProperty(E.prototype, "getter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
+1 -3
View File
@@ -47,9 +47,7 @@ var D = (function () {
return D;
})();
var x = {
get a() {
return 1;
}
get a() { return 1; }
};
var y = {
set b(v) { }
+1 -3
View File
@@ -44,9 +44,7 @@ var D = (function () {
return D;
})();
var x = {
get a() {
return 1;
}
get a() { return 1; }
};
var y = {
set b(v) { }
@@ -2,5 +2,4 @@
var v = { get foo() }
//// [accessorWithoutBody1.js]
var v = { get foo() {
} };
var v = { get foo() { } };
@@ -2,5 +2,4 @@
var v = { set foo(a) }
//// [accessorWithoutBody2.js]
var v = { set foo(a) {
} };
var v = { set foo(a) { } };
@@ -11,14 +11,10 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "x", {
get: function () {
return 1;
},
get: function () { return 1; },
enumerable: true,
configurable: true
});
return C;
})();
var y = { get foo() {
return 3;
} };
var y = { get foo() { return 3; } };
@@ -18,38 +18,26 @@ var LanguageSpec_section_4_5_error_cases = (function () {
function LanguageSpec_section_4_5_error_cases() {
}
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedSetter_SetterFirst", {
get: function () {
return "";
},
get: function () { return ""; },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedSetter_SetterLast", {
get: function () {
return "";
},
get: function () { return ""; },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedGetter_GetterFirst", {
get: function () {
return "";
},
set: function (aStr) {
aStr = 0;
},
get: function () { return ""; },
set: function (aStr) { aStr = 0; },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedGetter_GetterLast", {
get: function () {
return "";
},
set: function (aStr) {
aStr = 0;
},
get: function () { return ""; },
set: function (aStr) { aStr = 0; },
enumerable: true,
configurable: true
});
@@ -47,49 +47,37 @@ var LanguageSpec_section_4_5_inference = (function () {
function LanguageSpec_section_4_5_inference() {
}
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredGetterFromSetterAnnotation", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredGetterFromSetterAnnotation_GetterFirst", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredFromGetter", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredFromGetter_SetterFirst", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredSetterFromGetterAnnotation", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredSetterFromGetterAnnotation_GetterFirst", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
@@ -84,6 +84,4 @@ var r16 = a + M;
var r17 = a + '';
var r18 = a + 123;
var r19 = a + { a: '' };
var r20 = a + (function (a) {
return a;
});
var r20 = a + (function (a) { return a; });

Some files were not shown because too many files have changed in this diff Show More