mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into taggedTemplates
Conflicts: src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json src/compiler/emitter.ts
This commit is contained in:
@@ -43,3 +43,4 @@ scripts/word2md.js
|
||||
scripts/ior.js
|
||||
scripts/*.js.map
|
||||
coverage/
|
||||
internal/
|
||||
|
||||
@@ -194,7 +194,7 @@ var compilerFilename = "tsc.js";
|
||||
* @param keepComments: false to compile using --removeComments
|
||||
* @param callback: a function to execute after the compilation process ends
|
||||
*/
|
||||
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, callback) {
|
||||
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
|
||||
file(outFile, prereqs, function() {
|
||||
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
|
||||
var options = "--module commonjs -noImplicitAny";
|
||||
@@ -227,6 +227,10 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
|
||||
options += " -sourcemap -mapRoot file:///" + path.resolve(path.dirname(outFile));
|
||||
}
|
||||
|
||||
if (stripInternal) {
|
||||
options += " --stripInternal"
|
||||
}
|
||||
|
||||
var cmd = host + " " + dir + compilerFilename + " " + options + " ";
|
||||
cmd = cmd + sources.join(" ");
|
||||
console.log(cmd + "\n");
|
||||
@@ -331,7 +335,8 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
|
||||
/*outDir*/ undefined,
|
||||
/*preserveConstEnums*/ true,
|
||||
/*keepComments*/ false,
|
||||
/*noResolve*/ false);
|
||||
/*noResolve*/ false,
|
||||
/*stripInternal*/ false);
|
||||
|
||||
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
|
||||
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
|
||||
@@ -347,6 +352,7 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright
|
||||
/*preserveConstEnums*/ true,
|
||||
/*keepComments*/ true,
|
||||
/*noResolve*/ true,
|
||||
/*stripInternal*/ true,
|
||||
/*callback*/ function () {
|
||||
function makeDefinitionFiles(definitionsRoots, standaloneDefinitionsFile, nodeDefinitionsFile) {
|
||||
// Create the standalone definition file
|
||||
@@ -376,6 +382,10 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright
|
||||
desc("Builds the full compiler and services");
|
||||
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile]);
|
||||
|
||||
// Local target to build only tsc.js
|
||||
desc("Builds only the compiler");
|
||||
task("tsc", ["generate-diagnostics", "lib", tscFile]);
|
||||
|
||||
// Local target to build the compiler and services
|
||||
desc("Sets release mode flag");
|
||||
task("release", function() {
|
||||
@@ -451,14 +461,16 @@ directory(builtLocalDirectory);
|
||||
var run = path.join(builtLocalDirectory, "run.js");
|
||||
compileFile(run, harnessSources, [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources), [], /*useBuiltCompiler:*/ true);
|
||||
|
||||
var internalTests = "internal/"
|
||||
|
||||
var localBaseline = "tests/baselines/local/";
|
||||
var refBaseline = "tests/baselines/reference/";
|
||||
|
||||
var localRwcBaseline = "tests/baselines/rwc/local/";
|
||||
var refRwcBaseline = "tests/baselines/rwc/reference/";
|
||||
var localRwcBaseline = path.join(internalTests, "baselines/rwc/local");
|
||||
var refRwcBaseline = path.join(internalTests, "baselines/rwc/reference");
|
||||
|
||||
var localTest262Baseline = "tests/baselines/test262/local/";
|
||||
var refTest262Baseline = "tests/baselines/test262/reference/";
|
||||
var localTest262Baseline = path.join(internalTests, "baselines/test262/local");
|
||||
var refTest262Baseline = path.join(internalTests, "baselines/test262/reference");
|
||||
|
||||
desc("Builds the test infrastructure using the built compiler");
|
||||
task("tests", ["local", run].concat(libraryTargets));
|
||||
@@ -491,11 +503,13 @@ function cleanTestDirs() {
|
||||
jake.rmRf(localBaseline);
|
||||
}
|
||||
|
||||
// Clean the local Rwc baselines directory
|
||||
// Clean the local Rwc baselines directory
|
||||
if (fs.existsSync(localRwcBaseline)) {
|
||||
jake.rmRf(localRwcBaseline);
|
||||
}
|
||||
|
||||
jake.mkdirP(localRwcBaseline);
|
||||
jake.mkdirP(localTest262Baseline);
|
||||
jake.mkdirP(localBaseline);
|
||||
}
|
||||
|
||||
@@ -507,8 +521,8 @@ function writeTestConfigFile(tests, testConfigFile) {
|
||||
}
|
||||
|
||||
function deleteTemporaryProjectOutput() {
|
||||
if (fs.existsSync(localBaseline + "projectOutput/")) {
|
||||
jake.rmRf(localBaseline + "projectOutput/");
|
||||
if (fs.existsSync(path.join(localBaseline, "projectOutput/"))) {
|
||||
jake.rmRf(path.join(localBaseline, "projectOutput/"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+799
-396
File diff suppressed because it is too large
Load Diff
Vendored
+15
-1
@@ -283,6 +283,11 @@ declare module "typescript" {
|
||||
ThisNodeOrAnySubNodesHasError = 32,
|
||||
HasAggregatedChildData = 64,
|
||||
}
|
||||
const enum RelationComparisonResult {
|
||||
Succeeded = 1,
|
||||
Failed = 2,
|
||||
FailedAndReported = 3,
|
||||
}
|
||||
interface Node extends TextRange {
|
||||
kind: SyntaxKind;
|
||||
flags: NodeFlags;
|
||||
@@ -994,11 +999,15 @@ declare module "typescript" {
|
||||
Union = 16384,
|
||||
Anonymous = 32768,
|
||||
FromSignature = 65536,
|
||||
Unwidened = 131072,
|
||||
ObjectLiteral = 131072,
|
||||
ContainsUndefinedOrNull = 262144,
|
||||
ContainsObjectLiteral = 524288,
|
||||
Intrinsic = 127,
|
||||
Primitive = 510,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 48128,
|
||||
RequiresWidening = 786432,
|
||||
}
|
||||
interface Type {
|
||||
flags: TypeFlags;
|
||||
@@ -1123,6 +1132,7 @@ declare module "typescript" {
|
||||
diagnostics?: boolean;
|
||||
emitBOM?: boolean;
|
||||
help?: boolean;
|
||||
listFiles?: boolean;
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
module?: ModuleKind;
|
||||
@@ -1136,6 +1146,7 @@ declare module "typescript" {
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
preserveConstEnums?: boolean;
|
||||
project?: string;
|
||||
removeComments?: boolean;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
@@ -1168,6 +1179,7 @@ declare module "typescript" {
|
||||
interface CommandLineOption {
|
||||
name: string;
|
||||
type: string | Map<number>;
|
||||
isFilePath?: boolean;
|
||||
shortName?: string;
|
||||
description?: DiagnosticMessage;
|
||||
paramType?: DiagnosticMessage;
|
||||
@@ -1428,6 +1440,7 @@ declare module "typescript" {
|
||||
isOpen: boolean;
|
||||
version: string;
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
}
|
||||
/**
|
||||
@@ -1470,6 +1483,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface LanguageServiceHost extends Logger {
|
||||
getCompilationSettings(): CompilerOptions;
|
||||
getNewLine?(): string;
|
||||
getScriptFileNames(): string[];
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptIsOpen(fileName: string): boolean;
|
||||
|
||||
Vendored
+15
-1
@@ -283,6 +283,11 @@ declare module ts {
|
||||
ThisNodeOrAnySubNodesHasError = 32,
|
||||
HasAggregatedChildData = 64,
|
||||
}
|
||||
const enum RelationComparisonResult {
|
||||
Succeeded = 1,
|
||||
Failed = 2,
|
||||
FailedAndReported = 3,
|
||||
}
|
||||
interface Node extends TextRange {
|
||||
kind: SyntaxKind;
|
||||
flags: NodeFlags;
|
||||
@@ -994,11 +999,15 @@ declare module ts {
|
||||
Union = 16384,
|
||||
Anonymous = 32768,
|
||||
FromSignature = 65536,
|
||||
Unwidened = 131072,
|
||||
ObjectLiteral = 131072,
|
||||
ContainsUndefinedOrNull = 262144,
|
||||
ContainsObjectLiteral = 524288,
|
||||
Intrinsic = 127,
|
||||
Primitive = 510,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 48128,
|
||||
RequiresWidening = 786432,
|
||||
}
|
||||
interface Type {
|
||||
flags: TypeFlags;
|
||||
@@ -1123,6 +1132,7 @@ declare module ts {
|
||||
diagnostics?: boolean;
|
||||
emitBOM?: boolean;
|
||||
help?: boolean;
|
||||
listFiles?: boolean;
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
module?: ModuleKind;
|
||||
@@ -1136,6 +1146,7 @@ declare module ts {
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
preserveConstEnums?: boolean;
|
||||
project?: string;
|
||||
removeComments?: boolean;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
@@ -1168,6 +1179,7 @@ declare module ts {
|
||||
interface CommandLineOption {
|
||||
name: string;
|
||||
type: string | Map<number>;
|
||||
isFilePath?: boolean;
|
||||
shortName?: string;
|
||||
description?: DiagnosticMessage;
|
||||
paramType?: DiagnosticMessage;
|
||||
@@ -1428,6 +1440,7 @@ declare module ts {
|
||||
isOpen: boolean;
|
||||
version: string;
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
}
|
||||
/**
|
||||
@@ -1470,6 +1483,7 @@ declare module ts {
|
||||
}
|
||||
interface LanguageServiceHost extends Logger {
|
||||
getCompilationSettings(): CompilerOptions;
|
||||
getNewLine?(): string;
|
||||
getScriptFileNames(): string[];
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptIsOpen(fileName: string): boolean;
|
||||
|
||||
+783
-374
File diff suppressed because it is too large
Load Diff
Vendored
+5
-1
@@ -44,6 +44,7 @@ declare module ts {
|
||||
function getProperty<T>(map: Map<T>, key: string): T;
|
||||
function isEmpty<T>(map: Map<T>): boolean;
|
||||
function clone<T>(object: T): T;
|
||||
function extend<T>(first: Map<T>, second: Map<T>): Map<T>;
|
||||
function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U;
|
||||
function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U;
|
||||
function lookUp<T>(map: Map<T>, key: string): T;
|
||||
@@ -125,6 +126,7 @@ declare module ts {
|
||||
createDirectory(directoryName: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
readDirectory(path: string, extension?: string): string[];
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
@@ -186,7 +188,7 @@ declare module ts {
|
||||
function isObjectLiteralMethod(node: Node): boolean;
|
||||
function getContainingFunction(node: Node): FunctionLikeDeclaration;
|
||||
function getThisContainer(node: Node, includeArrowFunctions: boolean): Node;
|
||||
function getSuperContainer(node: Node): Node;
|
||||
function getSuperContainer(node: Node, includeFunctions: boolean): Node;
|
||||
function getInvokedExpression(node: CallLikeExpression): Expression;
|
||||
function isExpression(node: Node): boolean;
|
||||
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
|
||||
@@ -244,6 +246,8 @@ declare module ts {
|
||||
declare module ts {
|
||||
var optionDeclarations: CommandLineOption[];
|
||||
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
|
||||
function readConfigFile(filename: string): any;
|
||||
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
|
||||
}
|
||||
declare module ts {
|
||||
interface ListItemInfo {
|
||||
|
||||
Vendored
+5
-1
@@ -44,6 +44,7 @@ declare module "typescript" {
|
||||
function getProperty<T>(map: Map<T>, key: string): T;
|
||||
function isEmpty<T>(map: Map<T>): boolean;
|
||||
function clone<T>(object: T): T;
|
||||
function extend<T>(first: Map<T>, second: Map<T>): Map<T>;
|
||||
function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U;
|
||||
function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U;
|
||||
function lookUp<T>(map: Map<T>, key: string): T;
|
||||
@@ -125,6 +126,7 @@ declare module "typescript" {
|
||||
createDirectory(directoryName: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
readDirectory(path: string, extension?: string): string[];
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
@@ -186,7 +188,7 @@ declare module "typescript" {
|
||||
function isObjectLiteralMethod(node: Node): boolean;
|
||||
function getContainingFunction(node: Node): FunctionLikeDeclaration;
|
||||
function getThisContainer(node: Node, includeArrowFunctions: boolean): Node;
|
||||
function getSuperContainer(node: Node): Node;
|
||||
function getSuperContainer(node: Node, includeFunctions: boolean): Node;
|
||||
function getInvokedExpression(node: CallLikeExpression): Expression;
|
||||
function isExpression(node: Node): boolean;
|
||||
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
|
||||
@@ -244,6 +246,8 @@ declare module "typescript" {
|
||||
declare module "typescript" {
|
||||
var optionDeclarations: CommandLineOption[];
|
||||
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
|
||||
function readConfigFile(filename: string): any;
|
||||
function parseConfigFile(json: any, basePath?: string): ParsedCommandLine;
|
||||
}
|
||||
declare module "typescript" {
|
||||
interface ListItemInfo {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+589
-208
File diff suppressed because it is too large
Load Diff
+44
-44
@@ -1,46 +1,46 @@
|
||||
{
|
||||
"name": "typescript",
|
||||
"author": "Microsoft Corp.",
|
||||
"homepage": "http://typescriptlang.org/",
|
||||
"version": "1.4.0",
|
||||
"licenses": [
|
||||
{
|
||||
"type": "Apache License 2.0",
|
||||
"url": "https://github.com/Microsoft/TypeScript/blob/master/LICENSE.txt"
|
||||
}
|
||||
],
|
||||
"description": "TypeScript is a language for application scale JavaScript development",
|
||||
"keywords": [
|
||||
"TypeScript",
|
||||
"Microsoft",
|
||||
"compiler",
|
||||
"language",
|
||||
"javascript"
|
||||
],
|
||||
"bugs": {
|
||||
"url" : "https://github.com/Microsoft/TypeScript/issues"
|
||||
},
|
||||
"repository" : {
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/Microsoft/TypeScript.git"
|
||||
},
|
||||
"preferGlobal" : true,
|
||||
"main" : "./bin/typescriptServices.js",
|
||||
"bin" : {
|
||||
"tsc" : "./bin/tsc"
|
||||
},
|
||||
"engines" : {
|
||||
"node" : ">=0.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jake" : "latest",
|
||||
"mocha" : "latest",
|
||||
"chai" : "latest",
|
||||
"browserify" : "latest",
|
||||
"istanbul": "latest",
|
||||
"codeclimate-test-reporter": "latest"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jake generate-code-coverage"
|
||||
}
|
||||
"name": "typescript",
|
||||
"author": "Microsoft Corp.",
|
||||
"homepage": "http://typescriptlang.org/",
|
||||
"version": "1.5.0",
|
||||
"licenses": [
|
||||
{
|
||||
"type": "Apache License 2.0",
|
||||
"url": "https://github.com/Microsoft/TypeScript/blob/master/LICENSE.txt"
|
||||
}
|
||||
],
|
||||
"description": "TypeScript is a language for application scale JavaScript development",
|
||||
"keywords": [
|
||||
"TypeScript",
|
||||
"Microsoft",
|
||||
"compiler",
|
||||
"language",
|
||||
"javascript"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/TypeScript/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Microsoft/TypeScript.git"
|
||||
},
|
||||
"preferGlobal": true,
|
||||
"main": "./bin/typescriptServices.js",
|
||||
"bin": {
|
||||
"tsc": "./bin/tsc"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jake": "latest",
|
||||
"mocha": "latest",
|
||||
"chai": "latest",
|
||||
"browserify": "latest",
|
||||
"istanbul": "latest",
|
||||
"codeclimate-test-reporter": "latest"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jake generate-code-coverage"
|
||||
}
|
||||
}
|
||||
|
||||
+35
-22
@@ -1,6 +1,8 @@
|
||||
/// <reference path="parser.ts"/>
|
||||
|
||||
module ts {
|
||||
/* @internal */ export var bindTime = 0;
|
||||
|
||||
export const enum ModuleInstanceState {
|
||||
NonInstantiated = 0,
|
||||
Instantiated = 1,
|
||||
@@ -50,17 +52,23 @@ module ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns false if any of the following are true:
|
||||
* 1. declaration has no name
|
||||
* 2. declaration has a literal name (not computed)
|
||||
* 3. declaration has a computed property name that is a known symbol
|
||||
* 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 hasComputedNameButNotSymbol(declaration: Declaration): boolean {
|
||||
export function hasDynamicName(declaration: Declaration): boolean {
|
||||
return declaration.name && declaration.name.kind === SyntaxKind.ComputedPropertyName;
|
||||
}
|
||||
|
||||
export function bindSourceFile(file: SourceFile) {
|
||||
export function bindSourceFile(file: SourceFile): void {
|
||||
var start = new Date().getTime();
|
||||
bindSourceFileWorker(file);
|
||||
bindTime += new Date().getTime() - start;
|
||||
}
|
||||
|
||||
function bindSourceFileWorker(file: SourceFile): void {
|
||||
var parent: Node;
|
||||
var container: Node;
|
||||
var blockScopeContainer: Node;
|
||||
@@ -96,7 +104,7 @@ module ts {
|
||||
if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) {
|
||||
return '"' + (<LiteralExpression>node.name).text + '"';
|
||||
}
|
||||
Debug.assert(!hasComputedNameButNotSymbol(node));
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
return (<Identifier | LiteralExpression>node.name).text;
|
||||
}
|
||||
switch (node.kind) {
|
||||
@@ -118,11 +126,7 @@ module ts {
|
||||
}
|
||||
|
||||
function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
|
||||
// Nodes with computed property names will not get symbols, because the type checker
|
||||
// does not make properties for them.
|
||||
if (hasComputedNameButNotSymbol(node)) {
|
||||
return undefined;
|
||||
}
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
|
||||
var name = getDeclarationName(node);
|
||||
if (name !== undefined) {
|
||||
@@ -139,9 +143,9 @@ module ts {
|
||||
: Diagnostics.Duplicate_identifier_0;
|
||||
|
||||
forEach(symbol.declarations, declaration => {
|
||||
file.semanticDiagnostics.push(createDiagnosticForNode(declaration.name, message, getDisplayName(declaration)));
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(declaration.name, message, getDisplayName(declaration)));
|
||||
});
|
||||
file.semanticDiagnostics.push(createDiagnosticForNode(node.name, message, getDisplayName(node)));
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node.name, message, getDisplayName(node)));
|
||||
|
||||
symbol = createSymbol(0, name);
|
||||
}
|
||||
@@ -162,7 +166,7 @@ module ts {
|
||||
if (node.name) {
|
||||
node.name.parent = node;
|
||||
}
|
||||
file.semanticDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0],
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0],
|
||||
Diagnostics.Duplicate_identifier_0, prototypeSymbol.name));
|
||||
}
|
||||
symbol.exports[prototypeSymbol.name] = prototypeSymbol;
|
||||
@@ -396,14 +400,14 @@ module ts {
|
||||
break;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.EnumMember:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes, /*isBlockScopeContainer*/ false);
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
@@ -416,7 +420,7 @@ module ts {
|
||||
// as other properties in the object literal. So we use SymbolFlags.PropertyExcludes
|
||||
// so that it will conflict with any other object literal members with the same
|
||||
// name.
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : 0),
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : 0),
|
||||
isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
@@ -426,10 +430,10 @@ module ts {
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0, /*isBlockScopeContainer:*/ true);
|
||||
break;
|
||||
case SyntaxKind.GetAccessor:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes, /*isBlockScopeContainer*/ true);
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes, /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
case SyntaxKind.SetAccessor:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes, /*isBlockScopeContainer*/ true);
|
||||
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes, /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
|
||||
case SyntaxKind.FunctionType:
|
||||
@@ -475,7 +479,7 @@ module ts {
|
||||
break;
|
||||
case SyntaxKind.SourceFile:
|
||||
if (isExternalModule(<SourceFile>node)) {
|
||||
bindAnonymousDeclaration(<SourceFile>node, SymbolFlags.ValueModule, '"' + removeFileExtension((<SourceFile>node).filename) + '"', /*isBlockScopeContainer*/ true);
|
||||
bindAnonymousDeclaration(<SourceFile>node, SymbolFlags.ValueModule, '"' + removeFileExtension((<SourceFile>node).fileName) + '"', /*isBlockScopeContainer*/ true);
|
||||
break;
|
||||
}
|
||||
case SyntaxKind.Block:
|
||||
@@ -511,5 +515,14 @@ module ts {
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
|
||||
}
|
||||
}
|
||||
|
||||
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) {
|
||||
if (hasDynamicName(node)) {
|
||||
bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer);
|
||||
}
|
||||
else {
|
||||
bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+464
-290
File diff suppressed because it is too large
Load Diff
@@ -134,6 +134,12 @@ module ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures,
|
||||
},
|
||||
{
|
||||
name: "stripInternal",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "target",
|
||||
shortName: "t",
|
||||
@@ -158,7 +164,7 @@ module ts {
|
||||
|
||||
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
|
||||
var options: CompilerOptions = {};
|
||||
var filenames: string[] = [];
|
||||
var fileNames: string[] = [];
|
||||
var errors: Diagnostic[] = [];
|
||||
var shortOptionNames: Map<string> = {};
|
||||
var optionNameMap: Map<CommandLineOption> = {};
|
||||
@@ -172,7 +178,7 @@ module ts {
|
||||
parseStrings(commandLine);
|
||||
return {
|
||||
options,
|
||||
filenames,
|
||||
fileNames,
|
||||
errors
|
||||
};
|
||||
|
||||
@@ -226,16 +232,16 @@ module ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
filenames.push(s);
|
||||
fileNames.push(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parseResponseFile(filename: string) {
|
||||
var text = sys.readFile(filename);
|
||||
function parseResponseFile(fileName: string) {
|
||||
var text = sys.readFile(fileName);
|
||||
|
||||
if (!text) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, filename));
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -253,7 +259,7 @@ module ts {
|
||||
pos++;
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unterminated_quoted_string_in_response_file_0, filename));
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -265,9 +271,9 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function readConfigFile(filename: string): any {
|
||||
export function readConfigFile(fileName: string): any {
|
||||
try {
|
||||
var text = sys.readFile(filename);
|
||||
var text = sys.readFile(fileName);
|
||||
return /\S/.test(text) ? JSON.parse(text) : {};
|
||||
}
|
||||
catch (e) {
|
||||
@@ -279,7 +285,7 @@ module ts {
|
||||
|
||||
return {
|
||||
options: getCompilerOptions(),
|
||||
filenames: getFiles(),
|
||||
fileNames: getFiles(),
|
||||
errors
|
||||
};
|
||||
|
||||
|
||||
+48
-44
@@ -118,6 +118,12 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function addRange<T>(to: T[], from: T[]): void {
|
||||
for (var i = 0, n = from.length; i < n; i++) {
|
||||
to.push(from[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last element of an array if non-empty, undefined otherwise.
|
||||
*/
|
||||
@@ -280,7 +286,6 @@ module ts {
|
||||
messageText: text,
|
||||
category: message.category,
|
||||
code: message.code,
|
||||
isEarly: message.isEarly
|
||||
};
|
||||
}
|
||||
|
||||
@@ -299,8 +304,7 @@ module ts {
|
||||
|
||||
messageText: text,
|
||||
category: message.category,
|
||||
code: message.code,
|
||||
isEarly: message.isEarly
|
||||
code: message.code
|
||||
};
|
||||
}
|
||||
|
||||
@@ -327,38 +331,6 @@ module ts {
|
||||
return headChain;
|
||||
}
|
||||
|
||||
export function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain, newLine: string): Diagnostic {
|
||||
Debug.assert(start >= 0, "start must be non-negative, is " + start);
|
||||
Debug.assert(length >= 0, "length must be non-negative, is " + length);
|
||||
|
||||
var code = diagnosticChain.code;
|
||||
var category = diagnosticChain.category;
|
||||
var messageText = "";
|
||||
|
||||
var indent = 0;
|
||||
while (diagnosticChain) {
|
||||
if (indent) {
|
||||
messageText += newLine;
|
||||
|
||||
for (var i = 0; i < indent; i++) {
|
||||
messageText += " ";
|
||||
}
|
||||
}
|
||||
messageText += diagnosticChain.messageText;
|
||||
indent++;
|
||||
diagnosticChain = diagnosticChain.next;
|
||||
}
|
||||
|
||||
return {
|
||||
file,
|
||||
start,
|
||||
length,
|
||||
code,
|
||||
category,
|
||||
messageText
|
||||
};
|
||||
}
|
||||
|
||||
export function compareValues<T>(a: T, b: T): Comparison {
|
||||
if (a === b) return Comparison.EqualTo;
|
||||
if (a === undefined) return Comparison.LessThan;
|
||||
@@ -366,17 +338,45 @@ module ts {
|
||||
return a < b ? Comparison.LessThan : Comparison.GreaterThan;
|
||||
}
|
||||
|
||||
function getDiagnosticFilename(diagnostic: Diagnostic): string {
|
||||
return diagnostic.file ? diagnostic.file.filename : undefined;
|
||||
function getDiagnosticFileName(diagnostic: Diagnostic): string {
|
||||
return diagnostic.file ? diagnostic.file.fileName : undefined;
|
||||
}
|
||||
|
||||
export function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): number {
|
||||
return compareValues(getDiagnosticFilename(d1), getDiagnosticFilename(d2)) ||
|
||||
export function compareDiagnostics(d1: Diagnostic, d2: Diagnostic): Comparison {
|
||||
return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) ||
|
||||
compareValues(d1.start, d2.start) ||
|
||||
compareValues(d1.length, d2.length) ||
|
||||
compareValues(d1.code, d2.code) ||
|
||||
compareValues(d1.messageText, d2.messageText) ||
|
||||
0;
|
||||
compareMessageText(d1.messageText, d2.messageText) ||
|
||||
Comparison.EqualTo;
|
||||
}
|
||||
|
||||
function compareMessageText(text1: string | DiagnosticMessageChain, text2: string | DiagnosticMessageChain): Comparison {
|
||||
while (text1 && text2) {
|
||||
// We still have both chains.
|
||||
var string1 = typeof text1 === "string" ? text1 : text1.messageText;
|
||||
var string2 = typeof text2 === "string" ? text2 : text2.messageText;
|
||||
|
||||
var res = compareValues(string1, string2);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
|
||||
text1 = typeof text1 === "string" ? undefined : text1.next;
|
||||
text2 = typeof text2 === "string" ? undefined : text2.next;
|
||||
}
|
||||
|
||||
if (!text1 && !text2) {
|
||||
// if the chains are done, then these messages are the same.
|
||||
return Comparison.EqualTo;
|
||||
}
|
||||
|
||||
// We still have one chain remaining. The shorter chain should come first.
|
||||
return text1 ? Comparison.GreaterThan : Comparison.LessThan;
|
||||
}
|
||||
|
||||
export function sortAndDeduplicateDiagnostics(diagnostics: Diagnostic[]): Diagnostic[]{
|
||||
return deduplicateSortedDiagnostics(diagnostics.sort(compareDiagnostics));
|
||||
}
|
||||
|
||||
export function deduplicateSortedDiagnostics(diagnostics: Diagnostic[]): Diagnostic[] {
|
||||
@@ -474,8 +474,8 @@ module ts {
|
||||
return normalizedPathComponents(path, rootLength);
|
||||
}
|
||||
|
||||
export function getNormalizedAbsolutePath(filename: string, currentDirectory: string) {
|
||||
return getNormalizedPathFromPathComponents(getNormalizedPathComponents(filename, currentDirectory));
|
||||
export function getNormalizedAbsolutePath(fileName: string, currentDirectory: string) {
|
||||
return getNormalizedPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
|
||||
}
|
||||
|
||||
export function getNormalizedPathFromPathComponents(pathComponents: string[]) {
|
||||
@@ -573,7 +573,7 @@ module ts {
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
export function getBaseFilename(path: string) {
|
||||
export function getBaseFileName(path: string) {
|
||||
var i = path.lastIndexOf(directorySeparator);
|
||||
return i < 0 ? path : path.substring(i + 1);
|
||||
}
|
||||
@@ -646,6 +646,10 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts";
|
||||
}
|
||||
|
||||
export interface ObjectAllocator {
|
||||
getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
getSymbolConstructor(): new (flags: SymbolFlags, name: string) => Symbol;
|
||||
|
||||
@@ -4,87 +4,87 @@ module ts {
|
||||
export var Diagnostics = {
|
||||
Unterminated_string_literal: { code: 1002, category: DiagnosticCategory.Error, key: "Unterminated string literal." },
|
||||
Identifier_expected: { code: 1003, category: DiagnosticCategory.Error, key: "Identifier expected." },
|
||||
_0_expected: { code: 1005, category: DiagnosticCategory.Error, key: "'{0}' expected.", isEarly: true },
|
||||
_0_expected: { code: 1005, category: DiagnosticCategory.Error, key: "'{0}' expected." },
|
||||
A_file_cannot_have_a_reference_to_itself: { code: 1006, category: DiagnosticCategory.Error, key: "A file cannot have a reference to itself." },
|
||||
Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed.", isEarly: true },
|
||||
Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed." },
|
||||
Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." },
|
||||
Unexpected_token: { code: 1012, category: DiagnosticCategory.Error, key: "Unexpected token." },
|
||||
Catch_clause_parameter_cannot_have_a_type_annotation: { code: 1013, category: DiagnosticCategory.Error, key: "Catch clause parameter cannot have a type annotation.", isEarly: true },
|
||||
A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list.", isEarly: true },
|
||||
Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer.", isEarly: true },
|
||||
A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter.", isEarly: true },
|
||||
An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter.", isEarly: true },
|
||||
An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier.", isEarly: true },
|
||||
An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark.", isEarly: true },
|
||||
An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer.", isEarly: true },
|
||||
An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation.", isEarly: true },
|
||||
An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation.", isEarly: true },
|
||||
An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'.", isEarly: true },
|
||||
Catch_clause_parameter_cannot_have_a_type_annotation: { code: 1013, category: DiagnosticCategory.Error, key: "Catch clause parameter cannot have a type annotation." },
|
||||
A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: DiagnosticCategory.Error, key: "A rest parameter must be last in a parameter list." },
|
||||
Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: DiagnosticCategory.Error, key: "Parameter cannot have question mark and initializer." },
|
||||
A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: DiagnosticCategory.Error, key: "A required parameter cannot follow an optional parameter." },
|
||||
An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: DiagnosticCategory.Error, key: "An index signature cannot have a rest parameter." },
|
||||
An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an accessibility modifier." },
|
||||
An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have a question mark." },
|
||||
An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: DiagnosticCategory.Error, key: "An index signature parameter cannot have an initializer." },
|
||||
An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation." },
|
||||
An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." },
|
||||
An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." },
|
||||
A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." },
|
||||
An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." },
|
||||
A_class_can_only_extend_a_single_class: { code: 1026, category: DiagnosticCategory.Error, key: "A class can only extend a single class." },
|
||||
A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." },
|
||||
Accessibility_modifier_already_seen: { code: 1028, category: DiagnosticCategory.Error, key: "Accessibility modifier already seen.", isEarly: true },
|
||||
_0_modifier_must_precede_1_modifier: { code: 1029, category: DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier.", isEarly: true },
|
||||
_0_modifier_already_seen: { code: 1030, category: DiagnosticCategory.Error, key: "'{0}' modifier already seen.", isEarly: true },
|
||||
_0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element.", isEarly: true },
|
||||
Accessibility_modifier_already_seen: { code: 1028, category: DiagnosticCategory.Error, key: "Accessibility modifier already seen." },
|
||||
_0_modifier_must_precede_1_modifier: { code: 1029, category: DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." },
|
||||
_0_modifier_already_seen: { code: 1030, category: DiagnosticCategory.Error, key: "'{0}' modifier already seen." },
|
||||
_0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." },
|
||||
An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." },
|
||||
super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." },
|
||||
Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names.", isEarly: true },
|
||||
Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts.", isEarly: true },
|
||||
A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context.", isEarly: true },
|
||||
Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts.", isEarly: true },
|
||||
_0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element.", isEarly: true },
|
||||
A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration.", isEarly: true },
|
||||
Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." },
|
||||
Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." },
|
||||
A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." },
|
||||
Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." },
|
||||
_0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." },
|
||||
A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." },
|
||||
A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." },
|
||||
A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional.", isEarly: true },
|
||||
A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer.", isEarly: true },
|
||||
A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter.", isEarly: true },
|
||||
A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter.", isEarly: true },
|
||||
A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer.", isEarly: true },
|
||||
A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter.", isEarly: true },
|
||||
A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters.", isEarly: true },
|
||||
Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher.", isEarly: true },
|
||||
Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer.", isEarly: true },
|
||||
An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module.", isEarly: true },
|
||||
Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers.", isEarly: true },
|
||||
A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." },
|
||||
A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." },
|
||||
A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: DiagnosticCategory.Error, key: "A 'set' accessor must have exactly one parameter." },
|
||||
A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have an optional parameter." },
|
||||
A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." },
|
||||
A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." },
|
||||
A_get_accessor_cannot_have_parameters: { code: 1054, category: DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." },
|
||||
Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." },
|
||||
Enum_member_must_have_initializer: { code: 1061, category: DiagnosticCategory.Error, key: "Enum member must have initializer." },
|
||||
An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in an internal module." },
|
||||
Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: DiagnosticCategory.Error, key: "Ambient enum elements can only have integer literal initializers." },
|
||||
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: DiagnosticCategory.Error, key: "Unexpected token. A constructor, method, accessor, or property was expected." },
|
||||
A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration.", isEarly: true },
|
||||
A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." },
|
||||
Invalid_reference_directive_syntax: { code: 1084, category: DiagnosticCategory.Error, key: "Invalid 'reference' directive syntax." },
|
||||
Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher.", isEarly: true },
|
||||
An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context.", isEarly: true },
|
||||
_0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration.", isEarly: true },
|
||||
_0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter.", isEarly: true },
|
||||
Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement.", isEarly: true },
|
||||
Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration.", isEarly: true },
|
||||
Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration.", isEarly: true },
|
||||
An_accessor_cannot_have_type_parameters: { code: 1094, category: DiagnosticCategory.Error, key: "An accessor cannot have type parameters.", isEarly: true },
|
||||
A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation.", isEarly: true },
|
||||
An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: DiagnosticCategory.Error, key: "An index signature must have exactly one parameter.", isEarly: true },
|
||||
_0_list_cannot_be_empty: { code: 1097, category: DiagnosticCategory.Error, key: "'{0}' list cannot be empty.", isEarly: true },
|
||||
Type_parameter_list_cannot_be_empty: { code: 1098, category: DiagnosticCategory.Error, key: "Type parameter list cannot be empty.", isEarly: true },
|
||||
Type_argument_list_cannot_be_empty: { code: 1099, category: DiagnosticCategory.Error, key: "Type argument list cannot be empty.", isEarly: true },
|
||||
Invalid_use_of_0_in_strict_mode: { code: 1100, category: DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode.", isEarly: true },
|
||||
with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode.", isEarly: true },
|
||||
delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode.", isEarly: true },
|
||||
A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement.", isEarly: true },
|
||||
A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement.", isEarly: true },
|
||||
Jump_target_cannot_cross_function_boundary: { code: 1107, category: DiagnosticCategory.Error, key: "Jump target cannot cross function boundary.", isEarly: true },
|
||||
A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body.", isEarly: true },
|
||||
Expression_expected: { code: 1109, category: DiagnosticCategory.Error, key: "Expression expected.", isEarly: true },
|
||||
Type_expected: { code: 1110, category: DiagnosticCategory.Error, key: "Type expected.", isEarly: true },
|
||||
A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional.", isEarly: true },
|
||||
A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement.", isEarly: true },
|
||||
Duplicate_label_0: { code: 1114, category: DiagnosticCategory.Error, key: "Duplicate label '{0}'", isEarly: true },
|
||||
A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement.", isEarly: true },
|
||||
A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement.", isEarly: true },
|
||||
An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode.", isEarly: true },
|
||||
An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name.", isEarly: true },
|
||||
An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name.", isEarly: true },
|
||||
An_export_assignment_cannot_have_modifiers: { code: 1120, category: DiagnosticCategory.Error, key: "An export assignment cannot have modifiers.", isEarly: true },
|
||||
Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode.", isEarly: true },
|
||||
A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: DiagnosticCategory.Error, key: "A tuple type element list cannot be empty.", isEarly: true },
|
||||
Variable_declaration_list_cannot_be_empty: { code: 1123, category: DiagnosticCategory.Error, key: "Variable declaration list cannot be empty.", isEarly: true },
|
||||
Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." },
|
||||
An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." },
|
||||
_0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a constructor declaration." },
|
||||
_0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a parameter." },
|
||||
Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: DiagnosticCategory.Error, key: "Only a single variable declaration is allowed in a 'for...in' statement." },
|
||||
Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: DiagnosticCategory.Error, key: "Type parameters cannot appear on a constructor declaration." },
|
||||
Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: DiagnosticCategory.Error, key: "Type annotation cannot appear on a constructor declaration." },
|
||||
An_accessor_cannot_have_type_parameters: { code: 1094, category: DiagnosticCategory.Error, key: "An accessor cannot have type parameters." },
|
||||
A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: DiagnosticCategory.Error, key: "A 'set' accessor cannot have a return type annotation." },
|
||||
An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: DiagnosticCategory.Error, key: "An index signature must have exactly one parameter." },
|
||||
_0_list_cannot_be_empty: { code: 1097, category: DiagnosticCategory.Error, key: "'{0}' list cannot be empty." },
|
||||
Type_parameter_list_cannot_be_empty: { code: 1098, category: DiagnosticCategory.Error, key: "Type parameter list cannot be empty." },
|
||||
Type_argument_list_cannot_be_empty: { code: 1099, category: DiagnosticCategory.Error, key: "Type argument list cannot be empty." },
|
||||
Invalid_use_of_0_in_strict_mode: { code: 1100, category: DiagnosticCategory.Error, key: "Invalid use of '{0}' in strict mode." },
|
||||
with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in strict mode." },
|
||||
delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: DiagnosticCategory.Error, key: "'delete' cannot be called on an identifier in strict mode." },
|
||||
A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: DiagnosticCategory.Error, key: "A 'continue' statement can only be used within an enclosing iteration statement." },
|
||||
A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: DiagnosticCategory.Error, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." },
|
||||
Jump_target_cannot_cross_function_boundary: { code: 1107, category: DiagnosticCategory.Error, key: "Jump target cannot cross function boundary." },
|
||||
A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: DiagnosticCategory.Error, key: "A 'return' statement can only be used within a function body." },
|
||||
Expression_expected: { code: 1109, category: DiagnosticCategory.Error, key: "Expression expected." },
|
||||
Type_expected: { code: 1110, category: DiagnosticCategory.Error, key: "Type expected." },
|
||||
A_class_member_cannot_be_declared_optional: { code: 1112, category: DiagnosticCategory.Error, key: "A class member cannot be declared optional." },
|
||||
A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: DiagnosticCategory.Error, key: "A 'default' clause cannot appear more than once in a 'switch' statement." },
|
||||
Duplicate_label_0: { code: 1114, category: DiagnosticCategory.Error, key: "Duplicate label '{0}'" },
|
||||
A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: DiagnosticCategory.Error, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." },
|
||||
A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: DiagnosticCategory.Error, key: "A 'break' statement can only jump to a label of an enclosing statement." },
|
||||
An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." },
|
||||
An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." },
|
||||
An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." },
|
||||
An_export_assignment_cannot_have_modifiers: { code: 1120, category: DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." },
|
||||
Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: DiagnosticCategory.Error, key: "Octal literals are not allowed in strict mode." },
|
||||
A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: DiagnosticCategory.Error, key: "A tuple type element list cannot be empty." },
|
||||
Variable_declaration_list_cannot_be_empty: { code: 1123, category: DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." },
|
||||
Digit_expected: { code: 1124, category: DiagnosticCategory.Error, key: "Digit expected." },
|
||||
Hexadecimal_digit_expected: { code: 1125, category: DiagnosticCategory.Error, key: "Hexadecimal digit expected." },
|
||||
Unexpected_end_of_text: { code: 1126, category: DiagnosticCategory.Error, key: "Unexpected end of text." },
|
||||
@@ -96,52 +96,52 @@ module ts {
|
||||
Enum_member_expected: { code: 1132, category: DiagnosticCategory.Error, key: "Enum member expected." },
|
||||
Type_reference_expected: { code: 1133, category: DiagnosticCategory.Error, key: "Type reference expected." },
|
||||
Variable_declaration_expected: { code: 1134, category: DiagnosticCategory.Error, key: "Variable declaration expected." },
|
||||
Argument_expression_expected: { code: 1135, category: DiagnosticCategory.Error, key: "Argument expression expected.", isEarly: true },
|
||||
Argument_expression_expected: { code: 1135, category: DiagnosticCategory.Error, key: "Argument expression expected." },
|
||||
Property_assignment_expected: { code: 1136, category: DiagnosticCategory.Error, key: "Property assignment expected." },
|
||||
Expression_or_comma_expected: { code: 1137, category: DiagnosticCategory.Error, key: "Expression or comma expected." },
|
||||
Parameter_declaration_expected: { code: 1138, category: DiagnosticCategory.Error, key: "Parameter declaration expected." },
|
||||
Type_parameter_declaration_expected: { code: 1139, category: DiagnosticCategory.Error, key: "Type parameter declaration expected." },
|
||||
Type_argument_expected: { code: 1140, category: DiagnosticCategory.Error, key: "Type argument expected." },
|
||||
String_literal_expected: { code: 1141, category: DiagnosticCategory.Error, key: "String literal expected.", isEarly: true },
|
||||
Line_break_not_permitted_here: { code: 1142, category: DiagnosticCategory.Error, key: "Line break not permitted here.", isEarly: true },
|
||||
String_literal_expected: { code: 1141, category: DiagnosticCategory.Error, key: "String literal expected." },
|
||||
Line_break_not_permitted_here: { code: 1142, category: DiagnosticCategory.Error, key: "Line break not permitted here." },
|
||||
or_expected: { code: 1144, category: DiagnosticCategory.Error, key: "'{' or ';' expected." },
|
||||
Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members.", isEarly: true },
|
||||
Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: DiagnosticCategory.Error, key: "Modifiers not permitted on index signature members." },
|
||||
Declaration_expected: { code: 1146, category: DiagnosticCategory.Error, key: "Declaration expected." },
|
||||
Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module.", isEarly: true },
|
||||
Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." },
|
||||
Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." },
|
||||
Filename_0_differs_from_already_included_filename_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "Filename '{0}' differs from already included filename '{1}' only in casing" },
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.", isEarly: true },
|
||||
File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" },
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
|
||||
var_let_or_const_expected: { code: 1152, category: DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." },
|
||||
let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher.", isEarly: true },
|
||||
const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher.", isEarly: true },
|
||||
const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized", isEarly: true },
|
||||
const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block.", isEarly: true },
|
||||
let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block.", isEarly: true },
|
||||
let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." },
|
||||
const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." },
|
||||
const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" },
|
||||
const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." },
|
||||
let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." },
|
||||
Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." },
|
||||
Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." },
|
||||
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional.", isEarly: true },
|
||||
yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration.", isEarly: true },
|
||||
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums.", isEarly: true },
|
||||
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.", isEarly: true },
|
||||
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.", isEarly: true },
|
||||
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.", isEarly: true },
|
||||
Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in method overloads.", isEarly: true },
|
||||
Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in interfaces.", isEarly: true },
|
||||
Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in type literals.", isEarly: true },
|
||||
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." },
|
||||
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_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.", isEarly: true },
|
||||
extends_clause_must_precede_implements_clause: { code: 1173, category: DiagnosticCategory.Error, key: "'extends' clause must precede 'implements' clause.", isEarly: true },
|
||||
Classes_can_only_extend_a_single_class: { code: 1174, category: DiagnosticCategory.Error, key: "Classes can only extend a single class.", isEarly: true },
|
||||
implements_clause_already_seen: { code: 1175, category: DiagnosticCategory.Error, key: "'implements' clause already seen.", isEarly: true },
|
||||
Interface_declaration_cannot_have_implements_clause: { code: 1176, category: DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause.", isEarly: true },
|
||||
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." },
|
||||
Classes_can_only_extend_a_single_class: { code: 1174, category: DiagnosticCategory.Error, key: "Classes can only extend a single class." },
|
||||
implements_clause_already_seen: { code: 1175, category: DiagnosticCategory.Error, key: "'implements' clause already seen." },
|
||||
Interface_declaration_cannot_have_implements_clause: { code: 1176, category: DiagnosticCategory.Error, key: "Interface declaration cannot have 'implements' clause." },
|
||||
Binary_digit_expected: { code: 1177, category: DiagnosticCategory.Error, key: "Binary digit expected." },
|
||||
Octal_digit_expected: { code: 1178, category: DiagnosticCategory.Error, key: "Octal digit expected." },
|
||||
Unexpected_token_expected: { code: 1179, category: DiagnosticCategory.Error, key: "Unexpected token. '{' expected." },
|
||||
Property_destructuring_pattern_expected: { code: 1180, category: DiagnosticCategory.Error, key: "Property destructuring pattern expected." },
|
||||
Array_element_destructuring_pattern_expected: { code: 1181, category: DiagnosticCategory.Error, key: "Array element destructuring pattern expected." },
|
||||
A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer.", isEarly: true },
|
||||
Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts.", isEarly: true },
|
||||
An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts.", isEarly: true },
|
||||
A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." },
|
||||
Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." },
|
||||
An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." },
|
||||
Modifiers_cannot_appear_here: { code: 1184, category: DiagnosticCategory.Error, key: "Modifiers cannot appear here." },
|
||||
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." },
|
||||
@@ -283,10 +283,10 @@ module ts {
|
||||
Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." },
|
||||
Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." },
|
||||
The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: DiagnosticCategory.Error, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." },
|
||||
Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration.", isEarly: true },
|
||||
The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant.", isEarly: true },
|
||||
Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant.", isEarly: true },
|
||||
Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'.", isEarly: true },
|
||||
Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: DiagnosticCategory.Error, key: "Block-scoped variable '{0}' used before its declaration." },
|
||||
The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator cannot be a constant." },
|
||||
Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: DiagnosticCategory.Error, key: "Left-hand side of assignment expression cannot be a constant." },
|
||||
Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: DiagnosticCategory.Error, key: "Cannot redeclare block-scoped variable '{0}'." },
|
||||
An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: DiagnosticCategory.Error, key: "An enum member cannot have a numeric name." },
|
||||
The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." },
|
||||
Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." },
|
||||
@@ -298,6 +298,10 @@ 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'." },
|
||||
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." },
|
||||
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}'." },
|
||||
@@ -368,12 +372,12 @@ module ts {
|
||||
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.", isEarly: true },
|
||||
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.", isEarly: true },
|
||||
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}'.", isEarly: true },
|
||||
Property_0_does_not_exist_on_const_enum_1: { code: 4088, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'." },
|
||||
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}" },
|
||||
@@ -428,6 +432,7 @@ module ts {
|
||||
File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." },
|
||||
File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." },
|
||||
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
|
||||
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -445,8 +450,9 @@ module ts {
|
||||
_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
|
||||
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
|
||||
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
|
||||
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported.", isEarly: true },
|
||||
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported.", isEarly: true },
|
||||
Computed_property_names_are_not_currently_supported: { code: 9002, category: DiagnosticCategory.Error, key: "Computed property names are not currently supported.", isEarly: true },
|
||||
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." },
|
||||
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." },
|
||||
};
|
||||
}
|
||||
@@ -9,8 +9,7 @@
|
||||
},
|
||||
"'{0}' expected.": {
|
||||
"category": "Error",
|
||||
"code": 1005,
|
||||
"isEarly": true
|
||||
"code": 1005
|
||||
},
|
||||
"A file cannot have a reference to itself.": {
|
||||
"category": "Error",
|
||||
@@ -18,8 +17,7 @@
|
||||
},
|
||||
"Trailing comma not allowed.": {
|
||||
"category": "Error",
|
||||
"code": 1009,
|
||||
"isEarly": true
|
||||
"code": 1009
|
||||
},
|
||||
"'*/' expected.": {
|
||||
"category": "Error",
|
||||
@@ -31,58 +29,47 @@
|
||||
},
|
||||
"Catch clause parameter cannot have a type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 1013,
|
||||
"isEarly": true
|
||||
"code": 1013
|
||||
},
|
||||
"A rest parameter must be last in a parameter list.": {
|
||||
"category": "Error",
|
||||
"code": 1014,
|
||||
"isEarly": true
|
||||
"code": 1014
|
||||
},
|
||||
"Parameter cannot have question mark and initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1015,
|
||||
"isEarly": true
|
||||
"code": 1015
|
||||
},
|
||||
"A required parameter cannot follow an optional parameter.": {
|
||||
"category": "Error",
|
||||
"code": 1016,
|
||||
"isEarly": true
|
||||
"code": 1016
|
||||
},
|
||||
"An index signature cannot have a rest parameter.": {
|
||||
"category": "Error",
|
||||
"code": 1017,
|
||||
"isEarly": true
|
||||
"code": 1017
|
||||
},
|
||||
"An index signature parameter cannot have an accessibility modifier.": {
|
||||
"category": "Error",
|
||||
"code": 1018,
|
||||
"isEarly": true
|
||||
"code": 1018
|
||||
},
|
||||
"An index signature parameter cannot have a question mark.": {
|
||||
"category": "Error",
|
||||
"code": 1019,
|
||||
"isEarly": true
|
||||
"code": 1019
|
||||
},
|
||||
"An index signature parameter cannot have an initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1020,
|
||||
"isEarly": true
|
||||
"code": 1020
|
||||
},
|
||||
"An index signature must have a type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 1021,
|
||||
"isEarly": true
|
||||
"code": 1021
|
||||
},
|
||||
"An index signature parameter must have a type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 1022,
|
||||
"isEarly": true
|
||||
"code": 1022
|
||||
},
|
||||
"An index signature parameter type must be 'string' or 'number'.": {
|
||||
"category": "Error",
|
||||
"code": 1023,
|
||||
"isEarly": true
|
||||
"code": 1023
|
||||
},
|
||||
"A class or interface declaration can only have one 'extends' clause.": {
|
||||
"category": "Error",
|
||||
@@ -102,23 +89,19 @@
|
||||
},
|
||||
"Accessibility modifier already seen.": {
|
||||
"category": "Error",
|
||||
"code": 1028,
|
||||
"isEarly": true
|
||||
"code": 1028
|
||||
},
|
||||
"'{0}' modifier must precede '{1}' modifier.": {
|
||||
"category": "Error",
|
||||
"code": 1029,
|
||||
"isEarly": true
|
||||
"code": 1029
|
||||
},
|
||||
"'{0}' modifier already seen.": {
|
||||
"category": "Error",
|
||||
"code": 1030,
|
||||
"isEarly": true
|
||||
"code": 1030
|
||||
},
|
||||
"'{0}' modifier cannot appear on a class element.": {
|
||||
"category": "Error",
|
||||
"code": 1031,
|
||||
"isEarly": true
|
||||
"code": 1031
|
||||
},
|
||||
"An interface declaration cannot have an 'implements' clause.": {
|
||||
"category": "Error",
|
||||
@@ -130,33 +113,27 @@
|
||||
},
|
||||
"Only ambient modules can use quoted names.": {
|
||||
"category": "Error",
|
||||
"code": 1035,
|
||||
"isEarly": true
|
||||
"code": 1035
|
||||
},
|
||||
"Statements are not allowed in ambient contexts.": {
|
||||
"category": "Error",
|
||||
"code": 1036,
|
||||
"isEarly": true
|
||||
"code": 1036
|
||||
},
|
||||
"A 'declare' modifier cannot be used in an already ambient context.": {
|
||||
"category": "Error",
|
||||
"code": 1038,
|
||||
"isEarly": true
|
||||
"code": 1038
|
||||
},
|
||||
"Initializers are not allowed in ambient contexts.": {
|
||||
"category": "Error",
|
||||
"code": 1039,
|
||||
"isEarly": true
|
||||
"code": 1039
|
||||
},
|
||||
"'{0}' modifier cannot appear on a module element.": {
|
||||
"category": "Error",
|
||||
"code": 1044,
|
||||
"isEarly": true
|
||||
"code": 1044
|
||||
},
|
||||
"A 'declare' modifier cannot be used with an interface declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1045,
|
||||
"isEarly": true
|
||||
"code": 1045
|
||||
},
|
||||
"A 'declare' modifier is required for a top level declaration in a .d.ts file.": {
|
||||
"category": "Error",
|
||||
@@ -164,58 +141,47 @@
|
||||
},
|
||||
"A rest parameter cannot be optional.": {
|
||||
"category": "Error",
|
||||
"code": 1047,
|
||||
"isEarly": true
|
||||
"code": 1047
|
||||
},
|
||||
"A rest parameter cannot have an initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1048,
|
||||
"isEarly": true
|
||||
"code": 1048
|
||||
},
|
||||
"A 'set' accessor must have exactly one parameter.": {
|
||||
"category": "Error",
|
||||
"code": 1049,
|
||||
"isEarly": true
|
||||
"code": 1049
|
||||
},
|
||||
"A 'set' accessor cannot have an optional parameter.": {
|
||||
"category": "Error",
|
||||
"code": 1051,
|
||||
"isEarly": true
|
||||
"code": 1051
|
||||
},
|
||||
"A 'set' accessor parameter cannot have an initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1052,
|
||||
"isEarly": true
|
||||
"code": 1052
|
||||
},
|
||||
"A 'set' accessor cannot have rest parameter.": {
|
||||
"category": "Error",
|
||||
"code": 1053,
|
||||
"isEarly": true
|
||||
"code": 1053
|
||||
},
|
||||
"A 'get' accessor cannot have parameters.": {
|
||||
"category": "Error",
|
||||
"code": 1054,
|
||||
"isEarly": true
|
||||
"code": 1054
|
||||
},
|
||||
"Accessors are only available when targeting ECMAScript 5 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1056,
|
||||
"isEarly": true
|
||||
"code": 1056
|
||||
},
|
||||
"Enum member must have initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1061,
|
||||
"isEarly": true
|
||||
"code": 1061
|
||||
},
|
||||
"An export assignment cannot be used in an internal module.": {
|
||||
"category": "Error",
|
||||
"code": 1063,
|
||||
"isEarly": true
|
||||
"code": 1063
|
||||
},
|
||||
"Ambient enum elements can only have integer literal initializers.": {
|
||||
"category": "Error",
|
||||
"code": 1066,
|
||||
"isEarly": true
|
||||
"code": 1066
|
||||
},
|
||||
"Unexpected token. A constructor, method, accessor, or property was expected.": {
|
||||
"category": "Error",
|
||||
@@ -223,8 +189,7 @@
|
||||
},
|
||||
"A 'declare' modifier cannot be used with an import declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1079,
|
||||
"isEarly": true
|
||||
"code": 1079
|
||||
},
|
||||
"Invalid 'reference' directive syntax.": {
|
||||
"category": "Error",
|
||||
@@ -232,173 +197,139 @@
|
||||
},
|
||||
"Octal literals are not available when targeting ECMAScript 5 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1085,
|
||||
"isEarly": true
|
||||
"code": 1085
|
||||
},
|
||||
"An accessor cannot be declared in an ambient context.": {
|
||||
"category": "Error",
|
||||
"code": 1086,
|
||||
"isEarly": true
|
||||
"code": 1086
|
||||
},
|
||||
"'{0}' modifier cannot appear on a constructor declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1089,
|
||||
"isEarly": true
|
||||
"code": 1089
|
||||
},
|
||||
"'{0}' modifier cannot appear on a parameter.": {
|
||||
"category": "Error",
|
||||
"code": 1090,
|
||||
"isEarly": true
|
||||
"code": 1090
|
||||
},
|
||||
"Only a single variable declaration is allowed in a 'for...in' statement.": {
|
||||
"category": "Error",
|
||||
"code": 1091,
|
||||
"isEarly": true
|
||||
"code": 1091
|
||||
},
|
||||
"Type parameters cannot appear on a constructor declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1092,
|
||||
"isEarly": true
|
||||
"code": 1092
|
||||
},
|
||||
"Type annotation cannot appear on a constructor declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1093,
|
||||
"isEarly": true
|
||||
"code": 1093
|
||||
},
|
||||
"An accessor cannot have type parameters.": {
|
||||
"category": "Error",
|
||||
"code": 1094,
|
||||
"isEarly": true
|
||||
"code": 1094
|
||||
},
|
||||
"A 'set' accessor cannot have a return type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 1095,
|
||||
"isEarly": true
|
||||
"code": 1095
|
||||
},
|
||||
"An index signature must have exactly one parameter.": {
|
||||
"category": "Error",
|
||||
"code": 1096,
|
||||
"isEarly": true
|
||||
"code": 1096
|
||||
},
|
||||
"'{0}' list cannot be empty.": {
|
||||
"category": "Error",
|
||||
"code": 1097,
|
||||
"isEarly": true
|
||||
"code": 1097
|
||||
},
|
||||
"Type parameter list cannot be empty.": {
|
||||
"category": "Error",
|
||||
"code": 1098,
|
||||
"isEarly": true
|
||||
"code": 1098
|
||||
},
|
||||
"Type argument list cannot be empty.": {
|
||||
"category": "Error",
|
||||
"code": 1099,
|
||||
"isEarly": true
|
||||
"code": 1099
|
||||
},
|
||||
"Invalid use of '{0}' in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1100,
|
||||
"isEarly": true
|
||||
"code": 1100
|
||||
},
|
||||
"'with' statements are not allowed in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1101,
|
||||
"isEarly": true
|
||||
"code": 1101
|
||||
},
|
||||
"'delete' cannot be called on an identifier in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1102,
|
||||
"isEarly": true
|
||||
"code": 1102
|
||||
},
|
||||
"A 'continue' statement can only be used within an enclosing iteration statement.": {
|
||||
"category": "Error",
|
||||
"code": 1104,
|
||||
"isEarly": true
|
||||
"code": 1104
|
||||
},
|
||||
"A 'break' statement can only be used within an enclosing iteration or switch statement.": {
|
||||
"category": "Error",
|
||||
"code": 1105,
|
||||
"isEarly": true
|
||||
"code": 1105
|
||||
},
|
||||
"Jump target cannot cross function boundary.": {
|
||||
"category": "Error",
|
||||
"code": 1107,
|
||||
"isEarly": true
|
||||
"code": 1107
|
||||
},
|
||||
"A 'return' statement can only be used within a function body.": {
|
||||
"category": "Error",
|
||||
"code": 1108,
|
||||
"isEarly": true
|
||||
"code": 1108
|
||||
},
|
||||
"Expression expected.": {
|
||||
"category": "Error",
|
||||
"code": 1109,
|
||||
"isEarly": true
|
||||
"code": 1109
|
||||
},
|
||||
"Type expected.": {
|
||||
"category": "Error",
|
||||
"code": 1110,
|
||||
"isEarly": true
|
||||
"code": 1110
|
||||
},
|
||||
"A class member cannot be declared optional.": {
|
||||
"category": "Error",
|
||||
"code": 1112,
|
||||
"isEarly": true
|
||||
"code": 1112
|
||||
},
|
||||
"A 'default' clause cannot appear more than once in a 'switch' statement.": {
|
||||
"category": "Error",
|
||||
"code": 1113,
|
||||
"isEarly": true
|
||||
"code": 1113
|
||||
},
|
||||
"Duplicate label '{0}'": {
|
||||
"category": "Error",
|
||||
"code": 1114,
|
||||
"isEarly": true
|
||||
"code": 1114
|
||||
},
|
||||
"A 'continue' statement can only jump to a label of an enclosing iteration statement.": {
|
||||
"category": "Error",
|
||||
"code": 1115,
|
||||
"isEarly": true
|
||||
"code": 1115
|
||||
},
|
||||
"A 'break' statement can only jump to a label of an enclosing statement.": {
|
||||
"category": "Error",
|
||||
"code": 1116,
|
||||
"isEarly": true
|
||||
"code": 1116
|
||||
},
|
||||
"An object literal cannot have multiple properties with the same name in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1117,
|
||||
"isEarly": true
|
||||
"code": 1117
|
||||
},
|
||||
"An object literal cannot have multiple get/set accessors with the same name.": {
|
||||
"category": "Error",
|
||||
"code": 1118,
|
||||
"isEarly": true
|
||||
"code": 1118
|
||||
},
|
||||
"An object literal cannot have property and accessor with the same name.": {
|
||||
"category": "Error",
|
||||
"code": 1119,
|
||||
"isEarly": true
|
||||
"code": 1119
|
||||
},
|
||||
"An export assignment cannot have modifiers.": {
|
||||
"category": "Error",
|
||||
"code": 1120,
|
||||
"isEarly": true
|
||||
"code": 1120
|
||||
},
|
||||
"Octal literals are not allowed in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1121,
|
||||
"isEarly": true
|
||||
"code": 1121
|
||||
},
|
||||
"A tuple type element list cannot be empty.": {
|
||||
"category": "Error",
|
||||
"code": 1122,
|
||||
"isEarly": true
|
||||
"code": 1122
|
||||
},
|
||||
"Variable declaration list cannot be empty.": {
|
||||
"category": "Error",
|
||||
"code": 1123,
|
||||
"isEarly": true
|
||||
"code": 1123
|
||||
},
|
||||
"Digit expected.": {
|
||||
"category": "Error",
|
||||
@@ -446,8 +377,7 @@
|
||||
},
|
||||
"Argument expression expected.": {
|
||||
"category": "Error",
|
||||
"code": 1135,
|
||||
"isEarly": true
|
||||
"code": 1135
|
||||
},
|
||||
"Property assignment expected.": {
|
||||
"category": "Error",
|
||||
@@ -471,13 +401,11 @@
|
||||
},
|
||||
"String literal expected.": {
|
||||
"category": "Error",
|
||||
"code": 1141,
|
||||
"isEarly": true
|
||||
"code": 1141
|
||||
},
|
||||
"Line break not permitted here.": {
|
||||
"category": "Error",
|
||||
"code": 1142,
|
||||
"isEarly": true
|
||||
"code": 1142
|
||||
},
|
||||
"'{' or ';' expected.": {
|
||||
"category": "Error",
|
||||
@@ -485,8 +413,7 @@
|
||||
},
|
||||
"Modifiers not permitted on index signature members.": {
|
||||
"category": "Error",
|
||||
"code": 1145,
|
||||
"isEarly": true
|
||||
"code": 1145
|
||||
},
|
||||
"Declaration expected.": {
|
||||
"category": "Error",
|
||||
@@ -494,21 +421,19 @@
|
||||
},
|
||||
"Import declarations in an internal module cannot reference an external module.": {
|
||||
"category": "Error",
|
||||
"code": 1147,
|
||||
"isEarly": true
|
||||
"code": 1147
|
||||
},
|
||||
"Cannot compile external modules unless the '--module' flag is provided.": {
|
||||
"category": "Error",
|
||||
"code": 1148
|
||||
},
|
||||
"Filename '{0}' differs from already included filename '{1}' only in casing": {
|
||||
"File name '{0}' differs from already included file name '{1}' only in casing": {
|
||||
"category": "Error",
|
||||
"code": 1149
|
||||
},
|
||||
"'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.": {
|
||||
"category": "Error",
|
||||
"code": 1150,
|
||||
"isEarly": true
|
||||
"code": 1150
|
||||
},
|
||||
"'var', 'let' or 'const' expected.": {
|
||||
"category": "Error",
|
||||
@@ -516,28 +441,23 @@
|
||||
},
|
||||
"'let' declarations are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1153,
|
||||
"isEarly": true
|
||||
"code": 1153
|
||||
},
|
||||
"'const' declarations are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1154,
|
||||
"isEarly": true
|
||||
"code": 1154
|
||||
},
|
||||
"'const' declarations must be initialized": {
|
||||
"category": "Error",
|
||||
"code": 1155,
|
||||
"isEarly": true
|
||||
"code": 1155
|
||||
},
|
||||
"'const' declarations can only be declared inside a block.": {
|
||||
"category": "Error",
|
||||
"code": 1156,
|
||||
"isEarly": true
|
||||
"code": 1156
|
||||
},
|
||||
"'let' declarations can only be declared inside a block.": {
|
||||
"category": "Error",
|
||||
"code": 1157,
|
||||
"isEarly": true
|
||||
"code": 1157
|
||||
},
|
||||
"Unterminated template literal.": {
|
||||
"category": "Error",
|
||||
@@ -549,48 +469,39 @@
|
||||
},
|
||||
"An object member cannot be declared optional.": {
|
||||
"category": "Error",
|
||||
"code": 1162,
|
||||
"isEarly": true
|
||||
"code": 1162
|
||||
},
|
||||
"'yield' expression must be contained_within a generator declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1163,
|
||||
"isEarly": true
|
||||
"code": 1163
|
||||
},
|
||||
"Computed property names are not allowed in enums.": {
|
||||
"category": "Error",
|
||||
"code": 1164,
|
||||
"isEarly": true
|
||||
"code": 1164
|
||||
},
|
||||
"Computed property names are not allowed in an ambient context.": {
|
||||
"category": "Error",
|
||||
"code": 1165,
|
||||
"isEarly": true
|
||||
"code": 1165
|
||||
},
|
||||
"Computed property names are not allowed in class property declarations.": {
|
||||
"category": "Error",
|
||||
"code": 1166,
|
||||
"isEarly": true
|
||||
"code": 1166
|
||||
},
|
||||
"Computed property names are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1167,
|
||||
"isEarly": true
|
||||
"code": 1167
|
||||
},
|
||||
"Computed property names are not allowed in method overloads.": {
|
||||
"category": "Error",
|
||||
"code": 1168,
|
||||
"isEarly": true
|
||||
"code": 1168
|
||||
},
|
||||
"Computed property names are not allowed in interfaces.": {
|
||||
"category": "Error",
|
||||
"code": 1169,
|
||||
"isEarly": true
|
||||
"code": 1169
|
||||
},
|
||||
"Computed property names are not allowed in type literals.": {
|
||||
"category": "Error",
|
||||
"code": 1170,
|
||||
"isEarly": true
|
||||
"code": 1170
|
||||
},
|
||||
"A comma expression is not allowed in a computed property name.": {
|
||||
"category": "Error",
|
||||
@@ -598,28 +509,23 @@
|
||||
},
|
||||
"'extends' clause already seen.": {
|
||||
"category": "Error",
|
||||
"code": 1172,
|
||||
"isEarly": true
|
||||
"code": 1172
|
||||
},
|
||||
"'extends' clause must precede 'implements' clause.": {
|
||||
"category": "Error",
|
||||
"code": 1173,
|
||||
"isEarly": true
|
||||
"code": 1173
|
||||
},
|
||||
"Classes can only extend a single class.": {
|
||||
"category": "Error",
|
||||
"code": 1174,
|
||||
"isEarly": true
|
||||
"code": 1174
|
||||
},
|
||||
"'implements' clause already seen.": {
|
||||
"category": "Error",
|
||||
"code": 1175,
|
||||
"isEarly": true
|
||||
"code": 1175
|
||||
},
|
||||
"Interface declaration cannot have 'implements' clause.": {
|
||||
"category": "Error",
|
||||
"code": 1176,
|
||||
"isEarly": true
|
||||
"code": 1176
|
||||
},
|
||||
"Binary digit expected.": {
|
||||
"category": "Error",
|
||||
@@ -643,18 +549,15 @@
|
||||
},
|
||||
"A destructuring declaration must have an initializer.": {
|
||||
"category": "Error",
|
||||
"code": 1182,
|
||||
"isEarly": true
|
||||
"code": 1182
|
||||
},
|
||||
"Destructuring declarations are not allowed in ambient contexts.": {
|
||||
"category": "Error",
|
||||
"code": 1183,
|
||||
"isEarly": true
|
||||
"code": 1183
|
||||
},
|
||||
"An implementation cannot be declared in ambient contexts.": {
|
||||
"category": "Error",
|
||||
"code": 1184,
|
||||
"isEarly": true
|
||||
"code": 1184
|
||||
},
|
||||
"Modifiers cannot appear here.": {
|
||||
"category": "Error",
|
||||
@@ -670,7 +573,7 @@
|
||||
},
|
||||
"A parameter property may not be a binding pattern.": {
|
||||
"category": "Error",
|
||||
"code": 1187
|
||||
"code": 1187
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
@@ -1223,23 +1126,19 @@
|
||||
},
|
||||
"Block-scoped variable '{0}' used before its declaration.": {
|
||||
"category": "Error",
|
||||
"code": 2448,
|
||||
"isEarly": true
|
||||
"code": 2448
|
||||
},
|
||||
"The operand of an increment or decrement operator cannot be a constant.": {
|
||||
"category": "Error",
|
||||
"code": 2449,
|
||||
"isEarly": true
|
||||
"code": 2449
|
||||
},
|
||||
"Left-hand side of assignment expression cannot be a constant.": {
|
||||
"category": "Error",
|
||||
"code": 2450,
|
||||
"isEarly": true
|
||||
"code": 2450
|
||||
},
|
||||
"Cannot redeclare block-scoped variable '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2451,
|
||||
"isEarly": true
|
||||
"code": 2451
|
||||
},
|
||||
"An enum member cannot have a numeric name.": {
|
||||
"category": "Error",
|
||||
@@ -1283,7 +1182,23 @@
|
||||
},
|
||||
"A binding pattern parameter cannot be optional in an implementation signature.": {
|
||||
"category": "Error",
|
||||
"code": 2463
|
||||
"code": 2463
|
||||
},
|
||||
"A computed property name must be of type 'string', 'number', or 'any'.": {
|
||||
"category": "Error",
|
||||
"code": 2464
|
||||
},
|
||||
"'this' cannot be referenced in a computed property name.": {
|
||||
"category": "Error",
|
||||
"code": 2465
|
||||
},
|
||||
"'super' cannot be referenced in a computed property name.": {
|
||||
"category": "Error",
|
||||
"code": 2466
|
||||
},
|
||||
"A computed property name cannot reference a type parameter from its containing type.": {
|
||||
"category": "Error",
|
||||
"code": 2466
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
@@ -1568,8 +1483,7 @@
|
||||
},
|
||||
"In 'const' enum declarations member initializer must be constant expression.": {
|
||||
"category": "Error",
|
||||
"code": 4083,
|
||||
"isEarly": true
|
||||
"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",
|
||||
@@ -1577,8 +1491,7 @@
|
||||
},
|
||||
"A const enum member can only be accessed using a string literal.": {
|
||||
"category": "Error",
|
||||
"code": 4085,
|
||||
"isEarly": true
|
||||
"code": 4085
|
||||
},
|
||||
"'const' enum member initializer was evaluated to a non-finite value.": {
|
||||
"category": "Error",
|
||||
@@ -1590,8 +1503,7 @@
|
||||
},
|
||||
"Property '{0}' does not exist on 'const' enum '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4088,
|
||||
"isEarly": true
|
||||
"code": 4088
|
||||
},
|
||||
"The current host does not support the '{0}' option.": {
|
||||
"category": "Error",
|
||||
@@ -1809,6 +1721,10 @@
|
||||
"category": "Message",
|
||||
"code": 6055
|
||||
},
|
||||
"Do not emit declarations for code that has an '@internal' annotation.": {
|
||||
"category": "Message",
|
||||
"code": 6056
|
||||
},
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
@@ -1878,19 +1794,20 @@
|
||||
"category": "Error",
|
||||
"code": 8000
|
||||
},
|
||||
"You cannot rename elements that are defined in the standard TypeScript library.": {
|
||||
"category": "Error",
|
||||
"code": 8001
|
||||
},
|
||||
"'yield' expressions are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9000,
|
||||
"isEarly": true
|
||||
"code": 9000
|
||||
},
|
||||
"Generators are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9001,
|
||||
"isEarly": true
|
||||
"code": 9001
|
||||
},
|
||||
"Computed property names are not currently supported.": {
|
||||
"The 'arguments' object cannot be referenced in an arrow function. Consider using a standard function expression.": {
|
||||
"category": "Error",
|
||||
"code": 9002,
|
||||
"isEarly": true
|
||||
"code": 9002
|
||||
}
|
||||
}
|
||||
|
||||
+381
-301
File diff suppressed because it is too large
Load Diff
+396
-425
@@ -3,6 +3,7 @@
|
||||
|
||||
module ts {
|
||||
var nodeConstructors = new Array<new () => Node>(SyntaxKind.Count);
|
||||
/* @internal */ export var parseTime = 0;
|
||||
|
||||
export function getNodeConstructor(kind: SyntaxKind): new () => Node {
|
||||
return nodeConstructors[kind] || (nodeConstructors[kind] = objectAllocator.getNodeConstructor(kind));
|
||||
@@ -356,6 +357,359 @@ module ts {
|
||||
forEachChild(sourceFile, walk);
|
||||
}
|
||||
|
||||
function moveElementEntirelyPastChangeRange(element: IncrementalElement, delta: number) {
|
||||
if (element.length) {
|
||||
visitArray(<IncrementalNodeArray>element);
|
||||
}
|
||||
else {
|
||||
visitNode(<IncrementalNode>element);
|
||||
}
|
||||
|
||||
function visitNode(node: IncrementalNode) {
|
||||
// Ditch any existing LS children we may have created. This way we can avoid
|
||||
// moving them forward.
|
||||
node._children = undefined;
|
||||
node.pos += delta;
|
||||
node.end += delta;
|
||||
|
||||
forEachChild(node, visitNode, visitArray);
|
||||
}
|
||||
|
||||
function visitArray(array: IncrementalNodeArray) {
|
||||
array.pos += delta;
|
||||
array.end += delta;
|
||||
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
visitNode(array[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function adjustIntersectingElement(element: IncrementalElement, changeStart: number, changeRangeOldEnd: number, changeRangeNewEnd: number, delta: number) {
|
||||
Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range");
|
||||
Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range");
|
||||
|
||||
// We have an element that intersects the change range in some way. It may have its
|
||||
// start, or its end (or both) in the changed range. We want to adjust any part
|
||||
// that intersects such that the final tree is in a consistent state. i.e. all
|
||||
// chlidren have spans within the span of their parent, and all siblings are ordered
|
||||
// properly.
|
||||
|
||||
// We may need to update both the 'pos' and the 'end' of the element.
|
||||
|
||||
// If the 'pos' is before the start of the change, then we don't need to touch it.
|
||||
// If it isn't, then the 'pos' must be inside the change. How we update it will
|
||||
// depend if delta is positive or negative. If delta is positive then we have
|
||||
// something like:
|
||||
//
|
||||
// -------------------AAA-----------------
|
||||
// -------------------BBBCCCCCCC-----------------
|
||||
//
|
||||
// In this case, we consider any node that started in the change range to still be
|
||||
// starting at the same position.
|
||||
//
|
||||
// however, if the delta is negative, then we instead have something like this:
|
||||
//
|
||||
// -------------------XXXYYYYYYY-----------------
|
||||
// -------------------ZZZ-----------------
|
||||
//
|
||||
// In this case, any element that started in the 'X' range will keep its position.
|
||||
// However any element htat started after that will have their pos adjusted to be
|
||||
// at the end of the new range. i.e. any node that started in the 'Y' range will
|
||||
// be adjusted to have their start at the end of the 'Z' range.
|
||||
//
|
||||
// The element will keep its position if possible. Or Move backward to the new-end
|
||||
// if it's in the 'Y' range.
|
||||
element.pos = Math.min(element.pos, changeRangeNewEnd);
|
||||
|
||||
// If the 'end' is after the change range, then we always adjust it by the delta
|
||||
// amount. However, if the end is in the change range, then how we adjust it
|
||||
// will depend on if delta is positive or negative. If delta is positive then we
|
||||
// have something like:
|
||||
//
|
||||
// -------------------AAA-----------------
|
||||
// -------------------BBBCCCCCCC-----------------
|
||||
//
|
||||
// In this case, we consider any node that ended inside the change range to keep its
|
||||
// end position.
|
||||
//
|
||||
// however, if the delta is negative, then we instead have something like this:
|
||||
//
|
||||
// -------------------XXXYYYYYYY-----------------
|
||||
// -------------------ZZZ-----------------
|
||||
//
|
||||
// In this case, any element that ended in the 'X' range will keep its position.
|
||||
// However any element htat ended after that will have their pos adjusted to be
|
||||
// at the end of the new range. i.e. any node that ended in the 'Y' range will
|
||||
// be adjusted to have their end at the end of the 'Z' range.
|
||||
if (element.end >= changeRangeOldEnd) {
|
||||
// Element ends after the change range. Always adjust the end pos.
|
||||
element.end += delta;
|
||||
}
|
||||
else {
|
||||
// Element ends in the change range. The element will keep its position if
|
||||
// possible. Or Move backward to the new-end if it's in the 'Y' range.
|
||||
element.end = Math.min(element.end, changeRangeNewEnd);
|
||||
}
|
||||
|
||||
Debug.assert(element.pos <= element.end);
|
||||
if (element.parent) {
|
||||
Debug.assert(element.pos >= element.parent.pos);
|
||||
Debug.assert(element.end <= element.parent.end);
|
||||
}
|
||||
}
|
||||
|
||||
function updateTokenPositionsAndMarkElements(node: IncrementalNode, changeStart: number, changeRangeOldEnd: number, changeRangeNewEnd: number, delta: number): void {
|
||||
visitNode(node);
|
||||
|
||||
function visitNode(child: IncrementalNode) {
|
||||
if (child.pos > changeRangeOldEnd) {
|
||||
// Node is entirely past the change range. We need to move both its pos and
|
||||
// end, forward or backward appropriately.
|
||||
moveElementEntirelyPastChangeRange(child, delta);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the element intersects the change range. If it does, then it is not
|
||||
// reusable. Also, we'll need to recurse to see what constituent portions we may
|
||||
// be able to use.
|
||||
var fullEnd = child.end;
|
||||
if (fullEnd >= changeStart) {
|
||||
child.intersectsChange = true;
|
||||
|
||||
// Adjust the pos or end (or both) of the intersecting element accordingly.
|
||||
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
||||
forEachChild(child, visitNode, visitArray);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, the node is entirely before the change range. No need to do anything with it.
|
||||
}
|
||||
|
||||
function visitArray(array: IncrementalNodeArray) {
|
||||
if (array.pos > changeRangeOldEnd) {
|
||||
// Array is entirely after the change range. We need to move it, and move any of
|
||||
// its children.
|
||||
moveElementEntirelyPastChangeRange(array, delta);
|
||||
}
|
||||
else {
|
||||
// Check if the element intersects the change range. If it does, then it is not
|
||||
// reusable. Also, we'll need to recurse to see what constituent portions we may
|
||||
// be able to use.
|
||||
var fullEnd = array.end;
|
||||
if (fullEnd >= changeStart) {
|
||||
array.intersectsChange = true;
|
||||
|
||||
// Adjust the pos or end (or both) of the intersecting array accordingly.
|
||||
adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
visitNode(array[i]);
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// Otherwise, the array is entirely before the change range. No need to do anything with it.
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function extendToAffectedRange(sourceFile: SourceFile, changeRange: TextChangeRange): TextChangeRange {
|
||||
// Consider the following code:
|
||||
// void foo() { /; }
|
||||
//
|
||||
// If the text changes with an insertion of / just before the semicolon then we end up with:
|
||||
// void foo() { //; }
|
||||
//
|
||||
// If we were to just use the changeRange a is, then we would not rescan the { token
|
||||
// (as it does not intersect the actual original change range). Because an edit may
|
||||
// change the token touching it, we actually need to look back *at least* one token so
|
||||
// that the prior token sees that change.
|
||||
var maxLookahead = 1;
|
||||
|
||||
var start = changeRange.span.start;
|
||||
|
||||
// the first iteration aligns us with the change start. subsequent iteration move us to
|
||||
// the left by maxLookahead tokens. We only need to do this as long as we're not at the
|
||||
// start of the tree.
|
||||
for (var i = 0; start > 0 && i <= maxLookahead; i++) {
|
||||
var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start);
|
||||
var position = nearestNode.pos;
|
||||
|
||||
start = Math.max(0, position - 1);
|
||||
}
|
||||
|
||||
var finalSpan = createTextSpanFromBounds(start, textSpanEnd(changeRange.span));
|
||||
var finalLength = changeRange.newLength + (changeRange.span.start - start);
|
||||
|
||||
return createTextChangeRange(finalSpan, finalLength);
|
||||
}
|
||||
|
||||
function findNearestNodeStartingBeforeOrAtPosition(sourceFile: SourceFile, position: number): Node {
|
||||
var bestResult: Node = sourceFile;
|
||||
var lastNodeEntirelyBeforePosition: Node;
|
||||
|
||||
forEachChild(sourceFile, visit);
|
||||
|
||||
if (lastNodeEntirelyBeforePosition) {
|
||||
var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition);
|
||||
if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) {
|
||||
bestResult = lastChildOfLastEntireNodeBeforePosition;
|
||||
}
|
||||
}
|
||||
|
||||
return bestResult;
|
||||
|
||||
function getLastChild(node: Node): Node {
|
||||
while (true) {
|
||||
var lastChild = getLastChildWorker(node);
|
||||
if (lastChild) {
|
||||
node = lastChild;
|
||||
}
|
||||
else {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getLastChildWorker(node: Node): Node {
|
||||
var last: Node = undefined;
|
||||
forEachChild(node, child => {
|
||||
if (nodeIsPresent(child)) {
|
||||
last = child;
|
||||
}
|
||||
});
|
||||
return last;
|
||||
}
|
||||
|
||||
function visit(child: Node) {
|
||||
if (nodeIsMissing(child)) {
|
||||
// Missing nodes are effectively invisible to us. We never even consider them
|
||||
// When trying to find the nearest node before us.
|
||||
return;
|
||||
}
|
||||
|
||||
// If the child intersects this position, then this node is currently the nearest
|
||||
// node that starts before the position.
|
||||
if (child.pos <= position) {
|
||||
if (child.pos >= bestResult.pos) {
|
||||
// This node starts before the position, and is closer to the position than
|
||||
// the previous best node we found. It is now the new best node.
|
||||
bestResult = child;
|
||||
}
|
||||
|
||||
// Now, the node may overlap the position, or it may end entirely before the
|
||||
// position. If it overlaps with the position, then either it, or one of its
|
||||
// children must be the nearest node before the position. So we can just
|
||||
// recurse into this child to see if we can find something better.
|
||||
if (position < child.end) {
|
||||
// The nearest node is either this child, or one of the children inside
|
||||
// of it. We've already marked this child as the best so far. Recurse
|
||||
// in case one of the children is better.
|
||||
forEachChild(child, visit);
|
||||
|
||||
// Once we look at the children of this node, then there's no need to
|
||||
// continue any further.
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Debug.assert(child.end <= position);
|
||||
// The child ends entirely before this position. Say you have the following
|
||||
// (where $ is the position)
|
||||
//
|
||||
// <complex expr 1> ? <complex expr 2> $ : <...> <...>
|
||||
//
|
||||
// We would want to find the nearest preceding node in "complex expr 2".
|
||||
// To support that, we keep track of this node, and once we're done searching
|
||||
// for a best node, we recurse down this node to see if we can find a good
|
||||
// result in it.
|
||||
//
|
||||
// This approach allows us to quickly skip over nodes that are entirely
|
||||
// before the position, while still allowing us to find any nodes in the
|
||||
// last one that might be what we want.
|
||||
lastNodeEntirelyBeforePosition = child;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Debug.assert(child.pos > position);
|
||||
// We're now at a node that is entirely past the position we're searching for.
|
||||
// This node (and all following nodes) could never contribute to the result,
|
||||
// so just skip them by returning 'true' here.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter
|
||||
// indicates what changed between the 'text' that this SourceFile has and the 'newText'.
|
||||
// The SourceFile will be created with the compiler attempting to reuse as many nodes from
|
||||
// this file as possible.
|
||||
//
|
||||
// Note: this function mutates nodes from this SourceFile. That means any existing nodes
|
||||
// from this SourceFile that are being held onto may change as a result (including
|
||||
// becoming detached from any SourceFile). It is recommended that this SourceFile not
|
||||
// be used once 'update' is called on it.
|
||||
export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile {
|
||||
if (textChangeRangeIsUnchanged(textChangeRange)) {
|
||||
// if the text didn't change, then we can just return our current source file as-is.
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
if (sourceFile.statements.length === 0) {
|
||||
// If we don't have any statements in the current source file, then there's no real
|
||||
// way to incrementally parse. So just do a full parse instead.
|
||||
return parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion,/*syntaxCursor*/ undefined, /*setNodeParents*/ true)
|
||||
}
|
||||
|
||||
var syntaxCursor = createSyntaxCursor(sourceFile);
|
||||
|
||||
// Make the actual change larger so that we know to reparse anything whose lookahead
|
||||
// might have intersected the change.
|
||||
var changeRange = extendToAffectedRange(sourceFile, textChangeRange);
|
||||
|
||||
// The is the amount the nodes after the edit range need to be adjusted. It can be
|
||||
// positive (if the edit added characters), negative (if the edit deleted characters)
|
||||
// or zero (if this was a pure overwrite with nothing added/removed).
|
||||
var delta = textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
|
||||
|
||||
// If we added or removed characters during the edit, then we need to go and adjust all
|
||||
// the nodes after the edit. Those nodes may move forward down (if we inserted chars)
|
||||
// or they may move backward (if we deleted chars).
|
||||
//
|
||||
// Doing this helps us out in two ways. First, it means that any nodes/tokens we want
|
||||
// to reuse are already at the appropriate position in the new text. That way when we
|
||||
// reuse them, we don't have to figure out if they need to be adjusted. Second, it makes
|
||||
// it very easy to determine if we can reuse a node. If the node's position is at where
|
||||
// we are in the text, then we can reuse it. Otherwise we can't. If hte node's position
|
||||
// is ahead of us, then we'll need to rescan tokens. If the node's position is behind
|
||||
// us, then we'll need to skip it or crumble it as appropriate
|
||||
//
|
||||
// We will also adjust the positions of nodes that intersect the change range as well.
|
||||
// By doing this, we ensure that all the positions in the old tree are consistent, not
|
||||
// just the positions of nodes entirely before/after the change range. By being
|
||||
// consistent, we can then easily map from positions to nodes in the old tree easily.
|
||||
//
|
||||
// Also, mark any syntax elements that intersect the changed span. We know, up front,
|
||||
// that we cannot reuse these elements.
|
||||
updateTokenPositionsAndMarkElements(<IncrementalNode><Node>sourceFile,
|
||||
changeRange.span.start, textSpanEnd(changeRange.span), textSpanEnd(textChangeRangeNewSpan(changeRange)), delta);
|
||||
|
||||
// Now that we've set up our internal incremental state just proceed and parse the
|
||||
// source file in the normal fashion. When possible the parser will retrieve and
|
||||
// reuse nodes from the old tree.
|
||||
//
|
||||
// Note: passing in 'true' for setNodeParents is very important. When incrementally
|
||||
// parsing, we will be reusing nodes from the old tree, and placing it into new
|
||||
// parents. If we don't set the parents now, we'll end up with an observably
|
||||
// inconsistent tree. Setting the parents on the new tree should be very fast. We
|
||||
// will immediately bail out of walking any subtrees when we can see that their parents
|
||||
// are already correct.
|
||||
var result = parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function isEvalOrArgumentsIdentifier(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.Identifier &&
|
||||
((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments");
|
||||
@@ -496,16 +850,33 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false): SourceFile {
|
||||
var parsingContext: ParsingContext;
|
||||
var identifiers: Map<string>;
|
||||
export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false): SourceFile {
|
||||
var start = new Date().getTime();
|
||||
var result = parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes);
|
||||
|
||||
parseTime += new Date().getTime() - start;
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: SyntaxCursor, setParentNodes = false): SourceFile {
|
||||
var parsingContext: ParsingContext = 0;
|
||||
var identifiers: Map<string> = {};
|
||||
var identifierCount = 0;
|
||||
var nodeCount = 0;
|
||||
var lineStarts: number[];
|
||||
var syntacticDiagnostics: Diagnostic[];
|
||||
var scanner: Scanner;
|
||||
var token: SyntaxKind;
|
||||
var syntaxCursor: SyntaxCursor;
|
||||
|
||||
var sourceFile = <SourceFile>createNode(SyntaxKind.SourceFile, /*pos*/ 0);
|
||||
|
||||
sourceFile.pos = 0;
|
||||
sourceFile.end = sourceText.length;
|
||||
sourceFile.text = sourceText;
|
||||
|
||||
sourceFile.parseDiagnostics = [];
|
||||
sourceFile.bindDiagnostics = [];
|
||||
sourceFile.languageVersion = languageVersion;
|
||||
sourceFile.fileName = normalizePath(fileName);
|
||||
sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0;
|
||||
|
||||
// Flags that dictate what parsing context we're in. For example:
|
||||
// Whether or not we are in strict parsing mode. All that changes in strict parsing mode is
|
||||
@@ -553,7 +924,7 @@ module ts {
|
||||
// Note: it should not be necessary to save/restore these flags during speculative/lookahead
|
||||
// parsing. These context flags are naturally stored and restored through normal recursive
|
||||
// descent parsing and unwinding.
|
||||
var contextFlags: ParserContextFlags;
|
||||
var contextFlags: ParserContextFlags = 0;
|
||||
|
||||
// Whether or not we've had a parse error since creating the last AST node. If we have
|
||||
// encountered an error, it will be stored on the next AST node we create. Parse errors
|
||||
@@ -582,406 +953,29 @@ module ts {
|
||||
//
|
||||
// Note: any errors at the end of the file that do not precede a regular node, should get
|
||||
// attached to the EOF token.
|
||||
var parseErrorBeforeNextFinishedNode: boolean;
|
||||
var parseErrorBeforeNextFinishedNode: boolean = false;
|
||||
|
||||
var sourceFile: SourceFile;
|
||||
// Create and prime the scanner before parsing the source elements.
|
||||
scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceText, scanError);
|
||||
token = nextToken();
|
||||
|
||||
return parseSourceFile(sourceText, setParentNodes);
|
||||
processReferenceComments(sourceFile);
|
||||
|
||||
function parseSourceFile(text: string, setParentNodes: boolean): SourceFile {
|
||||
// Set our initial state before parsing.
|
||||
sourceText = text;
|
||||
parsingContext = 0;
|
||||
identifiers = {};
|
||||
lineStarts = undefined;
|
||||
syntacticDiagnostics = undefined;
|
||||
contextFlags = 0;
|
||||
parseErrorBeforeNextFinishedNode = false;
|
||||
sourceFile.statements = parseList(ParsingContext.SourceElements, /*checkForStrictMode*/ true, parseSourceElement);
|
||||
Debug.assert(token === SyntaxKind.EndOfFileToken);
|
||||
sourceFile.endOfFileToken = parseTokenNode();
|
||||
|
||||
sourceFile = <SourceFile>createNode(SyntaxKind.SourceFile, 0);
|
||||
sourceFile.referenceDiagnostics = [];
|
||||
sourceFile.parseDiagnostics = [];
|
||||
sourceFile.semanticDiagnostics = [];
|
||||
setExternalModuleIndicator(sourceFile);
|
||||
|
||||
// Create and prime the scanner before parsing the source elements.
|
||||
scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceText, scanError);
|
||||
token = nextToken();
|
||||
sourceFile.nodeCount = nodeCount;
|
||||
sourceFile.identifierCount = identifierCount;
|
||||
sourceFile.identifiers = identifiers;
|
||||
|
||||
sourceFile.flags = fileExtensionIs(filename, ".d.ts") ? NodeFlags.DeclarationFile : 0;
|
||||
sourceFile.end = sourceText.length;
|
||||
sourceFile.filename = normalizePath(filename);
|
||||
sourceFile.text = sourceText;
|
||||
|
||||
sourceFile.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition;
|
||||
sourceFile.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter;
|
||||
sourceFile.getLineStarts = getLineStarts;
|
||||
sourceFile.getSyntacticDiagnostics = getSyntacticDiagnostics;
|
||||
sourceFile.update = update;
|
||||
|
||||
processReferenceComments(sourceFile);
|
||||
|
||||
sourceFile.statements = parseList(ParsingContext.SourceElements, /*checkForStrictMode*/ true, parseSourceElement);
|
||||
Debug.assert(token === SyntaxKind.EndOfFileToken);
|
||||
sourceFile.endOfFileToken = parseTokenNode();
|
||||
|
||||
setExternalModuleIndicator(sourceFile);
|
||||
|
||||
sourceFile.nodeCount = nodeCount;
|
||||
sourceFile.identifierCount = identifierCount;
|
||||
sourceFile.languageVersion = languageVersion;
|
||||
sourceFile.identifiers = identifiers;
|
||||
|
||||
if (setParentNodes) {
|
||||
fixupParentReferences(sourceFile);
|
||||
}
|
||||
|
||||
return sourceFile;
|
||||
if (setParentNodes) {
|
||||
fixupParentReferences(sourceFile);
|
||||
}
|
||||
|
||||
function update(newText: string, textChangeRange: TextChangeRange) {
|
||||
if (textChangeRangeIsUnchanged(textChangeRange)) {
|
||||
// if the text didn't change, then we can just return our current source file as-is.
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
if (sourceFile.statements.length === 0) {
|
||||
// If we don't have any statements in the current source file, then there's no real
|
||||
// way to incrementally parse. So just do a full parse instead.
|
||||
return parseSourceFile(newText, /*setNodeParents*/ true);
|
||||
}
|
||||
|
||||
syntaxCursor = createSyntaxCursor(sourceFile);
|
||||
|
||||
// Make the actual change larger so that we know to reparse anything whose lookahead
|
||||
// might have intersected the change.
|
||||
var changeRange = extendToAffectedRange(textChangeRange);
|
||||
|
||||
// The is the amount the nodes after the edit range need to be adjusted. It can be
|
||||
// positive (if the edit added characters), negative (if the edit deleted characters)
|
||||
// or zero (if this was a pure overwrite with nothing added/removed).
|
||||
var delta = textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
|
||||
|
||||
// If we added or removed characters during the edit, then we need to go and adjust all
|
||||
// the nodes after the edit. Those nodes may move forward down (if we inserted chars)
|
||||
// or they may move backward (if we deleted chars).
|
||||
//
|
||||
// Doing this helps us out in two ways. First, it means that any nodes/tokens we want
|
||||
// to reuse are already at the appropriate position in the new text. That way when we
|
||||
// reuse them, we don't have to figure out if they need to be adjusted. Second, it makes
|
||||
// it very easy to determine if we can reuse a node. If the node's position is at where
|
||||
// we are in the text, then we can reuse it. Otherwise we can't. If hte node's position
|
||||
// is ahead of us, then we'll need to rescan tokens. If the node's position is behind
|
||||
// us, then we'll need to skip it or crumble it as appropriate
|
||||
//
|
||||
// We will also adjust the positions of nodes that intersect the change range as well.
|
||||
// By doing this, we ensure that all the positions in the old tree are consistent, not
|
||||
// just the positions of nodes entirely before/after the change range. By being
|
||||
// consistent, we can then easily map from positions to nodes in the old tree easily.
|
||||
//
|
||||
// Also, mark any syntax elements that intersect the changed span. We know, up front,
|
||||
// that we cannot reuse these elements.
|
||||
updateTokenPositionsAndMarkElements(<IncrementalNode><Node>sourceFile,
|
||||
changeRange.span.start, textSpanEnd(changeRange.span), textSpanEnd(textChangeRangeNewSpan(changeRange)), delta);
|
||||
|
||||
// Now that we've set up our internal incremental state just proceed and parse the
|
||||
// source file in the normal fashion. When possible the parser will retrieve and
|
||||
// reuse nodes from the old tree.
|
||||
//
|
||||
// Note: passing in 'true' for setNodeParents is very important. When incrementally
|
||||
// parsing, we will be reusing nodes from the old tree, and placing it into new
|
||||
// parents. If we don't set the parents now, we'll end up with an observably
|
||||
// inconsistent tree. Setting the parents on the new tree should be very fast. We
|
||||
// will immediately bail out of walking any subtrees when we can see that their parents
|
||||
// are already correct.
|
||||
var result = parseSourceFile(newText, /*setNodeParents*/ true);
|
||||
|
||||
// Clear out the syntax cursor so it doesn't keep anything alive longer than it should.
|
||||
syntaxCursor = undefined;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function updateTokenPositionsAndMarkElements(node: IncrementalNode, changeStart: number, changeRangeOldEnd: number, changeRangeNewEnd: number, delta: number): void {
|
||||
visitNode(node);
|
||||
|
||||
function visitNode(child: IncrementalNode) {
|
||||
if (child.pos > changeRangeOldEnd) {
|
||||
// Node is entirely past the change range. We need to move both its pos and
|
||||
// end, forward or backward appropriately.
|
||||
moveElementEntirelyPastChangeRange(child, delta);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the element intersects the change range. If it does, then it is not
|
||||
// reusable. Also, we'll need to recurse to see what constituent portions we may
|
||||
// be able to use.
|
||||
var fullEnd = child.end;
|
||||
if (fullEnd >= changeStart) {
|
||||
child.intersectsChange = true;
|
||||
|
||||
// Adjust the pos or end (or both) of the intersecting element accordingly.
|
||||
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
||||
forEachChild(child, visitNode, visitArray);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, the node is entirely before the change range. No need to do anything with it.
|
||||
}
|
||||
|
||||
function visitArray(array: IncrementalNodeArray) {
|
||||
if (array.pos > changeRangeOldEnd) {
|
||||
// Array is entirely after the change range. We need to move it, and move any of
|
||||
// its children.
|
||||
moveElementEntirelyPastChangeRange(array, delta);
|
||||
}
|
||||
else {
|
||||
// Check if the element intersects the change range. If it does, then it is not
|
||||
// reusable. Also, we'll need to recurse to see what constituent portions we may
|
||||
// be able to use.
|
||||
var fullEnd = array.end;
|
||||
if (fullEnd >= changeStart) {
|
||||
array.intersectsChange = true;
|
||||
|
||||
// Adjust the pos or end (or both) of the intersecting array accordingly.
|
||||
adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
visitNode(array[i]);
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// Otherwise, the array is entirely before the change range. No need to do anything with it.
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function adjustIntersectingElement(element: IncrementalElement, changeStart: number, changeRangeOldEnd: number, changeRangeNewEnd: number, delta: number) {
|
||||
Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range");
|
||||
Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range");
|
||||
|
||||
// We have an element that intersects the change range in some way. It may have its
|
||||
// start, or its end (or both) in the changed range. We want to adjust any part
|
||||
// that intersects such that the final tree is in a consistent state. i.e. all
|
||||
// chlidren have spans within the span of their parent, and all siblings are ordered
|
||||
// properly.
|
||||
|
||||
// We may need to update both the 'pos' and the 'end' of the element.
|
||||
|
||||
// If the 'pos' is before the start of the change, then we don't need to touch it.
|
||||
// If it isn't, then the 'pos' must be inside the change. How we update it will
|
||||
// depend if delta is positive or negative. If delta is positive then we have
|
||||
// something like:
|
||||
//
|
||||
// -------------------AAA-----------------
|
||||
// -------------------BBBCCCCCCC-----------------
|
||||
//
|
||||
// In this case, we consider any node that started in the change range to still be
|
||||
// starting at the same position.
|
||||
//
|
||||
// however, if the delta is negative, then we instead have something like this:
|
||||
//
|
||||
// -------------------XXXYYYYYYY-----------------
|
||||
// -------------------ZZZ-----------------
|
||||
//
|
||||
// In this case, any element that started in the 'X' range will keep its position.
|
||||
// However any element htat started after that will have their pos adjusted to be
|
||||
// at the end of the new range. i.e. any node that started in the 'Y' range will
|
||||
// be adjusted to have their start at the end of the 'Z' range.
|
||||
//
|
||||
// The element will keep its position if possible. Or Move backward to the new-end
|
||||
// if it's in the 'Y' range.
|
||||
element.pos = Math.min(element.pos, changeRangeNewEnd);
|
||||
|
||||
// If the 'end' is after the change range, then we always adjust it by the delta
|
||||
// amount. However, if the end is in the change range, then how we adjust it
|
||||
// will depend on if delta is positive or negative. If delta is positive then we
|
||||
// have something like:
|
||||
//
|
||||
// -------------------AAA-----------------
|
||||
// -------------------BBBCCCCCCC-----------------
|
||||
//
|
||||
// In this case, we consider any node that ended inside the change range to keep its
|
||||
// end position.
|
||||
//
|
||||
// however, if the delta is negative, then we instead have something like this:
|
||||
//
|
||||
// -------------------XXXYYYYYYY-----------------
|
||||
// -------------------ZZZ-----------------
|
||||
//
|
||||
// In this case, any element that ended in the 'X' range will keep its position.
|
||||
// However any element htat ended after that will have their pos adjusted to be
|
||||
// at the end of the new range. i.e. any node that ended in the 'Y' range will
|
||||
// be adjusted to have their end at the end of the 'Z' range.
|
||||
if (element.end >= changeRangeOldEnd) {
|
||||
// Element ends after the change range. Always adjust the end pos.
|
||||
element.end += delta;
|
||||
}
|
||||
else {
|
||||
// Element ends in the change range. The element will keep its position if
|
||||
// possible. Or Move backward to the new-end if it's in the 'Y' range.
|
||||
element.end = Math.min(element.end, changeRangeNewEnd);
|
||||
}
|
||||
|
||||
Debug.assert(element.pos <= element.end);
|
||||
if (element.parent) {
|
||||
Debug.assert(element.pos >= element.parent.pos);
|
||||
Debug.assert(element.end <= element.parent.end);
|
||||
}
|
||||
}
|
||||
|
||||
function moveElementEntirelyPastChangeRange(element: IncrementalElement, delta: number) {
|
||||
if (element.length) {
|
||||
visitArray(<IncrementalNodeArray>element);
|
||||
}
|
||||
else {
|
||||
visitNode(<IncrementalNode>element);
|
||||
}
|
||||
|
||||
function visitNode(node: IncrementalNode) {
|
||||
// Ditch any existing LS children we may have created. This way we can avoid
|
||||
// moving them forward.
|
||||
node._children = undefined;
|
||||
node.pos += delta;
|
||||
node.end += delta;
|
||||
|
||||
forEachChild(node, visitNode, visitArray);
|
||||
}
|
||||
|
||||
function visitArray(array: IncrementalNodeArray) {
|
||||
array.pos += delta;
|
||||
array.end += delta;
|
||||
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
visitNode(array[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function extendToAffectedRange(changeRange: TextChangeRange): TextChangeRange {
|
||||
// Consider the following code:
|
||||
// void foo() { /; }
|
||||
//
|
||||
// If the text changes with an insertion of / just before the semicolon then we end up with:
|
||||
// void foo() { //; }
|
||||
//
|
||||
// If we were to just use the changeRange a is, then we would not rescan the { token
|
||||
// (as it does not intersect the actual original change range). Because an edit may
|
||||
// change the token touching it, we actually need to look back *at least* one token so
|
||||
// that the prior token sees that change.
|
||||
var maxLookahead = 1;
|
||||
|
||||
var start = changeRange.span.start;
|
||||
|
||||
// the first iteration aligns us with the change start. subsequent iteration move us to
|
||||
// the left by maxLookahead tokens. We only need to do this as long as we're not at the
|
||||
// start of the tree.
|
||||
for (var i = 0; start > 0 && i <= maxLookahead; i++) {
|
||||
var nearestNode = findNearestNodeStartingBeforeOrAtPosition(start);
|
||||
var position = nearestNode.pos;
|
||||
|
||||
start = Math.max(0, position - 1);
|
||||
}
|
||||
|
||||
var finalSpan = createTextSpanFromBounds(start, textSpanEnd(changeRange.span));
|
||||
var finalLength = changeRange.newLength + (changeRange.span.start - start);
|
||||
|
||||
return createTextChangeRange(finalSpan, finalLength);
|
||||
}
|
||||
|
||||
function findNearestNodeStartingBeforeOrAtPosition(position: number): Node {
|
||||
var bestResult: Node = sourceFile;
|
||||
var lastNodeEntirelyBeforePosition: Node;
|
||||
|
||||
forEachChild(sourceFile, visit);
|
||||
|
||||
if (lastNodeEntirelyBeforePosition) {
|
||||
var lastChildOfLastEntireNodeBeforePosition = getLastChild(lastNodeEntirelyBeforePosition);
|
||||
if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) {
|
||||
bestResult = lastChildOfLastEntireNodeBeforePosition;
|
||||
}
|
||||
}
|
||||
|
||||
return bestResult;
|
||||
|
||||
function getLastChild(node: Node): Node {
|
||||
while (true) {
|
||||
var lastChild = getLastChildWorker(node);
|
||||
if (lastChild) {
|
||||
node = lastChild;
|
||||
}
|
||||
else {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getLastChildWorker(node: Node): Node {
|
||||
var last:Node = undefined;
|
||||
forEachChild(node, child => {
|
||||
if (nodeIsPresent(child)) {
|
||||
last = child;
|
||||
}
|
||||
});
|
||||
return last;
|
||||
}
|
||||
|
||||
function visit(child: Node) {
|
||||
if (nodeIsMissing(child)) {
|
||||
// Missing nodes are effectively invisible to us. We never even consider them
|
||||
// When trying to find the nearest node before us.
|
||||
return;
|
||||
}
|
||||
|
||||
// If the child intersects this position, then this node is currently the nearest
|
||||
// node that starts before the position.
|
||||
if (child.pos <= position) {
|
||||
if (child.pos >= bestResult.pos) {
|
||||
// This node starts before the position, and is closer to the position than
|
||||
// the previous best node we found. It is now the new best node.
|
||||
bestResult = child;
|
||||
}
|
||||
|
||||
// Now, the node may overlap the position, or it may end entirely before the
|
||||
// position. If it overlaps with the position, then either it, or one of its
|
||||
// children must be the nearest node before the position. So we can just
|
||||
// recurse into this child to see if we can find something better.
|
||||
if (position < child.end) {
|
||||
// The nearest node is either this child, or one of the children inside
|
||||
// of it. We've already marked this child as the best so far. Recurse
|
||||
// in case one of the children is better.
|
||||
forEachChild(child, visit);
|
||||
|
||||
// Once we look at the children of this node, then there's no need to
|
||||
// continue any further.
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Debug.assert(child.end <= position);
|
||||
// The child ends entirely before this position. Say you have the following
|
||||
// (where $ is the position)
|
||||
//
|
||||
// <complex expr 1> ? <complex expr 2> $ : <...> <...>
|
||||
//
|
||||
// We would want to find the nearest preceding node in "complex expr 2".
|
||||
// To support that, we keep track of this node, and once we're done searching
|
||||
// for a best node, we recurse down this node to see if we can find a good
|
||||
// result in it.
|
||||
//
|
||||
// This approach allows us to quickly skip over nodes that are entirely
|
||||
// before the position, while still allowing us to find any nodes in the
|
||||
// last one that might be what we want.
|
||||
lastNodeEntirelyBeforePosition = child;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Debug.assert(child.pos > position);
|
||||
// We're now at a node that is entirely past the position we're searching for.
|
||||
// This node (and all following nodes) could never contribute to the result,
|
||||
// so just skip them by returning 'true' here.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sourceFile;
|
||||
|
||||
function setContextFlag(val: Boolean, flag: ParserContextFlags) {
|
||||
if (val) {
|
||||
@@ -1072,18 +1066,6 @@ module ts {
|
||||
return (contextFlags & ParserContextFlags.DisallowIn) !== 0;
|
||||
}
|
||||
|
||||
function getLineStarts(): number[] {
|
||||
return lineStarts || (lineStarts = computeLineStarts(sourceText));
|
||||
}
|
||||
|
||||
function getLineAndCharacterFromSourcePosition(position: number) {
|
||||
return getLineAndCharacterOfPosition(getLineStarts(), position);
|
||||
}
|
||||
|
||||
function getPositionFromSourceLineAndCharacter(line: number, character: number): number {
|
||||
return getPositionFromLineAndCharacter(getLineStarts(), line, character);
|
||||
}
|
||||
|
||||
function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void {
|
||||
var start = scanner.getTokenPos();
|
||||
var length = scanner.getTextPos() - start;
|
||||
@@ -4678,7 +4660,7 @@ module ts {
|
||||
}
|
||||
|
||||
function processReferenceComments(sourceFile: SourceFile): void {
|
||||
var triviaScanner = createScanner(languageVersion, /*skipTrivia*/false, sourceText);
|
||||
var triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, sourceText);
|
||||
var referencedFiles: FileReference[] = [];
|
||||
var amdDependencies: string[] = [];
|
||||
var amdModuleName: string;
|
||||
@@ -4707,7 +4689,7 @@ module ts {
|
||||
referencedFiles.push(fileReference);
|
||||
}
|
||||
if (diagnosticMessage) {
|
||||
sourceFile.referenceDiagnostics.push(createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage));
|
||||
sourceFile.parseDiagnostics.push(createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -4715,7 +4697,7 @@ module ts {
|
||||
var amdModuleNameMatchResult = amdModuleNameRegEx.exec(comment);
|
||||
if (amdModuleNameMatchResult) {
|
||||
if (amdModuleName) {
|
||||
sourceFile.referenceDiagnostics.push(createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments));
|
||||
sourceFile.parseDiagnostics.push(createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments));
|
||||
}
|
||||
amdModuleName = amdModuleNameMatchResult[2];
|
||||
}
|
||||
@@ -4741,17 +4723,6 @@ module ts {
|
||||
? node
|
||||
: undefined);
|
||||
}
|
||||
|
||||
function getSyntacticDiagnostics() {
|
||||
if (syntacticDiagnostics === undefined) {
|
||||
// Don't bother doing any grammar checks if there are already parser errors.
|
||||
// Otherwise we may end up with too many cascading errors.
|
||||
syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics);
|
||||
}
|
||||
|
||||
Debug.assert(syntacticDiagnostics !== undefined);
|
||||
return syntacticDiagnostics;
|
||||
}
|
||||
}
|
||||
|
||||
export function isLeftHandSideExpression(expr: Expression): boolean {
|
||||
|
||||
+171
-96
@@ -2,6 +2,8 @@
|
||||
/// <reference path="emitter.ts" />
|
||||
|
||||
module ts {
|
||||
/* @internal */ export var emitTime = 0;
|
||||
|
||||
export function createCompilerHost(options: CompilerOptions): CompilerHost {
|
||||
var currentDirectory: string;
|
||||
var existingDirectories: Map<boolean> = {};
|
||||
@@ -15,20 +17,20 @@ module ts {
|
||||
// returned by CScript sys environment
|
||||
var unsupportedFileEncodingErrorCode = -2147024809;
|
||||
|
||||
function getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
|
||||
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
|
||||
try {
|
||||
var text = sys.readFile(filename, options.charset);
|
||||
var text = sys.readFile(fileName, options.charset);
|
||||
}
|
||||
catch (e) {
|
||||
if (onError) {
|
||||
onError(e.number === unsupportedFileEncodingErrorCode ?
|
||||
createCompilerDiagnostic(Diagnostics.Unsupported_file_encoding).messageText :
|
||||
e.message);
|
||||
onError(e.number === unsupportedFileEncodingErrorCode
|
||||
? createCompilerDiagnostic(Diagnostics.Unsupported_file_encoding).messageText
|
||||
: e.message);
|
||||
}
|
||||
text = "";
|
||||
}
|
||||
|
||||
return text !== undefined ? createSourceFile(filename, text, languageVersion) : undefined;
|
||||
return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined;
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
|
||||
@@ -64,7 +66,7 @@ module ts {
|
||||
|
||||
return {
|
||||
getSourceFile,
|
||||
getDefaultLibFilename: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts"),
|
||||
getDefaultLibFileName: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFileName(options)),
|
||||
writeFile,
|
||||
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
|
||||
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
||||
@@ -73,161 +75,237 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program {
|
||||
export function getPreEmitDiagnostics(program: Program): Diagnostic[] {
|
||||
var diagnostics = program.getSyntacticDiagnostics().concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics());
|
||||
return sortAndDeduplicateDiagnostics(diagnostics);
|
||||
}
|
||||
|
||||
export function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string {
|
||||
if (typeof messageText === "string") {
|
||||
return messageText;
|
||||
}
|
||||
else {
|
||||
var diagnosticChain = messageText;
|
||||
var result = "";
|
||||
|
||||
var indent = 0;
|
||||
while (diagnosticChain) {
|
||||
if (indent) {
|
||||
result += newLine;
|
||||
|
||||
for (var i = 0; i < indent; i++) {
|
||||
result += " ";
|
||||
}
|
||||
}
|
||||
result += diagnosticChain.messageText;
|
||||
indent++;
|
||||
diagnosticChain = diagnosticChain.next;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program {
|
||||
var program: Program;
|
||||
var files: SourceFile[] = [];
|
||||
var filesByName: Map<SourceFile> = {};
|
||||
var errors: Diagnostic[] = [];
|
||||
var diagnostics = createDiagnosticCollection();
|
||||
var seenNoDefaultLib = options.noLib;
|
||||
var commonSourceDirectory: string;
|
||||
host = host || createCompilerHost(options);
|
||||
|
||||
forEach(rootNames, name => processRootFile(name, false));
|
||||
if (!seenNoDefaultLib) {
|
||||
processRootFile(host.getDefaultLibFilename(options), true);
|
||||
processRootFile(host.getDefaultLibFileName(options), true);
|
||||
}
|
||||
verifyCompilerOptions();
|
||||
errors.sort(compareDiagnostics);
|
||||
|
||||
|
||||
var diagnosticsProducingTypeChecker: TypeChecker;
|
||||
var noDiagnosticsTypeChecker: TypeChecker;
|
||||
var emitHost: EmitHost;
|
||||
|
||||
program = {
|
||||
getSourceFile: getSourceFile,
|
||||
getSourceFiles: () => files,
|
||||
getCompilerOptions: () => options,
|
||||
getCompilerHost: () => host,
|
||||
getDiagnostics: getDiagnostics,
|
||||
getGlobalDiagnostics: getGlobalDiagnostics,
|
||||
getDeclarationDiagnostics: getDeclarationDiagnostics,
|
||||
getSyntacticDiagnostics,
|
||||
getGlobalDiagnostics,
|
||||
getSemanticDiagnostics,
|
||||
getDeclarationDiagnostics,
|
||||
getTypeChecker,
|
||||
getDiagnosticsProducingTypeChecker,
|
||||
getCommonSourceDirectory: () => commonSourceDirectory,
|
||||
emitFiles: invokeEmitter,
|
||||
isEmitBlocked,
|
||||
emit,
|
||||
getCurrentDirectory: host.getCurrentDirectory,
|
||||
getNodeCount: () => getDiagnosticsProducingTypeChecker().getNodeCount(),
|
||||
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
|
||||
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
|
||||
getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(),
|
||||
};
|
||||
return program;
|
||||
|
||||
function getEmitHost() {
|
||||
return emitHost || (emitHost = createEmitHostFromProgram(program));
|
||||
}
|
||||
|
||||
function hasEarlyErrors(sourceFile?: SourceFile): boolean {
|
||||
return forEach(getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile), d => d.isEarly);
|
||||
}
|
||||
|
||||
function isEmitBlocked(sourceFile?: SourceFile): boolean {
|
||||
return getDiagnostics(sourceFile).length !== 0 ||
|
||||
hasEarlyErrors(sourceFile) ||
|
||||
(options.noEmitOnError && getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile).length !== 0);
|
||||
function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost {
|
||||
return {
|
||||
getCanonicalFileName: host.getCanonicalFileName,
|
||||
getCommonSourceDirectory: program.getCommonSourceDirectory,
|
||||
getCompilerOptions: program.getCompilerOptions,
|
||||
getCurrentDirectory: host.getCurrentDirectory,
|
||||
getNewLine: host.getNewLine,
|
||||
getSourceFile: program.getSourceFile,
|
||||
getSourceFiles: program.getSourceFiles,
|
||||
writeFile: writeFileCallback || host.writeFile,
|
||||
};
|
||||
}
|
||||
|
||||
function getDiagnosticsProducingTypeChecker() {
|
||||
return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ true));
|
||||
}
|
||||
|
||||
function getTypeChecker(produceDiagnostics: boolean) {
|
||||
if (produceDiagnostics) {
|
||||
return getDiagnosticsProducingTypeChecker();
|
||||
}
|
||||
else {
|
||||
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, produceDiagnostics));
|
||||
}
|
||||
function getTypeChecker() {
|
||||
return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = createTypeChecker(program, /*produceDiagnostics:*/ false));
|
||||
}
|
||||
|
||||
function getDeclarationDiagnostics(targetSourceFile: SourceFile): Diagnostic[]{
|
||||
var typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
typeChecker.getDiagnostics(targetSourceFile);
|
||||
var resolver = typeChecker.getEmitResolver();
|
||||
function getDeclarationDiagnostics(targetSourceFile: SourceFile): Diagnostic[] {
|
||||
var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(targetSourceFile);
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(), resolver, targetSourceFile);
|
||||
}
|
||||
|
||||
function invokeEmitter(targetSourceFile?: SourceFile) {
|
||||
var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver();
|
||||
return emitFiles(resolver, getEmitHost(), targetSourceFile);
|
||||
}
|
||||
|
||||
function getSourceFile(filename: string) {
|
||||
filename = host.getCanonicalFileName(filename);
|
||||
return hasProperty(filesByName, filename) ? filesByName[filename] : undefined;
|
||||
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback): EmitResult {
|
||||
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
|
||||
// immediately bail out.
|
||||
if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) {
|
||||
return { diagnostics: [], sourceMaps: undefined, emitSkipped: true };
|
||||
}
|
||||
|
||||
var start = new Date().getTime();
|
||||
|
||||
var emitResult = emitFiles(
|
||||
getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile),
|
||||
getEmitHost(writeFileCallback),
|
||||
sourceFile);
|
||||
|
||||
emitTime += new Date().getTime() - start;
|
||||
return emitResult;
|
||||
}
|
||||
|
||||
function getDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return sourceFile ? filter(errors, e => e.file === sourceFile) : errors;
|
||||
function getSourceFile(fileName: string) {
|
||||
fileName = host.getCanonicalFileName(fileName);
|
||||
return hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined;
|
||||
}
|
||||
|
||||
function getDiagnosticsHelper(sourceFile: SourceFile, getDiagnostics: (sourceFile: SourceFile) => Diagnostic[]): Diagnostic[] {
|
||||
if (sourceFile) {
|
||||
return getDiagnostics(sourceFile);
|
||||
}
|
||||
|
||||
var allDiagnostics: Diagnostic[] = [];
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
addRange(allDiagnostics, getDiagnostics(sourceFile));
|
||||
});
|
||||
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile);
|
||||
}
|
||||
|
||||
function getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile);
|
||||
}
|
||||
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
return sourceFile.parseDiagnostics;
|
||||
}
|
||||
|
||||
function getSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
var typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
var bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
var checkDiagnostics = typeChecker.getDiagnostics(sourceFile);
|
||||
var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
|
||||
|
||||
return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
|
||||
}
|
||||
|
||||
function getGlobalDiagnostics(): Diagnostic[] {
|
||||
return filter(errors, e => !e.file);
|
||||
var typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
var allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, typeChecker.getGlobalDiagnostics());
|
||||
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
|
||||
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function hasExtension(filename: string): boolean {
|
||||
return getBaseFilename(filename).indexOf(".") >= 0;
|
||||
function hasExtension(fileName: string): boolean {
|
||||
return getBaseFileName(fileName).indexOf(".") >= 0;
|
||||
}
|
||||
|
||||
function processRootFile(filename: string, isDefaultLib: boolean) {
|
||||
processSourceFile(normalizePath(filename), isDefaultLib);
|
||||
function processRootFile(fileName: string, isDefaultLib: boolean) {
|
||||
processSourceFile(normalizePath(fileName), isDefaultLib);
|
||||
}
|
||||
|
||||
function processSourceFile(filename: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
|
||||
function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
|
||||
if (refEnd !== undefined && refPos !== undefined) {
|
||||
var start = refPos;
|
||||
var length = refEnd - refPos;
|
||||
}
|
||||
var diagnostic: DiagnosticMessage;
|
||||
if (hasExtension(filename)) {
|
||||
if (!options.allowNonTsExtensions && !fileExtensionIs(filename, ".ts")) {
|
||||
if (hasExtension(fileName)) {
|
||||
if (!options.allowNonTsExtensions && !fileExtensionIs(host.getCanonicalFileName(fileName), ".ts")) {
|
||||
diagnostic = Diagnostics.File_0_must_have_extension_ts_or_d_ts;
|
||||
}
|
||||
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
else if (!findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
}
|
||||
else if (refFile && host.getCanonicalFileName(filename) === host.getCanonicalFileName(refFile.filename)) {
|
||||
else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) {
|
||||
diagnostic = Diagnostics.A_file_cannot_have_a_reference_to_itself;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (options.allowNonTsExtensions && !findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
}
|
||||
else if (!findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) && !findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd)) {
|
||||
else if (!findSourceFile(fileName + ".ts", isDefaultLib, refFile, refPos, refEnd) && !findSourceFile(fileName + ".d.ts", isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
filename += ".ts";
|
||||
fileName += ".ts";
|
||||
}
|
||||
}
|
||||
|
||||
if (diagnostic) {
|
||||
if (refFile) {
|
||||
errors.push(createFileDiagnostic(refFile, start, length, diagnostic, filename));
|
||||
diagnostics.add(createFileDiagnostic(refFile, start, length, diagnostic, fileName));
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(diagnostic, filename));
|
||||
diagnostics.add(createCompilerDiagnostic(diagnostic, fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get source file from normalized filename
|
||||
function findSourceFile(filename: string, isDefaultLib: boolean, refFile?: SourceFile, refStart?: number, refLength?: number): SourceFile {
|
||||
var canonicalName = host.getCanonicalFileName(filename);
|
||||
// Get source file from normalized fileName
|
||||
function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refStart?: number, refLength?: number): SourceFile {
|
||||
var canonicalName = host.getCanonicalFileName(fileName);
|
||||
if (hasProperty(filesByName, canonicalName)) {
|
||||
// We've already looked for this file, use cached result
|
||||
return getSourceFileFromCache(filename, canonicalName, /*useAbsolutePath*/ false);
|
||||
return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false);
|
||||
}
|
||||
else {
|
||||
var normalizedAbsolutePath = getNormalizedAbsolutePath(filename, host.getCurrentDirectory());
|
||||
var normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
|
||||
var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
|
||||
if (hasProperty(filesByName, canonicalAbsolutePath)) {
|
||||
return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true);
|
||||
}
|
||||
|
||||
// We haven't looked for this file, do so now and cache result
|
||||
var file = filesByName[canonicalName] = host.getSourceFile(filename, options.target, hostErrorMessage => {
|
||||
var file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
if (refFile) {
|
||||
errors.push(createFileDiagnostic(refFile, refStart, refLength,
|
||||
Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage));
|
||||
diagnostics.add(createFileDiagnostic(refFile, refStart, refLength,
|
||||
Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
});
|
||||
if (file) {
|
||||
@@ -237,7 +315,7 @@ module ts {
|
||||
filesByName[canonicalAbsolutePath] = file;
|
||||
|
||||
if (!options.noResolve) {
|
||||
var basePath = getDirectoryPath(filename);
|
||||
var basePath = getDirectoryPath(fileName);
|
||||
processReferencedFiles(file, basePath);
|
||||
processImportedModules(file, basePath);
|
||||
}
|
||||
@@ -247,20 +325,17 @@ module ts {
|
||||
else {
|
||||
files.push(file);
|
||||
}
|
||||
forEach(file.getSyntacticDiagnostics(), e => {
|
||||
errors.push(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
return file;
|
||||
|
||||
function getSourceFileFromCache(filename: string, canonicalName: string, useAbsolutePath: boolean): SourceFile {
|
||||
function getSourceFileFromCache(fileName: string, canonicalName: string, useAbsolutePath: boolean): SourceFile {
|
||||
var file = filesByName[canonicalName];
|
||||
if (file && host.useCaseSensitiveFileNames()) {
|
||||
var sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.filename, host.getCurrentDirectory()) : file.filename;
|
||||
var sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
|
||||
if (canonicalName !== sourceFileName) {
|
||||
errors.push(createFileDiagnostic(refFile, refStart, refLength,
|
||||
Diagnostics.Filename_0_differs_from_already_included_filename_1_only_in_casing, filename, sourceFileName));
|
||||
diagnostics.add(createFileDiagnostic(refFile, refStart, refLength,
|
||||
Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
|
||||
}
|
||||
}
|
||||
return file;
|
||||
@@ -269,8 +344,8 @@ module ts {
|
||||
|
||||
function processReferencedFiles(file: SourceFile, basePath: string) {
|
||||
forEach(file.referencedFiles, ref => {
|
||||
var referencedFilename = isRootedDiskPath(ref.filename) ? ref.filename : combinePaths(basePath, ref.filename);
|
||||
processSourceFile(normalizePath(referencedFilename), /* isDefaultLib */ false, file, ref.pos, ref.end);
|
||||
var referencedFileName = isRootedDiskPath(ref.fileName) ? ref.fileName : combinePaths(basePath, ref.fileName);
|
||||
processSourceFile(normalizePath(referencedFileName), /* isDefaultLib */ false, file, ref.pos, ref.end);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -324,8 +399,8 @@ module ts {
|
||||
}
|
||||
});
|
||||
|
||||
function findModuleSourceFile(filename: string, nameLiteral: LiteralExpression) {
|
||||
return findSourceFile(filename, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos);
|
||||
function findModuleSourceFile(fileName: string, nameLiteral: LiteralExpression) {
|
||||
return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,10 +408,10 @@ module ts {
|
||||
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
|
||||
// Error to specify --mapRoot or --sourceRoot without mapSourceFiles
|
||||
if (options.mapRoot) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option));
|
||||
}
|
||||
if (options.sourceRoot) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -347,7 +422,7 @@ module ts {
|
||||
var externalModuleErrorSpan = getErrorSpanForNode(firstExternalModule.externalModuleIndicator);
|
||||
var errorStart = skipTrivia(firstExternalModule.text, externalModuleErrorSpan.pos);
|
||||
var errorLength = externalModuleErrorSpan.end - errorStart;
|
||||
errors.push(createFileDiagnostic(firstExternalModule, errorStart, errorLength, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided));
|
||||
diagnostics.add(createFileDiagnostic(firstExternalModule, errorStart, errorLength, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided));
|
||||
}
|
||||
|
||||
// there has to be common source directory if user specified --outdir || --sourcRoot
|
||||
@@ -361,14 +436,14 @@ module ts {
|
||||
forEach(files, sourceFile => {
|
||||
// Each file contributes into common source file path
|
||||
if (!(sourceFile.flags & NodeFlags.DeclarationFile)
|
||||
&& !fileExtensionIs(sourceFile.filename, ".js")) {
|
||||
var sourcePathComponents = getNormalizedPathComponents(sourceFile.filename, host.getCurrentDirectory());
|
||||
&& !fileExtensionIs(sourceFile.fileName, ".js")) {
|
||||
var sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, host.getCurrentDirectory());
|
||||
sourcePathComponents.pop(); // FileName is not part of directory
|
||||
if (commonPathComponents) {
|
||||
for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) {
|
||||
if (commonPathComponents[i] !== sourcePathComponents[i]) {
|
||||
if (i === 0) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -401,11 +476,11 @@ module ts {
|
||||
|
||||
if (options.noEmit) {
|
||||
if (options.out || options.outDir) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir));
|
||||
}
|
||||
|
||||
if (options.declaration) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-6
@@ -278,12 +278,20 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number {
|
||||
Debug.assert(line > 0 && line <= lineStarts.length );
|
||||
export function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number {
|
||||
return computePositionFromLineAndCharacter(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 getLineAndCharacterOfPosition(lineStarts: number[], position: number) {
|
||||
export function getLineStarts(sourceFile: SourceFile): number[] {
|
||||
return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text));
|
||||
}
|
||||
|
||||
export function computeLineAndCharacterOfPosition(lineStarts: number[], position: number) {
|
||||
var lineNumber = binarySearch(lineStarts, position);
|
||||
if (lineNumber < 0) {
|
||||
// If the actual position was not found,
|
||||
@@ -298,9 +306,8 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function positionToLineAndCharacter(text: string, pos: number) {
|
||||
var lineStarts = computeLineStarts(text);
|
||||
return getLineAndCharacterOfPosition(lineStarts, pos);
|
||||
export function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter {
|
||||
return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
|
||||
}
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
+105
-84
@@ -2,7 +2,7 @@
|
||||
/// <reference path="commandLineParser.ts"/>
|
||||
|
||||
module ts {
|
||||
var version = "1.4.0.0";
|
||||
var version = "1.5.0.0";
|
||||
|
||||
export interface SourceFile {
|
||||
fileWatcher: FileWatcher;
|
||||
@@ -72,27 +72,27 @@ module ts {
|
||||
function countLines(program: Program): number {
|
||||
var count = 0;
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
count += file.getLineAndCharacterFromPosition(file.end).line;
|
||||
count += getLineAndCharacterOfPosition(file, file.end).line;
|
||||
});
|
||||
return count;
|
||||
}
|
||||
|
||||
function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string {
|
||||
var diagnostic: Diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
|
||||
return diagnostic.messageText;
|
||||
var diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
|
||||
return <string>diagnostic.messageText;
|
||||
}
|
||||
|
||||
function reportDiagnostic(diagnostic: Diagnostic) {
|
||||
var output = "";
|
||||
|
||||
if (diagnostic.file) {
|
||||
var loc = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
var loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
|
||||
output += diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): ";
|
||||
output += diagnostic.file.fileName + "(" + loc.line + "," + loc.character + "): ";
|
||||
}
|
||||
|
||||
var category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + sys.newLine;
|
||||
output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) + sys.newLine;
|
||||
|
||||
sys.write(output);
|
||||
}
|
||||
@@ -136,27 +136,27 @@ module ts {
|
||||
|
||||
function findConfigFile(): string {
|
||||
var searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
var filename = "tsconfig.json";
|
||||
var fileName = "tsconfig.json";
|
||||
while (true) {
|
||||
if (sys.fileExists(filename)) {
|
||||
return filename;
|
||||
if (sys.fileExists(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
searchPath = parentPath;
|
||||
filename = "../" + filename;
|
||||
fileName = "../" + fileName;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function executeCommandLine(args: string[]): void {
|
||||
var commandLine = parseCommandLine(args);
|
||||
var configFilename: string; // Configuration file name (if any)
|
||||
var configFileName: string; // Configuration file name (if any)
|
||||
var configFileWatcher: FileWatcher; // Configuration file watcher
|
||||
var cachedProgram: Program; // Program cached from last compilation
|
||||
var rootFilenames: string[]; // Root filenames for compilation
|
||||
var rootFileNames: string[]; // Root fileNames for compilation
|
||||
var compilerOptions: CompilerOptions; // Compiler options for compilation
|
||||
var compilerHost: CompilerHost; // Compiler host
|
||||
var hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
|
||||
@@ -165,7 +165,7 @@ module ts {
|
||||
if (commandLine.options.locale) {
|
||||
if (!isJSONSupported()) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
|
||||
}
|
||||
@@ -174,48 +174,48 @@ module ts {
|
||||
// setting up localization, report them and quit.
|
||||
if (commandLine.errors.length > 0) {
|
||||
reportDiagnostics(commandLine.errors);
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
|
||||
if (commandLine.options.version) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, version));
|
||||
return sys.exit(EmitReturnStatus.Succeeded);
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
if (commandLine.options.help) {
|
||||
printVersion();
|
||||
printHelp();
|
||||
return sys.exit(EmitReturnStatus.Succeeded);
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
if (commandLine.options.project) {
|
||||
if (!isJSONSupported()) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
configFilename = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json"));
|
||||
if (commandLine.filenames.length !== 0) {
|
||||
configFileName = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json"));
|
||||
if (commandLine.fileNames.length !== 0) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
}
|
||||
else if (commandLine.filenames.length === 0 && isJSONSupported()) {
|
||||
configFilename = findConfigFile();
|
||||
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
|
||||
configFileName = findConfigFile();
|
||||
}
|
||||
|
||||
if (commandLine.filenames.length === 0 && !configFilename) {
|
||||
if (commandLine.fileNames.length === 0 && !configFileName) {
|
||||
printVersion();
|
||||
printHelp();
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
if (commandLine.options.watch) {
|
||||
if (!sys.watchFile) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
if (configFilename) {
|
||||
configFileWatcher = sys.watchFile(configFilename, configFileChanged);
|
||||
if (configFileName) {
|
||||
configFileWatcher = sys.watchFile(configFileName, configFileChanged);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,22 +225,22 @@ module ts {
|
||||
function performCompilation() {
|
||||
|
||||
if (!cachedProgram) {
|
||||
if (configFilename) {
|
||||
var configObject = readConfigFile(configFilename);
|
||||
if (configFileName) {
|
||||
var configObject = readConfigFile(configFileName);
|
||||
if (!configObject) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, configFilename));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, configFileName));
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
var configParseResult = parseConfigFile(configObject, getDirectoryPath(configFilename));
|
||||
var configParseResult = parseConfigFile(configObject, getDirectoryPath(configFileName));
|
||||
if (configParseResult.errors.length > 0) {
|
||||
reportDiagnostics(configParseResult.errors);
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
rootFilenames = configParseResult.filenames;
|
||||
rootFileNames = configParseResult.fileNames;
|
||||
compilerOptions = extend(commandLine.options, configParseResult.options);
|
||||
}
|
||||
else {
|
||||
rootFilenames = commandLine.filenames;
|
||||
rootFileNames = commandLine.fileNames;
|
||||
compilerOptions = commandLine.options;
|
||||
}
|
||||
compilerHost = createCompilerHost(compilerOptions);
|
||||
@@ -248,7 +248,7 @@ module ts {
|
||||
compilerHost.getSourceFile = getSourceFile;
|
||||
}
|
||||
|
||||
var compileResult = compile(rootFilenames, compilerOptions, compilerHost);
|
||||
var compileResult = compile(rootFileNames, compilerOptions, compilerHost);
|
||||
|
||||
if (!commandLine.options.watch) {
|
||||
return sys.exit(compileResult.exitStatus);
|
||||
@@ -258,20 +258,20 @@ module ts {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
|
||||
}
|
||||
|
||||
function getSourceFile(filename: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) {
|
||||
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) {
|
||||
// Return existing SourceFile object if one is available
|
||||
if (cachedProgram) {
|
||||
var sourceFile = cachedProgram.getSourceFile(filename);
|
||||
var sourceFile = cachedProgram.getSourceFile(fileName);
|
||||
// A modified source file has no watcher and should not be reused
|
||||
if (sourceFile && sourceFile.fileWatcher) {
|
||||
return sourceFile;
|
||||
}
|
||||
}
|
||||
// Use default host function
|
||||
var sourceFile = hostGetSourceFile(filename, languageVersion, onError);
|
||||
var sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
if (sourceFile && commandLine.options.watch) {
|
||||
// Attach a file watcher
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.filename, () => sourceFileChanged(sourceFile));
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, () => sourceFileChanged(sourceFile));
|
||||
}
|
||||
return sourceFile;
|
||||
}
|
||||
@@ -321,45 +321,22 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function compile(filenames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
|
||||
var parseStart = new Date().getTime();
|
||||
var program = createProgram(filenames, compilerOptions, compilerHost);
|
||||
function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
|
||||
ts.parseTime = 0;
|
||||
ts.bindTime = 0;
|
||||
ts.checkTime = 0;
|
||||
ts.emitTime = 0;
|
||||
|
||||
var bindStart = new Date().getTime();
|
||||
var errors: Diagnostic[] = program.getDiagnostics();
|
||||
var exitStatus: EmitReturnStatus;
|
||||
var start = new Date().getTime();
|
||||
|
||||
if (errors.length) {
|
||||
var checkStart = bindStart;
|
||||
var emitStart = bindStart;
|
||||
var reportStart = bindStart;
|
||||
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
|
||||
}
|
||||
else {
|
||||
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
|
||||
var checkStart = new Date().getTime();
|
||||
errors = checker.getDiagnostics();
|
||||
if (program.isEmitBlocked()) {
|
||||
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
|
||||
}
|
||||
else if (compilerOptions.noEmit) {
|
||||
exitStatus = EmitReturnStatus.Succeeded;
|
||||
}
|
||||
else {
|
||||
var emitStart = new Date().getTime();
|
||||
var emitOutput = program.emitFiles();
|
||||
var emitErrors = emitOutput.diagnostics;
|
||||
exitStatus = emitOutput.emitResultStatus;
|
||||
var reportStart = new Date().getTime();
|
||||
errors = concatenate(errors, emitErrors);
|
||||
}
|
||||
}
|
||||
var program = createProgram(fileNames, compilerOptions, compilerHost);
|
||||
var exitStatus = compileProgram();
|
||||
|
||||
reportDiagnostics(errors);
|
||||
var end = start - new Date().getTime();
|
||||
|
||||
if (compilerOptions.listFiles) {
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
sys.write(file.filename + sys.newLine);
|
||||
sys.write(file.fileName + sys.newLine);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -367,21 +344,65 @@ module ts {
|
||||
var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
|
||||
reportCountStatistic("Files", program.getSourceFiles().length);
|
||||
reportCountStatistic("Lines", countLines(program));
|
||||
reportCountStatistic("Nodes", checker ? checker.getNodeCount() : 0);
|
||||
reportCountStatistic("Identifiers", checker ? checker.getIdentifierCount() : 0);
|
||||
reportCountStatistic("Symbols", checker ? checker.getSymbolCount() : 0);
|
||||
reportCountStatistic("Types", checker ? checker.getTypeCount() : 0);
|
||||
reportCountStatistic("Nodes", program.getNodeCount());
|
||||
reportCountStatistic("Identifiers", program.getIdentifierCount());
|
||||
reportCountStatistic("Symbols", program.getSymbolCount());
|
||||
reportCountStatistic("Types", program.getTypeCount());
|
||||
|
||||
if (memoryUsed >= 0) {
|
||||
reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
|
||||
}
|
||||
reportTimeStatistic("Parse time", bindStart - parseStart);
|
||||
reportTimeStatistic("Bind time", checkStart - bindStart);
|
||||
reportTimeStatistic("Check time", emitStart - checkStart);
|
||||
reportTimeStatistic("Emit time", reportStart - emitStart);
|
||||
reportTimeStatistic("Total time", reportStart - parseStart);
|
||||
|
||||
reportTimeStatistic("Parse time", ts.parseTime);
|
||||
reportTimeStatistic("Bind time", ts.bindTime);
|
||||
reportTimeStatistic("Check time", ts.checkTime);
|
||||
reportTimeStatistic("Emit time", ts.emitTime);
|
||||
reportTimeStatistic("Total time", start - end);
|
||||
}
|
||||
|
||||
return { program, exitStatus };
|
||||
|
||||
function compileProgram(): ExitStatus {
|
||||
// First get any syntactic errors.
|
||||
var diagnostics = program.getSyntacticDiagnostics();
|
||||
reportDiagnostics(diagnostics);
|
||||
|
||||
// If we didn't have any syntactic errors, then also try getting the global and
|
||||
// semantic errors.
|
||||
if (diagnostics.length === 0) {
|
||||
var diagnostics = program.getGlobalDiagnostics();
|
||||
reportDiagnostics(diagnostics);
|
||||
|
||||
if (diagnostics.length === 0) {
|
||||
var diagnostics = program.getSemanticDiagnostics();
|
||||
reportDiagnostics(diagnostics);
|
||||
}
|
||||
}
|
||||
|
||||
// If the user doesn't want us to emit, then we're done at this point.
|
||||
if (compilerOptions.noEmit) {
|
||||
return diagnostics.length
|
||||
? ExitStatus.DiagnosticsPresent_OutputsSkipped
|
||||
: ExitStatus.Success;
|
||||
}
|
||||
|
||||
// Otherwise, emit and report any errors we ran into.
|
||||
var emitOutput = program.emit();
|
||||
reportDiagnostics(emitOutput.diagnostics);
|
||||
|
||||
// If the emitter didn't emit anything, then pass that value along.
|
||||
if (emitOutput.emitSkipped) {
|
||||
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
|
||||
}
|
||||
|
||||
// The emitter emitted something, inform the caller if that happened in the presence
|
||||
// of diagnostics or not.
|
||||
if (diagnostics.length > 0 || emitOutput.diagnostics.length > 0) {
|
||||
ExitStatus.DiagnosticsPresent_OutputsGenerated;
|
||||
}
|
||||
|
||||
return ExitStatus.Success;
|
||||
}
|
||||
}
|
||||
|
||||
function printVersion() {
|
||||
@@ -413,7 +434,7 @@ module ts {
|
||||
output += getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine;
|
||||
|
||||
// Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
|
||||
var optsList = optionDeclarations.slice();
|
||||
var optsList = filter(optionDeclarations.slice(), v => !v.experimental);
|
||||
optsList.sort((a, b) => compareValues<string>(a.name.toLowerCase(), b.name.toLowerCase()));
|
||||
|
||||
// We want our descriptions to align at the same column in our output,
|
||||
|
||||
+132
-99
@@ -330,6 +330,12 @@ module ts {
|
||||
HasAggregatedChildData = 1 << 6
|
||||
}
|
||||
|
||||
export const enum RelationComparisonResult {
|
||||
Succeeded = 1, // Should be truthy
|
||||
Failed = 2,
|
||||
FailedAndReported = 3
|
||||
}
|
||||
|
||||
export interface Node extends TextRange {
|
||||
kind: SyntaxKind;
|
||||
flags: NodeFlags;
|
||||
@@ -866,7 +872,7 @@ module ts {
|
||||
}
|
||||
|
||||
export interface FileReference extends TextRange {
|
||||
filename: string;
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
export interface CommentRange extends TextRange {
|
||||
@@ -878,77 +884,79 @@ module ts {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
endOfFileToken: Node;
|
||||
|
||||
filename: string;
|
||||
fileName: string;
|
||||
text: string;
|
||||
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getLineStarts(): number[];
|
||||
|
||||
// Produces a new SourceFile for the 'newText' provided. The 'textChangeRange' parameter
|
||||
// indicates what changed between the 'text' that this SourceFile has and the 'newText'.
|
||||
// The SourceFile will be created with the compiler attempting to reuse as many nodes from
|
||||
// this file as possible.
|
||||
//
|
||||
// Note: this function mutates nodes from this SourceFile. That means any existing nodes
|
||||
// from this SourceFile that are being held onto may change as a result (including
|
||||
// becoming detached from any SourceFile). It is recommended that this SourceFile not
|
||||
// be used once 'update' is called on it.
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
|
||||
amdDependencies: string[];
|
||||
amdModuleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
|
||||
// Diagnostics reported about the "///<reference" comments in the file.
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
|
||||
// Parse errors refer specifically to things the parser could not understand at all (like
|
||||
// missing tokens, or tokens it didn't know how to deal with).
|
||||
parseDiagnostics: Diagnostic[];
|
||||
|
||||
// Returns all syntactic diagnostics (i.e. the reference, parser and grammar diagnostics).
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
|
||||
// File level diagnostics reported by the binder.
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
|
||||
hasNoDefaultLib: boolean;
|
||||
externalModuleIndicator: Node; // The first node that causes this file to be an external module
|
||||
nodeCount: number;
|
||||
identifierCount: number;
|
||||
symbolCount: number;
|
||||
|
||||
// The first node that causes this file to be an external module
|
||||
externalModuleIndicator: Node;
|
||||
languageVersion: ScriptTarget;
|
||||
identifiers: Map<string>;
|
||||
|
||||
/* @internal */ nodeCount: number;
|
||||
/* @internal */ identifierCount: number;
|
||||
/* @internal */ symbolCount: number;
|
||||
|
||||
// File level diagnostics reported by the parser (includes diagnostics about /// references
|
||||
// as well as code diagnostics).
|
||||
/* @internal */ parseDiagnostics: Diagnostic[];
|
||||
|
||||
// File level diagnostics reported by the binder.
|
||||
/* @internal */ bindDiagnostics: Diagnostic[];
|
||||
|
||||
// Stores a line map for the file.
|
||||
// This field should never be used directly to obtain line map, use getLineMap function instead.
|
||||
/* @internal */ lineMap: number[];
|
||||
}
|
||||
|
||||
export interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
|
||||
export interface WriteFileCallback {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
}
|
||||
|
||||
export interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
getCompilerHost(): CompilerHost;
|
||||
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
/**
|
||||
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
|
||||
* the javascript and declaration files will be produced for all the files in this program.
|
||||
* If targetSourceFile is specified, then only the javascript and declaration for that
|
||||
* specific file will be generated.
|
||||
*
|
||||
* If writeFile is not specified then the writeFile callback from the compiler host will be
|
||||
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the javascript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
|
||||
// Gets a type checker that can be used to semantically analyze source fils in the program.
|
||||
// The 'produceDiagnostics' flag determines if the checker will produce diagnostics while
|
||||
// analyzing the code. It can be set to 'false' to make many type checking operaitons
|
||||
// faster. With this flag set, the checker can avoid codepaths only necessary to produce
|
||||
// diagnostics, but not necessary to answer semantic questions about the code.
|
||||
//
|
||||
// If 'produceDiagnostics' is false, then any calls to get diagnostics from the TypeChecker
|
||||
// will throw an invalid operation exception.
|
||||
getTypeChecker(produceDiagnostics: boolean): TypeChecker;
|
||||
getTypeChecker(): TypeChecker;
|
||||
|
||||
getCommonSourceDirectory(): string;
|
||||
|
||||
emitFiles(targetSourceFile?: SourceFile): EmitResult;
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
// For testing purposes only. Should not be used by any other consumers (including the
|
||||
// language service).
|
||||
/* @internal */ getDiagnosticsProducingTypeChecker(): TypeChecker;
|
||||
|
||||
/* @internal */ getNodeCount(): number;
|
||||
/* @internal */ getIdentifierCount(): number;
|
||||
/* @internal */ getSymbolCount(): number;
|
||||
/* @internal */ getTypeCount(): number;
|
||||
}
|
||||
|
||||
export interface SourceMapSpan {
|
||||
@@ -973,37 +981,33 @@ module ts {
|
||||
}
|
||||
|
||||
// Return code used by getEmitOutput function to indicate status of the function
|
||||
export enum EmitReturnStatus {
|
||||
Succeeded = 0, // All outputs generated if requested (.js, .map, .d.ts), no errors reported
|
||||
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, nothing generated
|
||||
JSGeneratedWithSemanticErrors = 2, // .js and .map generated with semantic errors
|
||||
DeclarationGenerationSkipped = 3, // .d.ts generation skipped because of semantic errors or declaration emitter specific errors; Output .js with semantic errors
|
||||
EmitErrorsEncountered = 4, // Emitter errors occurred during emitting process
|
||||
CompilerOptionsErrors = 5, // Errors occurred in parsing compiler options, nothing generated
|
||||
export enum ExitStatus {
|
||||
// Compiler ran successfully. Either this was a simple do-nothing compilation (for example,
|
||||
// when -version or -help was provided, or this was a normal compilation, no diagnostics
|
||||
// were produced, and all outputs were generated successfully.
|
||||
Success = 0,
|
||||
|
||||
// Diagnostics were produced and because of them no code was generated.
|
||||
DiagnosticsPresent_OutputsSkipped = 1,
|
||||
|
||||
// Diagnostics were produced and outputs were generated in spite of them.
|
||||
DiagnosticsPresent_OutputsGenerated = 2,
|
||||
}
|
||||
|
||||
export interface EmitResult {
|
||||
emitResultStatus: EmitReturnStatus;
|
||||
emitSkipped: boolean;
|
||||
diagnostics: Diagnostic[];
|
||||
sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps
|
||||
}
|
||||
|
||||
export interface TypeCheckerHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getCompilerHost(): CompilerHost;
|
||||
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
}
|
||||
|
||||
export interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getNodeCount(): number;
|
||||
getIdentifierCount(): number;
|
||||
getSymbolCount(): number;
|
||||
getTypeCount(): number;
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
@@ -1028,10 +1032,19 @@ module ts {
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
|
||||
// Returns the constant value of this enum member, or 'undefined' if the enum member has a computed value.
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
|
||||
// Should not be called directly. Should only be accessed through the Program instance.
|
||||
/* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
/* @internal */ getGlobalDiagnostics(): Diagnostic[];
|
||||
/* @internal */ getEmitResolver(sourceFile?: SourceFile): EmitResolver;
|
||||
|
||||
/* @internal */ getNodeCount(): number;
|
||||
/* @internal */ getIdentifierCount(): number;
|
||||
/* @internal */ getSymbolCount(): number;
|
||||
/* @internal */ getTypeCount(): number;
|
||||
}
|
||||
|
||||
export interface SymbolDisplayBuilder {
|
||||
@@ -1074,6 +1087,7 @@ module ts {
|
||||
WriteOwnNameForAnyLike = 0x00000010, // Write symbol's own name instead of 'any' for any like types (eg. unknown, __resolving__ etc)
|
||||
WriteTypeArgumentsOfSignature = 0x00000020, // Write the type arguments instead of type parameters of the signature
|
||||
InElementType = 0x00000040, // Writing an array or union element type
|
||||
UseFullyQualifiedType = 0x00000080, // Write out the fully qualified type name (eg. Module.Type, instead of Type)
|
||||
}
|
||||
|
||||
export const enum SymbolFormatFlags {
|
||||
@@ -1115,8 +1129,6 @@ module ts {
|
||||
isReferencedImportDeclaration(node: ImportDeclaration): boolean;
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
hasSemanticErrors(sourceFile?: SourceFile): boolean;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
@@ -1124,7 +1136,7 @@ module ts {
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
|
||||
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
||||
getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number;
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isUnknownIdentifier(location: Node, name: string): boolean;
|
||||
}
|
||||
|
||||
@@ -1266,29 +1278,33 @@ module ts {
|
||||
}
|
||||
|
||||
export const enum TypeFlags {
|
||||
Any = 0x00000001,
|
||||
String = 0x00000002,
|
||||
Number = 0x00000004,
|
||||
Boolean = 0x00000008,
|
||||
Void = 0x00000010,
|
||||
Undefined = 0x00000020,
|
||||
Null = 0x00000040,
|
||||
Enum = 0x00000080, // Enum type
|
||||
StringLiteral = 0x00000100, // String literal type
|
||||
TypeParameter = 0x00000200, // Type parameter
|
||||
Class = 0x00000400, // Class
|
||||
Interface = 0x00000800, // Interface
|
||||
Reference = 0x00001000, // Generic type reference
|
||||
Tuple = 0x00002000, // Tuple
|
||||
Union = 0x00004000, // Union
|
||||
Anonymous = 0x00008000, // Anonymous
|
||||
FromSignature = 0x00010000, // Created for signature assignment check
|
||||
Unwidened = 0x00020000, // Unwidened type (is or contains Undefined or Null type)
|
||||
Any = 0x00000001,
|
||||
String = 0x00000002,
|
||||
Number = 0x00000004,
|
||||
Boolean = 0x00000008,
|
||||
Void = 0x00000010,
|
||||
Undefined = 0x00000020,
|
||||
Null = 0x00000040,
|
||||
Enum = 0x00000080, // Enum type
|
||||
StringLiteral = 0x00000100, // String literal type
|
||||
TypeParameter = 0x00000200, // Type parameter
|
||||
Class = 0x00000400, // Class
|
||||
Interface = 0x00000800, // Interface
|
||||
Reference = 0x00001000, // Generic type reference
|
||||
Tuple = 0x00002000, // Tuple
|
||||
Union = 0x00004000, // Union
|
||||
Anonymous = 0x00008000, // Anonymous
|
||||
FromSignature = 0x00010000, // Created for signature assignment check
|
||||
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
|
||||
|
||||
Intrinsic = Any | String | Number | Boolean | Void | Undefined | Null,
|
||||
Primitive = String | Number | Boolean | Void | Undefined | Null | StringLiteral | Enum,
|
||||
StringLike = String | StringLiteral,
|
||||
NumberLike = Number | Enum,
|
||||
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
|
||||
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral
|
||||
}
|
||||
|
||||
// Properties common to all types
|
||||
@@ -1407,7 +1423,6 @@ module ts {
|
||||
key: string;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
isEarly?: boolean;
|
||||
}
|
||||
|
||||
// A linked list of formatted diagnostic messages to be used as part of a multiline message.
|
||||
@@ -1425,13 +1440,9 @@ module ts {
|
||||
file: SourceFile;
|
||||
start: number;
|
||||
length: number;
|
||||
messageText: string;
|
||||
messageText: string | DiagnosticMessageChain;
|
||||
category: DiagnosticCategory;
|
||||
code: number;
|
||||
/**
|
||||
* Early error - any error (can be produced at parsing\binding\typechecking step) that blocks emit
|
||||
*/
|
||||
isEarly?: boolean;
|
||||
}
|
||||
|
||||
export enum DiagnosticCategory {
|
||||
@@ -1470,6 +1481,7 @@ module ts {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
|
||||
@@ -1496,18 +1508,19 @@ module ts {
|
||||
|
||||
export interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
filenames: string[];
|
||||
fileNames: string[];
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
|
||||
export interface CommandLineOption {
|
||||
name: string;
|
||||
type: string | Map<number>; // "string", "number", "boolean", or an object literal mapping named values to actual values
|
||||
isFilePath?: boolean; // True if option value is a path or filename
|
||||
isFilePath?: boolean; // True if option value is a path or fileName
|
||||
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
|
||||
description?: DiagnosticMessage; // The message describing what the command line switch does
|
||||
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter
|
||||
error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'
|
||||
experimental?: boolean;
|
||||
}
|
||||
|
||||
export const enum CharacterCodes {
|
||||
@@ -1650,10 +1663,10 @@ module ts {
|
||||
}
|
||||
|
||||
export interface CompilerHost {
|
||||
getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getCancellationToken? (): CancellationToken;
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
@@ -1669,4 +1682,24 @@ module ts {
|
||||
span: TextSpan;
|
||||
newLength: number;
|
||||
}
|
||||
|
||||
// @internal
|
||||
export interface DiagnosticCollection {
|
||||
// Adds a diagnostic to this diagnostic collection.
|
||||
add(diagnostic: Diagnostic): void;
|
||||
|
||||
// Gets all the diagnostics that aren't associated with a file.
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
|
||||
// If fileName is provided, gets all the diagnostics associated with that file name.
|
||||
// Otherwise, returns all the diagnostics (global and file associated) in this colletion.
|
||||
getDiagnostics(fileName?: string): Diagnostic[];
|
||||
|
||||
// Gets a count of how many times this collection has been modified. This value changes
|
||||
// each time 'add' is called (regardless of whether or not an equivalent diagnostic was
|
||||
// already in the collection). As such, it can be used as a simple way to tell if any
|
||||
// operation caused diagnostics to be returned by storing and comparing the return value
|
||||
// of this method before/after the operation is performed.
|
||||
getModificationCount(): number;
|
||||
}
|
||||
}
|
||||
|
||||
+134
-27
@@ -25,13 +25,12 @@ module ts {
|
||||
|
||||
export interface EmitHost extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
|
||||
getCommonSourceDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
writeFile: WriteFileCallback;
|
||||
}
|
||||
|
||||
// Pool writers to avoid needing to allocate them for every symbol we write.
|
||||
@@ -109,8 +108,8 @@ module ts {
|
||||
// This is a useful function for debugging purposes.
|
||||
export function nodePosToString(node: Node): string {
|
||||
var file = getSourceFileOfNode(node);
|
||||
var loc = file.getLineAndCharacterFromPosition(node.pos);
|
||||
return file.filename + "(" + loc.line + "," + loc.character + ")";
|
||||
var loc = getLineAndCharacterOfPosition(file, node.pos);
|
||||
return file.fileName + "(" + loc.line + "," + loc.character + ")";
|
||||
}
|
||||
|
||||
export function getStartPosOfNode(node: Node): number {
|
||||
@@ -199,12 +198,19 @@ module ts {
|
||||
return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain, newLine: string): Diagnostic {
|
||||
export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic {
|
||||
node = getErrorSpanForNode(node);
|
||||
var file = getSourceFileOfNode(node);
|
||||
var start = skipTrivia(file.text, node.pos);
|
||||
var length = node.end - start;
|
||||
return flattenDiagnosticChain(file, start, length, messageChain, newLine);
|
||||
return {
|
||||
file,
|
||||
start,
|
||||
length,
|
||||
code: messageChain.code,
|
||||
category: messageChain.category,
|
||||
messageText: messageChain.next ? messageChain : messageChain.messageText
|
||||
};
|
||||
}
|
||||
|
||||
export function getErrorSpanForNode(node: Node): Node {
|
||||
@@ -399,6 +405,21 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
// If the grandparent node is an object literal (as opposed to a class),
|
||||
// then the computed property is not a 'this' container.
|
||||
// A computed property name in a class needs to be a this container
|
||||
// so that we can error on it.
|
||||
if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
return node;
|
||||
}
|
||||
// If this is a computed property, then the parent should not
|
||||
// make it a this container. The parent might be a property
|
||||
// in an object literal, like a method or accessor. But in order for
|
||||
// such a parent to be a this container, the reference must be in
|
||||
// the *body* of the container.
|
||||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (!includeArrowFunctions) {
|
||||
continue;
|
||||
@@ -421,13 +442,32 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getSuperContainer(node: Node): Node {
|
||||
export function getSuperContainer(node: Node, includeFunctions: boolean): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
if (!node) return node;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
// If the grandparent node is an object literal (as opposed to a class),
|
||||
// then the computed property is not a 'super' container.
|
||||
// A computed property name in a class needs to be a super container
|
||||
// so that we can error on it.
|
||||
if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
return node;
|
||||
}
|
||||
// If this is a computed property, then the parent should not
|
||||
// make it a super container. The parent might be a property
|
||||
// in an object literal, like a method or accessor. But in order for
|
||||
// such a parent to be a super container, the reference must be in
|
||||
// the *body* of the container.
|
||||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (!includeFunctions) {
|
||||
continue;
|
||||
}
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
@@ -527,6 +567,8 @@ module ts {
|
||||
return node === (<TypeAssertion>parent).expression;
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return node === (<TemplateSpan>parent).expression;
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
return node === (<ComputedPropertyName>parent).expression;
|
||||
default:
|
||||
if (isExpression(parent)) {
|
||||
return true;
|
||||
@@ -710,7 +752,7 @@ module ts {
|
||||
|
||||
export function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference) {
|
||||
if (!host.getCompilerOptions().noResolve) {
|
||||
var referenceFileName = isRootedDiskPath(reference.filename) ? reference.filename : combinePaths(getDirectoryPath(sourceFile.filename), reference.filename);
|
||||
var referenceFileName = isRootedDiskPath(reference.fileName) ? reference.fileName : combinePaths(getDirectoryPath(sourceFile.fileName), reference.fileName);
|
||||
referenceFileName = getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory());
|
||||
return host.getSourceFile(referenceFileName);
|
||||
}
|
||||
@@ -768,7 +810,7 @@ module ts {
|
||||
fileReference: {
|
||||
pos: start,
|
||||
end: end,
|
||||
filename: matchResult[3]
|
||||
fileName: matchResult[3]
|
||||
},
|
||||
isNoDefaultLib: false
|
||||
};
|
||||
@@ -807,21 +849,6 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function createEmitHostFromProgram(program: Program): EmitHost {
|
||||
var compilerHost = program.getCompilerHost();
|
||||
return {
|
||||
getCanonicalFileName: compilerHost.getCanonicalFileName,
|
||||
getCommonSourceDirectory: program.getCommonSourceDirectory,
|
||||
getCompilerOptions: program.getCompilerOptions,
|
||||
getCurrentDirectory: compilerHost.getCurrentDirectory,
|
||||
getNewLine: compilerHost.getNewLine,
|
||||
getSourceFile: program.getSourceFile,
|
||||
getSourceFiles: program.getSourceFiles,
|
||||
isEmitBlocked: program.isEmitBlocked,
|
||||
writeFile: compilerHost.writeFile,
|
||||
};
|
||||
}
|
||||
|
||||
export function textSpanEnd(span: TextSpan) {
|
||||
return span.start + span.length
|
||||
}
|
||||
@@ -1032,4 +1059,84 @@ module ts {
|
||||
|
||||
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength: */newEndN - oldStartN);
|
||||
}
|
||||
|
||||
// @internal
|
||||
export function createDiagnosticCollection(): DiagnosticCollection {
|
||||
var nonFileDiagnostics: Diagnostic[] = [];
|
||||
var fileDiagnostics: Map<Diagnostic[]> = {};
|
||||
|
||||
var diagnosticsModified = false;
|
||||
var modificationCount = 0;
|
||||
|
||||
return {
|
||||
add,
|
||||
getGlobalDiagnostics,
|
||||
getDiagnostics,
|
||||
getModificationCount
|
||||
};
|
||||
|
||||
function getModificationCount() {
|
||||
return modificationCount;
|
||||
}
|
||||
|
||||
function add(diagnostic: Diagnostic): void {
|
||||
var diagnostics: Diagnostic[];
|
||||
if (diagnostic.file) {
|
||||
diagnostics = fileDiagnostics[diagnostic.file.fileName];
|
||||
if (!diagnostics) {
|
||||
diagnostics = [];
|
||||
fileDiagnostics[diagnostic.file.fileName] = diagnostics;
|
||||
}
|
||||
}
|
||||
else {
|
||||
diagnostics = nonFileDiagnostics;
|
||||
}
|
||||
|
||||
diagnostics.push(diagnostic);
|
||||
diagnosticsModified = true;
|
||||
modificationCount++;
|
||||
}
|
||||
|
||||
function getGlobalDiagnostics(): Diagnostic[] {
|
||||
sortAndDeduplicate();
|
||||
return nonFileDiagnostics;
|
||||
}
|
||||
|
||||
function getDiagnostics(fileName?: string): Diagnostic[] {
|
||||
sortAndDeduplicate();
|
||||
if (fileName) {
|
||||
return fileDiagnostics[fileName] || [];
|
||||
}
|
||||
|
||||
var allDiagnostics: Diagnostic[] = [];
|
||||
function pushDiagnostic(d: Diagnostic) {
|
||||
allDiagnostics.push(d);
|
||||
}
|
||||
|
||||
forEach(nonFileDiagnostics, pushDiagnostic);
|
||||
|
||||
for (var key in fileDiagnostics) {
|
||||
if (hasProperty(fileDiagnostics, key)) {
|
||||
forEach(fileDiagnostics[key], pushDiagnostic);
|
||||
}
|
||||
}
|
||||
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function sortAndDeduplicate() {
|
||||
if (!diagnosticsModified) {
|
||||
return;
|
||||
}
|
||||
|
||||
diagnosticsModified = false;
|
||||
nonFileDiagnostics = sortAndDeduplicateDiagnostics(nonFileDiagnostics);
|
||||
|
||||
for (var key in fileDiagnostics) {
|
||||
if (hasProperty(fileDiagnostics, key)) {
|
||||
fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,11 +256,40 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
it('Correct type baselines for ' + fileName, () => {
|
||||
// NEWTODO: Type baselines
|
||||
if (result.errors.length === 0) {
|
||||
Harness.Baseline.runBaseline('Correct expression types for ' + fileName, justName.replace(/\.ts/, '.types'), () => {
|
||||
// The full walker simulates the types that you would get from doing a full
|
||||
// compile. The pull walker simulates the types you get when you just do
|
||||
// a type query for a random node (like how the LS would do it). Most of the
|
||||
// time, these will be the same. However, occasionally, they can be different.
|
||||
// Specifically, when the compiler internally depends on symbol IDs to order
|
||||
// things, then we may see different results because symbols can be created in a
|
||||
// different order with 'pull' operations, and thus can produce slightly differing
|
||||
// output.
|
||||
//
|
||||
// For example, with a full type check, we may see a type outputed as: number | string
|
||||
// But with a pull type check, we may see it as: string | number
|
||||
//
|
||||
// These types are equivalent, but depend on what order the compiler observed
|
||||
// certain parts of the program.
|
||||
|
||||
var fullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ true);
|
||||
var pullWalker = new TypeWriterWalker(program, /*fullTypeCheck:*/ false);
|
||||
|
||||
var fullTypes = generateTypes(fullWalker);
|
||||
var pullTypes = generateTypes(pullWalker);
|
||||
|
||||
if (fullTypes !== pullTypes) {
|
||||
Harness.Baseline.runBaseline('Correct full expression types for ' + fileName, justName.replace(/\.ts/, '.types'), () => fullTypes);
|
||||
Harness.Baseline.runBaseline('Correct pull expression types for ' + fileName, justName.replace(/\.ts/, '.types.pull'), () => pullTypes);
|
||||
}
|
||||
else {
|
||||
Harness.Baseline.runBaseline('Correct expression types for ' + fileName, justName.replace(/\.ts/, '.types'), () => fullTypes);
|
||||
}
|
||||
|
||||
function generateTypes(walker: TypeWriterWalker): string {
|
||||
var allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
|
||||
var typeLines: string[] = [];
|
||||
var typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {};
|
||||
var walker = new TypeWriterWalker(program);
|
||||
|
||||
allFiles.forEach(file => {
|
||||
var codeLines = file.content.split('\n');
|
||||
walker.getTypes(file.unitName).forEach(result => {
|
||||
@@ -299,7 +328,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
});
|
||||
|
||||
return typeLines.join('');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
+53
-34
@@ -118,7 +118,7 @@ module FourSlash {
|
||||
baselineFile: 'BaselineFile',
|
||||
declaration: 'declaration',
|
||||
emitThisFile: 'emitThisFile', // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project
|
||||
filename: 'Filename',
|
||||
fileName: 'Filename',
|
||||
mapRoot: 'mapRoot',
|
||||
module: 'module',
|
||||
out: 'out',
|
||||
@@ -129,7 +129,7 @@ module FourSlash {
|
||||
};
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = [testOptMetadataNames.filename, testOptMetadataNames.emitThisFile, testOptMetadataNames.resolveReference];
|
||||
var fileMetadataNames = [testOptMetadataNames.fileName, testOptMetadataNames.emitThisFile, testOptMetadataNames.resolveReference];
|
||||
var globalMetadataNames = [testOptMetadataNames.baselineFile, testOptMetadataNames.declaration,
|
||||
testOptMetadataNames.mapRoot, testOptMetadataNames.module, testOptMetadataNames.out,
|
||||
testOptMetadataNames.outDir, testOptMetadataNames.sourceMap, testOptMetadataNames.sourceRoot]
|
||||
@@ -237,9 +237,6 @@ module FourSlash {
|
||||
getLength: () => {
|
||||
return sourceText.length;
|
||||
},
|
||||
getLineStartPositions: () => {
|
||||
return <number[]>[];
|
||||
},
|
||||
getChangeRange: (oldSnapshot: ts.IScriptSnapshot) => {
|
||||
return <ts.TextChangeRange>undefined;
|
||||
}
|
||||
@@ -271,7 +268,7 @@ module FourSlash {
|
||||
private scenarioActions: string[] = [];
|
||||
private taoInvalidReason: string = null;
|
||||
|
||||
private inputFiles: ts.Map<string> = {}; // Map between inputFile's filename and its content for easily looking up when resolving references
|
||||
private inputFiles: ts.Map<string> = {}; // Map between inputFile's fileName and its content for easily looking up when resolving references
|
||||
|
||||
// Add input file which has matched file name with the given reference-file path.
|
||||
// This is necessary when resolveReference flag is specified
|
||||
@@ -363,9 +360,9 @@ module FourSlash {
|
||||
};
|
||||
|
||||
this.testData.files.forEach(file => {
|
||||
var filename = file.fileName.replace(Harness.IO.directoryName(file.fileName), '').substr(1);
|
||||
var filenameWithoutExtension = filename.substr(0, filename.lastIndexOf("."));
|
||||
this.scenarioActions.push('<CreateFileOnDisk FileId="' + filename + '" FileNameWithoutExtension="' + filenameWithoutExtension + '" FileExtension=".ts"><![CDATA[' + file.content + ']]></CreateFileOnDisk>');
|
||||
var fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), '').substr(1);
|
||||
var fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf("."));
|
||||
this.scenarioActions.push('<CreateFileOnDisk FileId="' + fileName + '" FileNameWithoutExtension="' + fileNameWithoutExtension + '" FileExtension=".ts"><![CDATA[' + file.content + ']]></CreateFileOnDisk>');
|
||||
});
|
||||
|
||||
// Open the first file by default
|
||||
@@ -391,7 +388,7 @@ module FourSlash {
|
||||
this.currentCaretPosition = pos;
|
||||
|
||||
var lineStarts = ts.computeLineStarts(this.getCurrentFileContent());
|
||||
var lineCharPos = ts.getLineAndCharacterOfPosition(lineStarts, pos);
|
||||
var lineCharPos = ts.computeLineAndCharacterOfPosition(lineStarts, pos);
|
||||
this.scenarioActions.push('<MoveCaretToLineAndChar LineNumber="' + lineCharPos.line + '" CharNumber="' + lineCharPos.character + '" />');
|
||||
}
|
||||
|
||||
@@ -412,8 +409,8 @@ module FourSlash {
|
||||
var fileToOpen: FourSlashFile = this.findFile(indexOrName);
|
||||
fileToOpen.fileName = ts.normalizeSlashes(fileToOpen.fileName);
|
||||
this.activeFile = fileToOpen;
|
||||
var filename = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), '').substr(1);
|
||||
this.scenarioActions.push('<OpenFile FileName="" SrcFileId="' + filename + '" FileId="' + filename + '" />');
|
||||
var fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), '').substr(1);
|
||||
this.scenarioActions.push('<OpenFile FileName="" SrcFileId="' + fileName + '" FileId="' + fileName + '" />');
|
||||
}
|
||||
|
||||
public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) {
|
||||
@@ -516,7 +513,9 @@ module FourSlash {
|
||||
}
|
||||
|
||||
errors.forEach(function (error: ts.Diagnostic) {
|
||||
Harness.IO.log(" minChar: " + error.start + ", limChar: " + (error.start + error.length) + ", message: " + error.messageText + "\n");
|
||||
Harness.IO.log(" minChar: " + error.start +
|
||||
", limChar: " + (error.start + error.length) +
|
||||
", message: " + ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine) + "\n");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -665,7 +664,16 @@ module FourSlash {
|
||||
|
||||
Harness.IO.log(errorMsg);
|
||||
this.raiseError("Completion list is not empty at Caret");
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCompletionListAllowsNewIdentifier(negative: boolean) {
|
||||
var completions = this.getCompletionListAtCaret();
|
||||
|
||||
if ((completions && !completions.isNewIdentifierLocation) && !negative) {
|
||||
this.raiseError("Expected builder completion entry");
|
||||
} else if ((completions && completions.isNewIdentifierLocation) && negative) {
|
||||
this.raiseError("Un-expected builder completion entry");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -733,7 +741,7 @@ module FourSlash {
|
||||
var localFiles = this.testData.files.map<string>(file => file.fileName);
|
||||
// Count only the references in local files. Filter the ones in lib and other files.
|
||||
ts.forEach(references, entry => {
|
||||
if (localFiles.some((filename) => filename === entry.fileName)) {
|
||||
if (localFiles.some((fileName) => fileName === entry.fileName)) {
|
||||
++referencesCount;
|
||||
}
|
||||
});
|
||||
@@ -1141,16 +1149,24 @@ module FourSlash {
|
||||
// Loop through all the emittedFiles and emit them one by one
|
||||
emitFiles.forEach(emitFile => {
|
||||
var emitOutput = this.languageService.getEmitOutput(emitFile.fileName);
|
||||
var emitOutputStatus = emitOutput.emitOutputStatus;
|
||||
// Print emitOutputStatus in readable format
|
||||
resultString += "EmitOutputStatus : " + ts.EmitReturnStatus[emitOutputStatus];
|
||||
resultString += "\n";
|
||||
resultString += "EmitSkipped: " + emitOutput.emitSkipped + ts.sys.newLine;
|
||||
|
||||
if (emitOutput.emitSkipped) {
|
||||
resultString += "Diagnostics:" + ts.sys.newLine;
|
||||
var diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram());
|
||||
for (var i = 0, n = diagnostics.length; i < n; i++) {
|
||||
resultString += " " + diagnostics[0].messageText + ts.sys.newLine;
|
||||
}
|
||||
}
|
||||
|
||||
emitOutput.outputFiles.forEach((outputFile, idx, array) => {
|
||||
var filename = "Filename : " + outputFile.name + "\n";
|
||||
resultString = resultString + filename + outputFile.text;
|
||||
var fileName = "FileName : " + outputFile.name + ts.sys.newLine;
|
||||
resultString = resultString + fileName + outputFile.text;
|
||||
});
|
||||
resultString += "\n";
|
||||
resultString += ts.sys.newLine;
|
||||
});
|
||||
|
||||
return resultString;
|
||||
},
|
||||
true /* run immediately */);
|
||||
@@ -1182,7 +1198,10 @@ module FourSlash {
|
||||
|
||||
if (errorList.length) {
|
||||
errorList.forEach(err => {
|
||||
Harness.IO.log("start: " + err.start + ", length: " + err.length + ", message: " + err.messageText);
|
||||
Harness.IO.log(
|
||||
"start: " + err.start +
|
||||
", length: " + err.length +
|
||||
", message: " + ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1396,15 +1415,15 @@ module FourSlash {
|
||||
var incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName);
|
||||
Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined);
|
||||
|
||||
var incrementalSyntaxDiagnostics = incrementalSourceFile.getSyntacticDiagnostics();
|
||||
var incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics;
|
||||
|
||||
// Check syntactic structure
|
||||
var snapshot = this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName);
|
||||
var content = snapshot.getText(0, snapshot.getLength());
|
||||
|
||||
var referenceSourceFile = ts.createLanguageServiceSourceFile(
|
||||
this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*isOpen:*/ false, /*setNodeParents:*/ false);
|
||||
var referenceSyntaxDiagnostics = referenceSourceFile.getSyntacticDiagnostics();
|
||||
this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*setNodeParents:*/ false);
|
||||
var referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics;
|
||||
|
||||
Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics);
|
||||
Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile);
|
||||
@@ -2134,7 +2153,7 @@ module FourSlash {
|
||||
}
|
||||
} else if (typeof indexOrName === 'string') {
|
||||
var name = <string>indexOrName;
|
||||
// names are stored in the compiler with this relative path, this allows people to use goTo.file on just the filename
|
||||
// names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName
|
||||
name = name.indexOf('/') === -1 ? 'tests/cases/fourslash/' + name : name;
|
||||
var availableNames: string[] = [];
|
||||
var foundIt = false;
|
||||
@@ -2206,20 +2225,20 @@ module FourSlash {
|
||||
currentTestState = new TestState(testData);
|
||||
|
||||
var result = '';
|
||||
var host = Harness.Compiler.createCompilerHost([{ unitName: Harness.Compiler.fourslashFilename, content: undefined },
|
||||
var host = Harness.Compiler.createCompilerHost([{ unitName: Harness.Compiler.fourslashFileName, content: undefined },
|
||||
{ unitName: fileName, content: content }],
|
||||
(fn, contents) => result = contents,
|
||||
ts.ScriptTarget.Latest,
|
||||
ts.sys.useCaseSensitiveFileNames);
|
||||
// TODO (drosen): We need to enforce checking on these tests.
|
||||
var program = ts.createProgram([Harness.Compiler.fourslashFilename, fileName], { out: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host);
|
||||
var checker = ts.createTypeChecker(program, /*produceDiagnostics*/ true);
|
||||
var program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { out: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host);
|
||||
|
||||
var errors = program.getDiagnostics().concat(checker.getDiagnostics());
|
||||
if (errors.length > 0) {
|
||||
throw new Error('Error compiling ' + fileName + ': ' + errors.map(e => e.messageText).join('\r\n'));
|
||||
var diagnostics = ts.getPreEmitDiagnostics(program);
|
||||
if (diagnostics.length > 0) {
|
||||
throw new Error('Error compiling ' + fileName + ': ' +
|
||||
diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine)).join('\r\n'));
|
||||
}
|
||||
program.emitFiles();
|
||||
program.emit();
|
||||
result = result || ''; // Might have an empty fourslash file
|
||||
|
||||
// Compile and execute the test
|
||||
@@ -2299,8 +2318,8 @@ module FourSlash {
|
||||
if (globalMetadataNamesIndex === -1) {
|
||||
if (fileMetadataNamesIndex === -1) {
|
||||
throw new Error('Unrecognized metadata name "' + match[1] + '". Available global metadata names are: ' + globalMetadataNames.join(', ') + '; file metadata names are: ' + fileMetadataNames.join(', '));
|
||||
} else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(testOptMetadataNames.filename)) {
|
||||
// Found an @Filename directive, if this is not the first then create a new subfile
|
||||
} else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(testOptMetadataNames.fileName)) {
|
||||
// Found an @FileName directive, if this is not the first then create a new subfile
|
||||
if (currentFileContent) {
|
||||
var file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges);
|
||||
file.fileOptions = currentFileOptions;
|
||||
|
||||
+99
-82
@@ -52,7 +52,7 @@ module Utils {
|
||||
|
||||
export var currentExecutionEnvironment = getExecutionEnvironment();
|
||||
|
||||
export function evalFile(fileContents: string, filename: string, nodeContext?: any) {
|
||||
export function evalFile(fileContents: string, fileName: string, nodeContext?: any) {
|
||||
var environment = getExecutionEnvironment();
|
||||
switch (environment) {
|
||||
case ExecutionEnvironment.CScript:
|
||||
@@ -62,9 +62,9 @@ module Utils {
|
||||
case ExecutionEnvironment.Node:
|
||||
var vm = require('vm');
|
||||
if (nodeContext) {
|
||||
vm.runInNewContext(fileContents, nodeContext, filename);
|
||||
vm.runInNewContext(fileContents, nodeContext, fileName);
|
||||
} else {
|
||||
vm.runInThisContext(fileContents, filename);
|
||||
vm.runInThisContext(fileContents, fileName);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -107,7 +107,7 @@ module Utils {
|
||||
export function memoize<T extends Function>(f: T): T {
|
||||
var cache: { [idx: string]: any } = {};
|
||||
|
||||
return <any>(() => {
|
||||
return <any>(function () {
|
||||
var key = Array.prototype.join.call(arguments);
|
||||
var cachedResult = cache[key];
|
||||
if (cachedResult) {
|
||||
@@ -183,7 +183,7 @@ module Utils {
|
||||
return {
|
||||
start: diagnostic.start,
|
||||
length: diagnostic.length,
|
||||
messageText: diagnostic.messageText,
|
||||
messageText: ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine),
|
||||
category: (<any>ts).DiagnosticCategory[diagnostic.category],
|
||||
code: diagnostic.code
|
||||
};
|
||||
@@ -305,10 +305,11 @@ module Utils {
|
||||
|
||||
assert.equal(d1.start, d2.start, "d1.start !== d2.start");
|
||||
assert.equal(d1.length, d2.length, "d1.length !== d2.length");
|
||||
assert.equal(d1.messageText, d2.messageText, "d1.messageText !== d2.messageText");
|
||||
assert.equal(
|
||||
ts.flattenDiagnosticMessageText(d1.messageText, ts.sys.newLine),
|
||||
ts.flattenDiagnosticMessageText(d2.messageText, ts.sys.newLine), "d1.messageText !== d2.messageText");
|
||||
assert.equal(d1.category, d2.category, "d1.category !== d2.category");
|
||||
assert.equal(d1.code, d2.code, "d1.code !== d2.code");
|
||||
assert.equal(d1.isEarly, d2.isEarly, "d1.isEarly !== d2.isEarly");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,9 +391,9 @@ module Harness {
|
||||
writeFile(path: string, contents: string): void;
|
||||
directoryName(path: string): string;
|
||||
createDirectory(path: string): void;
|
||||
fileExists(filename: string): boolean;
|
||||
fileExists(fileName: string): boolean;
|
||||
directoryExists(path: string): boolean;
|
||||
deleteFile(filename: string): void;
|
||||
deleteFile(fileName: string): void;
|
||||
listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[];
|
||||
log(text: string): void;
|
||||
getMemoryUsage? (): number;
|
||||
@@ -622,7 +623,7 @@ module Harness {
|
||||
// root of the server
|
||||
if (dirPath.match(/localhost:\d+$/) || dirPath.match(/localhost:\d+\/$/)) {
|
||||
dirPath = null;
|
||||
// path + filename
|
||||
// path + fileName
|
||||
} else if (dirPath.indexOf('.') === -1) {
|
||||
dirPath = dirPath.substring(0, dirPath.lastIndexOf('/'));
|
||||
// path
|
||||
@@ -693,26 +694,26 @@ module Harness {
|
||||
|
||||
|
||||
module Harness {
|
||||
var tcServicesFilename = "typescriptServices.js";
|
||||
var tcServicesFileName = "typescriptServices.js";
|
||||
|
||||
export var libFolder: string;
|
||||
switch (Utils.getExecutionEnvironment()) {
|
||||
case Utils.ExecutionEnvironment.CScript:
|
||||
libFolder = "built/local/";
|
||||
tcServicesFilename = "built/local/typescriptServices.js";
|
||||
tcServicesFileName = "built/local/typescriptServices.js";
|
||||
break;
|
||||
case Utils.ExecutionEnvironment.Node:
|
||||
libFolder = "built/local/";
|
||||
tcServicesFilename = "built/local/typescriptServices.js";
|
||||
tcServicesFileName = "built/local/typescriptServices.js";
|
||||
break;
|
||||
case Utils.ExecutionEnvironment.Browser:
|
||||
libFolder = "built/local/";
|
||||
tcServicesFilename = "built/local/typescriptServices.js";
|
||||
tcServicesFileName = "built/local/typescriptServices.js";
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown context');
|
||||
}
|
||||
export var tcServicesFile = IO.readFile(tcServicesFilename);
|
||||
export var tcServicesFile = IO.readFile(tcServicesFileName);
|
||||
|
||||
export interface SourceMapEmitterCallback {
|
||||
(emittedFile: string, emittedLine: number, emittedColumn: number, sourceFile: string, sourceLine: number, sourceColumn: number, sourceName: string): void;
|
||||
@@ -801,7 +802,7 @@ module Harness {
|
||||
|
||||
|
||||
// Cache these between executions so we don't have to re-parse them for every test
|
||||
export var fourslashFilename = 'fourslash.ts';
|
||||
export var fourslashFileName = 'fourslash.ts';
|
||||
export var fourslashSourceFile: ts.SourceFile;
|
||||
|
||||
export function getCanonicalFileName(fileName: string): string {
|
||||
@@ -820,14 +821,14 @@ module Harness {
|
||||
return useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
|
||||
var filemap: { [filename: string]: ts.SourceFile; } = {};
|
||||
var filemap: { [fileName: string]: ts.SourceFile; } = {};
|
||||
var getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory;
|
||||
|
||||
// Register input files
|
||||
function register(file: { unitName: string; content: string; }) {
|
||||
if (file.content !== undefined) {
|
||||
var filename = ts.normalizeSlashes(file.unitName);
|
||||
filemap[getCanonicalFileName(filename)] = ts.createSourceFile(filename, file.content, scriptTarget);
|
||||
var fileName = ts.normalizeSlashes(file.unitName);
|
||||
filemap[getCanonicalFileName(fileName)] = ts.createSourceFile(fileName, file.content, scriptTarget);
|
||||
}
|
||||
};
|
||||
inputFiles.forEach(register);
|
||||
@@ -842,8 +843,8 @@ module Harness {
|
||||
var canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory));
|
||||
return Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(canonicalAbsolutePath)) ? filemap[canonicalAbsolutePath] : undefined;
|
||||
}
|
||||
else if (fn === fourslashFilename) {
|
||||
var tsFn = 'tests/cases/fourslash/' + fourslashFilename;
|
||||
else if (fn === fourslashFileName) {
|
||||
var tsFn = 'tests/cases/fourslash/' + fourslashFileName;
|
||||
fourslashSourceFile = fourslashSourceFile || ts.createSourceFile(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
|
||||
return fourslashSourceFile;
|
||||
}
|
||||
@@ -855,7 +856,7 @@ module Harness {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
getDefaultLibFilename: options => defaultLibFileName,
|
||||
getDefaultLibFileName: options => defaultLibFileName,
|
||||
writeFile,
|
||||
getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
|
||||
@@ -931,10 +932,12 @@ module Harness {
|
||||
settingsCallback(null);
|
||||
}
|
||||
|
||||
var newLine = '\r\n';
|
||||
|
||||
var useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
|
||||
this.settings.forEach(setting => {
|
||||
switch (setting.flag.toLowerCase()) {
|
||||
// "filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve"
|
||||
// "fileName", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve"
|
||||
case "module":
|
||||
case "modulegentarget":
|
||||
if (typeof setting.value === 'string') {
|
||||
@@ -1009,13 +1012,16 @@ module Harness {
|
||||
|
||||
case 'newline':
|
||||
case 'newlines':
|
||||
ts.sys.newLine = setting.value;
|
||||
newLine = setting.value;
|
||||
break;
|
||||
|
||||
case 'comments':
|
||||
options.removeComments = setting.value === 'false';
|
||||
break;
|
||||
|
||||
case 'stripinternal':
|
||||
options.stripInternal = !!setting.value;
|
||||
|
||||
case 'usecasesensitivefilenames':
|
||||
useCaseSensitiveFileNames = setting.value === 'true';
|
||||
break;
|
||||
@@ -1051,7 +1057,7 @@ module Harness {
|
||||
break;
|
||||
|
||||
case 'includebuiltfile':
|
||||
inputFiles.push({ unitName: setting.value, content: IO.readFile(libFolder + setting.value) });
|
||||
inputFiles.push({ unitName: setting.value, content: normalizeLineEndings(IO.readFile(libFolder + setting.value), newLine) });
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1062,42 +1068,34 @@ module Harness {
|
||||
var filemap: { [name: string]: ts.SourceFile; } = {};
|
||||
var register = (file: { unitName: string; content: string; }) => {
|
||||
if (file.content !== undefined) {
|
||||
var filename = ts.normalizeSlashes(file.unitName);
|
||||
filemap[getCanonicalFileName(filename)] = ts.createSourceFile(filename, file.content, options.target);
|
||||
var fileName = ts.normalizeSlashes(file.unitName);
|
||||
filemap[getCanonicalFileName(fileName)] = ts.createSourceFile(fileName, file.content, options.target);
|
||||
}
|
||||
};
|
||||
inputFiles.forEach(register);
|
||||
otherFiles.forEach(register);
|
||||
|
||||
var fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
|
||||
var programFiles = inputFiles.map(file => file.unitName);
|
||||
var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(otherFiles),
|
||||
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
|
||||
options.target, useCaseSensitiveFileNames, currentDirectory));
|
||||
|
||||
var checker = program.getTypeChecker(/*produceDiagnostics*/ true);
|
||||
|
||||
var isEmitBlocked = program.isEmitBlocked();
|
||||
|
||||
// only emit if there weren't parse errors
|
||||
var emitResult: ts.EmitResult;
|
||||
if (!isEmitBlocked) {
|
||||
emitResult = program.emitFiles();
|
||||
}
|
||||
var emitResult = program.emit();
|
||||
|
||||
var errors: HarnessDiagnostic[] = [];
|
||||
program.getDiagnostics().concat(checker.getDiagnostics()).concat(emitResult ? emitResult.diagnostics : []).forEach(err => {
|
||||
ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics).forEach(err => {
|
||||
// TODO: new compiler formats errors after this point to add . and newlines so we'll just do it manually for now
|
||||
errors.push(getMinimalDiagnostic(err));
|
||||
});
|
||||
this.lastErrors = errors;
|
||||
|
||||
var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult ? emitResult.sourceMaps : undefined);
|
||||
var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
onComplete(result, program);
|
||||
|
||||
// reset what newline means in case the last test changed it
|
||||
ts.sys.newLine = '\r\n';
|
||||
ts.sys.newLine = newLine;
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -1144,12 +1142,12 @@ module Harness {
|
||||
var sourceFileName: string;
|
||||
if (ts.isExternalModule(sourceFile) || !options.out) {
|
||||
if (options.outDir) {
|
||||
var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.filename, result.currentDirectoryForProgram);
|
||||
var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram);
|
||||
sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), "");
|
||||
sourceFileName = ts.combinePaths(options.outDir, sourceFilePath);
|
||||
}
|
||||
else {
|
||||
sourceFileName = sourceFile.filename;
|
||||
sourceFileName = sourceFile.fileName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1169,15 +1167,23 @@ module Harness {
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeLineEndings(text: string, lineEnding: string): string {
|
||||
var normalized = text.replace(/\r\n?/g, '\n');
|
||||
if (lineEnding !== '\n') {
|
||||
normalized = normalized.replace(/\n/g, lineEnding);
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function getMinimalDiagnostic(err: ts.Diagnostic): HarnessDiagnostic {
|
||||
var errorLineInfo = err.file ? err.file.getLineAndCharacterFromPosition(err.start) : { line: 0, character: 0 };
|
||||
return {
|
||||
filename: err.file && err.file.filename,
|
||||
fileName: err.file && err.file.fileName,
|
||||
start: err.start,
|
||||
end: err.start + err.length,
|
||||
line: errorLineInfo.line,
|
||||
character: errorLineInfo.character,
|
||||
message: err.messageText,
|
||||
message: ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine),
|
||||
category: ts.DiagnosticCategory[err.category].toLowerCase(),
|
||||
code: err.code
|
||||
};
|
||||
@@ -1187,8 +1193,8 @@ module Harness {
|
||||
// This is basically copied from tsc.ts's reportError to replicate what tsc does
|
||||
var errorOutput = "";
|
||||
ts.forEach(diagnostics, diagnotic => {
|
||||
if (diagnotic.filename) {
|
||||
errorOutput += diagnotic.filename + "(" + diagnotic.line + "," + diagnotic.character + "): ";
|
||||
if (diagnotic.fileName) {
|
||||
errorOutput += diagnotic.fileName + "(" + diagnotic.line + "," + diagnotic.character + "): ";
|
||||
}
|
||||
|
||||
errorOutput += diagnotic.category + " TS" + diagnotic.code + ": " + diagnotic.message + ts.sys.newLine;
|
||||
@@ -1198,7 +1204,7 @@ module Harness {
|
||||
}
|
||||
|
||||
function compareDiagnostics(d1: HarnessDiagnostic, d2: HarnessDiagnostic) {
|
||||
return ts.compareValues(d1.filename, d2.filename) ||
|
||||
return ts.compareValues(d1.fileName, d2.fileName) ||
|
||||
ts.compareValues(d1.start, d2.start) ||
|
||||
ts.compareValues(d1.end, d2.end) ||
|
||||
ts.compareValues(d1.code, d2.code) ||
|
||||
@@ -1224,14 +1230,14 @@ module Harness {
|
||||
}
|
||||
|
||||
// Report global errors
|
||||
var globalErrors = diagnostics.filter(err => !err.filename);
|
||||
var globalErrors = diagnostics.filter(err => !err.fileName);
|
||||
globalErrors.forEach(outputErrorText);
|
||||
|
||||
// 'merge' the lines of each input file with any errors associated with it
|
||||
inputFiles.filter(f => f.content !== undefined).forEach(inputFile => {
|
||||
// Filter down to the errors in the file
|
||||
var fileErrors = diagnostics.filter(e => {
|
||||
var errFn = e.filename;
|
||||
var errFn = e.fileName;
|
||||
return errFn && errFn === inputFile.unitName;
|
||||
});
|
||||
|
||||
@@ -1295,12 +1301,12 @@ module Harness {
|
||||
});
|
||||
|
||||
var numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
return diagnostic.filename && isLibraryFile(diagnostic.filename);
|
||||
return diagnostic.fileName && isLibraryFile(diagnostic.fileName);
|
||||
});
|
||||
|
||||
var numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
// Count an error generated from tests262-harness folder.This should only apply for test262
|
||||
return diagnostic.filename && diagnostic.filename.indexOf("test262-harness") >= 0;
|
||||
return diagnostic.fileName && diagnostic.fileName.indexOf("test262-harness") >= 0;
|
||||
});
|
||||
|
||||
// Verify we didn't miss any errors in total
|
||||
@@ -1311,7 +1317,7 @@ module Harness {
|
||||
}
|
||||
|
||||
export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[], clean?: (s: string) => string) {
|
||||
// Collect, test, and sort the filenames
|
||||
// Collect, test, and sort the fileNames
|
||||
function cleanName(fn: string) {
|
||||
var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/');
|
||||
return fn.substr(lastSlash + 1).toLowerCase();
|
||||
@@ -1324,7 +1330,7 @@ module Harness {
|
||||
// Some extra spacing if this isn't the first file
|
||||
if (result.length) result = result + '\r\n\r\n';
|
||||
|
||||
// Filename header + content
|
||||
// FileName header + content
|
||||
result = result + '/*====== ' + outputFile.fileName + ' ======*/\r\n';
|
||||
if (clean) {
|
||||
result = result + clean(outputFile.code);
|
||||
@@ -1354,7 +1360,7 @@ module Harness {
|
||||
}
|
||||
|
||||
export interface HarnessDiagnostic {
|
||||
filename: string;
|
||||
fileName: string;
|
||||
start: number;
|
||||
end: number;
|
||||
line: number;
|
||||
@@ -1455,7 +1461,7 @@ module Harness {
|
||||
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors"];
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal"];
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSetting[] {
|
||||
|
||||
@@ -1469,7 +1475,7 @@ module Harness {
|
||||
return opts;
|
||||
}
|
||||
|
||||
/** Given a test file containing // @Filename directives, return an array of named units of code to be added to an existing compiler instance */
|
||||
/** Given a test file containing // @FileName directives, return an array of named units of code to be added to an existing compiler instance */
|
||||
export function makeUnitsFromTest(code: string, fileName: string): { settings: CompilerSetting[]; testUnitData: TestUnitData[]; } {
|
||||
var settings = extractCompilerSettings(code);
|
||||
|
||||
@@ -1557,26 +1563,37 @@ module Harness {
|
||||
export interface BaselineOptions {
|
||||
LineEndingSensitive?: boolean;
|
||||
Subfolder?: string;
|
||||
Baselinefolder?: string;
|
||||
}
|
||||
|
||||
export function localPath(fileName: string, subfolder?: string) {
|
||||
return baselinePath(fileName, 'local', subfolder);
|
||||
export function localPath(fileName: string, baselineFolder?: string, subfolder?: string) {
|
||||
if (baselineFolder === undefined) {
|
||||
return baselinePath(fileName, 'local', 'tests/baselines', subfolder);
|
||||
}
|
||||
else {
|
||||
return baselinePath(fileName, 'local', baselineFolder, subfolder);
|
||||
}
|
||||
}
|
||||
|
||||
function referencePath(fileName: string, subfolder?: string) {
|
||||
return baselinePath(fileName, 'reference', subfolder);
|
||||
function referencePath(fileName: string, baselineFolder?: string, subfolder?: string) {
|
||||
if (baselineFolder === undefined) {
|
||||
return baselinePath(fileName, 'reference', 'tests/baselines', subfolder);
|
||||
}
|
||||
else {
|
||||
return baselinePath(fileName, 'reference', baselineFolder, subfolder);
|
||||
}
|
||||
}
|
||||
|
||||
function baselinePath(fileName: string, type: string, subfolder?: string) {
|
||||
function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) {
|
||||
if (subfolder !== undefined) {
|
||||
return Harness.userSpecifiedroot + 'tests/baselines/' + subfolder + '/' + type + '/' + fileName;
|
||||
return Harness.userSpecifiedroot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName;
|
||||
} else {
|
||||
return Harness.userSpecifiedroot + 'tests/baselines/' + type + '/' + fileName;
|
||||
return Harness.userSpecifiedroot + baselineFolder + '/' + type + '/' + fileName;
|
||||
}
|
||||
}
|
||||
|
||||
var fileCache: { [idx: string]: boolean } = {};
|
||||
function generateActual(actualFilename: string, generateContent: () => string): string {
|
||||
function generateActual(actualFileName: string, generateContent: () => string): string {
|
||||
// For now this is written using TypeScript, because sys is not available when running old test cases.
|
||||
// But we need to move to sys once we have
|
||||
// Creates the directory including its parent if not already present
|
||||
@@ -1595,11 +1612,11 @@ module Harness {
|
||||
}
|
||||
|
||||
// Create folders if needed
|
||||
createDirectoryStructure(Harness.IO.directoryName(actualFilename));
|
||||
createDirectoryStructure(Harness.IO.directoryName(actualFileName));
|
||||
|
||||
// Delete the actual file in case it fails
|
||||
if (IO.fileExists(actualFilename)) {
|
||||
IO.deleteFile(actualFilename);
|
||||
if (IO.fileExists(actualFileName)) {
|
||||
IO.deleteFile(actualFileName);
|
||||
}
|
||||
|
||||
var actual = generateContent();
|
||||
@@ -1611,13 +1628,13 @@ module Harness {
|
||||
// Store the content in the 'local' folder so we
|
||||
// can accept it later (manually)
|
||||
if (actual !== null) {
|
||||
IO.writeFile(actualFilename, actual);
|
||||
IO.writeFile(actualFileName, actual);
|
||||
}
|
||||
|
||||
return actual;
|
||||
}
|
||||
|
||||
function compareToBaseline(actual: string, relativeFilename: string, opts: BaselineOptions) {
|
||||
function compareToBaseline(actual: string, relativeFileName: string, opts: BaselineOptions) {
|
||||
// actual is now either undefined (the generator had an error), null (no file requested),
|
||||
// or some real output of the function
|
||||
if (actual === undefined) {
|
||||
@@ -1625,15 +1642,15 @@ module Harness {
|
||||
return;
|
||||
}
|
||||
|
||||
var refFilename = referencePath(relativeFilename, opts && opts.Subfolder);
|
||||
var refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
|
||||
if (actual === null) {
|
||||
actual = '<no content>';
|
||||
}
|
||||
|
||||
var expected = '<no content>';
|
||||
if (IO.fileExists(refFilename)) {
|
||||
expected = IO.readFile(refFilename);
|
||||
if (IO.fileExists(refFileName)) {
|
||||
expected = IO.readFile(refFileName);
|
||||
}
|
||||
|
||||
var lineEndingSensitive = opts && opts.LineEndingSensitive;
|
||||
@@ -1646,34 +1663,34 @@ module Harness {
|
||||
return { expected, actual };
|
||||
}
|
||||
|
||||
function writeComparison(expected: string, actual: string, relativeFilename: string, actualFilename: string, descriptionForDescribe: string) {
|
||||
function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) {
|
||||
var encoded_actual = (new Buffer(actual)).toString('utf8')
|
||||
if (expected != encoded_actual) {
|
||||
// Overwrite & issue error
|
||||
var errMsg = 'The baseline file ' + relativeFilename + ' has changed';
|
||||
var errMsg = 'The baseline file ' + relativeFileName + ' has changed';
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
export function runBaseline(
|
||||
descriptionForDescribe: string,
|
||||
relativeFilename: string,
|
||||
relativeFileName: string,
|
||||
generateContent: () => string,
|
||||
runImmediately = false,
|
||||
opts?: BaselineOptions): void {
|
||||
|
||||
var actual = <string>undefined;
|
||||
var actualFilename = localPath(relativeFilename, opts && opts.Subfolder);
|
||||
var actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
|
||||
if (runImmediately) {
|
||||
actual = generateActual(actualFilename, generateContent);
|
||||
var comparison = compareToBaseline(actual, relativeFilename, opts);
|
||||
writeComparison(comparison.expected, comparison.actual, relativeFilename, actualFilename, descriptionForDescribe);
|
||||
actual = generateActual(actualFileName, generateContent);
|
||||
var comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe);
|
||||
} else {
|
||||
actual = generateActual(actualFilename, generateContent);
|
||||
actual = generateActual(actualFileName, generateContent);
|
||||
|
||||
var comparison = compareToBaseline(actual, relativeFilename, opts);
|
||||
writeComparison(comparison.expected, comparison.actual, relativeFilename, actualFilename, descriptionForDescribe);
|
||||
var comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ module Harness.LanguageService {
|
||||
public editRanges: { length: number; textChangeRange: ts.TextChangeRange; }[] = [];
|
||||
public lineMap: number[] = null;
|
||||
|
||||
constructor(public fileName: string, public content: string, public isOpen = true) {
|
||||
constructor(public fileName: string, public content: string) {
|
||||
this.setContent(content);
|
||||
}
|
||||
|
||||
@@ -72,14 +72,6 @@ module Harness.LanguageService {
|
||||
return this.textSnapshot.length;
|
||||
}
|
||||
|
||||
public getLineStartPositions(): string {
|
||||
if (this.lineMap === null) {
|
||||
this.lineMap = ts.computeLineStarts(this.textSnapshot);
|
||||
}
|
||||
|
||||
return JSON.stringify(this.lineMap);
|
||||
}
|
||||
|
||||
public getChangeRange(oldScript: ts.ScriptSnapshotShim): string {
|
||||
var oldShim = <ScriptSnapshotShim>oldScript;
|
||||
var range = this.scriptInfo.getTextChangeRangeBetweenVersions(oldShim.version, this.version);
|
||||
@@ -109,11 +101,9 @@ module Harness.LanguageService {
|
||||
fileName: string,
|
||||
compilationSettings: ts.CompilerOptions,
|
||||
scriptSnapshot: ts.IScriptSnapshot,
|
||||
version: string,
|
||||
isOpen: boolean): ts.SourceFile {
|
||||
version: string): ts.SourceFile {
|
||||
var sourceFile = ts.createSourceFile(fileName, scriptSnapshot.getText(0, scriptSnapshot.getLength()), compilationSettings.target);
|
||||
sourceFile.version = version;
|
||||
sourceFile.isOpen = isOpen;
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
@@ -123,10 +113,9 @@ module Harness.LanguageService {
|
||||
compilationSettings: ts.CompilerOptions,
|
||||
scriptSnapshot: ts.IScriptSnapshot,
|
||||
version: string,
|
||||
isOpen: boolean,
|
||||
textChangeRange: ts.TextChangeRange
|
||||
): ts.SourceFile {
|
||||
return ts.updateLanguageServiceSourceFile(document, scriptSnapshot, version, isOpen, textChangeRange);
|
||||
return ts.updateLanguageServiceSourceFile(document, scriptSnapshot, version, textChangeRange);
|
||||
}
|
||||
|
||||
public releaseDocument(fileName: string, compilationSettings: ts.CompilerOptions): void {
|
||||
@@ -145,6 +134,10 @@ module Harness.LanguageService {
|
||||
public trace(s: string) {
|
||||
}
|
||||
|
||||
public getNewLine(): string {
|
||||
return "\r\n";
|
||||
}
|
||||
|
||||
public addDefaultLibrary() {
|
||||
this.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.defaultLibSourceFile.text);
|
||||
}
|
||||
@@ -159,13 +152,17 @@ module Harness.LanguageService {
|
||||
}
|
||||
|
||||
private getScriptInfo(fileName: string): ScriptInfo {
|
||||
return this.fileNameToScript[fileName];
|
||||
return ts.lookUp(this.fileNameToScript, fileName);
|
||||
}
|
||||
|
||||
public addScript(fileName: string, content: string) {
|
||||
this.fileNameToScript[fileName] = new ScriptInfo(fileName, content);
|
||||
}
|
||||
|
||||
private contains(fileName: string): boolean {
|
||||
return ts.hasProperty(this.fileNameToScript, fileName);
|
||||
}
|
||||
|
||||
public updateScript(fileName: string, content: string) {
|
||||
var script = this.getScriptInfo(fileName);
|
||||
if (script !== null) {
|
||||
@@ -217,26 +214,28 @@ module Harness.LanguageService {
|
||||
return "";
|
||||
}
|
||||
|
||||
public getDefaultLibFilename(): string {
|
||||
public getDefaultLibFileName(): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
public getScriptFileNames(): string {
|
||||
var fileNames: string[] = [];
|
||||
ts.forEachKey(this.fileNameToScript, (fileName) => { fileNames.push(fileName); });
|
||||
ts.forEachKey(this.fileNameToScript,(fileName) => { fileNames.push(fileName); });
|
||||
return JSON.stringify(fileNames);
|
||||
}
|
||||
|
||||
public getScriptSnapshot(fileName: string): ts.ScriptSnapshotShim {
|
||||
return new ScriptSnapshotShim(this.getScriptInfo(fileName));
|
||||
if (this.contains(fileName)) {
|
||||
return new ScriptSnapshotShim(this.getScriptInfo(fileName));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public getScriptVersion(fileName: string): string {
|
||||
return this.getScriptInfo(fileName).version.toString();
|
||||
}
|
||||
|
||||
public getScriptIsOpen(fileName: string): boolean {
|
||||
return this.getScriptInfo(fileName).isOpen;
|
||||
if (this.contains(fileName)) {
|
||||
return this.getScriptInfo(fileName).version.toString();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public getLocalizedDiagnosticMessages(): string {
|
||||
@@ -272,7 +271,6 @@ module Harness.LanguageService {
|
||||
public parseSourceText(fileName: string, sourceText: ts.IScriptSnapshot): ts.SourceFile {
|
||||
var result = ts.createSourceFile(fileName, sourceText.getText(0, sourceText.getLength()), ts.ScriptTarget.Latest);
|
||||
result.version = "1";
|
||||
result.isOpen = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -292,7 +290,7 @@ module Harness.LanguageService {
|
||||
assert.isTrue(line >= 1);
|
||||
assert.isTrue(col >= 1);
|
||||
|
||||
return ts.getPositionFromLineAndCharacter(script.lineMap, line, col);
|
||||
return ts.computePositionFromLineAndCharacter(script.lineMap, line, col);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,7 +301,7 @@ module Harness.LanguageService {
|
||||
var script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
assert.isNotNull(script);
|
||||
|
||||
var result = ts.getLineAndCharacterOfPosition(script.lineMap, position);
|
||||
var result = ts.computeLineAndCharacterOfPosition(script.lineMap, position);
|
||||
|
||||
assert.isTrue(result.line >= 1);
|
||||
assert.isTrue(result.character >= 1);
|
||||
|
||||
@@ -60,18 +60,18 @@ interface IOLog {
|
||||
}
|
||||
|
||||
interface PlaybackControl {
|
||||
startReplayFromFile(logFilename: string): void;
|
||||
startReplayFromFile(logFileName: string): void;
|
||||
startReplayFromString(logContents: string): void;
|
||||
startReplayFromData(log: IOLog): void;
|
||||
endReplay(): void;
|
||||
startRecord(logFilename: string): void;
|
||||
startRecord(logFileName: string): void;
|
||||
endRecord(): void;
|
||||
}
|
||||
|
||||
module Playback {
|
||||
var recordLog: IOLog = undefined;
|
||||
var replayLog: IOLog = undefined;
|
||||
var recordLogFilenameBase = '';
|
||||
var recordLogFileNameBase = '';
|
||||
|
||||
interface Memoized<T> {
|
||||
(s: string): T;
|
||||
@@ -130,15 +130,15 @@ module Playback {
|
||||
replayLog = undefined;
|
||||
};
|
||||
|
||||
wrapper.startRecord = (filenameBase) => {
|
||||
recordLogFilenameBase = filenameBase;
|
||||
wrapper.startRecord = (fileNameBase) => {
|
||||
recordLogFileNameBase = fileNameBase;
|
||||
recordLog = createEmptyLog();
|
||||
};
|
||||
}
|
||||
|
||||
function recordReplay<T extends Function>(original: T, underlying: any) {
|
||||
function createWrapper(record: T, replay: T): T {
|
||||
return <any>(() => {
|
||||
return <any>(function () {
|
||||
if (replayLog !== undefined) {
|
||||
return replay.apply(undefined, arguments);
|
||||
} else if (recordLog !== undefined) {
|
||||
@@ -176,7 +176,7 @@ module Playback {
|
||||
|
||||
function findResultByPath<T>(wrapper: { resolvePath(s: string): string }, logArray: { path: string; result?: T }[], expectedPath: string, defaultValue?: T): T {
|
||||
var normalizedName = ts.normalizeSlashes(expectedPath).toLowerCase();
|
||||
// Try to find the result through normal filename
|
||||
// Try to find the result through normal fileName
|
||||
for (var i = 0; i < logArray.length; i++) {
|
||||
if (ts.normalizeSlashes(logArray[i].path).toLowerCase() === normalizedName) {
|
||||
return logArray[i].result;
|
||||
@@ -231,7 +231,7 @@ module Playback {
|
||||
wrapper.endRecord = () => {
|
||||
if (recordLog !== undefined) {
|
||||
var i = 0;
|
||||
var fn = () => recordLogFilenameBase + i + '.json';
|
||||
var fn = () => recordLogFileNameBase + i + '.json';
|
||||
while (underlying.fileExists(fn())) i++;
|
||||
underlying.writeFile(fn(), JSON.stringify(recordLog));
|
||||
recordLog = undefined;
|
||||
|
||||
@@ -91,8 +91,8 @@ class ProjectRunner extends RunnerBase {
|
||||
// We have these two separate locations because when comparing baselines the baseline verifier will delete the existing file
|
||||
// so even if it was created by compiler in that location, the file will be deleted by verified before we can read it
|
||||
// so lets keep these two locations separate
|
||||
function getProjectOutputFolder(filename: string, moduleKind: ts.ModuleKind) {
|
||||
return Harness.Baseline.localPath("projectOutput/" + testCaseJustName + "/" + moduleNameToString(moduleKind) + "/" + filename);
|
||||
function getProjectOutputFolder(fileName: string, moduleKind: ts.ModuleKind) {
|
||||
return Harness.Baseline.localPath("projectOutput/" + testCaseJustName + "/" + moduleNameToString(moduleKind) + "/" + fileName);
|
||||
}
|
||||
|
||||
function cleanProjectUrl(url: string) {
|
||||
@@ -123,28 +123,24 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: ()=> string[],
|
||||
getSourceFileText: (filename: string) => string,
|
||||
writeFile: (filename: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult {
|
||||
getSourceFileText: (fileName: string) => string,
|
||||
writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult {
|
||||
|
||||
var program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost());
|
||||
var errors = program.getDiagnostics();
|
||||
var sourceMapData: ts.SourceMapData[] = null;
|
||||
if (!errors.length) {
|
||||
var checker = program.getTypeChecker(/*produceDiagnostics:*/ true);
|
||||
errors = checker.getDiagnostics();
|
||||
var emitResult = program.emitFiles();
|
||||
errors = ts.concatenate(errors, emitResult.diagnostics);
|
||||
sourceMapData = emitResult.sourceMaps;
|
||||
var errors = ts.getPreEmitDiagnostics(program);
|
||||
|
||||
// Clean up source map data that will be used in baselining
|
||||
if (sourceMapData) {
|
||||
for (var i = 0; i < sourceMapData.length; i++) {
|
||||
for (var j = 0; j < sourceMapData[i].sourceMapSources.length; j++) {
|
||||
sourceMapData[i].sourceMapSources[j] = cleanProjectUrl(sourceMapData[i].sourceMapSources[j]);
|
||||
}
|
||||
sourceMapData[i].jsSourceMappingURL = cleanProjectUrl(sourceMapData[i].jsSourceMappingURL);
|
||||
sourceMapData[i].sourceMapSourceRoot = cleanProjectUrl(sourceMapData[i].sourceMapSourceRoot);
|
||||
var emitResult = program.emit();
|
||||
errors = ts.concatenate(errors, emitResult.diagnostics);
|
||||
var sourceMapData = emitResult.sourceMaps;
|
||||
|
||||
// Clean up source map data that will be used in baselining
|
||||
if (sourceMapData) {
|
||||
for (var i = 0; i < sourceMapData.length; i++) {
|
||||
for (var j = 0; j < sourceMapData[i].sourceMapSources.length; j++) {
|
||||
sourceMapData[i].sourceMapSources[j] = cleanProjectUrl(sourceMapData[i].sourceMapSources[j]);
|
||||
}
|
||||
sourceMapData[i].jsSourceMappingURL = cleanProjectUrl(sourceMapData[i].jsSourceMappingURL);
|
||||
sourceMapData[i].sourceMapSourceRoot = cleanProjectUrl(sourceMapData[i].sourceMapSourceRoot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,15 +164,15 @@ class ProjectRunner extends RunnerBase {
|
||||
};
|
||||
}
|
||||
|
||||
function getSourceFile(filename: string, languageVersion: ts.ScriptTarget): ts.SourceFile {
|
||||
function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile {
|
||||
var sourceFile: ts.SourceFile = undefined;
|
||||
if (filename === Harness.Compiler.defaultLibFileName) {
|
||||
if (fileName === Harness.Compiler.defaultLibFileName) {
|
||||
sourceFile = languageVersion === ts.ScriptTarget.ES6 ? Harness.Compiler.defaultES6LibSourceFile : Harness.Compiler.defaultLibSourceFile;
|
||||
}
|
||||
else {
|
||||
var text = getSourceFileText(filename);
|
||||
var text = getSourceFileText(fileName);
|
||||
if (text !== undefined) {
|
||||
sourceFile = ts.createSourceFile(filename, text, languageVersion);
|
||||
sourceFile = ts.createSourceFile(fileName, text, languageVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +182,7 @@ class ProjectRunner extends RunnerBase {
|
||||
function createCompilerHost(): ts.CompilerHost {
|
||||
return {
|
||||
getSourceFile,
|
||||
getDefaultLibFilename: options => options.target === ts.ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts",
|
||||
getDefaultLibFileName: options => Harness.Compiler.defaultLibFileName,
|
||||
writeFile,
|
||||
getCurrentDirectory,
|
||||
getCanonicalFileName: Harness.Compiler.getCanonicalFileName,
|
||||
@@ -211,11 +207,11 @@ class ProjectRunner extends RunnerBase {
|
||||
nonSubfolderDiskFiles,
|
||||
};
|
||||
|
||||
function getSourceFileText(filename: string): string {
|
||||
function getSourceFileText(fileName: string): string {
|
||||
try {
|
||||
var text = ts.sys.readFile(ts.isRootedDiskPath(filename)
|
||||
? filename
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(filename));
|
||||
var text = ts.sys.readFile(ts.isRootedDiskPath(fileName)
|
||||
? fileName
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName));
|
||||
}
|
||||
catch (e) {
|
||||
// text doesn't get defined.
|
||||
@@ -223,30 +219,30 @@ class ProjectRunner extends RunnerBase {
|
||||
return text;
|
||||
}
|
||||
|
||||
function writeFile(filename: string, data: string, writeByteOrderMark: boolean) {
|
||||
var diskFileName = ts.isRootedDiskPath(filename)
|
||||
? filename
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(filename);
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
var diskFileName = ts.isRootedDiskPath(fileName)
|
||||
? fileName
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName);
|
||||
|
||||
var diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName,
|
||||
getCurrentDirectory(), Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
if (ts.isRootedDiskPath(diskRelativeName) || diskRelativeName.substr(0, 3) === "../") {
|
||||
// If the generated output file resides in the parent folder or is rooted path,
|
||||
// we need to instead create files that can live in the project reference folder
|
||||
// but make sure extension of these files matches with the filename the compiler asked to write
|
||||
// but make sure extension of these files matches with the fileName the compiler asked to write
|
||||
diskRelativeName = "diskFile" + nonSubfolderDiskFiles++ +
|
||||
(Harness.Compiler.isDTS(filename) ? ".d.ts" :
|
||||
Harness.Compiler.isJS(filename) ? ".js" : ".js.map");
|
||||
(Harness.Compiler.isDTS(fileName) ? ".d.ts" :
|
||||
Harness.Compiler.isJS(fileName) ? ".js" : ".js.map");
|
||||
}
|
||||
|
||||
if (Harness.Compiler.isJS(filename)) {
|
||||
if (Harness.Compiler.isJS(fileName)) {
|
||||
// Make sure if there is URl we have it cleaned up
|
||||
var indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL=");
|
||||
if (indexOfSourceMapUrl != -1) {
|
||||
data = data.substring(0, indexOfSourceMapUrl + 21) + cleanProjectUrl(data.substring(indexOfSourceMapUrl + 21));
|
||||
}
|
||||
}
|
||||
else if (Harness.Compiler.isJSMap(filename)) {
|
||||
else if (Harness.Compiler.isJSMap(fileName)) {
|
||||
// Make sure sources list is cleaned
|
||||
var sourceMapData = JSON.parse(data);
|
||||
for (var i = 0; i < sourceMapData.sources.length; i++) {
|
||||
@@ -269,26 +265,26 @@ class ProjectRunner extends RunnerBase {
|
||||
ensureDirectoryStructure(ts.getDirectoryPath(ts.normalizePath(outputFilePath)));
|
||||
ts.sys.writeFile(outputFilePath, data, writeByteOrderMark);
|
||||
|
||||
outputFiles.push({ emittedFileName: filename, code: data, fileName: diskRelativeName, writeByteOrderMark: writeByteOrderMark });
|
||||
outputFiles.push({ emittedFileName: fileName, code: data, fileName: diskRelativeName, writeByteOrderMark: writeByteOrderMark });
|
||||
}
|
||||
}
|
||||
|
||||
function compileCompileDTsFiles(compilerResult: BatchCompileProjectTestCaseResult) {
|
||||
var allInputFiles: { emittedFileName: string; code: string; }[] = [];
|
||||
var compilerOptions = compilerResult.program.getCompilerOptions();
|
||||
var compilerHost = compilerResult.program.getCompilerHost();
|
||||
|
||||
ts.forEach(compilerResult.program.getSourceFiles(), sourceFile => {
|
||||
if (Harness.Compiler.isDTS(sourceFile.filename)) {
|
||||
allInputFiles.unshift({ emittedFileName: sourceFile.filename, code: sourceFile.text });
|
||||
if (Harness.Compiler.isDTS(sourceFile.fileName)) {
|
||||
allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text });
|
||||
}
|
||||
else if (ts.shouldEmitToOwnFile(sourceFile, compilerResult.program.getCompilerOptions())) {
|
||||
if (compilerOptions.outDir) {
|
||||
var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.filename, compilerHost.getCurrentDirectory());
|
||||
var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory());
|
||||
sourceFilePath = sourceFilePath.replace(compilerResult.program.getCommonSourceDirectory(), "");
|
||||
var emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath));
|
||||
}
|
||||
else {
|
||||
var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.filename);
|
||||
var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName);
|
||||
}
|
||||
|
||||
var outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts";
|
||||
@@ -311,19 +307,19 @@ class ProjectRunner extends RunnerBase {
|
||||
function getInputFiles() {
|
||||
return ts.map(allInputFiles, outputFile => outputFile.emittedFileName);
|
||||
}
|
||||
function getSourceFileText(filename: string): string {
|
||||
return ts.forEach(allInputFiles, inputFile => inputFile.emittedFileName === filename ? inputFile.code : undefined);
|
||||
function getSourceFileText(fileName: string): string {
|
||||
return ts.forEach(allInputFiles, inputFile => inputFile.emittedFileName === fileName ? inputFile.code : undefined);
|
||||
}
|
||||
|
||||
function writeFile(filename: string, data: string, writeByteOrderMark: boolean) {
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
function getErrorsBaseline(compilerResult: CompileProjectFilesResult) {
|
||||
var inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
sourceFile => sourceFile.filename !== "lib.d.ts"),
|
||||
sourceFile => sourceFile.fileName !== "lib.d.ts"),
|
||||
sourceFile => {
|
||||
return { unitName: sourceFile.filename, content: sourceFile.text };
|
||||
return { unitName: sourceFile.fileName, content: sourceFile.text };
|
||||
});
|
||||
var diagnostics = ts.map(compilerResult.errors, error => Harness.Compiler.getMinimalDiagnostic(error));
|
||||
|
||||
@@ -348,7 +344,7 @@ class ProjectRunner extends RunnerBase {
|
||||
baselineCheck: testCase.baselineCheck,
|
||||
runTest: testCase.runTest,
|
||||
bug: testCase.bug,
|
||||
resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.filename),
|
||||
resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.fileName),
|
||||
emittedFiles: ts.map(compilerResult.outputFiles, outputFile => outputFile.emittedFileName)
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class RunnerBase {
|
||||
throw new Error('method not implemented');
|
||||
}
|
||||
|
||||
/** Replaces instances of full paths with filenames only */
|
||||
/** Replaces instances of full paths with fileNames only */
|
||||
static removeFullPaths(path: string) {
|
||||
var fixedPath = path;
|
||||
|
||||
|
||||
@@ -26,7 +26,10 @@ module RWC {
|
||||
var otherFiles: { unitName: string; content: string; }[] = [];
|
||||
var compilerResult: Harness.Compiler.CompilerResult;
|
||||
var compilerOptions: ts.CompilerOptions;
|
||||
var baselineOpts: Harness.Baseline.BaselineOptions = { Subfolder: 'rwc' };
|
||||
var baselineOpts: Harness.Baseline.BaselineOptions = {
|
||||
Subfolder: 'rwc',
|
||||
Baselinefolder: 'internal/baselines'
|
||||
};
|
||||
var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
|
||||
var currentDirectory: string;
|
||||
|
||||
@@ -56,7 +59,7 @@ module RWC {
|
||||
runWithIOLog(ioLog, () => {
|
||||
harnessCompiler.reset();
|
||||
// Load the files
|
||||
ts.forEach(opts.filenames, fileName => {
|
||||
ts.forEach(opts.fileNames, fileName => {
|
||||
inputFiles.push(getHarnessCompilerInputUnit(fileName));
|
||||
});
|
||||
|
||||
@@ -170,7 +173,7 @@ module RWC {
|
||||
}
|
||||
|
||||
class RWCRunner extends RunnerBase {
|
||||
private static sourcePath = "tests/cases/rwc/";
|
||||
private static sourcePath = "internal/cases/rwc/";
|
||||
|
||||
/** Setup the runner's tests so that they are ready to be executed by the harness
|
||||
* The first test should be a describe/it block that sets up the harness's compiler instance appropriately
|
||||
@@ -183,7 +186,7 @@ class RWCRunner extends RunnerBase {
|
||||
}
|
||||
}
|
||||
|
||||
private runTest(jsonFilename: string) {
|
||||
RWC.runRWCTest(jsonFilename);
|
||||
private runTest(jsonFileName: string) {
|
||||
RWC.runRWCTest(jsonFileName);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
/// <reference path='syntacticCleaner.ts' />
|
||||
|
||||
class Test262BaselineRunner extends RunnerBase {
|
||||
private static basePath = 'tests/cases/test262';
|
||||
private static basePath = 'internal/cases/test262';
|
||||
private static helpersFilePath = 'tests/cases/test262-harness/helpers.d.ts';
|
||||
private static helperFile = {
|
||||
unitName: Test262BaselineRunner.helpersFilePath,
|
||||
@@ -15,7 +15,10 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
target: ts.ScriptTarget.Latest,
|
||||
module: ts.ModuleKind.CommonJS
|
||||
};
|
||||
private static baselineOptions: Harness.Baseline.BaselineOptions = { Subfolder: 'test262' };
|
||||
private static baselineOptions: Harness.Baseline.BaselineOptions = {
|
||||
Subfolder: 'test262',
|
||||
Baselinefolder: 'internal/baselines'
|
||||
};
|
||||
|
||||
private static getTestFilePath(filename: string): string {
|
||||
return Test262BaselineRunner.basePath + "/" + filename;
|
||||
|
||||
@@ -12,10 +12,12 @@ class TypeWriterWalker {
|
||||
|
||||
private checker: ts.TypeChecker;
|
||||
|
||||
constructor(private program: ts.Program) {
|
||||
constructor(private program: ts.Program, fullTypeCheck: boolean) {
|
||||
// Consider getting both the diagnostics checker and the non-diagnostics checker to verify
|
||||
// they are consistent.
|
||||
this.checker = program.getTypeChecker(/*produceDiagnostics:*/ true);
|
||||
this.checker = fullTypeCheck
|
||||
? program.getDiagnosticsProducingTypeChecker()
|
||||
: program.getTypeChecker();
|
||||
}
|
||||
|
||||
public getTypes(fileName: string): TypeWriterResult[] {
|
||||
|
||||
Vendored
+1
-1
@@ -82,7 +82,7 @@ declare module Intl {
|
||||
second?: string;
|
||||
timeZoneName?: string;
|
||||
formatMatcher?: string;
|
||||
hour12: boolean;
|
||||
hour12?: boolean;
|
||||
}
|
||||
|
||||
interface ResolvedDateTimeFormatOptions {
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export interface Logger {
|
||||
log(s: string): void;
|
||||
}
|
||||
|
||||
export class NullLogger implements Logger {
|
||||
public log(s: string): void {
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,266 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path="references.ts" />
|
||||
|
||||
module TypeScript {
|
||||
export interface IOptions {
|
||||
name?: string;
|
||||
flag?: boolean;
|
||||
short?: string;
|
||||
usage?: {
|
||||
locCode: string; // DiagnosticCode
|
||||
args: string[]
|
||||
};
|
||||
set?: (s: string) => void;
|
||||
type?: string; // DiagnosticCode
|
||||
experimental?: boolean;
|
||||
}
|
||||
|
||||
export class OptionsParser {
|
||||
private DEFAULT_SHORT_FLAG = "-";
|
||||
private DEFAULT_LONG_FLAG = "--";
|
||||
|
||||
private printedVersion: boolean = false;
|
||||
|
||||
// Find the option record for the given string. Returns null if not found.
|
||||
private findOption(arg: string) {
|
||||
var upperCaseArg = arg && arg.toUpperCase();
|
||||
|
||||
for (var i = 0; i < this.options.length; i++) {
|
||||
var current = this.options[i];
|
||||
|
||||
if (upperCaseArg === (current.short && current.short.toUpperCase()) ||
|
||||
upperCaseArg === (current.name && current.name.toUpperCase())) {
|
||||
return current;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public unnamed: string[] = [];
|
||||
|
||||
public options: IOptions[] = [];
|
||||
|
||||
constructor(public host: IEnvironment, public version: string) {
|
||||
}
|
||||
|
||||
public printUsage() {
|
||||
this.printVersion();
|
||||
|
||||
var optionsWord = getLocalizedText(DiagnosticCode.options, null);
|
||||
var fileWord = getLocalizedText(DiagnosticCode.file1, null);
|
||||
var tscSyntax = "tsc [" + optionsWord + "] [" + fileWord + " ..]";
|
||||
var syntaxHelp = getLocalizedText(DiagnosticCode.Syntax_0, [tscSyntax]);
|
||||
this.host.standardOut.WriteLine(syntaxHelp);
|
||||
this.host.standardOut.WriteLine("");
|
||||
this.host.standardOut.WriteLine(getLocalizedText(DiagnosticCode.Examples, null) + " tsc hello.ts");
|
||||
this.host.standardOut.WriteLine(" tsc --out foo.js foo.ts");
|
||||
this.host.standardOut.WriteLine(" tsc @args.txt");
|
||||
this.host.standardOut.WriteLine("");
|
||||
this.host.standardOut.WriteLine(getLocalizedText(DiagnosticCode.Options, null));
|
||||
|
||||
var output: string[][] = [];
|
||||
var maxLength = 0;
|
||||
var i = 0;
|
||||
|
||||
this.options = this.options.sort(function (a, b) {
|
||||
var aName = a.name.toLowerCase();
|
||||
var bName = b.name.toLowerCase();
|
||||
|
||||
if (aName > bName) {
|
||||
return 1;
|
||||
} else if (aName < bName) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
// Build up output array
|
||||
for (i = 0; i < this.options.length; i++) {
|
||||
var option = this.options[i];
|
||||
|
||||
if (option.experimental) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!option.usage) {
|
||||
break;
|
||||
}
|
||||
|
||||
var usageString = " ";
|
||||
var type = option.type ? (" " + TypeScript.getLocalizedText(option.type, null)) : "";
|
||||
|
||||
if (option.short) {
|
||||
usageString += this.DEFAULT_SHORT_FLAG + option.short + type + ", ";
|
||||
}
|
||||
|
||||
usageString += this.DEFAULT_LONG_FLAG + option.name + type;
|
||||
|
||||
output.push([usageString, TypeScript.getLocalizedText(option.usage.locCode, option.usage.args)]);
|
||||
|
||||
if (usageString.length > maxLength) {
|
||||
maxLength = usageString.length;
|
||||
}
|
||||
}
|
||||
|
||||
var fileDescription = getLocalizedText(DiagnosticCode.Insert_command_line_options_and_files_from_a_file, null);
|
||||
output.push([" @<" + fileWord + ">", fileDescription]);
|
||||
|
||||
// Print padded output
|
||||
for (i = 0; i < output.length; i++) {
|
||||
this.host.standardOut.WriteLine(output[i][0] + (new Array(maxLength - output[i][0].length + 3)).join(" ") + output[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
public printVersion() {
|
||||
if (!this.printedVersion) {
|
||||
this.host.standardOut.WriteLine(getLocalizedText(DiagnosticCode.Version_0, [this.version]));
|
||||
this.printedVersion = true;
|
||||
}
|
||||
}
|
||||
|
||||
public option(name: string, config: IOptions, short?: string) {
|
||||
if (!config) {
|
||||
config = <any>short;
|
||||
short = null;
|
||||
}
|
||||
|
||||
config.name = name;
|
||||
config.short = short;
|
||||
config.flag = false;
|
||||
|
||||
this.options.push(config);
|
||||
}
|
||||
|
||||
public flag(name: string, config: IOptions, short?: string) {
|
||||
if (!config) {
|
||||
config = <any>short;
|
||||
short = null;
|
||||
}
|
||||
|
||||
config.name = name;
|
||||
config.short = short;
|
||||
config.flag = true;
|
||||
|
||||
this.options.push(config);
|
||||
}
|
||||
|
||||
// Parse an arguments string
|
||||
public parseString(argString: string) {
|
||||
var position = 0;
|
||||
var tokens = argString.match(/\s+|"|[^\s"]+/g);
|
||||
|
||||
function peek() {
|
||||
return tokens[position];
|
||||
}
|
||||
|
||||
function consume() {
|
||||
return tokens[position++];
|
||||
}
|
||||
|
||||
function consumeQuotedString() {
|
||||
var value = '';
|
||||
consume(); // skip opening quote.
|
||||
|
||||
var token = peek();
|
||||
|
||||
while (token && token !== '"') {
|
||||
consume();
|
||||
|
||||
value += token;
|
||||
|
||||
token = peek();
|
||||
}
|
||||
|
||||
consume(); // skip ending quote;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
var args: string[] = [];
|
||||
var currentArg = '';
|
||||
|
||||
while (position < tokens.length) {
|
||||
var token = peek();
|
||||
|
||||
if (token === '"') {
|
||||
currentArg += consumeQuotedString();
|
||||
} else if (token.match(/\s/)) {
|
||||
if (currentArg.length > 0) {
|
||||
args.push(currentArg);
|
||||
currentArg = '';
|
||||
}
|
||||
|
||||
consume();
|
||||
} else {
|
||||
consume();
|
||||
currentArg += token;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentArg.length > 0) {
|
||||
args.push(currentArg);
|
||||
}
|
||||
|
||||
this.parse(args);
|
||||
}
|
||||
|
||||
// Parse arguments as they come from the platform: split into arguments.
|
||||
public parse(args: string[]) {
|
||||
var position = 0;
|
||||
|
||||
function consume() {
|
||||
return args[position++];
|
||||
}
|
||||
|
||||
while (position < args.length) {
|
||||
var current = consume();
|
||||
var match = current.match(/^(--?|@)(.*)/);
|
||||
var value: any = null;
|
||||
|
||||
if (match) {
|
||||
if (match[1] === '@') {
|
||||
this.parseString(this.host.readFile(match[2], null).contents);
|
||||
} else {
|
||||
var arg = match[2];
|
||||
var option = this.findOption(arg);
|
||||
|
||||
if (option === null) {
|
||||
this.host.standardOut.WriteLine(getDiagnosticMessage(DiagnosticCode.Unknown_compiler_option_0, [arg]));
|
||||
this.host.standardOut.WriteLine(getLocalizedText(DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"]));
|
||||
} else {
|
||||
if (!option.flag) {
|
||||
value = consume();
|
||||
if (value === undefined) {
|
||||
// No value provided
|
||||
this.host.standardOut.WriteLine(getDiagnosticMessage(DiagnosticCode.Option_0_specified_without_1, [arg, getLocalizedText(option.type, null)]));
|
||||
this.host.standardOut.WriteLine(getLocalizedText(DiagnosticCode.Use_the_0_flag_to_see_options, ["--help"]));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
option.set(value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.unnamed.push(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,736 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='typescript.ts'/>
|
||||
///<reference path='io.ts'/>
|
||||
///<reference path='optionsParser.ts'/>
|
||||
|
||||
module TypeScript {
|
||||
class SourceFile {
|
||||
constructor(public scriptSnapshot: IScriptSnapshot, public byteOrderMark: ByteOrderMark) {
|
||||
}
|
||||
}
|
||||
|
||||
class DiagnosticsLogger implements ILogger {
|
||||
constructor(public ioHost: IEnvironment) {
|
||||
}
|
||||
public information(): boolean { return false; }
|
||||
public debug(): boolean { return false; }
|
||||
public warning(): boolean { return false; }
|
||||
public error(): boolean { return false; }
|
||||
public fatal(): boolean { return false; }
|
||||
public log(s: string): void {
|
||||
this.ioHost.standardOut.WriteLine(s);
|
||||
}
|
||||
}
|
||||
|
||||
export class BatchCompiler implements IReferenceResolverHost {
|
||||
public compilerVersion = "1.0.1.0";
|
||||
private inputFiles: string[] = [];
|
||||
private compilationSettings: ImmutableCompilationSettings;
|
||||
private resolvedFiles: IResolvedFile[] = [];
|
||||
private fileNameToSourceFile = new StringHashTable<SourceFile>();
|
||||
private hasErrors: boolean = false;
|
||||
private logger: ILogger = null;
|
||||
|
||||
constructor(private ioHost: IEnvironment) {
|
||||
}
|
||||
|
||||
// Begin batch compilation
|
||||
public batchCompile() {
|
||||
// Parse command line options
|
||||
if (this.parseOptions()) {
|
||||
var start = new Date().getTime();
|
||||
|
||||
if (this.compilationSettings.gatherDiagnostics()) {
|
||||
this.logger = new DiagnosticsLogger(this.ioHost);
|
||||
} else {
|
||||
this.logger = new NullLogger();
|
||||
}
|
||||
|
||||
if (this.compilationSettings.watch()) {
|
||||
// Watch will cause the program to stick around as long as the files exist
|
||||
this.watchFiles();
|
||||
return;
|
||||
}
|
||||
|
||||
// Resolve the compilation environemnt
|
||||
this.resolve();
|
||||
|
||||
this.compile();
|
||||
|
||||
if (this.compilationSettings.gatherDiagnostics()) {
|
||||
this.logger.log("");
|
||||
this.logger.log("File resolution time: " + TypeScript.fileResolutionTime);
|
||||
this.logger.log(" file read: " + TypeScript.fileResolutionIOTime);
|
||||
this.logger.log(" scan imports: " + TypeScript.fileResolutionScanImportsTime);
|
||||
this.logger.log(" import search: " + TypeScript.fileResolutionImportFileSearchTime);
|
||||
this.logger.log(" get lib.d.ts: " + TypeScript.fileResolutionGetDefaultLibraryTime);
|
||||
|
||||
this.logger.log("SyntaxTree parse time: " + TypeScript.syntaxTreeParseTime);
|
||||
this.logger.log("Syntax Diagnostics time: " + TypeScript.syntaxDiagnosticsTime);
|
||||
this.logger.log("Create declarations time: " + TypeScript.createDeclarationsTime);
|
||||
this.logger.log("");
|
||||
this.logger.log("Type check time: " + TypeScript.typeCheckTime);
|
||||
this.logger.log("");
|
||||
this.logger.log("Emit time: " + TypeScript.emitTime);
|
||||
this.logger.log("Declaration emit time: " + TypeScript.declarationEmitTime);
|
||||
|
||||
this.logger.log("Total number of symbols created: " + TypeScript.pullSymbolID);
|
||||
this.logger.log("Specialized types created: " + TypeScript.nSpecializationsCreated);
|
||||
this.logger.log("Specialized signatures created: " + TypeScript.nSpecializedSignaturesCreated);
|
||||
|
||||
this.logger.log(" IsExternallyVisibleTime: " + TypeScript.declarationEmitIsExternallyVisibleTime);
|
||||
this.logger.log(" TypeSignatureTime: " + TypeScript.declarationEmitTypeSignatureTime);
|
||||
this.logger.log(" GetBoundDeclTypeTime: " + TypeScript.declarationEmitGetBoundDeclTypeTime);
|
||||
this.logger.log(" IsOverloadedCallSignatureTime: " + TypeScript.declarationEmitIsOverloadedCallSignatureTime);
|
||||
this.logger.log(" FunctionDeclarationGetSymbolTime: " + TypeScript.declarationEmitFunctionDeclarationGetSymbolTime);
|
||||
this.logger.log(" GetBaseTypeTime: " + TypeScript.declarationEmitGetBaseTypeTime);
|
||||
this.logger.log(" GetAccessorFunctionTime: " + TypeScript.declarationEmitGetAccessorFunctionTime);
|
||||
this.logger.log(" GetTypeParameterSymbolTime: " + TypeScript.declarationEmitGetTypeParameterSymbolTime);
|
||||
this.logger.log(" GetImportDeclarationSymbolTime: " + TypeScript.declarationEmitGetImportDeclarationSymbolTime);
|
||||
|
||||
this.logger.log("Emit write file time: " + TypeScript.emitWriteFileTime);
|
||||
|
||||
this.logger.log("Compiler resolve path time: " + TypeScript.compilerResolvePathTime);
|
||||
this.logger.log("Compiler directory name time: " + TypeScript.compilerDirectoryNameTime);
|
||||
this.logger.log("Compiler directory exists time: " + TypeScript.compilerDirectoryExistsTime);
|
||||
this.logger.log("Compiler file exists time: " + TypeScript.compilerFileExistsTime);
|
||||
|
||||
this.logger.log("IO host resolve path time: " + TypeScript.ioHostResolvePathTime);
|
||||
this.logger.log("IO host directory name time: " + TypeScript.ioHostDirectoryNameTime);
|
||||
this.logger.log("IO host create directory structure time: " + TypeScript.ioHostCreateDirectoryStructureTime);
|
||||
this.logger.log("IO host write file time: " + TypeScript.ioHostWriteFileTime);
|
||||
|
||||
this.logger.log("Node make directory time: " + TypeScript.nodeMakeDirectoryTime);
|
||||
this.logger.log("Node writeFileSync time: " + TypeScript.nodeWriteFileSyncTime);
|
||||
this.logger.log("Node createBuffer time: " + TypeScript.nodeCreateBufferTime);
|
||||
|
||||
this.logger.log("Total time: " + (new Date().getTime() - start));
|
||||
}
|
||||
}
|
||||
|
||||
// Exit with the appropriate error code
|
||||
this.ioHost.quit(this.hasErrors ? 1 : 0);
|
||||
}
|
||||
|
||||
private resolve() {
|
||||
// Resolve file dependencies, if requested
|
||||
var includeDefaultLibrary = !this.compilationSettings.noLib();
|
||||
var resolvedFiles: IResolvedFile[] = [];
|
||||
|
||||
var start = new Date().getTime();
|
||||
|
||||
if (!this.compilationSettings.noResolve()) {
|
||||
// Resolve references
|
||||
var resolutionResults = ReferenceResolver.resolve(this.inputFiles, this, this.compilationSettings.useCaseSensitiveFileResolution());
|
||||
resolvedFiles = resolutionResults.resolvedFiles;
|
||||
|
||||
// Only include the library if useDefaultLib is set to true and did not see any 'no-default-lib' comments
|
||||
includeDefaultLibrary = !this.compilationSettings.noLib() && !resolutionResults.seenNoDefaultLibTag;
|
||||
|
||||
// Populate any diagnostic messages generated during resolution
|
||||
resolutionResults.diagnostics.forEach(d => this.addDiagnostic(d));
|
||||
}
|
||||
else {
|
||||
for (var i = 0, n = this.inputFiles.length; i < n; i++) {
|
||||
var inputFile = this.inputFiles[i];
|
||||
var referencedFiles: string[] = [];
|
||||
var importedFiles: string[] = [];
|
||||
|
||||
// If declaration files are going to be emitted, preprocess the file contents and add in referenced files as well
|
||||
if (this.compilationSettings.generateDeclarationFiles()) {
|
||||
var references = getReferencedFiles(inputFile, this.getScriptSnapshot(inputFile));
|
||||
for (var j = 0; j < references.length; j++) {
|
||||
referencedFiles.push(references[j].path);
|
||||
}
|
||||
|
||||
inputFile = this.resolvePath(inputFile);
|
||||
}
|
||||
|
||||
resolvedFiles.push({
|
||||
path: inputFile,
|
||||
referencedFiles: referencedFiles,
|
||||
importedFiles: importedFiles
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var defaultLibStart = new Date().getTime();
|
||||
if (includeDefaultLibrary) {
|
||||
var libraryResolvedFile: IResolvedFile = {
|
||||
path: this.getDefaultLibraryFilePath(),
|
||||
referencedFiles: [],
|
||||
importedFiles: []
|
||||
};
|
||||
|
||||
// Prepend the library to the resolved list
|
||||
resolvedFiles = [libraryResolvedFile].concat(resolvedFiles);
|
||||
}
|
||||
TypeScript.fileResolutionGetDefaultLibraryTime += new Date().getTime() - defaultLibStart;
|
||||
|
||||
this.resolvedFiles = resolvedFiles;
|
||||
|
||||
TypeScript.fileResolutionTime = new Date().getTime() - start;
|
||||
}
|
||||
|
||||
// Returns true if compilation failed from some reason.
|
||||
private compile(): void {
|
||||
var compiler = new TypeScriptCompiler(this.logger, this.compilationSettings);
|
||||
|
||||
this.resolvedFiles.forEach(resolvedFile => {
|
||||
var sourceFile = this.getSourceFile(resolvedFile.path);
|
||||
compiler.addFile(resolvedFile.path, sourceFile.scriptSnapshot, sourceFile.byteOrderMark, /*version:*/ 0, /*isOpen:*/ false, resolvedFile.referencedFiles);
|
||||
});
|
||||
|
||||
for (var it = compiler.compile((path: string) => this.resolvePath(path)); it.moveNext();) {
|
||||
var result = it.current();
|
||||
|
||||
result.diagnostics.forEach(d => this.addDiagnostic(d));
|
||||
if (!this.tryWriteOutputFiles(result.outputFiles)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse command line options
|
||||
private parseOptions() {
|
||||
var opts = new OptionsParser(this.ioHost, this.compilerVersion);
|
||||
|
||||
var mutableSettings = new CompilationSettings();
|
||||
opts.option('out', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Concatenate_and_emit_output_to_single_file,
|
||||
args: null
|
||||
},
|
||||
type: DiagnosticCode.file2,
|
||||
set: (str) => {
|
||||
mutableSettings.outFileOption = str;
|
||||
}
|
||||
});
|
||||
|
||||
opts.option('outDir', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Redirect_output_structure_to_the_directory,
|
||||
args: null
|
||||
},
|
||||
type: DiagnosticCode.DIRECTORY,
|
||||
set: (str) => {
|
||||
mutableSettings.outDirOption = str;
|
||||
}
|
||||
});
|
||||
|
||||
opts.flag('sourcemap', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Generates_corresponding_0_file,
|
||||
args: ['.map']
|
||||
},
|
||||
set: () => {
|
||||
mutableSettings.mapSourceFiles = true;
|
||||
}
|
||||
});
|
||||
|
||||
opts.option('mapRoot', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
|
||||
args: null
|
||||
},
|
||||
type: DiagnosticCode.LOCATION,
|
||||
set: (str) => {
|
||||
mutableSettings.mapRoot = str;
|
||||
}
|
||||
});
|
||||
|
||||
opts.option('sourceRoot', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
|
||||
args: null
|
||||
},
|
||||
type: DiagnosticCode.LOCATION,
|
||||
set: (str) => {
|
||||
mutableSettings.sourceRoot = str;
|
||||
}
|
||||
});
|
||||
|
||||
opts.flag('declaration', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Generates_corresponding_0_file,
|
||||
args: ['.d.ts']
|
||||
},
|
||||
set: () => {
|
||||
mutableSettings.generateDeclarationFiles = true;
|
||||
}
|
||||
}, 'd');
|
||||
|
||||
if (this.ioHost.watchFile) {
|
||||
opts.flag('watch', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Watch_input_files,
|
||||
args: null
|
||||
},
|
||||
set: () => {
|
||||
mutableSettings.watch = true;
|
||||
}
|
||||
}, 'w');
|
||||
}
|
||||
|
||||
opts.flag('propagateEnumConstants', {
|
||||
experimental: true,
|
||||
set: () => { mutableSettings.propagateEnumConstants = true; }
|
||||
});
|
||||
|
||||
opts.flag('removeComments', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Do_not_emit_comments_to_output,
|
||||
args: null
|
||||
},
|
||||
set: () => {
|
||||
mutableSettings.removeComments = true;
|
||||
}
|
||||
});
|
||||
|
||||
opts.flag('noResolve', {
|
||||
experimental: true,
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Skip_resolution_and_preprocessing,
|
||||
args: null
|
||||
},
|
||||
set: () => {
|
||||
mutableSettings.noResolve = true;
|
||||
}
|
||||
});
|
||||
|
||||
opts.flag('noLib', {
|
||||
experimental: true,
|
||||
set: () => {
|
||||
mutableSettings.noLib = true;
|
||||
}
|
||||
});
|
||||
|
||||
opts.flag('diagnostics', {
|
||||
experimental: true,
|
||||
set: () => {
|
||||
mutableSettings.gatherDiagnostics = true;
|
||||
}
|
||||
});
|
||||
|
||||
opts.option('target', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Specify_ECMAScript_target_version_0_default_or_1,
|
||||
args: ['ES3', 'ES5']
|
||||
},
|
||||
type: DiagnosticCode.VERSION,
|
||||
set: (type) => {
|
||||
type = type.toLowerCase();
|
||||
|
||||
if (type === 'es3') {
|
||||
mutableSettings.codeGenTarget = LanguageVersion.EcmaScript3;
|
||||
}
|
||||
else if (type === 'es5') {
|
||||
mutableSettings.codeGenTarget = LanguageVersion.EcmaScript5;
|
||||
}
|
||||
else {
|
||||
this.addDiagnostic(
|
||||
new Diagnostic(null, null, 0, 0, DiagnosticCode.Argument_for_0_option_must_be_1_or_2, ["target", "ES3", "ES5"]));
|
||||
}
|
||||
}
|
||||
}, 't');
|
||||
|
||||
opts.option('module', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Specify_module_code_generation_0_or_1,
|
||||
args: ['commonjs', 'amd']
|
||||
},
|
||||
type: DiagnosticCode.KIND,
|
||||
set: (type) => {
|
||||
type = type.toLowerCase();
|
||||
|
||||
if (type === 'commonjs') {
|
||||
mutableSettings.moduleGenTarget = ModuleGenTarget.Synchronous;
|
||||
}
|
||||
else if (type === 'amd') {
|
||||
mutableSettings.moduleGenTarget = ModuleGenTarget.Asynchronous;
|
||||
}
|
||||
else {
|
||||
this.addDiagnostic(
|
||||
new Diagnostic(null, null, 0, 0, DiagnosticCode.Argument_for_0_option_must_be_1_or_2, ["module", "commonjs", "amd"]));
|
||||
}
|
||||
}
|
||||
}, 'm');
|
||||
|
||||
var needsHelp = false;
|
||||
opts.flag('help', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Print_this_message,
|
||||
args: null
|
||||
},
|
||||
set: () => {
|
||||
needsHelp = true;
|
||||
}
|
||||
}, 'h');
|
||||
|
||||
opts.flag('useCaseSensitiveFileResolution', {
|
||||
experimental: true,
|
||||
set: () => {
|
||||
mutableSettings.useCaseSensitiveFileResolution = true;
|
||||
}
|
||||
});
|
||||
var shouldPrintVersionOnly = false;
|
||||
opts.flag('version', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Print_the_compiler_s_version_0,
|
||||
args: [this.compilerVersion]
|
||||
},
|
||||
set: () => {
|
||||
shouldPrintVersionOnly = true;
|
||||
}
|
||||
}, 'v');
|
||||
|
||||
var locale: string = null;
|
||||
opts.option('locale', {
|
||||
experimental: true,
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Specify_locale_for_errors_and_messages_For_example_0_or_1,
|
||||
args: ['en', 'ja-jp']
|
||||
},
|
||||
type: DiagnosticCode.STRING,
|
||||
set: (value) => {
|
||||
locale = value;
|
||||
}
|
||||
});
|
||||
|
||||
opts.flag('noImplicitAny', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Raise_error_on_expressions_and_declarations_with_an_implied_any_type,
|
||||
args: null
|
||||
},
|
||||
set: () => {
|
||||
mutableSettings.noImplicitAny = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (Environment.supportsCodePage()) {
|
||||
opts.option('codepage', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Specify_the_codepage_to_use_when_opening_source_files,
|
||||
args: null
|
||||
},
|
||||
type: DiagnosticCode.NUMBER,
|
||||
set: (arg) => {
|
||||
mutableSettings.codepage = parseInt(arg, 10);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
opts.parse(this.ioHost.arguments);
|
||||
|
||||
this.compilationSettings = ImmutableCompilationSettings.fromCompilationSettings(mutableSettings);
|
||||
|
||||
if (locale) {
|
||||
if (!this.setLocale(locale)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.inputFiles.push.apply(this.inputFiles, opts.unnamed);
|
||||
|
||||
if (shouldPrintVersionOnly) {
|
||||
opts.printVersion();
|
||||
return false;
|
||||
}
|
||||
// If no source files provided to compiler - print usage information
|
||||
else if (this.inputFiles.length === 0 || needsHelp) {
|
||||
opts.printUsage();
|
||||
return false;
|
||||
}
|
||||
|
||||
return !this.hasErrors;
|
||||
}
|
||||
|
||||
private setLocale(locale: string): boolean {
|
||||
var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
||||
if (!matchResult) {
|
||||
this.addDiagnostic(new Diagnostic(null, null, 0, 0, DiagnosticCode.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, ['en', 'ja-jp']));
|
||||
return false;
|
||||
}
|
||||
|
||||
var language = matchResult[1];
|
||||
var territory = matchResult[3];
|
||||
|
||||
// First try the entire locale, then fall back to just language if that's all we have.
|
||||
if (!this.setLanguageAndTerritory(language, territory) &&
|
||||
!this.setLanguageAndTerritory(language, null)) {
|
||||
|
||||
this.addDiagnostic(new Diagnostic(null, null, 0, 0, DiagnosticCode.Unsupported_locale_0, [locale]));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private setLanguageAndTerritory(language: string, territory: string): boolean {
|
||||
|
||||
var compilerFilePath = this.ioHost.executingFilePath();
|
||||
var containingDirectoryPath = this.ioHost.directoryName(compilerFilePath);
|
||||
|
||||
var filePath = IOUtils.combine(containingDirectoryPath, language);
|
||||
if (territory) {
|
||||
filePath = filePath + "-" + territory;
|
||||
}
|
||||
|
||||
filePath = this.resolvePath(IOUtils.combine(filePath, "diagnosticMessages.generated.json"));
|
||||
|
||||
if (!this.fileExists(filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var fileContents = this.ioHost.readFile(filePath, this.compilationSettings.codepage());
|
||||
TypeScript.LocalizedDiagnosticMessages = JSON.parse(fileContents.contents);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Handle -watch switch
|
||||
private watchFiles() {
|
||||
if (!this.ioHost.watchFile) {
|
||||
this.addDiagnostic(
|
||||
new Diagnostic(null, null, 0, 0, DiagnosticCode.Current_host_does_not_support_0_option, ['-w[atch]']));
|
||||
return;
|
||||
}
|
||||
|
||||
var lastResolvedFileSet: string[] = []
|
||||
var watchers: { [x: string]: IFileWatcher; } = {};
|
||||
var firstTime = true;
|
||||
|
||||
var addWatcher = (fileName: string) => {
|
||||
if (!watchers[fileName]) {
|
||||
var watcher = this.ioHost.watchFile(fileName, onWatchedFileChange);
|
||||
watchers[fileName] = watcher;
|
||||
}
|
||||
};
|
||||
|
||||
var removeWatcher = (fileName: string) => {
|
||||
if (watchers[fileName]) {
|
||||
watchers[fileName].close();
|
||||
delete watchers[fileName];
|
||||
}
|
||||
};
|
||||
|
||||
var onWatchedFileChange = () => {
|
||||
// Clean errors for previous compilation
|
||||
this.hasErrors = false;
|
||||
|
||||
// Clear out any source file data we've cached.
|
||||
this.fileNameToSourceFile = new StringHashTable<SourceFile>();
|
||||
|
||||
// Resolve file dependencies, if requested
|
||||
this.resolve();
|
||||
|
||||
// Check if any new files were added to the environment as a result of the file change
|
||||
var oldFiles = lastResolvedFileSet;
|
||||
var newFiles = this.resolvedFiles.map(resolvedFile => resolvedFile.path).sort();
|
||||
|
||||
var i = 0, j = 0;
|
||||
while (i < oldFiles.length && j < newFiles.length) {
|
||||
|
||||
var compareResult = oldFiles[i].localeCompare(newFiles[j]);
|
||||
if (compareResult === 0) {
|
||||
// No change here
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
else if (compareResult < 0) {
|
||||
// Entry in old list does not exist in the new one, it was removed
|
||||
removeWatcher(oldFiles[i]);
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
// Entry in new list does exist in the new one, it was added
|
||||
addWatcher(newFiles[j]);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
// All remaining unmatched items in the old list have been removed
|
||||
for (var k = i; k < oldFiles.length; k++) {
|
||||
removeWatcher(oldFiles[k]);
|
||||
}
|
||||
|
||||
// All remaing unmatched items in the new list have been added
|
||||
for (k = j; k < newFiles.length; k++) {
|
||||
addWatcher(newFiles[k]);
|
||||
}
|
||||
|
||||
// Update the state
|
||||
lastResolvedFileSet = newFiles;
|
||||
|
||||
// Print header
|
||||
if (!firstTime) {
|
||||
var fileNames = "";
|
||||
for (var k = 0; k < lastResolvedFileSet.length; k++) {
|
||||
fileNames += Environment.newLine + " " + lastResolvedFileSet[k];
|
||||
}
|
||||
this.ioHost.standardError.WriteLine(getLocalizedText(DiagnosticCode.NL_Recompiling_0, [fileNames]));
|
||||
}
|
||||
else {
|
||||
firstTime = false;
|
||||
}
|
||||
|
||||
// Trigger a new compilation
|
||||
this.compile();
|
||||
};
|
||||
|
||||
// Switch to using stdout for all error messages
|
||||
this.ioHost.standardOut = this.ioHost.standardOut;
|
||||
|
||||
onWatchedFileChange();
|
||||
}
|
||||
|
||||
private getSourceFile(fileName: string): SourceFile {
|
||||
var sourceFile: SourceFile = this.fileNameToSourceFile.lookup(fileName);
|
||||
if (!sourceFile) {
|
||||
// Attempt to read the file
|
||||
var fileInformation: FileInformation;
|
||||
|
||||
try {
|
||||
fileInformation = this.ioHost.readFile(fileName, this.compilationSettings.codepage());
|
||||
}
|
||||
catch (e) {
|
||||
this.addDiagnostic(new Diagnostic(null, null, 0, 0, DiagnosticCode.Cannot_read_file_0_1, [fileName, e.message]));
|
||||
fileInformation = new FileInformation("", ByteOrderMark.None);
|
||||
}
|
||||
|
||||
var snapshot = ScriptSnapshot.fromString(fileInformation.contents);
|
||||
var sourceFile = new SourceFile(snapshot, fileInformation.byteOrderMark);
|
||||
this.fileNameToSourceFile.add(fileName, sourceFile);
|
||||
}
|
||||
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
private getDefaultLibraryFilePath(): string {
|
||||
var compilerFilePath = this.ioHost.executingFilePath();
|
||||
var containingDirectoryPath = this.ioHost.directoryName(compilerFilePath);
|
||||
var libraryFilePath = this.resolvePath(IOUtils.combine(containingDirectoryPath, "lib.d.ts"));
|
||||
|
||||
return libraryFilePath;
|
||||
}
|
||||
|
||||
/// IReferenceResolverHost methods
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot {
|
||||
return this.getSourceFile(fileName).scriptSnapshot;
|
||||
}
|
||||
|
||||
resolveRelativePath(path: string, directory: string): string {
|
||||
var unQuotedPath = stripStartAndEndQuotes(path);
|
||||
var normalizedPath: string;
|
||||
|
||||
if (isRooted(unQuotedPath) || !directory) {
|
||||
normalizedPath = unQuotedPath;
|
||||
} else {
|
||||
normalizedPath = IOUtils.combine(directory, unQuotedPath);
|
||||
}
|
||||
|
||||
// get the absolute path
|
||||
normalizedPath = this.resolvePath(normalizedPath);
|
||||
|
||||
// Switch to forward slashes
|
||||
normalizedPath = switchToForwardSlashes(normalizedPath);
|
||||
|
||||
return normalizedPath;
|
||||
}
|
||||
|
||||
private fileExistsCache = createIntrinsicsObject<boolean>();
|
||||
|
||||
fileExists(path: string): boolean {
|
||||
var exists = this.fileExistsCache[path];
|
||||
if (exists === undefined) {
|
||||
var start = new Date().getTime();
|
||||
exists = this.ioHost.fileExists(path);
|
||||
this.fileExistsCache[path] = exists;
|
||||
TypeScript.compilerFileExistsTime += new Date().getTime() - start;
|
||||
}
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
getParentDirectory(path: string): string {
|
||||
var start = new Date().getTime();
|
||||
var result = this.ioHost.directoryName(path);
|
||||
TypeScript.compilerDirectoryNameTime += new Date().getTime() - start;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private addDiagnostic(diagnostic: Diagnostic): void {
|
||||
var diagnosticInfo = diagnostic.info();
|
||||
if (diagnosticInfo.category === DiagnosticCategory.Error) {
|
||||
this.hasErrors = true;
|
||||
}
|
||||
|
||||
this.ioHost.standardError.Write(TypeScriptCompiler.getFullDiagnosticText(diagnostic, path => this.resolvePath(path)));
|
||||
}
|
||||
|
||||
private tryWriteOutputFiles(outputFiles: OutputFile[]): boolean {
|
||||
for (var i = 0, n = outputFiles.length; i < n; i++) {
|
||||
var outputFile = outputFiles[i];
|
||||
|
||||
try {
|
||||
this.writeFile(outputFile.name, outputFile.text, outputFile.writeByteOrderMark);
|
||||
}
|
||||
catch (e) {
|
||||
this.addDiagnostic(
|
||||
new Diagnostic(outputFile.name, null, 0, 0, DiagnosticCode.Emit_Error_0, [e.message]));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
writeFile(fileName: string, contents: string, writeByteOrderMark: boolean): void {
|
||||
var start = new Date().getTime();
|
||||
IOUtils.writeFileAndFolderStructure(this.ioHost, fileName, contents, writeByteOrderMark);
|
||||
TypeScript.emitWriteFileTime += new Date().getTime() - start;
|
||||
}
|
||||
|
||||
directoryExists(path: string): boolean {
|
||||
var start = new Date().getTime();
|
||||
var result = this.ioHost.directoryExists(path);
|
||||
TypeScript.compilerDirectoryExistsTime += new Date().getTime() - start;
|
||||
return result;
|
||||
}
|
||||
|
||||
// For performance reasons we cache the results of resolvePath. This avoids costly lookup
|
||||
// on the disk once we've already resolved a path once.
|
||||
private resolvePathCache = createIntrinsicsObject<string>();
|
||||
|
||||
resolvePath(path: string): string {
|
||||
var cachedValue = this.resolvePathCache[path];
|
||||
if (!cachedValue) {
|
||||
var start = new Date().getTime();
|
||||
cachedValue = this.ioHost.absolutePath(path);
|
||||
this.resolvePathCache[path] = cachedValue;
|
||||
TypeScript.compilerResolvePathTime += new Date().getTime() - start;
|
||||
}
|
||||
|
||||
return cachedValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Start the batch compilation using the current hosts IO
|
||||
var batch = new TypeScript.BatchCompiler(Environment);
|
||||
batch.batchCompile();
|
||||
}
|
||||
@@ -120,7 +120,14 @@ module ts.formatting {
|
||||
|
||||
function findOutermostParent(position: number, expectedTokenKind: SyntaxKind, sourceFile: SourceFile): Node {
|
||||
var precedingToken = findPrecedingToken(position, sourceFile);
|
||||
if (!precedingToken || precedingToken.kind !== expectedTokenKind) {
|
||||
|
||||
// when it is claimed that trigger character was typed at given position
|
||||
// we verify that there is a token with a matching kind whose end is equal to position (because the character was just typed).
|
||||
// If this condition is not hold - then trigger character was typed in some other context,
|
||||
// i.e.in comment and thus should not trigger autoformatting
|
||||
if (!precedingToken ||
|
||||
precedingToken.kind !== expectedTokenKind ||
|
||||
position !== precedingToken.getEnd()) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ module ts.formatting {
|
||||
private activeRules: Rule[];
|
||||
private rulesMap: RulesMap;
|
||||
|
||||
constructor(private logger: Logger) {
|
||||
constructor() {
|
||||
this.globalRules = new Rules();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,9 @@ module ts.NavigationBar {
|
||||
case SyntaxKind.ArrayBindingPattern:
|
||||
forEach((<BindingPattern>node).elements, visit);
|
||||
break;
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
if (isBindingPattern(node)) {
|
||||
if (isBindingPattern((<VariableDeclaration>node).name)) {
|
||||
visit((<VariableDeclaration>node).name);
|
||||
break;
|
||||
}
|
||||
@@ -262,17 +263,34 @@ module ts.NavigationBar {
|
||||
return createItem(node, getTextOfNode((<FunctionLikeDeclaration>node).name), ts.ScriptElementKind.functionElement);
|
||||
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
if (isBindingPattern((<VariableDeclaration>node).name)) {
|
||||
break;
|
||||
}
|
||||
if (isConst(node)) {
|
||||
return createItem(node, getTextOfNode((<VariableDeclaration>node).name), ts.ScriptElementKind.constElement);
|
||||
}
|
||||
else if (isLet(node)) {
|
||||
return createItem(node, getTextOfNode((<VariableDeclaration>node).name), ts.ScriptElementKind.letElement);
|
||||
case SyntaxKind.BindingElement:
|
||||
var variableDeclarationNode: Node;
|
||||
var name: Node;
|
||||
|
||||
if (node.kind === SyntaxKind.BindingElement) {
|
||||
name = (<BindingElement>node).name;
|
||||
variableDeclarationNode = node;
|
||||
// binding elements are added only for variable declarations
|
||||
// bubble up to the containing variable declaration
|
||||
while (variableDeclarationNode && variableDeclarationNode.kind !== SyntaxKind.VariableDeclaration) {
|
||||
variableDeclarationNode = variableDeclarationNode.parent;
|
||||
}
|
||||
Debug.assert(variableDeclarationNode !== undefined);
|
||||
}
|
||||
else {
|
||||
return createItem(node, getTextOfNode((<VariableDeclaration>node).name), ts.ScriptElementKind.variableElement);
|
||||
Debug.assert(!isBindingPattern((<VariableDeclaration>node).name));
|
||||
variableDeclarationNode = node;
|
||||
name = (<VariableDeclaration>node).name;
|
||||
}
|
||||
|
||||
if (isConst(variableDeclarationNode)) {
|
||||
return createItem(node, getTextOfNode(name), ts.ScriptElementKind.constElement);
|
||||
}
|
||||
else if (isLet(variableDeclarationNode)) {
|
||||
return createItem(node, getTextOfNode(name), ts.ScriptElementKind.letElement);
|
||||
}
|
||||
else {
|
||||
return createItem(node, getTextOfNode(name), ts.ScriptElementKind.variableElement);
|
||||
}
|
||||
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -386,9 +404,9 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
hasGlobalNode = true;
|
||||
var rootName = isExternalModule(node) ?
|
||||
"\"" + escapeString(getBaseFilename(removeFileExtension(normalizePath(node.filename)))) + "\"" :
|
||||
"<global>"
|
||||
var rootName = isExternalModule(node)
|
||||
? "\"" + escapeString(getBaseFileName(removeFileExtension(normalizePath(node.fileName)))) + "\""
|
||||
: "<global>"
|
||||
|
||||
return getNavigationBarItem(rootName,
|
||||
ts.ScriptElementKind.moduleElement,
|
||||
|
||||
@@ -402,19 +402,13 @@ module TypeScript {
|
||||
Option_0_specified_without_1: "Option '{0}' specified without '{1}'",
|
||||
codepage_option_not_supported_on_current_platform: "'codepage' option not supported on current platform.",
|
||||
Concatenate_and_emit_output_to_single_file: "Concatenate and emit output to single file.",
|
||||
Generates_corresponding_0_file: "Generates corresponding {0} file.",
|
||||
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: "Specifies the location where debugger should locate map files instead of generated locations.",
|
||||
Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: "Specifies the location where debugger should locate TypeScript files instead of source locations.",
|
||||
Watch_input_files: "Watch input files.",
|
||||
Redirect_output_structure_to_the_directory: "Redirect output structure to the directory.",
|
||||
Do_not_emit_comments_to_output: "Do not emit comments to output.",
|
||||
Skip_resolution_and_preprocessing: "Skip resolution and preprocessing.",
|
||||
Specify_ECMAScript_target_version_0_default_or_1: "Specify ECMAScript target version: '{0}' (default), or '{1}'",
|
||||
Specify_module_code_generation_0_or_1: "Specify module code generation: '{0}' or '{1}'",
|
||||
Print_this_message: "Print this message.",
|
||||
Print_the_compiler_s_version_0: "Print the compiler's version: {0}",
|
||||
Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: "Allow use of deprecated '{0}' keyword when referencing an external module.",
|
||||
Specify_locale_for_errors_and_messages_For_example_0_or_1: "Specify locale for errors and messages. For example '{0}' or '{1}'",
|
||||
Syntax_0: "Syntax: {0}",
|
||||
options: "options",
|
||||
file1: "file",
|
||||
@@ -431,7 +425,6 @@ module TypeScript {
|
||||
LOCATION: "LOCATION",
|
||||
DIRECTORY: "DIRECTORY",
|
||||
NUMBER: "NUMBER",
|
||||
Specify_the_codepage_to_use_when_opening_source_files: "Specify the codepage to use when opening source files.",
|
||||
Additional_locations: "Additional locations:",
|
||||
This_version_of_the_Javascript_runtime_does_not_support_the_0_function: "This version of the Javascript runtime does not support the '{0}' function.",
|
||||
Unknown_rule: "Unknown rule.",
|
||||
|
||||
+630
-462
File diff suppressed because it is too large
Load Diff
+36
-35
@@ -25,9 +25,6 @@ module ts {
|
||||
/** Gets the length of this script snapshot. */
|
||||
getLength(): number;
|
||||
|
||||
/** This call returns the JSON-encoded array of the type: number[] */
|
||||
getLineStartPositions(): string;
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { span: { start: number; length: number }; newLength: number }
|
||||
@@ -37,6 +34,12 @@ module ts {
|
||||
getChangeRange(oldSnapshot: ScriptSnapshotShim): string;
|
||||
}
|
||||
|
||||
export interface Logger {
|
||||
log(s: string): void;
|
||||
trace(s: string): void;
|
||||
error(s: string): void;
|
||||
}
|
||||
|
||||
/** Public interface of the host of a language service shim instance.*/
|
||||
export interface LanguageServiceShimHost extends Logger {
|
||||
getCompilationSettings(): string;
|
||||
@@ -44,12 +47,12 @@ module ts {
|
||||
/** Returns a JSON-encoded value of the type: string[] */
|
||||
getScriptFileNames(): string;
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptIsOpen(fileName: string): boolean;
|
||||
getScriptSnapshot(fileName: string): ScriptSnapshotShim;
|
||||
getLocalizedDiagnosticMessages(): string;
|
||||
getCancellationToken(): CancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDefaultLibFilename(options: string): string;
|
||||
getDefaultLibFileName(options: string): string;
|
||||
getNewLine?(): string;
|
||||
}
|
||||
|
||||
///
|
||||
@@ -187,14 +190,6 @@ module ts {
|
||||
return this.scriptSnapshotShim.getLength();
|
||||
}
|
||||
|
||||
public getLineStartPositions(): number[] {
|
||||
if (this.lineStartPositions == null) {
|
||||
this.lineStartPositions = JSON.parse(this.scriptSnapshotShim.getLineStartPositions());
|
||||
}
|
||||
|
||||
return this.lineStartPositions;
|
||||
}
|
||||
|
||||
public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange {
|
||||
var oldSnapshotShim = <ScriptSnapshotShimAdapter>oldSnapshot;
|
||||
var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim);
|
||||
@@ -239,17 +234,14 @@ module ts {
|
||||
}
|
||||
|
||||
public getScriptSnapshot(fileName: string): IScriptSnapshot {
|
||||
return new ScriptSnapshotShimAdapter(this.shimHost.getScriptSnapshot(fileName));
|
||||
var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName);
|
||||
return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot);
|
||||
}
|
||||
|
||||
public getScriptVersion(fileName: string): string {
|
||||
return this.shimHost.getScriptVersion(fileName);
|
||||
}
|
||||
|
||||
public getScriptIsOpen(fileName: string): boolean {
|
||||
return this.shimHost.getScriptIsOpen(fileName);
|
||||
}
|
||||
|
||||
public getLocalizedDiagnosticMessages(): any {
|
||||
var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages();
|
||||
if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") {
|
||||
@@ -269,13 +261,13 @@ module ts {
|
||||
return this.shimHost.getCancellationToken();
|
||||
}
|
||||
|
||||
public getDefaultLibFilename(options: CompilerOptions): string {
|
||||
return this.shimHost.getDefaultLibFilename(JSON.stringify(options));
|
||||
}
|
||||
|
||||
public getCurrentDirectory(): string {
|
||||
return this.shimHost.getCurrentDirectory();
|
||||
}
|
||||
|
||||
public getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
|
||||
}
|
||||
}
|
||||
|
||||
function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any): any {
|
||||
@@ -376,9 +368,14 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
private static realizeDiagnostic(diagnostic: Diagnostic): { message: string; start: number; length: number; category: string; } {
|
||||
private realizeDiagnostics(diagnostics: Diagnostic[]): { message: string; start: number; length: number; category: string; }[]{
|
||||
var newLine = this.getNewLine();
|
||||
return diagnostics.map(d => this.realizeDiagnostic(d, newLine));
|
||||
}
|
||||
|
||||
private realizeDiagnostic(diagnostic: Diagnostic, newLine: string): { message: string; start: number; length: number; category: string; } {
|
||||
return {
|
||||
message: diagnostic.messageText,
|
||||
message: flattenDiagnosticMessageText(diagnostic.messageText, newLine),
|
||||
start: diagnostic.start,
|
||||
length: diagnostic.length,
|
||||
/// TODO: no need for the tolowerCase call
|
||||
@@ -405,12 +402,16 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
private getNewLine(): string {
|
||||
return this.host.getNewLine ? this.host.getNewLine() : "\r\n";
|
||||
}
|
||||
|
||||
public getSyntacticDiagnostics(fileName: string): string {
|
||||
return this.forwardJSONCall(
|
||||
"getSyntacticDiagnostics('" + fileName + "')",
|
||||
() => {
|
||||
var errors = this.languageService.getSyntacticDiagnostics(fileName);
|
||||
return errors.map(LanguageServiceShimObject.realizeDiagnostic);
|
||||
var diagnostics = this.languageService.getSyntacticDiagnostics(fileName);
|
||||
return this.realizeDiagnostics(diagnostics);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -418,8 +419,8 @@ module ts {
|
||||
return this.forwardJSONCall(
|
||||
"getSemanticDiagnostics('" + fileName + "')",
|
||||
() => {
|
||||
var errors = this.languageService.getSemanticDiagnostics(fileName);
|
||||
return errors.map(LanguageServiceShimObject.realizeDiagnostic);
|
||||
var diagnostics = this.languageService.getSemanticDiagnostics(fileName);
|
||||
return this.realizeDiagnostics(diagnostics);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -427,8 +428,8 @@ module ts {
|
||||
return this.forwardJSONCall(
|
||||
"getCompilerOptionsDiagnostics()",
|
||||
() => {
|
||||
var errors = this.languageService.getCompilerOptionsDiagnostics();
|
||||
return errors.map(LanguageServiceShimObject.realizeDiagnostic)
|
||||
var diagnostics = this.languageService.getCompilerOptionsDiagnostics();
|
||||
return this.realizeDiagnostics(diagnostics);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -669,9 +670,9 @@ module ts {
|
||||
class ClassifierShimObject extends ShimBase implements ClassifierShim {
|
||||
public classifier: Classifier;
|
||||
|
||||
constructor(factory: ShimFactory, public logger: Logger) {
|
||||
constructor(factory: ShimFactory) {
|
||||
super(factory);
|
||||
this.classifier = createClassifier(this.logger);
|
||||
this.classifier = createClassifier();
|
||||
}
|
||||
|
||||
/// COLORIZATION
|
||||
@@ -710,7 +711,7 @@ module ts {
|
||||
|
||||
forEach(result.referencedFiles, refFile => {
|
||||
convertResult.referencedFiles.push({
|
||||
path: normalizePath(refFile.filename),
|
||||
path: normalizePath(refFile.fileName),
|
||||
position: refFile.pos,
|
||||
length: refFile.end - refFile.pos
|
||||
});
|
||||
@@ -718,7 +719,7 @@ module ts {
|
||||
|
||||
forEach(result.importedFiles, importedFile => {
|
||||
convertResult.importedFiles.push({
|
||||
path: normalizeSlashes(importedFile.filename),
|
||||
path: normalizeSlashes(importedFile.fileName),
|
||||
position: importedFile.pos,
|
||||
length: importedFile.end - importedFile.pos
|
||||
});
|
||||
@@ -761,7 +762,7 @@ module ts {
|
||||
|
||||
public createClassifierShim(logger: Logger): ClassifierShim {
|
||||
try {
|
||||
return new ClassifierShimObject(this, logger);
|
||||
return new ClassifierShimObject(this);
|
||||
}
|
||||
catch (err) {
|
||||
logInternalError(logger, err);
|
||||
|
||||
-7
@@ -383,19 +383,13 @@ declare module TypeScript {
|
||||
Option_0_specified_without_1: string;
|
||||
codepage_option_not_supported_on_current_platform: string;
|
||||
Concatenate_and_emit_output_to_single_file: string;
|
||||
Generates_corresponding_0_file: string;
|
||||
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: string;
|
||||
Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: string;
|
||||
Watch_input_files: string;
|
||||
Redirect_output_structure_to_the_directory: string;
|
||||
Do_not_emit_comments_to_output: string;
|
||||
Skip_resolution_and_preprocessing: string;
|
||||
Specify_ECMAScript_target_version_0_default_or_1: string;
|
||||
Specify_module_code_generation_0_or_1: string;
|
||||
Print_this_message: string;
|
||||
Print_the_compiler_s_version_0: string;
|
||||
Allow_use_of_deprecated_0_keyword_when_referencing_an_external_module: string;
|
||||
Specify_locale_for_errors_and_messages_For_example_0_or_1: string;
|
||||
Syntax_0: string;
|
||||
options: string;
|
||||
file1: string;
|
||||
@@ -412,7 +406,6 @@ declare module TypeScript {
|
||||
LOCATION: string;
|
||||
DIRECTORY: string;
|
||||
NUMBER: string;
|
||||
Specify_the_codepage_to_use_when_opening_source_files: string;
|
||||
Additional_locations: string;
|
||||
This_version_of_the_Javascript_runtime_does_not_support_the_0_function: string;
|
||||
Unknown_rule: string;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
//// [ArrowFunction1.ts]
|
||||
var v = (a: ) => {
|
||||
|
||||
};
|
||||
|
||||
//// [ArrowFunction1.js]
|
||||
var v = function (a) {
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [ArrowFunction2.ts]
|
||||
var v = (a: b,) => {
|
||||
|
||||
};
|
||||
|
||||
//// [ArrowFunction2.js]
|
||||
var v = function (a) {
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [ArrowFunction3.ts]
|
||||
var v = (a): => {
|
||||
|
||||
};
|
||||
|
||||
//// [ArrowFunction3.js]
|
||||
var v = function (a) {
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [ExportAssignment7.ts]
|
||||
export class C {
|
||||
}
|
||||
|
||||
export = B;
|
||||
|
||||
//// [ExportAssignment7.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
exports.C = C;
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [ExportAssignment8.ts]
|
||||
export = B;
|
||||
|
||||
export class C {
|
||||
}
|
||||
|
||||
//// [ExportAssignment8.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
exports.C = C;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//// [ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.ts]
|
||||
module A {
|
||||
|
||||
class Point {
|
||||
constructor(public x: number, public y: number) { }
|
||||
}
|
||||
|
||||
export var UnitSquare : {
|
||||
top: { left: Point, right: Point },
|
||||
bottom: { left: Point, right: Point }
|
||||
} = null;
|
||||
}
|
||||
|
||||
//// [ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.js]
|
||||
var A;
|
||||
(function (A) {
|
||||
var Point = (function () {
|
||||
function Point(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
A.UnitSquare = null;
|
||||
})(A || (A = {}));
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [FunctionDeclaration10_es6.ts]
|
||||
function * foo(a = yield => yield) {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration10_es6.js]
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = function (yield) { return yield; }; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [FunctionDeclaration11_es6.ts]
|
||||
function * yield() {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration11_es6.js]
|
||||
function yield() {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionDeclaration12_es6.ts]
|
||||
var v = function * yield() { }
|
||||
|
||||
//// [FunctionDeclaration12_es6.js]
|
||||
var v = , yield = function () {
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
//// [FunctionDeclaration13_es6.ts]
|
||||
function * foo() {
|
||||
// Legal to use 'yield' in a type context.
|
||||
var v: yield;
|
||||
}
|
||||
|
||||
|
||||
//// [FunctionDeclaration13_es6.js]
|
||||
function foo() {
|
||||
// Legal to use 'yield' in a type context.
|
||||
var v;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [FunctionDeclaration1_es6.ts]
|
||||
function * foo() {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration1_es6.js]
|
||||
function foo() {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [FunctionDeclaration5_es6.ts]
|
||||
function*foo(yield) {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration5_es6.js]
|
||||
yield;
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [FunctionDeclaration6_es6.ts]
|
||||
function*foo(a = yield) {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration6_es6.js]
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = yield; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//// [FunctionDeclaration7_es6.ts]
|
||||
function*bar() {
|
||||
// 'yield' here is an identifier, and not a yield expression.
|
||||
function*foo(a = yield) {
|
||||
}
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration7_es6.js]
|
||||
function bar() {
|
||||
// 'yield' here is an identifier, and not a yield expression.
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = yield; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS9002: Computed property names are not currently supported.
|
||||
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 (1 errors) ====
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (3 errors) ====
|
||||
var v = { [yield]: foo }
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [FunctionDeclaration8_es6.ts]
|
||||
var v = { [yield]: foo }
|
||||
|
||||
//// [FunctionDeclaration8_es6.js]
|
||||
var v = { [yield]: foo };
|
||||
@@ -1,12 +1,15 @@
|
||||
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 TS9002: Computed property names 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 (2 errors) ====
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (3 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
var v = { [yield]: foo }
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [FunctionDeclaration9_es6.ts]
|
||||
function * foo() {
|
||||
var v = { [yield]: foo }
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration9_es6.js]
|
||||
function foo() {
|
||||
var v = { []: foo };
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionExpression1_es6.ts]
|
||||
var v = function * () { }
|
||||
|
||||
//// [FunctionExpression1_es6.js]
|
||||
var v = function () {
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionExpression2_es6.ts]
|
||||
var v = function * foo() { }
|
||||
|
||||
//// [FunctionExpression2_es6.js]
|
||||
var v = function foo() {
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionPropertyAssignments1_es6.ts]
|
||||
var v = { *foo() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments1_es6.js]
|
||||
var v = { foo: function () {
|
||||
} };
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionPropertyAssignments2_es6.ts]
|
||||
var v = { *() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments2_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionPropertyAssignments3_es6.ts]
|
||||
var v = { *{ } }
|
||||
|
||||
//// [FunctionPropertyAssignments3_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionPropertyAssignments4_es6.ts]
|
||||
var v = { * }
|
||||
|
||||
//// [FunctionPropertyAssignments4_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
@@ -1,7 +1,13 @@
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS9002: Computed property names are not currently supported.
|
||||
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 (1 errors) ====
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (3 errors) ====
|
||||
var v = { *[foo()]() { } }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
~~~~~~~
|
||||
!!! error TS9002: Computed property names are not currently supported.
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionPropertyAssignments5_es6.ts]
|
||||
var v = { *[foo()]() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments5_es6.js]
|
||||
var v = { [foo()]: function () {
|
||||
} };
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionPropertyAssignments6_es6.ts]
|
||||
var v = { *<T>() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments6_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [MemberAccessorDeclaration15.ts]
|
||||
class C {
|
||||
set Foo(public a: number) { }
|
||||
}
|
||||
|
||||
//// [MemberAccessorDeclaration15.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, "Foo", {
|
||||
set: function (a) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [MemberFunctionDeclaration1_es6.ts]
|
||||
class C {
|
||||
*foo() { }
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration1_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [MemberFunctionDeclaration2_es6.ts]
|
||||
class C {
|
||||
public * foo() { }
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration2_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,6): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts (2 errors) ====
|
||||
class C {
|
||||
*[foo]() { }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [MemberFunctionDeclaration3_es6.ts]
|
||||
class C {
|
||||
*[foo]() { }
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration3_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[foo] = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [MemberFunctionDeclaration4_es6.ts]
|
||||
class C {
|
||||
*() { }
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration4_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype. = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [MemberFunctionDeclaration5_es6.ts]
|
||||
class C {
|
||||
*
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration5_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [MemberFunctionDeclaration6_es6.ts]
|
||||
class C {
|
||||
*foo
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration6_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [MemberFunctionDeclaration7_es6.ts]
|
||||
class C {
|
||||
*foo<T>() { }
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration7_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,22 @@
|
||||
//// [MemberFunctionDeclaration8_es6.ts]
|
||||
class C {
|
||||
foo() {
|
||||
// Make sure we don't think of *bar as the start of a generator method.
|
||||
if (a) # * bar;
|
||||
return bar;
|
||||
}
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration8_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
// Make sure we don't think of *bar as the start of a generator method.
|
||||
if (a)
|
||||
;
|
||||
* bar;
|
||||
return bar;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [Protected1.ts]
|
||||
protected class C {
|
||||
}
|
||||
|
||||
//// [Protected1.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [Protected2.ts]
|
||||
protected module M {
|
||||
}
|
||||
|
||||
//// [Protected2.js]
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [Protected3.ts]
|
||||
class C {
|
||||
protected constructor() { }
|
||||
}
|
||||
|
||||
//// [Protected3.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [Protected4.ts]
|
||||
class C {
|
||||
protected public m() { }
|
||||
}
|
||||
|
||||
//// [Protected4.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.m = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [Protected6.ts]
|
||||
class C {
|
||||
static protected m() { }
|
||||
}
|
||||
|
||||
//// [Protected6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.m = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [Protected7.ts]
|
||||
class C {
|
||||
protected private m() { }
|
||||
}
|
||||
|
||||
//// [Protected7.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.m = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user