mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into LessAggresiveCompletionList
This commit is contained in:
@@ -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/"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -471,7 +471,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:
|
||||
|
||||
@@ -538,7 +538,7 @@ module ts {
|
||||
}
|
||||
|
||||
var moduleReferenceLiteral = <LiteralExpression>moduleReferenceExpression;
|
||||
var searchPath = getDirectoryPath(getSourceFile(location).filename);
|
||||
var searchPath = getDirectoryPath(getSourceFile(location).fileName);
|
||||
|
||||
// Module names are escaped in our symbol table. However, string literal values aren't.
|
||||
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
|
||||
@@ -553,8 +553,8 @@ module ts {
|
||||
}
|
||||
}
|
||||
while (true) {
|
||||
var filename = normalizePath(combinePaths(searchPath, moduleName));
|
||||
var sourceFile = host.getSourceFile(filename + ".ts") || host.getSourceFile(filename + ".d.ts");
|
||||
var fileName = normalizePath(combinePaths(searchPath, moduleName));
|
||||
var sourceFile = host.getSourceFile(fileName + ".ts") || host.getSourceFile(fileName + ".d.ts");
|
||||
if (sourceFile || isRelative) break;
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) break;
|
||||
@@ -564,7 +564,7 @@ module ts {
|
||||
if (sourceFile.symbol) {
|
||||
return getResolvedExportSymbol(sourceFile.symbol);
|
||||
}
|
||||
error(moduleReferenceLiteral, Diagnostics.File_0_is_not_an_external_module, sourceFile.filename);
|
||||
error(moduleReferenceLiteral, Diagnostics.File_0_is_not_an_external_module, sourceFile.fileName);
|
||||
return;
|
||||
}
|
||||
error(moduleReferenceLiteral, Diagnostics.Cannot_find_external_module_0, moduleName);
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -364,12 +364,12 @@ 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)) ||
|
||||
return compareValues(getDiagnosticFileName(d1), getDiagnosticFileName(d2)) ||
|
||||
compareValues(d1.start, d2.start) ||
|
||||
compareValues(d1.length, d2.length) ||
|
||||
compareValues(d1.code, d2.code) ||
|
||||
@@ -472,8 +472,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[]) {
|
||||
@@ -571,7 +571,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);
|
||||
}
|
||||
@@ -644,7 +644,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getDefaultLibFilename(options: CompilerOptions): string {
|
||||
export function getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts";
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ module ts {
|
||||
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." },
|
||||
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" },
|
||||
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." },
|
||||
@@ -433,6 +433,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." },
|
||||
|
||||
@@ -427,7 +427,7 @@
|
||||
"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
|
||||
},
|
||||
@@ -1725,6 +1725,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",
|
||||
|
||||
+94
-75
@@ -55,7 +55,7 @@ module ts {
|
||||
|
||||
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.filename, ".js")) {
|
||||
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.fileName, ".js")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -134,7 +134,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number) {
|
||||
return currentSourceFile.getLineAndCharacterFromPosition(pos).line;
|
||||
return getLineAndCharacterOfPosition(currentSourceFile, pos).line;
|
||||
}
|
||||
|
||||
function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]) {
|
||||
@@ -169,16 +169,16 @@ module ts {
|
||||
|
||||
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string){
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos);
|
||||
var lastLine = currentSourceFile.getLineStarts().length;
|
||||
var firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos);
|
||||
var lastLine = getLineStarts(currentSourceFile).length;
|
||||
var firstCommentLineIndent: number;
|
||||
for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
|
||||
var nextLineStart = currentLine === lastLine ? (comment.end + 1) : currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, /*character*/1);
|
||||
var nextLineStart = currentLine === lastLine ? (comment.end + 1) : getPositionFromLineAndCharacter(currentSourceFile, currentLine + 1, /*character*/1);
|
||||
|
||||
if (pos !== comment.pos) {
|
||||
// If we are not emitting first line, we need to write the spaces to adjust the alignment
|
||||
if (firstCommentLineIndent === undefined) {
|
||||
firstCommentLineIndent = calculateIndent(currentSourceFile.getPositionFromLineAndCharacter(firstCommentLineAndCharacter.line, /*character*/1),
|
||||
firstCommentLineIndent = calculateIndent(getPositionFromLineAndCharacter(currentSourceFile, firstCommentLineAndCharacter.line, /*character*/1),
|
||||
comment.pos);
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string) {
|
||||
var sourceFilePath = getNormalizedAbsolutePath(sourceFile.filename, host.getCurrentDirectory());
|
||||
var sourceFilePath = getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory());
|
||||
sourceFilePath = sourceFilePath.replace(host.getCommonSourceDirectory(), "");
|
||||
return combinePaths(newDirPath, sourceFilePath);
|
||||
}
|
||||
@@ -325,15 +325,15 @@ module ts {
|
||||
var emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(sourceFile, host, compilerOptions.outDir));
|
||||
}
|
||||
else {
|
||||
var emitOutputFilePathWithoutExtension = removeFileExtension(sourceFile.filename);
|
||||
var emitOutputFilePathWithoutExtension = removeFileExtension(sourceFile.fileName);
|
||||
}
|
||||
|
||||
return emitOutputFilePathWithoutExtension + extension;
|
||||
}
|
||||
|
||||
function writeFile(host: EmitHost, diagnostics: Diagnostic[], filename: string, data: string, writeByteOrderMark: boolean) {
|
||||
host.writeFile(filename, data, writeByteOrderMark, hostErrorMessage => {
|
||||
diagnostics.push(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, filename, hostErrorMessage));
|
||||
function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
host.writeFile(fileName, data, writeByteOrderMark, hostErrorMessage => {
|
||||
diagnostics.push(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -355,9 +355,86 @@ module ts {
|
||||
var reportedDeclarationError = false;
|
||||
|
||||
var emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments;
|
||||
var emit = compilerOptions.stripInternal ? stripInternal : emitNode;
|
||||
|
||||
var aliasDeclarationEmitInfo: AliasDeclarationEmitInfo[] = [];
|
||||
|
||||
// Contains the reference paths that needs to go in the declaration file.
|
||||
// Collecting this separately because reference paths need to be first thing in the declaration file
|
||||
// and we could be collecting these paths from multiple files into single one with --out option
|
||||
var referencePathsOutput = "";
|
||||
|
||||
if (root) {
|
||||
// Emitting just a single file, so emit references in this file only
|
||||
if (!compilerOptions.noResolve) {
|
||||
var addedGlobalFileReference = false;
|
||||
forEach(root.referencedFiles, fileReference => {
|
||||
var referencedFile = tryResolveScriptReference(host, root, fileReference);
|
||||
|
||||
// All the references that are not going to be part of same file
|
||||
if (referencedFile && ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
|
||||
shouldEmitToOwnFile(referencedFile, compilerOptions) || // This is referenced file is emitting its own js file
|
||||
!addedGlobalFileReference)) { // Or the global out file corresponding to this reference was not added
|
||||
|
||||
writeReferencePath(referencedFile);
|
||||
if (!isExternalModuleOrDeclarationFile(referencedFile)) {
|
||||
addedGlobalFileReference = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
emitSourceFile(root);
|
||||
}
|
||||
else {
|
||||
// Emit references corresponding to this file
|
||||
var emittedReferencedFiles: SourceFile[] = [];
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
|
||||
// Check what references need to be added
|
||||
if (!compilerOptions.noResolve) {
|
||||
forEach(sourceFile.referencedFiles, fileReference => {
|
||||
var referencedFile = tryResolveScriptReference(host, sourceFile, fileReference);
|
||||
|
||||
// If the reference file is a declaration file or an external module, emit that reference
|
||||
if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) &&
|
||||
!contains(emittedReferencedFiles, referencedFile))) { // If the file reference was not already emitted
|
||||
|
||||
writeReferencePath(referencedFile);
|
||||
emittedReferencedFiles.push(referencedFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
emitSourceFile(sourceFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
reportedDeclarationError,
|
||||
aliasDeclarationEmitInfo,
|
||||
synchronousDeclarationOutput: writer.getText(),
|
||||
referencePathsOutput,
|
||||
}
|
||||
|
||||
function hasInternalAnnotation(range: CommentRange) {
|
||||
var text = currentSourceFile.text;
|
||||
var comment = text.substring(range.pos, range.end);
|
||||
return comment.indexOf("@internal") >= 0;
|
||||
}
|
||||
|
||||
function stripInternal(node: Node) {
|
||||
if (node) {
|
||||
var leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
||||
if (forEach(leadingCommentRanges, hasInternalAnnotation)) {
|
||||
return;
|
||||
}
|
||||
|
||||
emitNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
function createAndSetNewTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter {
|
||||
var writer = <EmitTextWriterWithSymbolWriter>createTextWriter(newLine);
|
||||
writer.trackSymbol = trackSymbol;
|
||||
@@ -463,7 +540,7 @@ module ts {
|
||||
|
||||
function emitLines(nodes: Node[]) {
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
emitNode(nodes[i]);
|
||||
emit(nodes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1402,13 +1479,9 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
// Contains the reference paths that needs to go in the declaration file.
|
||||
// Collecting this separately because reference paths need to be first thing in the declaration file
|
||||
// and we could be collecting these paths from multiple files into single one with --out option
|
||||
var referencePathsOutput = "";
|
||||
function writeReferencePath(referencedFile: SourceFile) {
|
||||
var declFileName = referencedFile.flags & NodeFlags.DeclarationFile
|
||||
? referencedFile.filename // Declaration file, use declaration file name
|
||||
? referencedFile.fileName // Declaration file, use declaration file name
|
||||
: shouldEmitToOwnFile(referencedFile, compilerOptions)
|
||||
? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file
|
||||
: removeFileExtension(compilerOptions.out) + ".d.ts";// Global out file
|
||||
@@ -1422,60 +1495,6 @@ module ts {
|
||||
|
||||
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine;
|
||||
}
|
||||
|
||||
if (root) {
|
||||
// Emitting just a single file, so emit references in this file only
|
||||
if (!compilerOptions.noResolve) {
|
||||
var addedGlobalFileReference = false;
|
||||
forEach(root.referencedFiles, fileReference => {
|
||||
var referencedFile = tryResolveScriptReference(host, root, fileReference);
|
||||
|
||||
// All the references that are not going to be part of same file
|
||||
if (referencedFile && ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
|
||||
shouldEmitToOwnFile(referencedFile, compilerOptions) || // This is referenced file is emitting its own js file
|
||||
!addedGlobalFileReference)) { // Or the global out file corresponding to this reference was not added
|
||||
|
||||
writeReferencePath(referencedFile);
|
||||
if (!isExternalModuleOrDeclarationFile(referencedFile)) {
|
||||
addedGlobalFileReference = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
emitNode(root);
|
||||
}
|
||||
else {
|
||||
// Emit references corresponding to this file
|
||||
var emittedReferencedFiles: SourceFile[] = [];
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
|
||||
// Check what references need to be added
|
||||
if (!compilerOptions.noResolve) {
|
||||
forEach(sourceFile.referencedFiles, fileReference => {
|
||||
var referencedFile = tryResolveScriptReference(host, sourceFile, fileReference);
|
||||
|
||||
// If the reference file is a declaration file or an external module, emit that reference
|
||||
if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) &&
|
||||
!contains(emittedReferencedFiles, referencedFile))) { // If the file reference was not already emitted
|
||||
|
||||
writeReferencePath(referencedFile);
|
||||
emittedReferencedFiles.push(referencedFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
emitNode(sourceFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
reportedDeclarationError,
|
||||
aliasDeclarationEmitInfo,
|
||||
synchronousDeclarationOutput: writer.getText(),
|
||||
referencePathsOutput,
|
||||
}
|
||||
}
|
||||
|
||||
export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] {
|
||||
@@ -1660,7 +1679,7 @@ module ts {
|
||||
}
|
||||
|
||||
function recordSourceMapSpan(pos: number) {
|
||||
var sourceLinePos = currentSourceFile.getLineAndCharacterFromPosition(pos);
|
||||
var sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos);
|
||||
var emittedLine = writer.getLine();
|
||||
var emittedColumn = writer.getColumn();
|
||||
|
||||
@@ -1716,14 +1735,14 @@ module ts {
|
||||
var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir;
|
||||
|
||||
sourceMapData.sourceMapSources.push(getRelativePathToDirectoryOrUrl(sourcesDirectoryPath,
|
||||
node.filename,
|
||||
node.fileName,
|
||||
host.getCurrentDirectory(),
|
||||
host.getCanonicalFileName,
|
||||
/*isAbsolutePathAnUrl*/ true));
|
||||
sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1;
|
||||
|
||||
// The one that can be used from program to get the actual source file
|
||||
sourceMapData.inputSourceFileNames.push(node.filename);
|
||||
sourceMapData.inputSourceFileNames.push(node.fileName);
|
||||
}
|
||||
|
||||
function recordScopeNameOfNode(node: Node, scopeName?: string) {
|
||||
@@ -1838,7 +1857,7 @@ module ts {
|
||||
}
|
||||
|
||||
// Initialize source map data
|
||||
var sourceMapJsFile = getBaseFilename(normalizeSlashes(jsFilePath));
|
||||
var sourceMapJsFile = getBaseFileName(normalizeSlashes(jsFilePath));
|
||||
sourceMapData = {
|
||||
sourceMapFilePath: jsFilePath + ".map",
|
||||
jsSourceMappingURL: sourceMapJsFile + ".map",
|
||||
|
||||
+401
-422
@@ -356,6 +356,368 @@ module ts {
|
||||
forEachChild(sourceFile, walk);
|
||||
}
|
||||
|
||||
export function getSyntacticDiagnostics(sourceFile: SourceFile) {
|
||||
if (!sourceFile.syntacticDiagnostics) {
|
||||
// Don't bother doing any grammar checks if there are already parser errors.
|
||||
// Otherwise we may end up with too many cascading errors.
|
||||
sourceFile.syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics);
|
||||
}
|
||||
return sourceFile.syntacticDiagnostics;
|
||||
}
|
||||
|
||||
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");
|
||||
@@ -495,17 +857,27 @@ module ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false): SourceFile {
|
||||
return parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes);
|
||||
}
|
||||
|
||||
export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false): SourceFile {
|
||||
var parsingContext: ParsingContext;
|
||||
var identifiers: Map<string>;
|
||||
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 = sourceFile.end = 0;
|
||||
sourceFile.referenceDiagnostics = [];
|
||||
sourceFile.parseDiagnostics = [];
|
||||
sourceFile.semanticDiagnostics = [];
|
||||
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 +925,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 +954,36 @@ 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;
|
||||
sourceFile.syntacticDiagnostics = undefined;
|
||||
sourceFile.referenceDiagnostics = [];
|
||||
sourceFile.parseDiagnostics = [];
|
||||
sourceFile.semanticDiagnostics = [];
|
||||
sourceFile.end = sourceText.length;
|
||||
sourceFile.text = sourceText;
|
||||
|
||||
return parseSourceFile(sourceText, setParentNodes);
|
||||
// Create and prime the scanner before parsing the source elements.
|
||||
scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceText, scanError);
|
||||
token = nextToken();
|
||||
|
||||
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;
|
||||
processReferenceComments(sourceFile);
|
||||
|
||||
sourceFile = <SourceFile>createNode(SyntaxKind.SourceFile, 0);
|
||||
sourceFile.referenceDiagnostics = [];
|
||||
sourceFile.parseDiagnostics = [];
|
||||
sourceFile.semanticDiagnostics = [];
|
||||
sourceFile.statements = parseList(ParsingContext.SourceElements, /*checkForStrictMode*/ true, parseSourceElement);
|
||||
Debug.assert(token === SyntaxKind.EndOfFileToken);
|
||||
sourceFile.endOfFileToken = parseTokenNode();
|
||||
|
||||
// Create and prime the scanner before parsing the source elements.
|
||||
scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceText, scanError);
|
||||
token = nextToken();
|
||||
setExternalModuleIndicator(sourceFile);
|
||||
|
||||
sourceFile.flags = fileExtensionIs(filename, ".d.ts") ? NodeFlags.DeclarationFile : 0;
|
||||
sourceFile.end = sourceText.length;
|
||||
sourceFile.filename = normalizePath(filename);
|
||||
sourceFile.text = sourceText;
|
||||
sourceFile.nodeCount = nodeCount;
|
||||
sourceFile.identifierCount = identifierCount;
|
||||
sourceFile.identifiers = identifiers;
|
||||
|
||||
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 +1074,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 +4668,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;
|
||||
@@ -4741,17 +4731,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 {
|
||||
|
||||
+41
-41
@@ -15,9 +15,9 @@ 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) {
|
||||
@@ -28,7 +28,7 @@ module ts {
|
||||
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 +64,7 @@ module ts {
|
||||
|
||||
return {
|
||||
getSourceFile,
|
||||
getDefaultLibFilename: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFilename(options)),
|
||||
getDefaultLibFileName: options => combinePaths(getDirectoryPath(normalizePath(sys.getExecutingFilePath())), getDefaultLibFileName(options)),
|
||||
writeFile,
|
||||
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
|
||||
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
||||
@@ -83,7 +83,7 @@ module ts {
|
||||
|
||||
forEach(rootNames, name => processRootFile(name, false));
|
||||
if (!seenNoDefaultLib) {
|
||||
processRootFile(host.getDefaultLibFilename(options), true);
|
||||
processRootFile(host.getDefaultLibFileName(options), true);
|
||||
}
|
||||
verifyCompilerOptions();
|
||||
errors.sort(compareDiagnostics);
|
||||
@@ -146,9 +146,9 @@ module ts {
|
||||
return emitFiles(resolver, getEmitHost(), targetSourceFile);
|
||||
}
|
||||
|
||||
function getSourceFile(filename: string) {
|
||||
filename = host.getCanonicalFileName(filename);
|
||||
return hasProperty(filesByName, filename) ? filesByName[filename] : undefined;
|
||||
function getSourceFile(fileName: string) {
|
||||
fileName = host.getCanonicalFileName(fileName);
|
||||
return hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined;
|
||||
}
|
||||
|
||||
function getDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
|
||||
@@ -159,73 +159,73 @@ module ts {
|
||||
return filter(errors, e => !e.file);
|
||||
}
|
||||
|
||||
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(host.getCanonicalFileName(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));
|
||||
errors.push(createFileDiagnostic(refFile, start, length, diagnostic, fileName));
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(diagnostic, filename));
|
||||
errors.push(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.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage));
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
});
|
||||
if (file) {
|
||||
@@ -235,7 +235,7 @@ module ts {
|
||||
filesByName[canonicalAbsolutePath] = file;
|
||||
|
||||
if (!options.noResolve) {
|
||||
var basePath = getDirectoryPath(filename);
|
||||
var basePath = getDirectoryPath(fileName);
|
||||
processReferencedFiles(file, basePath);
|
||||
processImportedModules(file, basePath);
|
||||
}
|
||||
@@ -245,20 +245,20 @@ module ts {
|
||||
else {
|
||||
files.push(file);
|
||||
}
|
||||
forEach(file.getSyntacticDiagnostics(), e => {
|
||||
forEach(getSyntacticDiagnostics(file), 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.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
|
||||
}
|
||||
}
|
||||
return file;
|
||||
@@ -267,8 +267,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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -322,8 +322,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,8 +359,8 @@ 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++) {
|
||||
|
||||
+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;
|
||||
|
||||
+31
-31
@@ -72,7 +72,7 @@ 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;
|
||||
}
|
||||
@@ -86,9 +86,9 @@ module ts {
|
||||
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();
|
||||
@@ -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
|
||||
@@ -193,17 +193,17 @@ module ts {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
@@ -214,8 +214,8 @@ module ts {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
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));
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, configFileName));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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,9 +321,9 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function compile(filenames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
|
||||
function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
|
||||
var parseStart = new Date().getTime();
|
||||
var program = createProgram(filenames, compilerOptions, compilerHost);
|
||||
var program = createProgram(fileNames, compilerOptions, compilerHost);
|
||||
|
||||
var bindStart = new Date().getTime();
|
||||
var errors: Diagnostic[] = program.getDiagnostics();
|
||||
@@ -359,7 +359,7 @@ module ts {
|
||||
|
||||
if (compilerOptions.listFiles) {
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
sys.write(file.filename + sys.newLine);
|
||||
sys.write(file.fileName + sys.newLine);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -413,7 +413,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,
|
||||
|
||||
+39
-36
@@ -872,7 +872,7 @@ module ts {
|
||||
}
|
||||
|
||||
export interface FileReference extends TextRange {
|
||||
filename: string;
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
export interface CommentRange extends TextRange {
|
||||
@@ -884,53 +884,54 @@ 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[];
|
||||
|
||||
hasNoDefaultLib: boolean;
|
||||
externalModuleIndicator: Node; // The first node that causes this file to be an external module
|
||||
languageVersion: ScriptTarget;
|
||||
identifiers: Map<string>;
|
||||
|
||||
// @internal
|
||||
nodeCount: number;
|
||||
|
||||
// @internal
|
||||
identifierCount: number;
|
||||
|
||||
// @internal
|
||||
symbolCount: number;
|
||||
|
||||
// @internal
|
||||
// Diagnostics reported about the "///<reference" comments in the file.
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
|
||||
|
||||
// @internal
|
||||
// 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[];
|
||||
|
||||
|
||||
// @internal
|
||||
// File level diagnostics reported by the binder.
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
|
||||
// @internal
|
||||
// Returns all syntactic diagnostics (i.e. the reference, parser and grammar diagnostics).
|
||||
// This field should never be used directly, use getSyntacticDiagnostics function instead.
|
||||
syntacticDiagnostics: Diagnostic[];
|
||||
|
||||
hasNoDefaultLib: boolean;
|
||||
externalModuleIndicator: Node; // The first node that causes this file to be an external module
|
||||
nodeCount: number;
|
||||
identifierCount: number;
|
||||
symbolCount: number;
|
||||
languageVersion: ScriptTarget;
|
||||
identifiers: Map<string>;
|
||||
// @internal
|
||||
// Stores a line map for the file.
|
||||
// This field should never be used directly to obtain line map, use getLineMap function instead.
|
||||
lineMap: number[];
|
||||
}
|
||||
|
||||
export interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
|
||||
@@ -999,7 +1000,7 @@ module ts {
|
||||
getCompilerHost(): CompilerHost;
|
||||
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
}
|
||||
|
||||
export interface TypeChecker {
|
||||
@@ -1476,6 +1477,7 @@ module ts {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
|
||||
@@ -1502,18 +1504,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 {
|
||||
@@ -1656,10 +1659,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(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
|
||||
@@ -31,7 +31,7 @@ module ts {
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
}
|
||||
|
||||
// Pool writers to avoid needing to allocate them for every symbol we write.
|
||||
@@ -109,8 +109,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 {
|
||||
@@ -746,7 +746,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);
|
||||
}
|
||||
@@ -804,7 +804,7 @@ module ts {
|
||||
fileReference: {
|
||||
pos: start,
|
||||
end: end,
|
||||
filename: matchResult[3]
|
||||
fileName: matchResult[3]
|
||||
},
|
||||
isNoDefaultLib: false
|
||||
};
|
||||
|
||||
+19
-19
@@ -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]
|
||||
@@ -268,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
|
||||
@@ -360,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
|
||||
@@ -388,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 + '" />');
|
||||
}
|
||||
|
||||
@@ -409,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) {
|
||||
@@ -739,7 +739,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;
|
||||
}
|
||||
});
|
||||
@@ -1152,8 +1152,8 @@ module FourSlash {
|
||||
resultString += "EmitOutputStatus : " + ts.EmitReturnStatus[emitOutputStatus];
|
||||
resultString += "\n";
|
||||
emitOutput.outputFiles.forEach((outputFile, idx, array) => {
|
||||
var filename = "Filename : " + outputFile.name + "\n";
|
||||
resultString = resultString + filename + outputFile.text;
|
||||
var fileName = "FileName : " + outputFile.name + "\n";
|
||||
resultString = resultString + fileName + outputFile.text;
|
||||
});
|
||||
resultString += "\n";
|
||||
});
|
||||
@@ -1402,7 +1402,7 @@ module FourSlash {
|
||||
var incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName);
|
||||
Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined);
|
||||
|
||||
var incrementalSyntaxDiagnostics = incrementalSourceFile.getSyntacticDiagnostics();
|
||||
var incrementalSyntaxDiagnostics = ts.getSyntacticDiagnostics(incrementalSourceFile);
|
||||
|
||||
// Check syntactic structure
|
||||
var snapshot = this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName);
|
||||
@@ -1410,7 +1410,7 @@ module FourSlash {
|
||||
|
||||
var referenceSourceFile = ts.createLanguageServiceSourceFile(
|
||||
this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*setNodeParents:*/ false);
|
||||
var referenceSyntaxDiagnostics = referenceSourceFile.getSyntacticDiagnostics();
|
||||
var referenceSyntaxDiagnostics = ts.getSyntacticDiagnostics(referenceSourceFile);
|
||||
|
||||
Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics);
|
||||
Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile);
|
||||
@@ -2140,7 +2140,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;
|
||||
@@ -2212,13 +2212,13 @@ 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 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 errors = program.getDiagnostics().concat(checker.getDiagnostics());
|
||||
@@ -2305,8 +2305,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;
|
||||
|
||||
+76
-62
@@ -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:
|
||||
@@ -389,9 +389,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;
|
||||
@@ -621,7 +621,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
|
||||
@@ -692,26 +692,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;
|
||||
@@ -800,7 +800,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 {
|
||||
@@ -819,14 +819,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);
|
||||
@@ -841,8 +841,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;
|
||||
}
|
||||
@@ -854,7 +854,7 @@ module Harness {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
getDefaultLibFilename: options => defaultLibFileName,
|
||||
getDefaultLibFileName: options => defaultLibFileName,
|
||||
writeFile,
|
||||
getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
|
||||
@@ -935,7 +935,7 @@ module Harness {
|
||||
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') {
|
||||
@@ -1017,6 +1017,9 @@ module Harness {
|
||||
options.removeComments = setting.value === 'false';
|
||||
break;
|
||||
|
||||
case 'stripinternal':
|
||||
options.stripInternal = !!setting.value;
|
||||
|
||||
case 'usecasesensitivefilenames':
|
||||
useCaseSensitiveFileNames = setting.value === 'true';
|
||||
break;
|
||||
@@ -1063,8 +1066,8 @@ 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);
|
||||
@@ -1145,12 +1148,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 {
|
||||
@@ -1181,7 +1184,7 @@ module Harness {
|
||||
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,
|
||||
@@ -1196,8 +1199,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;
|
||||
@@ -1207,7 +1210,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) ||
|
||||
@@ -1233,14 +1236,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;
|
||||
});
|
||||
|
||||
@@ -1304,12 +1307,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
|
||||
@@ -1320,7 +1323,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();
|
||||
@@ -1333,7 +1336,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);
|
||||
@@ -1363,7 +1366,7 @@ module Harness {
|
||||
}
|
||||
|
||||
export interface HarnessDiagnostic {
|
||||
filename: string;
|
||||
fileName: string;
|
||||
start: number;
|
||||
end: number;
|
||||
line: number;
|
||||
@@ -1464,7 +1467,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[] {
|
||||
|
||||
@@ -1478,7 +1481,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);
|
||||
|
||||
@@ -1566,26 +1569,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
|
||||
@@ -1604,11 +1618,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();
|
||||
@@ -1620,13 +1634,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) {
|
||||
@@ -1634,15 +1648,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;
|
||||
@@ -1655,34 +1669,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ module Harness.LanguageService {
|
||||
return "";
|
||||
}
|
||||
|
||||
public getDefaultLibFilename(): string {
|
||||
public getDefaultLibFileName(): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -286,7 +286,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,7 +297,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,8 +130,8 @@ module Playback {
|
||||
replayLog = undefined;
|
||||
};
|
||||
|
||||
wrapper.startRecord = (filenameBase) => {
|
||||
recordLogFilenameBase = filenameBase;
|
||||
wrapper.startRecord = (fileNameBase) => {
|
||||
recordLogFileNameBase = fileNameBase;
|
||||
recordLog = createEmptyLog();
|
||||
};
|
||||
}
|
||||
@@ -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,8 +123,8 @@ 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();
|
||||
@@ -168,15 +168,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 +186,7 @@ class ProjectRunner extends RunnerBase {
|
||||
function createCompilerHost(): ts.CompilerHost {
|
||||
return {
|
||||
getSourceFile,
|
||||
getDefaultLibFilename: options => Harness.Compiler.defaultLibFileName,
|
||||
getDefaultLibFileName: options => Harness.Compiler.defaultLibFileName,
|
||||
writeFile,
|
||||
getCurrentDirectory,
|
||||
getCanonicalFileName: Harness.Compiler.getCanonicalFileName,
|
||||
@@ -211,11 +211,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 +223,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,7 +269,7 @@ 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 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,17 +278,17 @@ class ProjectRunner extends RunnerBase {
|
||||
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, compilerHost.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 +311,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 +348,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;
|
||||
|
||||
@@ -404,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,
|
||||
|
||||
+181
-162
@@ -61,6 +61,11 @@ module ts {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,25 +718,19 @@ module ts {
|
||||
|
||||
class SourceFileObject extends NodeObject implements SourceFile {
|
||||
public _declarationBrand: any;
|
||||
public filename: string;
|
||||
public fileName: string;
|
||||
public text: string;
|
||||
public scriptSnapshot: IScriptSnapshot;
|
||||
public lineMap: number[];
|
||||
|
||||
public statements: NodeArray<Statement>;
|
||||
public endOfFileToken: Node;
|
||||
|
||||
// These methods will have their implementation provided by the implementation the
|
||||
// compiler actually exports off of SourceFile.
|
||||
public getLineAndCharacterFromPosition: (position: number) => LineAndCharacter;
|
||||
public getPositionFromLineAndCharacter: (line: number, character: number) => number;
|
||||
public getLineStarts: () => number[];
|
||||
public getSyntacticDiagnostics: () => Diagnostic[];
|
||||
public update: (newText: string, textChangeRange: TextChangeRange) => SourceFile;
|
||||
|
||||
public amdDependencies: string[];
|
||||
public amdModuleName: string;
|
||||
public referencedFiles: FileReference[];
|
||||
|
||||
public syntacticDiagnostics: Diagnostic[];
|
||||
public referenceDiagnostics: Diagnostic[];
|
||||
public parseDiagnostics: Diagnostic[];
|
||||
public semanticDiagnostics: Diagnostic[];
|
||||
@@ -748,6 +747,26 @@ module ts {
|
||||
|
||||
private namedDeclarations: Declaration[];
|
||||
|
||||
public getSyntacticDiagnostics(): Diagnostic[]{
|
||||
return getSyntacticDiagnostics(this);
|
||||
}
|
||||
|
||||
public update(newText: string, textChangeRange: TextChangeRange): SourceFile {
|
||||
return updateSourceFile(this, newText, textChangeRange);
|
||||
}
|
||||
|
||||
public getLineAndCharacterFromPosition(position: number): LineAndCharacter {
|
||||
return getLineAndCharacterOfPosition(this, position);
|
||||
}
|
||||
|
||||
public getLineStarts(): number[] {
|
||||
return getLineStarts(this);
|
||||
}
|
||||
|
||||
public getPositionFromLineAndCharacter(line: number, character: number): number {
|
||||
return getPositionFromLineAndCharacter(this, line, character);
|
||||
}
|
||||
|
||||
public getNamedDeclarations() {
|
||||
if (!this.namedDeclarations) {
|
||||
var sourceFile = this;
|
||||
@@ -848,7 +867,7 @@ module ts {
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
log? (s: string): void;
|
||||
trace? (s: string): void;
|
||||
error? (s: string): void;
|
||||
@@ -902,7 +921,7 @@ module ts {
|
||||
|
||||
getProgram(): Program;
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
|
||||
dispose(): void;
|
||||
}
|
||||
@@ -1174,11 +1193,11 @@ module ts {
|
||||
*/
|
||||
export interface DocumentRegistry {
|
||||
/**
|
||||
* Request a stored SourceFile with a given filename and compilationSettings.
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -1188,13 +1207,13 @@ module ts {
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(
|
||||
filename: string,
|
||||
fileName: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string): SourceFile;
|
||||
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given filename
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
@@ -1202,7 +1221,7 @@ module ts {
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -1215,7 +1234,7 @@ module ts {
|
||||
*/
|
||||
updateDocument(
|
||||
sourceFile: SourceFile,
|
||||
filename: string,
|
||||
fileName: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
@@ -1227,10 +1246,10 @@ module ts {
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param filename The name of the file to be released
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(filename: string, compilationSettings: CompilerOptions): void
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void
|
||||
}
|
||||
|
||||
// TODO: move these to enums
|
||||
@@ -1351,7 +1370,7 @@ module ts {
|
||||
/// Language Service
|
||||
|
||||
interface CompletionSession {
|
||||
filename: string; // the file where the completion was requested
|
||||
fileName: string; // the file where the completion was requested
|
||||
position: number; // position in the file where the completion was requested
|
||||
entries: CompletionEntry[]; // entries for this completion
|
||||
symbols: Map<Symbol>; // symbols by entry name map
|
||||
@@ -1367,7 +1386,7 @@ module ts {
|
||||
|
||||
// Information about a specific host file.
|
||||
interface HostFileInformation {
|
||||
hostFilename: string;
|
||||
hostFileName: string;
|
||||
version: string;
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
}
|
||||
@@ -1419,9 +1438,9 @@ module ts {
|
||||
}
|
||||
|
||||
export function getDefaultCompilerOptions(): CompilerOptions {
|
||||
// Set "ScriptTarget.Latest" target by default for language service
|
||||
// Always default to "ScriptTarget.ES5" for the language service
|
||||
return {
|
||||
target: ScriptTarget.Latest,
|
||||
target: ScriptTarget.ES5,
|
||||
module: ModuleKind.None,
|
||||
};
|
||||
}
|
||||
@@ -1450,17 +1469,17 @@ module ts {
|
||||
// at each language service public entry point, since we don't know when
|
||||
// set of scripts handled by the host changes.
|
||||
class HostCache {
|
||||
private filenameToEntry: Map<HostFileInformation>;
|
||||
private fileNameToEntry: Map<HostFileInformation>;
|
||||
private _compilationSettings: CompilerOptions;
|
||||
|
||||
constructor(private host: LanguageServiceHost) {
|
||||
// script id => script index
|
||||
this.filenameToEntry = {};
|
||||
this.fileNameToEntry = {};
|
||||
|
||||
// Initialize the list with the root file names
|
||||
var rootFilenames = host.getScriptFileNames();
|
||||
for (var i = 0, n = rootFilenames.length; i < n; i++) {
|
||||
this.createEntry(rootFilenames[i]);
|
||||
var rootFileNames = host.getScriptFileNames();
|
||||
for (var i = 0, n = rootFileNames.length; i < n; i++) {
|
||||
this.createEntry(rootFileNames[i]);
|
||||
}
|
||||
|
||||
// store the compilation settings
|
||||
@@ -1471,64 +1490,64 @@ module ts {
|
||||
return this._compilationSettings;
|
||||
}
|
||||
|
||||
private createEntry(filename: string) {
|
||||
private createEntry(fileName: string) {
|
||||
var entry: HostFileInformation;
|
||||
var scriptSnapshot = this.host.getScriptSnapshot(filename);
|
||||
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
|
||||
if (scriptSnapshot) {
|
||||
entry = {
|
||||
hostFilename: filename,
|
||||
version: this.host.getScriptVersion(filename),
|
||||
hostFileName: fileName,
|
||||
version: this.host.getScriptVersion(fileName),
|
||||
scriptSnapshot: scriptSnapshot
|
||||
};
|
||||
}
|
||||
|
||||
return this.filenameToEntry[normalizeSlashes(filename)] = entry;
|
||||
return this.fileNameToEntry[normalizeSlashes(fileName)] = entry;
|
||||
}
|
||||
|
||||
public getEntry(filename: string): HostFileInformation {
|
||||
return lookUp(this.filenameToEntry, normalizeSlashes(filename));
|
||||
public getEntry(fileName: string): HostFileInformation {
|
||||
return lookUp(this.fileNameToEntry, normalizeSlashes(fileName));
|
||||
}
|
||||
|
||||
public contains(filename: string): boolean {
|
||||
return hasProperty(this.filenameToEntry, normalizeSlashes(filename));
|
||||
public contains(fileName: string): boolean {
|
||||
return hasProperty(this.fileNameToEntry, normalizeSlashes(fileName));
|
||||
}
|
||||
|
||||
public getOrCreateEntry(filename: string): HostFileInformation {
|
||||
if (this.contains(filename)) {
|
||||
return this.getEntry(filename);
|
||||
public getOrCreateEntry(fileName: string): HostFileInformation {
|
||||
if (this.contains(fileName)) {
|
||||
return this.getEntry(fileName);
|
||||
}
|
||||
|
||||
return this.createEntry(filename);
|
||||
return this.createEntry(fileName);
|
||||
}
|
||||
|
||||
public getRootFilenames(): string[] {
|
||||
public getRootFileNames(): string[] {
|
||||
var fileNames: string[] = [];
|
||||
|
||||
forEachKey(this.filenameToEntry, key => {
|
||||
if (hasProperty(this.filenameToEntry, key) && this.filenameToEntry[key])
|
||||
forEachKey(this.fileNameToEntry, key => {
|
||||
if (hasProperty(this.fileNameToEntry, key) && this.fileNameToEntry[key])
|
||||
fileNames.push(key);
|
||||
});
|
||||
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
public getVersion(filename: string): string {
|
||||
var file = this.getEntry(filename);
|
||||
public getVersion(fileName: string): string {
|
||||
var file = this.getEntry(fileName);
|
||||
return file && file.version;
|
||||
}
|
||||
|
||||
public getScriptSnapshot(filename: string): IScriptSnapshot {
|
||||
var file = this.getEntry(filename);
|
||||
public getScriptSnapshot(fileName: string): IScriptSnapshot {
|
||||
var file = this.getEntry(fileName);
|
||||
return file && file.scriptSnapshot;
|
||||
}
|
||||
|
||||
public getChangeRange(filename: string, lastKnownVersion: string, oldScriptSnapshot: IScriptSnapshot): TextChangeRange {
|
||||
var currentVersion = this.getVersion(filename);
|
||||
public getChangeRange(fileName: string, lastKnownVersion: string, oldScriptSnapshot: IScriptSnapshot): TextChangeRange {
|
||||
var currentVersion = this.getVersion(fileName);
|
||||
if (lastKnownVersion === currentVersion) {
|
||||
return unchangedTextChangeRange; // "No changes"
|
||||
}
|
||||
|
||||
var scriptSnapshot = this.getScriptSnapshot(filename);
|
||||
var scriptSnapshot = this.getScriptSnapshot(fileName);
|
||||
return scriptSnapshot.getChangeRange(oldScriptSnapshot);
|
||||
}
|
||||
}
|
||||
@@ -1538,7 +1557,7 @@ module ts {
|
||||
|
||||
// For our syntactic only features, we also keep a cache of the syntax tree for the
|
||||
// currently edited file.
|
||||
private currentFilename: string = "";
|
||||
private currentFileName: string = "";
|
||||
private currentFileVersion: string = null;
|
||||
private currentSourceFile: SourceFile = null;
|
||||
|
||||
@@ -1551,26 +1570,26 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
private initialize(filename: string) {
|
||||
private initialize(fileName: string) {
|
||||
// ensure that both source file and syntax tree are either initialized or not initialized
|
||||
var start = new Date().getTime();
|
||||
this.hostCache = new HostCache(this.host);
|
||||
this.log("SyntaxTreeCache.Initialize: new HostCache: " + (new Date().getTime() - start));
|
||||
|
||||
var version = this.hostCache.getVersion(filename);
|
||||
var version = this.hostCache.getVersion(fileName);
|
||||
var sourceFile: SourceFile;
|
||||
|
||||
if (this.currentFilename !== filename) {
|
||||
var scriptSnapshot = this.hostCache.getScriptSnapshot(filename);
|
||||
if (this.currentFileName !== fileName) {
|
||||
var scriptSnapshot = this.hostCache.getScriptSnapshot(fileName);
|
||||
|
||||
var start = new Date().getTime();
|
||||
sourceFile = createLanguageServiceSourceFile(filename, scriptSnapshot, ScriptTarget.Latest, version, /*setNodeParents:*/ true);
|
||||
sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, ScriptTarget.Latest, version, /*setNodeParents:*/ true);
|
||||
this.log("SyntaxTreeCache.Initialize: createSourceFile: " + (new Date().getTime() - start));
|
||||
}
|
||||
else if (this.currentFileVersion !== version) {
|
||||
var scriptSnapshot = this.hostCache.getScriptSnapshot(filename);
|
||||
var scriptSnapshot = this.hostCache.getScriptSnapshot(fileName);
|
||||
|
||||
var editRange = this.hostCache.getChangeRange(filename, this.currentFileVersion, this.currentSourceFile.scriptSnapshot);
|
||||
var editRange = this.hostCache.getChangeRange(fileName, this.currentFileVersion, this.currentSourceFile.scriptSnapshot);
|
||||
|
||||
var start = new Date().getTime();
|
||||
sourceFile = updateLanguageServiceSourceFile(this.currentSourceFile, scriptSnapshot, version, editRange);
|
||||
@@ -1580,18 +1599,18 @@ module ts {
|
||||
if (sourceFile) {
|
||||
// All done, ensure state is up to date
|
||||
this.currentFileVersion = version;
|
||||
this.currentFilename = filename;
|
||||
this.currentFileName = fileName;
|
||||
this.currentSourceFile = sourceFile;
|
||||
}
|
||||
}
|
||||
|
||||
public getCurrentSourceFile(filename: string): SourceFile {
|
||||
this.initialize(filename);
|
||||
public getCurrentSourceFile(fileName: string): SourceFile {
|
||||
this.initialize(fileName);
|
||||
return this.currentSourceFile;
|
||||
}
|
||||
|
||||
public getCurrentScriptSnapshot(filename: string): IScriptSnapshot {
|
||||
return this.getCurrentSourceFile(filename).scriptSnapshot;
|
||||
public getCurrentScriptSnapshot(fileName: string): IScriptSnapshot {
|
||||
return this.getCurrentSourceFile(fileName).scriptSnapshot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1600,8 +1619,8 @@ module ts {
|
||||
sourceFile.scriptSnapshot = scriptSnapshot;
|
||||
}
|
||||
|
||||
export function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile {
|
||||
var sourceFile = createSourceFile(filename, scriptSnapshot.getText(0, scriptSnapshot.getLength()), scriptTarget, setNodeParents);
|
||||
export function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile {
|
||||
var sourceFile = createSourceFile(fileName, scriptSnapshot.getText(0, scriptSnapshot.getLength()), scriptTarget, setNodeParents);
|
||||
setSourceFileFields(sourceFile, scriptSnapshot, version);
|
||||
// after full parsing we can use table with interned strings as name table
|
||||
sourceFile.nameTable = sourceFile.identifiers;
|
||||
@@ -1634,7 +1653,7 @@ module ts {
|
||||
if (version !== sourceFile.version) {
|
||||
// Once incremental parsing is ready, then just call into this function.
|
||||
if (!disableIncrementalParsing) {
|
||||
var newSourceFile = sourceFile.update(scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange);
|
||||
var newSourceFile = updateSourceFile(sourceFile, scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange);
|
||||
setSourceFileFields(newSourceFile, scriptSnapshot, version);
|
||||
// after incremental parsing nameTable might not be up-to-date
|
||||
// drop it so it can be lazily recreated later
|
||||
@@ -1645,7 +1664,7 @@ module ts {
|
||||
}
|
||||
|
||||
// Otherwise, just create a new source file.
|
||||
return createLanguageServiceSourceFile(sourceFile.filename, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true);
|
||||
return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true);
|
||||
}
|
||||
|
||||
export function createDocumentRegistry(): DocumentRegistry {
|
||||
@@ -1686,17 +1705,17 @@ module ts {
|
||||
}
|
||||
|
||||
function acquireDocument(
|
||||
filename: string,
|
||||
fileName: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string): SourceFile {
|
||||
|
||||
var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true);
|
||||
var entry = lookUp(bucket, filename);
|
||||
var entry = lookUp(bucket, fileName);
|
||||
if (!entry) {
|
||||
var sourceFile = createLanguageServiceSourceFile(filename, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false);
|
||||
var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false);
|
||||
|
||||
bucket[filename] = entry = {
|
||||
bucket[fileName] = entry = {
|
||||
sourceFile: sourceFile,
|
||||
refCount: 0,
|
||||
owners: []
|
||||
@@ -1709,7 +1728,7 @@ module ts {
|
||||
|
||||
function updateDocument(
|
||||
sourceFile: SourceFile,
|
||||
filename: string,
|
||||
fileName: string,
|
||||
compilationSettings: CompilerOptions,
|
||||
scriptSnapshot: IScriptSnapshot,
|
||||
version: string,
|
||||
@@ -1718,23 +1737,23 @@ module ts {
|
||||
|
||||
var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ false);
|
||||
Debug.assert(bucket !== undefined);
|
||||
var entry = lookUp(bucket, filename);
|
||||
var entry = lookUp(bucket, fileName);
|
||||
Debug.assert(entry !== undefined);
|
||||
|
||||
entry.sourceFile = updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, textChangeRange);
|
||||
return entry.sourceFile;
|
||||
}
|
||||
|
||||
function releaseDocument(filename: string, compilationSettings: CompilerOptions): void {
|
||||
function releaseDocument(fileName: string, compilationSettings: CompilerOptions): void {
|
||||
var bucket = getBucketForCompilationSettings(compilationSettings, false);
|
||||
Debug.assert(bucket !== undefined);
|
||||
|
||||
var entry = lookUp(bucket, filename);
|
||||
var entry = lookUp(bucket, fileName);
|
||||
entry.refCount--;
|
||||
|
||||
Debug.assert(entry.refCount >= 0);
|
||||
if (entry.refCount === 0) {
|
||||
delete bucket[filename];
|
||||
delete bucket[fileName];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1786,7 +1805,7 @@ module ts {
|
||||
var importPath = scanner.getTokenValue();
|
||||
var pos = scanner.getTokenPos();
|
||||
importedFiles.push({
|
||||
filename: importPath,
|
||||
fileName: importPath,
|
||||
pos: pos,
|
||||
end: pos + importPath.length
|
||||
});
|
||||
@@ -1979,7 +1998,7 @@ module ts {
|
||||
|
||||
// this checker is used to answer all LS questions except errors
|
||||
var typeInfoResolver: TypeChecker;
|
||||
var useCaseSensitivefilenames = false;
|
||||
var useCaseSensitivefileNames = false;
|
||||
var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
|
||||
var activeCompletionSession: CompletionSession; // The current active completion session, used to get the completion entry details
|
||||
|
||||
@@ -1994,14 +2013,14 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getCanonicalFileName(filename: string) {
|
||||
return useCaseSensitivefilenames ? filename : filename.toLowerCase();
|
||||
function getCanonicalFileName(fileName: string) {
|
||||
return useCaseSensitivefileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
|
||||
function getValidSourceFile(filename: string): SourceFile {
|
||||
var sourceFile = program.getSourceFile(getCanonicalFileName(filename));
|
||||
function getValidSourceFile(fileName: string): SourceFile {
|
||||
var sourceFile = program.getSourceFile(getCanonicalFileName(fileName));
|
||||
if (!sourceFile) {
|
||||
throw new Error("Could not find file: '" + filename + "'.");
|
||||
throw new Error("Could not find file: '" + fileName + "'.");
|
||||
}
|
||||
return sourceFile;
|
||||
}
|
||||
@@ -2034,14 +2053,14 @@ module ts {
|
||||
var changesInCompilationSettingsAffectSyntax = oldSettings && oldSettings.target !== newSettings.target;
|
||||
|
||||
// Now create a new compiler
|
||||
var newProgram = createProgram(hostCache.getRootFilenames(), newSettings, {
|
||||
var newProgram = createProgram(hostCache.getRootFileNames(), newSettings, {
|
||||
getSourceFile: getOrCreateSourceFile,
|
||||
getCancellationToken: () => cancellationToken,
|
||||
getCanonicalFileName: (filename) => useCaseSensitivefilenames ? filename : filename.toLowerCase(),
|
||||
useCaseSensitiveFileNames: () => useCaseSensitivefilenames,
|
||||
getCanonicalFileName: (fileName) => useCaseSensitivefileNames ? fileName : fileName.toLowerCase(),
|
||||
useCaseSensitiveFileNames: () => useCaseSensitivefileNames,
|
||||
getNewLine: () => host.getNewLine ? host.getNewLine() : "\r\n",
|
||||
getDefaultLibFilename: (options) => host.getDefaultLibFilename(options),
|
||||
writeFile: (filename, data, writeByteOrderMark) => { },
|
||||
getDefaultLibFileName: (options) => host.getDefaultLibFileName(options),
|
||||
writeFile: (fileName, data, writeByteOrderMark) => { },
|
||||
getCurrentDirectory: () => host.getCurrentDirectory()
|
||||
});
|
||||
|
||||
@@ -2050,9 +2069,9 @@ module ts {
|
||||
if (program) {
|
||||
var oldSourceFiles = program.getSourceFiles();
|
||||
for (var i = 0, n = oldSourceFiles.length; i < n; i++) {
|
||||
var filename = oldSourceFiles[i].filename;
|
||||
if (!newProgram.getSourceFile(filename) || changesInCompilationSettingsAffectSyntax) {
|
||||
documentRegistry.releaseDocument(filename, oldSettings);
|
||||
var fileName = oldSourceFiles[i].fileName;
|
||||
if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) {
|
||||
documentRegistry.releaseDocument(fileName, oldSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2062,13 +2081,13 @@ module ts {
|
||||
|
||||
return;
|
||||
|
||||
function getOrCreateSourceFile(filename: string): SourceFile {
|
||||
function getOrCreateSourceFile(fileName: string): SourceFile {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
// The program is asking for this file, check first if the host can locate it.
|
||||
// If the host can not locate the file, then it does not exist. return undefined
|
||||
// to the program to allow reporting of errors for missing files.
|
||||
var hostFileInformation = hostCache.getOrCreateEntry(filename);
|
||||
var hostFileInformation = hostCache.getOrCreateEntry(fileName);
|
||||
if (!hostFileInformation) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -2079,7 +2098,7 @@ module ts {
|
||||
if (!changesInCompilationSettingsAffectSyntax) {
|
||||
|
||||
// Check if the old program had this file already
|
||||
var oldSourceFile = program && program.getSourceFile(filename);
|
||||
var oldSourceFile = program && program.getSourceFile(fileName);
|
||||
if (oldSourceFile) {
|
||||
// This SourceFile is safe to reuse, return it
|
||||
if (sourceFileUpToDate(oldSourceFile)) {
|
||||
@@ -2087,17 +2106,17 @@ module ts {
|
||||
}
|
||||
|
||||
// We have an older version of the sourceFile, incrementally parse the changes
|
||||
var textChangeRange = hostCache.getChangeRange(filename, oldSourceFile.version, oldSourceFile.scriptSnapshot);
|
||||
return documentRegistry.updateDocument(oldSourceFile, filename, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, textChangeRange);
|
||||
var textChangeRange = hostCache.getChangeRange(fileName, oldSourceFile.version, oldSourceFile.scriptSnapshot);
|
||||
return documentRegistry.updateDocument(oldSourceFile, fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version, textChangeRange);
|
||||
}
|
||||
}
|
||||
|
||||
// Could not find this file in the old program, create a new SourceFile for it.
|
||||
return documentRegistry.acquireDocument(filename, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version);
|
||||
return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version);
|
||||
}
|
||||
|
||||
function sourceFileUpToDate(sourceFile: SourceFile): boolean {
|
||||
return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.filename);
|
||||
return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName);
|
||||
}
|
||||
|
||||
function programUpToDate(): boolean {
|
||||
@@ -2107,14 +2126,14 @@ module ts {
|
||||
}
|
||||
|
||||
// If number of files in the program do not match, it is not up-to-date
|
||||
var rootFilenames = hostCache.getRootFilenames();
|
||||
if (program.getSourceFiles().length !== rootFilenames.length) {
|
||||
var rootFileNames = hostCache.getRootFileNames();
|
||||
if (program.getSourceFiles().length !== rootFileNames.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If any file is not up-to-date, then the whole program is not up-to-date
|
||||
for (var i = 0, n = rootFilenames.length; i < n; i++) {
|
||||
if (!sourceFileUpToDate(program.getSourceFile(rootFilenames[i]))) {
|
||||
for (var i = 0, n = rootFileNames.length; i < n; i++) {
|
||||
if (!sourceFileUpToDate(program.getSourceFile(rootFileNames[i]))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2144,30 +2163,30 @@ module ts {
|
||||
function dispose(): void {
|
||||
if (program) {
|
||||
forEach(program.getSourceFiles(),
|
||||
(f) => { documentRegistry.releaseDocument(f.filename, program.getCompilerOptions()); });
|
||||
(f) => { documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); });
|
||||
}
|
||||
}
|
||||
|
||||
/// Diagnostics
|
||||
function getSyntacticDiagnostics(filename: string) {
|
||||
function getSyntacticDiagnostics(fileName: string) {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = normalizeSlashes(filename);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
return program.getDiagnostics(getValidSourceFile(filename));
|
||||
return program.getDiagnostics(getValidSourceFile(fileName));
|
||||
}
|
||||
|
||||
/**
|
||||
* getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors
|
||||
* If '-d' enabled, report both semantic and emitter errors
|
||||
*/
|
||||
function getSemanticDiagnostics(filename: string) {
|
||||
function getSemanticDiagnostics(fileName: string) {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = normalizeSlashes(filename)
|
||||
fileName = normalizeSlashes(fileName)
|
||||
var compilerOptions = program.getCompilerOptions();
|
||||
var checker = getDiagnosticsProducingTypeChecker();
|
||||
var targetSourceFile = getValidSourceFile(filename);
|
||||
var targetSourceFile = getValidSourceFile(fileName);
|
||||
|
||||
// Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file.
|
||||
// Therefore only get diagnostics for given file.
|
||||
@@ -2238,13 +2257,13 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
function getCompletionsAtPosition(filename: string, position: number) {
|
||||
function getCompletionsAtPosition(fileName: string, position: number) {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = normalizeSlashes(filename);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var syntacticStart = new Date().getTime();
|
||||
var sourceFile = getValidSourceFile(filename);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var start = new Date().getTime();
|
||||
var currentToken = getTokenAtPosition(sourceFile, position);
|
||||
@@ -2299,7 +2318,7 @@ module ts {
|
||||
|
||||
// Clear the current activeCompletionSession for this session
|
||||
activeCompletionSession = {
|
||||
filename: filename,
|
||||
fileName: fileName,
|
||||
position: position,
|
||||
entries: [],
|
||||
symbols: {},
|
||||
@@ -2637,17 +2656,17 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getCompletionEntryDetails(filename: string, position: number, entryName: string): CompletionEntryDetails {
|
||||
function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails {
|
||||
// Note: No need to call synchronizeHostData, as we have captured all the data we need
|
||||
// in the getCompletionsAtPosition earlier
|
||||
filename = normalizeSlashes(filename);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var sourceFile = getValidSourceFile(filename);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var session = activeCompletionSession;
|
||||
|
||||
// Ensure that the current active completion session is still valid for this request
|
||||
if (!session || session.filename !== filename || session.position !== position) {
|
||||
if (!session || session.fileName !== fileName || session.position !== position) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -2660,7 +2679,7 @@ module ts {
|
||||
// passing the meaning for the node so that we don't report that a suggestion for a value is an interface.
|
||||
// We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration.
|
||||
Debug.assert(session.typeChecker.getTypeOfSymbolAtLocation(symbol, location) !== undefined, "Could not find type for symbol");
|
||||
var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(filename), location, session.typeChecker, location, SemanticMeaning.All);
|
||||
var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, session.typeChecker, location, SemanticMeaning.All);
|
||||
return {
|
||||
name: entryName,
|
||||
kind: displayPartsDocumentationsAndSymbolKind.symbolKind,
|
||||
@@ -3203,11 +3222,11 @@ module ts {
|
||||
}
|
||||
|
||||
/// Goto definition
|
||||
function getDefinitionAtPosition(filename: string, position: number): DefinitionInfo[] {
|
||||
function getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = normalizeSlashes(filename);
|
||||
var sourceFile = getValidSourceFile(filename);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
@@ -3227,10 +3246,10 @@ module ts {
|
||||
var referenceFile = tryResolveScriptReference(program, sourceFile, comment);
|
||||
if (referenceFile) {
|
||||
return [{
|
||||
fileName: referenceFile.filename,
|
||||
fileName: referenceFile.fileName,
|
||||
textSpan: createTextSpanFromBounds(0, 0),
|
||||
kind: ScriptElementKind.scriptElement,
|
||||
name: comment.filename,
|
||||
name: comment.fileName,
|
||||
containerName: undefined,
|
||||
containerKind: undefined
|
||||
}];
|
||||
@@ -3283,7 +3302,7 @@ module ts {
|
||||
|
||||
function getDefinitionInfo(node: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo {
|
||||
return {
|
||||
fileName: node.getSourceFile().filename,
|
||||
fileName: node.getSourceFile().fileName,
|
||||
textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()),
|
||||
kind: symbolKind,
|
||||
name: symbolName,
|
||||
@@ -3339,11 +3358,11 @@ module ts {
|
||||
}
|
||||
|
||||
/// References and Occurrences
|
||||
function getOccurrencesAtPosition(filename: string, position: number): ReferenceEntry[] {
|
||||
function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = normalizeSlashes(filename);
|
||||
var sourceFile = getValidSourceFile(filename);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
if (!node) {
|
||||
@@ -3478,7 +3497,7 @@ module ts {
|
||||
|
||||
if (shouldHighlightNextKeyword) {
|
||||
result.push({
|
||||
fileName: filename,
|
||||
fileName: fileName,
|
||||
textSpan: createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end),
|
||||
isWriteAccess: false
|
||||
});
|
||||
@@ -4206,7 +4225,7 @@ module ts {
|
||||
if ((findInStrings && isInString(position)) ||
|
||||
(findInComments && isInComment(position))) {
|
||||
result.push({
|
||||
fileName: sourceFile.filename,
|
||||
fileName: sourceFile.fileName,
|
||||
textSpan: createTextSpan(position, searchText.length),
|
||||
isWriteAccess: false
|
||||
});
|
||||
@@ -4591,7 +4610,7 @@ module ts {
|
||||
}
|
||||
|
||||
return {
|
||||
fileName: node.getSourceFile().filename,
|
||||
fileName: node.getSourceFile().fileName,
|
||||
textSpan: createTextSpanFromBounds(start, end),
|
||||
isWriteAccess: isWriteAccess(node)
|
||||
};
|
||||
@@ -4633,7 +4652,7 @@ module ts {
|
||||
forEach(program.getSourceFiles(), sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
var filename = sourceFile.filename;
|
||||
var fileName = sourceFile.fileName;
|
||||
var declarations = sourceFile.getNamedDeclarations();
|
||||
for (var i = 0, n = declarations.length; i < n; i++) {
|
||||
var declaration = declarations[i];
|
||||
@@ -4647,7 +4666,7 @@ module ts {
|
||||
kind: getNodeKind(declaration),
|
||||
kindModifiers: getNodeModifiers(declaration),
|
||||
matchKind: MatchKind[matchKind],
|
||||
fileName: filename,
|
||||
fileName: fileName,
|
||||
textSpan: createTextSpanFromBounds(declaration.getStart(), declaration.getEnd()),
|
||||
// TODO(jfreeman): What should be the containerName when the container has a computed name?
|
||||
containerName: container && container.name ? (<Identifier>container.name).text : "",
|
||||
@@ -4707,17 +4726,17 @@ module ts {
|
||||
return forEach(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
|
||||
}
|
||||
|
||||
function getEmitOutput(filename: string): EmitOutput {
|
||||
function getEmitOutput(fileName: string): EmitOutput {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = normalizeSlashes(filename);
|
||||
var sourceFile = getValidSourceFile(filename);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
var outputFiles: OutputFile[] = [];
|
||||
|
||||
function writeFile(filename: string, data: string, writeByteOrderMark: boolean) {
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
outputFiles.push({
|
||||
name: filename,
|
||||
name: fileName,
|
||||
writeByteOrderMark: writeByteOrderMark,
|
||||
text: data
|
||||
});
|
||||
@@ -4866,16 +4885,16 @@ module ts {
|
||||
}
|
||||
|
||||
/// Syntactic features
|
||||
function getCurrentSourceFile(filename: string): SourceFile {
|
||||
filename = normalizeSlashes(filename);
|
||||
var currentSourceFile = syntaxTreeCache.getCurrentSourceFile(filename);
|
||||
function getCurrentSourceFile(fileName: string): SourceFile {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var currentSourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
return currentSourceFile;
|
||||
}
|
||||
|
||||
function getNameOrDottedNameSpan(filename: string, startPos: number, endPos: number): TextSpan {
|
||||
filename = ts.normalizeSlashes(filename);
|
||||
function getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
|
||||
fileName = ts.normalizeSlashes(fileName);
|
||||
// Get node at the location
|
||||
var node = getTouchingPropertyName(getCurrentSourceFile(filename), startPos);
|
||||
var node = getTouchingPropertyName(getCurrentSourceFile(fileName), startPos);
|
||||
|
||||
if (!node) {
|
||||
return;
|
||||
@@ -4927,16 +4946,16 @@ module ts {
|
||||
return createTextSpanFromBounds(nodeForStartPos.getStart(), node.getEnd());
|
||||
}
|
||||
|
||||
function getBreakpointStatementAtPosition(filename: string, position: number) {
|
||||
function getBreakpointStatementAtPosition(fileName: string, position: number) {
|
||||
// doesn't use compiler - no need to synchronize with host
|
||||
filename = ts.normalizeSlashes(filename);
|
||||
return BreakpointResolver.spanInSourceFileAtLocation(getCurrentSourceFile(filename), position);
|
||||
fileName = ts.normalizeSlashes(fileName);
|
||||
return BreakpointResolver.spanInSourceFileAtLocation(getCurrentSourceFile(fileName), position);
|
||||
}
|
||||
|
||||
function getNavigationBarItems(filename: string): NavigationBarItem[] {
|
||||
filename = normalizeSlashes(filename);
|
||||
function getNavigationBarItems(fileName: string): NavigationBarItem[] {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
return NavigationBar.getNavigationBarItems(getCurrentSourceFile(filename));
|
||||
return NavigationBar.getNavigationBarItems(getCurrentSourceFile(fileName));
|
||||
}
|
||||
|
||||
function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
@@ -5232,15 +5251,15 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getOutliningSpans(filename: string): OutliningSpan[] {
|
||||
function getOutliningSpans(fileName: string): OutliningSpan[] {
|
||||
// doesn't use compiler - no need to synchronize with host
|
||||
filename = normalizeSlashes(filename);
|
||||
var sourceFile = getCurrentSourceFile(filename);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
return OutliningElementsCollector.collectElements(sourceFile);
|
||||
}
|
||||
|
||||
function getBraceMatchingAtPosition(filename: string, position: number) {
|
||||
var sourceFile = getCurrentSourceFile(filename);
|
||||
function getBraceMatchingAtPosition(fileName: string, position: number) {
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
var result: TextSpan[] = [];
|
||||
|
||||
var token = getTouchingToken(sourceFile, position);
|
||||
@@ -5292,11 +5311,11 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getIndentationAtPosition(filename: string, position: number, editorOptions: EditorOptions) {
|
||||
filename = normalizeSlashes(filename);
|
||||
function getIndentationAtPosition(fileName: string, position: number, editorOptions: EditorOptions) {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var start = new Date().getTime();
|
||||
var sourceFile = getCurrentSourceFile(filename);
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
log("getIndentationAtPosition: getCurrentSourceFile: " + (new Date().getTime() - start));
|
||||
|
||||
var start = new Date().getTime();
|
||||
@@ -5338,7 +5357,7 @@ module ts {
|
||||
return [];
|
||||
}
|
||||
|
||||
function getTodoComments(filename: string, descriptors: TodoCommentDescriptor[]): TodoComment[] {
|
||||
function getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] {
|
||||
// Note: while getting todo comments seems like a syntactic operation, we actually
|
||||
// treat it as a semantic operation here. This is because we expect our host to call
|
||||
// this on every single file. If we treat this syntactically, then that will cause
|
||||
@@ -5347,9 +5366,9 @@ module ts {
|
||||
// anything away.
|
||||
synchronizeHostData();
|
||||
|
||||
filename = normalizeSlashes(filename);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var sourceFile = getValidSourceFile(filename);
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
@@ -5890,7 +5909,7 @@ module ts {
|
||||
export function getDefaultLibFilePath(options: CompilerOptions): string {
|
||||
// Check __dirname is defined and that we are on a node.js system.
|
||||
if (typeof __dirname !== "undefined") {
|
||||
return __dirname + directorySeparator + getDefaultLibFilename(options);
|
||||
return __dirname + directorySeparator + getDefaultLibFileName(options);
|
||||
}
|
||||
|
||||
throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. ");
|
||||
|
||||
@@ -51,7 +51,7 @@ module ts {
|
||||
getLocalizedDiagnosticMessages(): string;
|
||||
getCancellationToken(): CancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDefaultLibFilename(options: string): string;
|
||||
getDefaultLibFileName(options: string): string;
|
||||
}
|
||||
|
||||
///
|
||||
@@ -264,8 +264,8 @@ module ts {
|
||||
return this.shimHost.getCurrentDirectory();
|
||||
}
|
||||
|
||||
public getDefaultLibFilename(options: CompilerOptions): string {
|
||||
return this.shimHost.getDefaultLibFilename(JSON.stringify(options));
|
||||
public getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,7 +701,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
|
||||
});
|
||||
@@ -709,7 +709,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
|
||||
});
|
||||
|
||||
@@ -13,9 +13,9 @@ declare var console: any;
|
||||
|
||||
import ts = require("typescript");
|
||||
|
||||
export function compile(filenames: string[], options: ts.CompilerOptions): void {
|
||||
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
|
||||
var host = ts.createCompilerHost(options);
|
||||
var program = ts.createProgram(filenames, options, host);
|
||||
var program = ts.createProgram(fileNames, options, host);
|
||||
var checker = ts.createTypeChecker(program, /*produceDiagnostics*/ true);
|
||||
var result = program.emitFiles();
|
||||
|
||||
@@ -25,7 +25,7 @@ export function compile(filenames: string[], options: ts.CompilerOptions): void
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(`${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
});
|
||||
|
||||
console.log(`Process exiting with code '${result.emitResultStatus}'.`);
|
||||
@@ -715,7 +715,7 @@ declare module "typescript" {
|
||||
exportName: Identifier;
|
||||
}
|
||||
interface FileReference extends TextRange {
|
||||
filename: string;
|
||||
fileName: string;
|
||||
}
|
||||
interface CommentRange extends TextRange {
|
||||
hasTrailingNewLine?: boolean;
|
||||
@@ -723,30 +723,19 @@ declare module "typescript" {
|
||||
interface SourceFile extends Declaration {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
endOfFileToken: Node;
|
||||
filename: string;
|
||||
fileName: string;
|
||||
text: string;
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getLineStarts(): number[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
amdDependencies: string[];
|
||||
amdModuleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
parseDiagnostics: Diagnostic[];
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
hasNoDefaultLib: boolean;
|
||||
externalModuleIndicator: Node;
|
||||
nodeCount: number;
|
||||
identifierCount: number;
|
||||
symbolCount: number;
|
||||
languageVersion: ScriptTarget;
|
||||
identifiers: Map<string>;
|
||||
}
|
||||
interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface Program extends ScriptReferenceHost {
|
||||
@@ -796,7 +785,7 @@ declare module "typescript" {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getCompilerHost(): CompilerHost;
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
}
|
||||
interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
@@ -1189,6 +1178,7 @@ declare module "typescript" {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
@@ -1208,7 +1198,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
filenames: string[];
|
||||
fileNames: string[];
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
interface CommandLineOption {
|
||||
@@ -1219,6 +1209,7 @@ declare module "typescript" {
|
||||
description?: DiagnosticMessage;
|
||||
paramType?: DiagnosticMessage;
|
||||
error?: DiagnosticMessage;
|
||||
experimental?: boolean;
|
||||
}
|
||||
const enum CharacterCodes {
|
||||
nullCharacter = 0,
|
||||
@@ -1349,10 +1340,10 @@ declare module "typescript" {
|
||||
isCancellationRequested(): boolean;
|
||||
}
|
||||
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(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
@@ -1393,15 +1384,14 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
character: number;
|
||||
};
|
||||
function positionToLineAndCharacter(text: string, pos: number): {
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
character: number;
|
||||
};
|
||||
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
||||
function isWhiteSpace(ch: number): boolean;
|
||||
function isLineBreak(ch: number): boolean;
|
||||
function isOctalDigit(ch: number): boolean;
|
||||
@@ -1417,8 +1407,10 @@ declare module "typescript" {
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function isLeftHandSideExpression(expr: Expression): boolean;
|
||||
function isAssignmentOperator(token: SyntaxKind): boolean;
|
||||
}
|
||||
@@ -1476,6 +1468,11 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
@@ -1513,7 +1510,7 @@ declare module "typescript" {
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
log?(s: string): void;
|
||||
trace?(s: string): void;
|
||||
error?(s: string): void;
|
||||
@@ -1547,7 +1544,7 @@ declare module "typescript" {
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
|
||||
getEmitOutput(fileName: string): EmitOutput;
|
||||
getProgram(): Program;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
dispose(): void;
|
||||
}
|
||||
interface ClassifiedSpan {
|
||||
@@ -1784,11 +1781,11 @@ declare module "typescript" {
|
||||
*/
|
||||
interface DocumentRegistry {
|
||||
/**
|
||||
* Request a stored SourceFile with a given filename and compilationSettings.
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -1797,9 +1794,9 @@ declare module "typescript" {
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given filename
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
@@ -1807,7 +1804,7 @@ declare module "typescript" {
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -1818,17 +1815,17 @@ declare module "typescript" {
|
||||
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
||||
* was not found in the registry and a new one was created.
|
||||
*/
|
||||
updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param filename The name of the file to be released
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(filename: string, compilationSettings: CompilerOptions): void;
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
}
|
||||
class ScriptElementKind {
|
||||
static unknown: string;
|
||||
@@ -1899,7 +1896,7 @@ declare module "typescript" {
|
||||
isCancellationRequested(): boolean;
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
var disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function createDocumentRegistry(): DocumentRegistry;
|
||||
@@ -1922,15 +1919,15 @@ declare module "typescript" {
|
||||
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
||||
*/
|
||||
var ts = require("typescript");
|
||||
function compile(filenames, options) {
|
||||
function compile(fileNames, options) {
|
||||
var host = ts.createCompilerHost(options);
|
||||
var program = ts.createProgram(filenames, options, host);
|
||||
var program = ts.createProgram(fileNames, options, host);
|
||||
var checker = ts.createTypeChecker(program, true);
|
||||
var result = program.emitFiles();
|
||||
var allDiagnostics = program.getDiagnostics().concat(checker.getDiagnostics()).concat(result.diagnostics);
|
||||
allDiagnostics.forEach(function (diagnostic) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(diagnostic.file.filename + " (" + lineChar.line + "," + lineChar.character + "): " + diagnostic.messageText);
|
||||
console.log(diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + diagnostic.messageText);
|
||||
});
|
||||
console.log("Process exiting with code '" + result.emitResultStatus + "'.");
|
||||
process.exit(result.emitResultStatus);
|
||||
|
||||
@@ -15,9 +15,9 @@ declare var console: any;
|
||||
import ts = require("typescript");
|
||||
>ts : typeof ts
|
||||
|
||||
export function compile(filenames: string[], options: ts.CompilerOptions): void {
|
||||
>compile : (filenames: string[], options: ts.CompilerOptions) => void
|
||||
>filenames : string[]
|
||||
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
|
||||
>compile : (fileNames: string[], options: ts.CompilerOptions) => void
|
||||
>fileNames : string[]
|
||||
>options : ts.CompilerOptions
|
||||
>ts : unknown
|
||||
>CompilerOptions : ts.CompilerOptions
|
||||
@@ -30,13 +30,13 @@ export function compile(filenames: string[], options: ts.CompilerOptions): void
|
||||
>createCompilerHost : (options: ts.CompilerOptions) => ts.CompilerHost
|
||||
>options : ts.CompilerOptions
|
||||
|
||||
var program = ts.createProgram(filenames, options, host);
|
||||
var program = ts.createProgram(fileNames, options, host);
|
||||
>program : ts.Program
|
||||
>ts.createProgram(filenames, options, host) : ts.Program
|
||||
>ts.createProgram(fileNames, options, host) : ts.Program
|
||||
>ts.createProgram : (rootNames: string[], options: ts.CompilerOptions, host: ts.CompilerHost) => ts.Program
|
||||
>ts : typeof ts
|
||||
>createProgram : (rootNames: string[], options: ts.CompilerOptions, host: ts.CompilerHost) => ts.Program
|
||||
>filenames : string[]
|
||||
>fileNames : string[]
|
||||
>options : ts.CompilerOptions
|
||||
>host : ts.CompilerHost
|
||||
|
||||
@@ -80,35 +80,35 @@ export function compile(filenames: string[], options: ts.CompilerOptions): void
|
||||
>diagnostics : ts.Diagnostic[]
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
>allDiagnostics.forEach(diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`); }) : void
|
||||
>allDiagnostics.forEach(diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`); }) : void
|
||||
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>allDiagnostics : ts.Diagnostic[]
|
||||
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`); } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`); } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic : ts.Diagnostic
|
||||
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition : (position: number) => ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.file : ts.SourceFile
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (position: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.start : number
|
||||
>diagnostic : ts.Diagnostic
|
||||
>start : number
|
||||
|
||||
console.log(`${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
>console.log(`${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`) : any
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
>console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
>diagnostic.file.filename : string
|
||||
>diagnostic.file.fileName : string
|
||||
>diagnostic.file : ts.SourceFile
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>lineChar.line : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>line : number
|
||||
@@ -142,7 +142,7 @@ export function compile(filenames: string[], options: ts.CompilerOptions): void
|
||||
|
||||
compile(process.argv.slice(2), {
|
||||
>compile(process.argv.slice(2), { noEmitOnError: true, noImplicitAny: true, target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS}) : void
|
||||
>compile : (filenames: string[], options: ts.CompilerOptions) => void
|
||||
>compile : (fileNames: string[], options: ts.CompilerOptions) => void
|
||||
>process.argv.slice(2) : any
|
||||
>process.argv.slice : any
|
||||
>process.argv : any
|
||||
@@ -2180,8 +2180,8 @@ declare module "typescript" {
|
||||
>FileReference : FileReference
|
||||
>TextRange : TextRange
|
||||
|
||||
filename: string;
|
||||
>filename : string
|
||||
fileName: string;
|
||||
>fileName : string
|
||||
}
|
||||
interface CommentRange extends TextRange {
|
||||
>CommentRange : CommentRange
|
||||
@@ -2203,32 +2203,12 @@ declare module "typescript" {
|
||||
>endOfFileToken : Node
|
||||
>Node : Node
|
||||
|
||||
filename: string;
|
||||
>filename : string
|
||||
fileName: string;
|
||||
>fileName : string
|
||||
|
||||
text: string;
|
||||
>text : string
|
||||
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (position: number) => LineAndCharacter
|
||||
>position : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
|
||||
amdDependencies: string[];
|
||||
>amdDependencies : string[]
|
||||
|
||||
@@ -2239,22 +2219,6 @@ declare module "typescript" {
|
||||
>referencedFiles : FileReference[]
|
||||
>FileReference : FileReference
|
||||
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
>referenceDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
parseDiagnostics: Diagnostic[];
|
||||
>parseDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
>semanticDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
hasNoDefaultLib: boolean;
|
||||
>hasNoDefaultLib : boolean
|
||||
|
||||
@@ -2262,15 +2226,6 @@ declare module "typescript" {
|
||||
>externalModuleIndicator : Node
|
||||
>Node : Node
|
||||
|
||||
nodeCount: number;
|
||||
>nodeCount : number
|
||||
|
||||
identifierCount: number;
|
||||
>identifierCount : number
|
||||
|
||||
symbolCount: number;
|
||||
>symbolCount : number
|
||||
|
||||
languageVersion: ScriptTarget;
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
@@ -2286,9 +2241,9 @@ declare module "typescript" {
|
||||
>getCompilerOptions : () => CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getCurrentDirectory(): string;
|
||||
@@ -2444,9 +2399,9 @@ declare module "typescript" {
|
||||
>getSourceFiles : () => SourceFile[]
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
}
|
||||
interface TypeChecker {
|
||||
@@ -3835,6 +3790,9 @@ declare module "typescript" {
|
||||
watch?: boolean;
|
||||
>watch : boolean
|
||||
|
||||
stripInternal?: boolean;
|
||||
>stripInternal : boolean
|
||||
|
||||
[option: string]: string | number | boolean;
|
||||
>option : string
|
||||
}
|
||||
@@ -3881,8 +3839,8 @@ declare module "typescript" {
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
filenames: string[];
|
||||
>filenames : string[]
|
||||
fileNames: string[];
|
||||
>fileNames : string[]
|
||||
|
||||
errors: Diagnostic[];
|
||||
>errors : Diagnostic[]
|
||||
@@ -3915,6 +3873,9 @@ declare module "typescript" {
|
||||
error?: DiagnosticMessage;
|
||||
>error : DiagnosticMessage
|
||||
>DiagnosticMessage : DiagnosticMessage
|
||||
|
||||
experimental?: boolean;
|
||||
>experimental : boolean
|
||||
}
|
||||
const enum CharacterCodes {
|
||||
>CharacterCodes : CharacterCodes
|
||||
@@ -4297,17 +4258,17 @@ declare module "typescript" {
|
||||
interface CompilerHost {
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
>getSourceFile : (filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
>getSourceFile : (fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) => SourceFile
|
||||
>fileName : string
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
>onError : (message: string) => void
|
||||
>message : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
>getDefaultLibFilename : (options: CompilerOptions) => string
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
>getDefaultLibFileName : (options: CompilerOptions) => string
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
@@ -4315,9 +4276,9 @@ declare module "typescript" {
|
||||
>getCancellationToken : () => CancellationToken
|
||||
>CancellationToken : CancellationToken
|
||||
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
>writeFile : (filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) => void
|
||||
>filename : string
|
||||
writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
>writeFile : (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) => void
|
||||
>fileName : string
|
||||
>data : string
|
||||
>writeByteOrderMark : boolean
|
||||
>onError : (message: string) => void
|
||||
@@ -4446,14 +4407,26 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function getLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
>getLineAndCharacterOfPosition : (lineStarts: number[], position: number) => { line: number; character: number; }
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
>getLineStarts : (sourceFile: SourceFile) => number[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
>computeLineAndCharacterOfPosition : (lineStarts: number[], position: number) => { line: number; character: number; }
|
||||
>lineStarts : number[]
|
||||
>position : number
|
||||
|
||||
@@ -4464,18 +4437,13 @@ declare module "typescript" {
|
||||
>character : number
|
||||
|
||||
};
|
||||
function positionToLineAndCharacter(text: string, pos: number): {
|
||||
>positionToLineAndCharacter : (text: string, pos: number) => { line: number; character: number; }
|
||||
>text : string
|
||||
>pos : number
|
||||
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (sourceFile: SourceFile, position: number) => LineAndCharacter
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>position : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
line: number;
|
||||
>line : number
|
||||
|
||||
character: number;
|
||||
>character : number
|
||||
|
||||
};
|
||||
function isWhiteSpace(ch: number): boolean;
|
||||
>isWhiteSpace : (ch: number) => boolean
|
||||
>ch : number
|
||||
@@ -4562,14 +4530,29 @@ declare module "typescript" {
|
||||
>SyntaxKind : SyntaxKind
|
||||
>NodeFlags : NodeFlags
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateSourceFile : (sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
>isEvalOrArgumentsIdentifier : (node: Node) => boolean
|
||||
>node : Node
|
||||
>Node : Node
|
||||
|
||||
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
>createSourceFile : (filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean) => SourceFile
|
||||
>filename : string
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean) => SourceFile
|
||||
>fileName : string
|
||||
>sourceText : string
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
@@ -4783,6 +4766,30 @@ declare module "typescript" {
|
||||
getNamedDeclarations(): Declaration[];
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
}
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
@@ -4869,8 +4876,8 @@ declare module "typescript" {
|
||||
getCurrentDirectory(): string;
|
||||
>getCurrentDirectory : () => string
|
||||
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
>getDefaultLibFilename : (options: CompilerOptions) => string
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
>getDefaultLibFileName : (options: CompilerOptions) => string
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
@@ -5059,9 +5066,9 @@ declare module "typescript" {
|
||||
>getProgram : () => Program
|
||||
>Program : Program
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
dispose(): void;
|
||||
@@ -5651,11 +5658,11 @@ declare module "typescript" {
|
||||
>DocumentRegistry : DocumentRegistry
|
||||
|
||||
/**
|
||||
* Request a stored SourceFile with a given filename and compilationSettings.
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -5664,9 +5671,9 @@ declare module "typescript" {
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
>acquireDocument : (filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile
|
||||
>filename : string
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
>acquireDocument : (fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
@@ -5675,7 +5682,7 @@ declare module "typescript" {
|
||||
>SourceFile : SourceFile
|
||||
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given filename
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
@@ -5683,7 +5690,7 @@ declare module "typescript" {
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -5694,11 +5701,11 @@ declare module "typescript" {
|
||||
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
||||
* was not found in the registry and a new one was created.
|
||||
*/
|
||||
updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateDocument : (sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateDocument : (sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
@@ -5714,12 +5721,12 @@ declare module "typescript" {
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param filename The name of the file to be released
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(filename: string, compilationSettings: CompilerOptions): void;
|
||||
>releaseDocument : (filename: string, compilationSettings: CompilerOptions) => void
|
||||
>filename : string
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
>releaseDocument : (fileName: string, compilationSettings: CompilerOptions) => void
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
}
|
||||
@@ -5919,9 +5926,9 @@ declare module "typescript" {
|
||||
throwIfCancellationRequested(): void;
|
||||
>throwIfCancellationRequested : () => void
|
||||
}
|
||||
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
>createLanguageServiceSourceFile : (filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile
|
||||
>filename : string
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
>createLanguageServiceSourceFile : (fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile
|
||||
>fileName : string
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
>IScriptSnapshot : IScriptSnapshot
|
||||
>scriptTarget : ScriptTarget
|
||||
|
||||
@@ -52,14 +52,14 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
|
||||
function report(node: ts.Node, message: string) {
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
console.log(`${sourceFile.filename} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
}
|
||||
}
|
||||
|
||||
var filenames = process.argv.slice(2);
|
||||
filenames.forEach(filename => {
|
||||
var fileNames = process.argv.slice(2);
|
||||
fileNames.forEach(fileName => {
|
||||
// Parse a file
|
||||
var sourceFile = ts.createSourceFile(filename, fs.readFileSync(filename).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
|
||||
var sourceFile = ts.createSourceFile(fileName, fs.readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
|
||||
|
||||
// delint it
|
||||
delint(sourceFile);
|
||||
@@ -744,7 +744,7 @@ declare module "typescript" {
|
||||
exportName: Identifier;
|
||||
}
|
||||
interface FileReference extends TextRange {
|
||||
filename: string;
|
||||
fileName: string;
|
||||
}
|
||||
interface CommentRange extends TextRange {
|
||||
hasTrailingNewLine?: boolean;
|
||||
@@ -752,30 +752,19 @@ declare module "typescript" {
|
||||
interface SourceFile extends Declaration {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
endOfFileToken: Node;
|
||||
filename: string;
|
||||
fileName: string;
|
||||
text: string;
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getLineStarts(): number[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
amdDependencies: string[];
|
||||
amdModuleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
parseDiagnostics: Diagnostic[];
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
hasNoDefaultLib: boolean;
|
||||
externalModuleIndicator: Node;
|
||||
nodeCount: number;
|
||||
identifierCount: number;
|
||||
symbolCount: number;
|
||||
languageVersion: ScriptTarget;
|
||||
identifiers: Map<string>;
|
||||
}
|
||||
interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface Program extends ScriptReferenceHost {
|
||||
@@ -825,7 +814,7 @@ declare module "typescript" {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getCompilerHost(): CompilerHost;
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
}
|
||||
interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
@@ -1218,6 +1207,7 @@ declare module "typescript" {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
@@ -1237,7 +1227,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
filenames: string[];
|
||||
fileNames: string[];
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
interface CommandLineOption {
|
||||
@@ -1248,6 +1238,7 @@ declare module "typescript" {
|
||||
description?: DiagnosticMessage;
|
||||
paramType?: DiagnosticMessage;
|
||||
error?: DiagnosticMessage;
|
||||
experimental?: boolean;
|
||||
}
|
||||
const enum CharacterCodes {
|
||||
nullCharacter = 0,
|
||||
@@ -1378,10 +1369,10 @@ declare module "typescript" {
|
||||
isCancellationRequested(): boolean;
|
||||
}
|
||||
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(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
@@ -1422,15 +1413,14 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
character: number;
|
||||
};
|
||||
function positionToLineAndCharacter(text: string, pos: number): {
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
character: number;
|
||||
};
|
||||
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
||||
function isWhiteSpace(ch: number): boolean;
|
||||
function isLineBreak(ch: number): boolean;
|
||||
function isOctalDigit(ch: number): boolean;
|
||||
@@ -1446,8 +1436,10 @@ declare module "typescript" {
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function isLeftHandSideExpression(expr: Expression): boolean;
|
||||
function isAssignmentOperator(token: SyntaxKind): boolean;
|
||||
}
|
||||
@@ -1505,6 +1497,11 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
@@ -1542,7 +1539,7 @@ declare module "typescript" {
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
log?(s: string): void;
|
||||
trace?(s: string): void;
|
||||
error?(s: string): void;
|
||||
@@ -1576,7 +1573,7 @@ declare module "typescript" {
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
|
||||
getEmitOutput(fileName: string): EmitOutput;
|
||||
getProgram(): Program;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
dispose(): void;
|
||||
}
|
||||
interface ClassifiedSpan {
|
||||
@@ -1813,11 +1810,11 @@ declare module "typescript" {
|
||||
*/
|
||||
interface DocumentRegistry {
|
||||
/**
|
||||
* Request a stored SourceFile with a given filename and compilationSettings.
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -1826,9 +1823,9 @@ declare module "typescript" {
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given filename
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
@@ -1836,7 +1833,7 @@ declare module "typescript" {
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -1847,17 +1844,17 @@ declare module "typescript" {
|
||||
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
||||
* was not found in the registry and a new one was created.
|
||||
*/
|
||||
updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param filename The name of the file to be released
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(filename: string, compilationSettings: CompilerOptions): void;
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
}
|
||||
class ScriptElementKind {
|
||||
static unknown: string;
|
||||
@@ -1928,7 +1925,7 @@ declare module "typescript" {
|
||||
isCancellationRequested(): boolean;
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
var disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function createDocumentRegistry(): DocumentRegistry;
|
||||
@@ -1983,14 +1980,14 @@ function delint(sourceFile) {
|
||||
}
|
||||
function report(node, message) {
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
console.log(sourceFile.filename + " (" + lineChar.line + "," + lineChar.character + "): " + message);
|
||||
console.log(sourceFile.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + message);
|
||||
}
|
||||
}
|
||||
exports.delint = delint;
|
||||
var filenames = process.argv.slice(2);
|
||||
filenames.forEach(function (filename) {
|
||||
var fileNames = process.argv.slice(2);
|
||||
fileNames.forEach(function (fileName) {
|
||||
// Parse a file
|
||||
var sourceFile = ts.createSourceFile(filename, fs.readFileSync(filename).toString(), 2 /* ES6 */, true);
|
||||
var sourceFile = ts.createSourceFile(fileName, fs.readFileSync(fileName).toString(), 2 /* ES6 */, true);
|
||||
// delint it
|
||||
delint(sourceFile);
|
||||
});
|
||||
|
||||
@@ -227,22 +227,22 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterFromPosition(node.getStart()) : ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterFromPosition : (position: number) => ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>sourceFile : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (position: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>node.getStart() : number
|
||||
>node.getStart : (sourceFile?: ts.SourceFile) => number
|
||||
>node : ts.Node
|
||||
>getStart : (sourceFile?: ts.SourceFile) => number
|
||||
|
||||
console.log(`${sourceFile.filename} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
>console.log(`${sourceFile.filename} (${lineChar.line},${lineChar.character}): ${message}`) : any
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
>console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
>sourceFile.filename : string
|
||||
>sourceFile.fileName : string
|
||||
>sourceFile : ts.SourceFile
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>lineChar.line : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>line : number
|
||||
@@ -253,8 +253,8 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
}
|
||||
}
|
||||
|
||||
var filenames = process.argv.slice(2);
|
||||
>filenames : any
|
||||
var fileNames = process.argv.slice(2);
|
||||
>fileNames : any
|
||||
>process.argv.slice(2) : any
|
||||
>process.argv.slice : any
|
||||
>process.argv : any
|
||||
@@ -262,29 +262,29 @@ var filenames = process.argv.slice(2);
|
||||
>argv : any
|
||||
>slice : any
|
||||
|
||||
filenames.forEach(filename => {
|
||||
>filenames.forEach(filename => { // Parse a file var sourceFile = ts.createSourceFile(filename, fs.readFileSync(filename).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile);}) : any
|
||||
>filenames.forEach : any
|
||||
>filenames : any
|
||||
fileNames.forEach(fileName => {
|
||||
>fileNames.forEach(fileName => { // Parse a file var sourceFile = ts.createSourceFile(fileName, fs.readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile);}) : any
|
||||
>fileNames.forEach : any
|
||||
>fileNames : any
|
||||
>forEach : any
|
||||
>filename => { // Parse a file var sourceFile = ts.createSourceFile(filename, fs.readFileSync(filename).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile);} : (filename: any) => void
|
||||
>filename : any
|
||||
>fileName => { // Parse a file var sourceFile = ts.createSourceFile(fileName, fs.readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true); // delint it delint(sourceFile);} : (fileName: any) => void
|
||||
>fileName : any
|
||||
|
||||
// Parse a file
|
||||
var sourceFile = ts.createSourceFile(filename, fs.readFileSync(filename).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
|
||||
var sourceFile = ts.createSourceFile(fileName, fs.readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
|
||||
>sourceFile : ts.SourceFile
|
||||
>ts.createSourceFile(filename, fs.readFileSync(filename).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true) : ts.SourceFile
|
||||
>ts.createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
|
||||
>ts.createSourceFile(fileName, fs.readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true) : ts.SourceFile
|
||||
>ts.createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
|
||||
>ts : typeof ts
|
||||
>createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
|
||||
>filename : any
|
||||
>fs.readFileSync(filename).toString() : any
|
||||
>fs.readFileSync(filename).toString : any
|
||||
>fs.readFileSync(filename) : any
|
||||
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
|
||||
>fileName : any
|
||||
>fs.readFileSync(fileName).toString() : any
|
||||
>fs.readFileSync(fileName).toString : any
|
||||
>fs.readFileSync(fileName) : any
|
||||
>fs.readFileSync : any
|
||||
>fs : any
|
||||
>readFileSync : any
|
||||
>filename : any
|
||||
>fileName : any
|
||||
>toString : any
|
||||
>ts.ScriptTarget.ES6 : ts.ScriptTarget
|
||||
>ts.ScriptTarget : typeof ts.ScriptTarget
|
||||
@@ -2310,8 +2310,8 @@ declare module "typescript" {
|
||||
>FileReference : FileReference
|
||||
>TextRange : TextRange
|
||||
|
||||
filename: string;
|
||||
>filename : string
|
||||
fileName: string;
|
||||
>fileName : string
|
||||
}
|
||||
interface CommentRange extends TextRange {
|
||||
>CommentRange : CommentRange
|
||||
@@ -2333,32 +2333,12 @@ declare module "typescript" {
|
||||
>endOfFileToken : Node
|
||||
>Node : Node
|
||||
|
||||
filename: string;
|
||||
>filename : string
|
||||
fileName: string;
|
||||
>fileName : string
|
||||
|
||||
text: string;
|
||||
>text : string
|
||||
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (position: number) => LineAndCharacter
|
||||
>position : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
|
||||
amdDependencies: string[];
|
||||
>amdDependencies : string[]
|
||||
|
||||
@@ -2369,22 +2349,6 @@ declare module "typescript" {
|
||||
>referencedFiles : FileReference[]
|
||||
>FileReference : FileReference
|
||||
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
>referenceDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
parseDiagnostics: Diagnostic[];
|
||||
>parseDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
>semanticDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
hasNoDefaultLib: boolean;
|
||||
>hasNoDefaultLib : boolean
|
||||
|
||||
@@ -2392,15 +2356,6 @@ declare module "typescript" {
|
||||
>externalModuleIndicator : Node
|
||||
>Node : Node
|
||||
|
||||
nodeCount: number;
|
||||
>nodeCount : number
|
||||
|
||||
identifierCount: number;
|
||||
>identifierCount : number
|
||||
|
||||
symbolCount: number;
|
||||
>symbolCount : number
|
||||
|
||||
languageVersion: ScriptTarget;
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
@@ -2416,9 +2371,9 @@ declare module "typescript" {
|
||||
>getCompilerOptions : () => CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getCurrentDirectory(): string;
|
||||
@@ -2574,9 +2529,9 @@ declare module "typescript" {
|
||||
>getSourceFiles : () => SourceFile[]
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
}
|
||||
interface TypeChecker {
|
||||
@@ -3965,6 +3920,9 @@ declare module "typescript" {
|
||||
watch?: boolean;
|
||||
>watch : boolean
|
||||
|
||||
stripInternal?: boolean;
|
||||
>stripInternal : boolean
|
||||
|
||||
[option: string]: string | number | boolean;
|
||||
>option : string
|
||||
}
|
||||
@@ -4011,8 +3969,8 @@ declare module "typescript" {
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
filenames: string[];
|
||||
>filenames : string[]
|
||||
fileNames: string[];
|
||||
>fileNames : string[]
|
||||
|
||||
errors: Diagnostic[];
|
||||
>errors : Diagnostic[]
|
||||
@@ -4045,6 +4003,9 @@ declare module "typescript" {
|
||||
error?: DiagnosticMessage;
|
||||
>error : DiagnosticMessage
|
||||
>DiagnosticMessage : DiagnosticMessage
|
||||
|
||||
experimental?: boolean;
|
||||
>experimental : boolean
|
||||
}
|
||||
const enum CharacterCodes {
|
||||
>CharacterCodes : CharacterCodes
|
||||
@@ -4427,17 +4388,17 @@ declare module "typescript" {
|
||||
interface CompilerHost {
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
>getSourceFile : (filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
>getSourceFile : (fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) => SourceFile
|
||||
>fileName : string
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
>onError : (message: string) => void
|
||||
>message : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
>getDefaultLibFilename : (options: CompilerOptions) => string
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
>getDefaultLibFileName : (options: CompilerOptions) => string
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
@@ -4445,9 +4406,9 @@ declare module "typescript" {
|
||||
>getCancellationToken : () => CancellationToken
|
||||
>CancellationToken : CancellationToken
|
||||
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
>writeFile : (filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) => void
|
||||
>filename : string
|
||||
writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
>writeFile : (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) => void
|
||||
>fileName : string
|
||||
>data : string
|
||||
>writeByteOrderMark : boolean
|
||||
>onError : (message: string) => void
|
||||
@@ -4576,14 +4537,26 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function getLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
>getLineAndCharacterOfPosition : (lineStarts: number[], position: number) => { line: number; character: number; }
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
>getLineStarts : (sourceFile: SourceFile) => number[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
>computeLineAndCharacterOfPosition : (lineStarts: number[], position: number) => { line: number; character: number; }
|
||||
>lineStarts : number[]
|
||||
>position : number
|
||||
|
||||
@@ -4594,18 +4567,13 @@ declare module "typescript" {
|
||||
>character : number
|
||||
|
||||
};
|
||||
function positionToLineAndCharacter(text: string, pos: number): {
|
||||
>positionToLineAndCharacter : (text: string, pos: number) => { line: number; character: number; }
|
||||
>text : string
|
||||
>pos : number
|
||||
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (sourceFile: SourceFile, position: number) => LineAndCharacter
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>position : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
line: number;
|
||||
>line : number
|
||||
|
||||
character: number;
|
||||
>character : number
|
||||
|
||||
};
|
||||
function isWhiteSpace(ch: number): boolean;
|
||||
>isWhiteSpace : (ch: number) => boolean
|
||||
>ch : number
|
||||
@@ -4692,14 +4660,29 @@ declare module "typescript" {
|
||||
>SyntaxKind : SyntaxKind
|
||||
>NodeFlags : NodeFlags
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateSourceFile : (sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
>isEvalOrArgumentsIdentifier : (node: Node) => boolean
|
||||
>node : Node
|
||||
>Node : Node
|
||||
|
||||
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
>createSourceFile : (filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean) => SourceFile
|
||||
>filename : string
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean) => SourceFile
|
||||
>fileName : string
|
||||
>sourceText : string
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
@@ -4913,6 +4896,30 @@ declare module "typescript" {
|
||||
getNamedDeclarations(): Declaration[];
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
}
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
@@ -4999,8 +5006,8 @@ declare module "typescript" {
|
||||
getCurrentDirectory(): string;
|
||||
>getCurrentDirectory : () => string
|
||||
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
>getDefaultLibFilename : (options: CompilerOptions) => string
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
>getDefaultLibFileName : (options: CompilerOptions) => string
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
@@ -5189,9 +5196,9 @@ declare module "typescript" {
|
||||
>getProgram : () => Program
|
||||
>Program : Program
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
dispose(): void;
|
||||
@@ -5781,11 +5788,11 @@ declare module "typescript" {
|
||||
>DocumentRegistry : DocumentRegistry
|
||||
|
||||
/**
|
||||
* Request a stored SourceFile with a given filename and compilationSettings.
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -5794,9 +5801,9 @@ declare module "typescript" {
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
>acquireDocument : (filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile
|
||||
>filename : string
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
>acquireDocument : (fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
@@ -5805,7 +5812,7 @@ declare module "typescript" {
|
||||
>SourceFile : SourceFile
|
||||
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given filename
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
@@ -5813,7 +5820,7 @@ declare module "typescript" {
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -5824,11 +5831,11 @@ declare module "typescript" {
|
||||
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
||||
* was not found in the registry and a new one was created.
|
||||
*/
|
||||
updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateDocument : (sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateDocument : (sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
@@ -5844,12 +5851,12 @@ declare module "typescript" {
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param filename The name of the file to be released
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(filename: string, compilationSettings: CompilerOptions): void;
|
||||
>releaseDocument : (filename: string, compilationSettings: CompilerOptions) => void
|
||||
>filename : string
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
>releaseDocument : (fileName: string, compilationSettings: CompilerOptions) => void
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
}
|
||||
@@ -6049,9 +6056,9 @@ declare module "typescript" {
|
||||
throwIfCancellationRequested(): void;
|
||||
>throwIfCancellationRequested : () => void
|
||||
}
|
||||
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
>createLanguageServiceSourceFile : (filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile
|
||||
>filename : string
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
>createLanguageServiceSourceFile : (fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile
|
||||
>fileName : string
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
>IScriptSnapshot : IScriptSnapshot
|
||||
>scriptTarget : ScriptTarget
|
||||
|
||||
@@ -27,16 +27,16 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
|
||||
// Create a compilerHost object to allow the compiler to read and write files
|
||||
var compilerHost = {
|
||||
getSourceFile: (filename, target) => {
|
||||
return files[filename] !== undefined ?
|
||||
ts.createSourceFile(filename, files[filename], target) : undefined;
|
||||
getSourceFile: (fileName, target) => {
|
||||
return files[fileName] !== undefined ?
|
||||
ts.createSourceFile(fileName, files[fileName], target) : undefined;
|
||||
},
|
||||
writeFile: (name, text, writeByteOrderMark) => {
|
||||
outputs.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
|
||||
},
|
||||
getDefaultLibFilename: () => "lib.d.ts",
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
useCaseSensitiveFileNames: () => false,
|
||||
getCanonicalFileName: (filename) => filename,
|
||||
getCanonicalFileName: (fileName) => fileName,
|
||||
getCurrentDirectory: () => "",
|
||||
getNewLine: () => "\n"
|
||||
};
|
||||
@@ -56,7 +56,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
}
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) { return e.file.filename + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; })
|
||||
errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; })
|
||||
};
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ declare module "typescript" {
|
||||
exportName: Identifier;
|
||||
}
|
||||
interface FileReference extends TextRange {
|
||||
filename: string;
|
||||
fileName: string;
|
||||
}
|
||||
interface CommentRange extends TextRange {
|
||||
hasTrailingNewLine?: boolean;
|
||||
@@ -753,30 +753,19 @@ declare module "typescript" {
|
||||
interface SourceFile extends Declaration {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
endOfFileToken: Node;
|
||||
filename: string;
|
||||
fileName: string;
|
||||
text: string;
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getLineStarts(): number[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
amdDependencies: string[];
|
||||
amdModuleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
parseDiagnostics: Diagnostic[];
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
hasNoDefaultLib: boolean;
|
||||
externalModuleIndicator: Node;
|
||||
nodeCount: number;
|
||||
identifierCount: number;
|
||||
symbolCount: number;
|
||||
languageVersion: ScriptTarget;
|
||||
identifiers: Map<string>;
|
||||
}
|
||||
interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface Program extends ScriptReferenceHost {
|
||||
@@ -826,7 +815,7 @@ declare module "typescript" {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getCompilerHost(): CompilerHost;
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
}
|
||||
interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
@@ -1219,6 +1208,7 @@ declare module "typescript" {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
@@ -1238,7 +1228,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
filenames: string[];
|
||||
fileNames: string[];
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
interface CommandLineOption {
|
||||
@@ -1249,6 +1239,7 @@ declare module "typescript" {
|
||||
description?: DiagnosticMessage;
|
||||
paramType?: DiagnosticMessage;
|
||||
error?: DiagnosticMessage;
|
||||
experimental?: boolean;
|
||||
}
|
||||
const enum CharacterCodes {
|
||||
nullCharacter = 0,
|
||||
@@ -1379,10 +1370,10 @@ declare module "typescript" {
|
||||
isCancellationRequested(): boolean;
|
||||
}
|
||||
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(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
@@ -1423,15 +1414,14 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
character: number;
|
||||
};
|
||||
function positionToLineAndCharacter(text: string, pos: number): {
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
character: number;
|
||||
};
|
||||
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
||||
function isWhiteSpace(ch: number): boolean;
|
||||
function isLineBreak(ch: number): boolean;
|
||||
function isOctalDigit(ch: number): boolean;
|
||||
@@ -1447,8 +1437,10 @@ declare module "typescript" {
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function isLeftHandSideExpression(expr: Expression): boolean;
|
||||
function isAssignmentOperator(token: SyntaxKind): boolean;
|
||||
}
|
||||
@@ -1506,6 +1498,11 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
@@ -1543,7 +1540,7 @@ declare module "typescript" {
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
log?(s: string): void;
|
||||
trace?(s: string): void;
|
||||
error?(s: string): void;
|
||||
@@ -1577,7 +1574,7 @@ declare module "typescript" {
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
|
||||
getEmitOutput(fileName: string): EmitOutput;
|
||||
getProgram(): Program;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
dispose(): void;
|
||||
}
|
||||
interface ClassifiedSpan {
|
||||
@@ -1814,11 +1811,11 @@ declare module "typescript" {
|
||||
*/
|
||||
interface DocumentRegistry {
|
||||
/**
|
||||
* Request a stored SourceFile with a given filename and compilationSettings.
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -1827,9 +1824,9 @@ declare module "typescript" {
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given filename
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
@@ -1837,7 +1834,7 @@ declare module "typescript" {
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -1848,17 +1845,17 @@ declare module "typescript" {
|
||||
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
||||
* was not found in the registry and a new one was created.
|
||||
*/
|
||||
updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param filename The name of the file to be released
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(filename: string, compilationSettings: CompilerOptions): void;
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
}
|
||||
class ScriptElementKind {
|
||||
static unknown: string;
|
||||
@@ -1929,7 +1926,7 @@ declare module "typescript" {
|
||||
isCancellationRequested(): boolean;
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
var disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function createDocumentRegistry(): DocumentRegistry;
|
||||
@@ -1963,15 +1960,15 @@ function transform(contents, compilerOptions) {
|
||||
var outputs = [];
|
||||
// Create a compilerHost object to allow the compiler to read and write files
|
||||
var compilerHost = {
|
||||
getSourceFile: function (filename, target) {
|
||||
return files[filename] !== undefined ? ts.createSourceFile(filename, files[filename], target) : undefined;
|
||||
getSourceFile: function (fileName, target) {
|
||||
return files[fileName] !== undefined ? ts.createSourceFile(fileName, files[fileName], target) : undefined;
|
||||
},
|
||||
writeFile: function (name, text, writeByteOrderMark) {
|
||||
outputs.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
|
||||
},
|
||||
getDefaultLibFilename: function () { return "lib.d.ts"; },
|
||||
getDefaultLibFileName: function () { return "lib.d.ts"; },
|
||||
useCaseSensitiveFileNames: function () { return false; },
|
||||
getCanonicalFileName: function (filename) { return filename; },
|
||||
getCanonicalFileName: function (fileName) { return fileName; },
|
||||
getCurrentDirectory: function () { return ""; },
|
||||
getNewLine: function () { return "\n"; }
|
||||
};
|
||||
@@ -1990,7 +1987,7 @@ function transform(contents, compilerOptions) {
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) {
|
||||
return e.file.filename + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText;
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText;
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,32 +60,32 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
|
||||
// Create a compilerHost object to allow the compiler to read and write files
|
||||
var compilerHost = {
|
||||
>compilerHost : { getSourceFile: (filename: any, target: any) => ts.SourceFile; writeFile: (name: any, text: any, writeByteOrderMark: any) => void; getDefaultLibFilename: () => string; useCaseSensitiveFileNames: () => boolean; getCanonicalFileName: (filename: any) => any; getCurrentDirectory: () => string; getNewLine: () => string; }
|
||||
>{ getSourceFile: (filename, target) => { return files[filename] !== undefined ? ts.createSourceFile(filename, files[filename], target) : undefined; }, writeFile: (name, text, writeByteOrderMark) => { outputs.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, getDefaultLibFilename: () => "lib.d.ts", useCaseSensitiveFileNames: () => false, getCanonicalFileName: (filename) => filename, getCurrentDirectory: () => "", getNewLine: () => "\n" } : { getSourceFile: (filename: any, target: any) => ts.SourceFile; writeFile: (name: any, text: any, writeByteOrderMark: any) => void; getDefaultLibFilename: () => string; useCaseSensitiveFileNames: () => boolean; getCanonicalFileName: (filename: any) => any; getCurrentDirectory: () => string; getNewLine: () => string; }
|
||||
>compilerHost : { getSourceFile: (fileName: any, target: any) => ts.SourceFile; writeFile: (name: any, text: any, writeByteOrderMark: any) => void; getDefaultLibFileName: () => string; useCaseSensitiveFileNames: () => boolean; getCanonicalFileName: (fileName: any) => any; getCurrentDirectory: () => string; getNewLine: () => string; }
|
||||
>{ getSourceFile: (fileName, target) => { return files[fileName] !== undefined ? ts.createSourceFile(fileName, files[fileName], target) : undefined; }, writeFile: (name, text, writeByteOrderMark) => { outputs.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, getDefaultLibFileName: () => "lib.d.ts", useCaseSensitiveFileNames: () => false, getCanonicalFileName: (fileName) => fileName, getCurrentDirectory: () => "", getNewLine: () => "\n" } : { getSourceFile: (fileName: any, target: any) => ts.SourceFile; writeFile: (name: any, text: any, writeByteOrderMark: any) => void; getDefaultLibFileName: () => string; useCaseSensitiveFileNames: () => boolean; getCanonicalFileName: (fileName: any) => any; getCurrentDirectory: () => string; getNewLine: () => string; }
|
||||
|
||||
getSourceFile: (filename, target) => {
|
||||
>getSourceFile : (filename: any, target: any) => ts.SourceFile
|
||||
>(filename, target) => { return files[filename] !== undefined ? ts.createSourceFile(filename, files[filename], target) : undefined; } : (filename: any, target: any) => ts.SourceFile
|
||||
>filename : any
|
||||
getSourceFile: (fileName, target) => {
|
||||
>getSourceFile : (fileName: any, target: any) => ts.SourceFile
|
||||
>(fileName, target) => { return files[fileName] !== undefined ? ts.createSourceFile(fileName, files[fileName], target) : undefined; } : (fileName: any, target: any) => ts.SourceFile
|
||||
>fileName : any
|
||||
>target : any
|
||||
|
||||
return files[filename] !== undefined ?
|
||||
>files[filename] !== undefined ? ts.createSourceFile(filename, files[filename], target) : undefined : ts.SourceFile
|
||||
>files[filename] !== undefined : boolean
|
||||
>files[filename] : any
|
||||
return files[fileName] !== undefined ?
|
||||
>files[fileName] !== undefined ? ts.createSourceFile(fileName, files[fileName], target) : undefined : ts.SourceFile
|
||||
>files[fileName] !== undefined : boolean
|
||||
>files[fileName] : any
|
||||
>files : { "file.ts": string; "lib.d.ts": any; }
|
||||
>filename : any
|
||||
>fileName : any
|
||||
>undefined : undefined
|
||||
|
||||
ts.createSourceFile(filename, files[filename], target) : undefined;
|
||||
>ts.createSourceFile(filename, files[filename], target) : ts.SourceFile
|
||||
>ts.createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
|
||||
ts.createSourceFile(fileName, files[fileName], target) : undefined;
|
||||
>ts.createSourceFile(fileName, files[fileName], target) : ts.SourceFile
|
||||
>ts.createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
|
||||
>ts : typeof ts
|
||||
>createSourceFile : (filename: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
|
||||
>filename : any
|
||||
>files[filename] : any
|
||||
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, setParentNodes?: boolean) => ts.SourceFile
|
||||
>fileName : any
|
||||
>files[fileName] : any
|
||||
>files : { "file.ts": string; "lib.d.ts": any; }
|
||||
>filename : any
|
||||
>fileName : any
|
||||
>target : any
|
||||
>undefined : undefined
|
||||
|
||||
@@ -111,19 +111,19 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
>writeByteOrderMark : any
|
||||
|
||||
},
|
||||
getDefaultLibFilename: () => "lib.d.ts",
|
||||
>getDefaultLibFilename : () => string
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
>getDefaultLibFileName : () => string
|
||||
>() => "lib.d.ts" : () => string
|
||||
|
||||
useCaseSensitiveFileNames: () => false,
|
||||
>useCaseSensitiveFileNames : () => boolean
|
||||
>() => false : () => boolean
|
||||
|
||||
getCanonicalFileName: (filename) => filename,
|
||||
>getCanonicalFileName : (filename: any) => any
|
||||
>(filename) => filename : (filename: any) => any
|
||||
>filename : any
|
||||
>filename : any
|
||||
getCanonicalFileName: (fileName) => fileName,
|
||||
>getCanonicalFileName : (fileName: any) => any
|
||||
>(fileName) => fileName : (fileName: any) => any
|
||||
>fileName : any
|
||||
>fileName : any
|
||||
|
||||
getCurrentDirectory: () => "",
|
||||
>getCurrentDirectory : () => string
|
||||
@@ -144,7 +144,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
>createProgram : (rootNames: string[], options: ts.CompilerOptions, host: ts.CompilerHost) => ts.Program
|
||||
>["file.ts"] : string[]
|
||||
>compilerOptions : ts.CompilerOptions
|
||||
>compilerHost : { getSourceFile: (filename: any, target: any) => ts.SourceFile; writeFile: (name: any, text: any, writeByteOrderMark: any) => void; getDefaultLibFilename: () => string; useCaseSensitiveFileNames: () => boolean; getCanonicalFileName: (filename: any) => any; getCurrentDirectory: () => string; getNewLine: () => string; }
|
||||
>compilerHost : { getSourceFile: (fileName: any, target: any) => ts.SourceFile; writeFile: (name: any, text: any, writeByteOrderMark: any) => void; getDefaultLibFileName: () => string; useCaseSensitiveFileNames: () => boolean; getCanonicalFileName: (fileName: any) => any; getCurrentDirectory: () => string; getNewLine: () => string; }
|
||||
|
||||
// Query for early errors
|
||||
var errors = program.getDiagnostics();
|
||||
@@ -185,36 +185,36 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
>emitFiles : (targetSourceFile?: ts.SourceFile) => ts.EmitResult
|
||||
}
|
||||
return {
|
||||
>{ outputs: outputs, errors: errors.map(function (e) { return e.file.filename + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; }) } : { outputs: any[]; errors: string[]; }
|
||||
>{ outputs: outputs, errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; }) } : { outputs: any[]; errors: string[]; }
|
||||
|
||||
outputs: outputs,
|
||||
>outputs : any[]
|
||||
>outputs : any[]
|
||||
|
||||
errors: errors.map(function (e) { return e.file.filename + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; })
|
||||
errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; })
|
||||
>errors : string[]
|
||||
>errors.map(function (e) { return e.file.filename + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; }) : string[]
|
||||
>errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; }) : string[]
|
||||
>errors.map : <U>(callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[]
|
||||
>errors : ts.Diagnostic[]
|
||||
>map : <U>(callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[]
|
||||
>function (e) { return e.file.filename + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; } : (e: ts.Diagnostic) => string
|
||||
>function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; } : (e: ts.Diagnostic) => string
|
||||
>e : ts.Diagnostic
|
||||
>e.file.filename + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText : string
|
||||
>e.file.filename + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " : string
|
||||
>e.file.filename + "(" + e.file.getLineAndCharacterFromPosition(e.start).line : string
|
||||
>e.file.filename + "(" : string
|
||||
>e.file.filename : string
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText : string
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " : string
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line : string
|
||||
>e.file.fileName + "(" : string
|
||||
>e.file.fileName : string
|
||||
>e.file : ts.SourceFile
|
||||
>e : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>e.file.getLineAndCharacterFromPosition(e.start).line : number
|
||||
>e.file.getLineAndCharacterFromPosition(e.start) : ts.LineAndCharacter
|
||||
>e.file.getLineAndCharacterFromPosition : (position: number) => ts.LineAndCharacter
|
||||
>e.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>e.file : ts.SourceFile
|
||||
>e : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (position: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>e.start : number
|
||||
>e : ts.Diagnostic
|
||||
>start : number
|
||||
@@ -2258,8 +2258,8 @@ declare module "typescript" {
|
||||
>FileReference : FileReference
|
||||
>TextRange : TextRange
|
||||
|
||||
filename: string;
|
||||
>filename : string
|
||||
fileName: string;
|
||||
>fileName : string
|
||||
}
|
||||
interface CommentRange extends TextRange {
|
||||
>CommentRange : CommentRange
|
||||
@@ -2281,32 +2281,12 @@ declare module "typescript" {
|
||||
>endOfFileToken : Node
|
||||
>Node : Node
|
||||
|
||||
filename: string;
|
||||
>filename : string
|
||||
fileName: string;
|
||||
>fileName : string
|
||||
|
||||
text: string;
|
||||
>text : string
|
||||
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (position: number) => LineAndCharacter
|
||||
>position : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
|
||||
amdDependencies: string[];
|
||||
>amdDependencies : string[]
|
||||
|
||||
@@ -2317,22 +2297,6 @@ declare module "typescript" {
|
||||
>referencedFiles : FileReference[]
|
||||
>FileReference : FileReference
|
||||
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
>referenceDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
parseDiagnostics: Diagnostic[];
|
||||
>parseDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
>semanticDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
hasNoDefaultLib: boolean;
|
||||
>hasNoDefaultLib : boolean
|
||||
|
||||
@@ -2340,15 +2304,6 @@ declare module "typescript" {
|
||||
>externalModuleIndicator : Node
|
||||
>Node : Node
|
||||
|
||||
nodeCount: number;
|
||||
>nodeCount : number
|
||||
|
||||
identifierCount: number;
|
||||
>identifierCount : number
|
||||
|
||||
symbolCount: number;
|
||||
>symbolCount : number
|
||||
|
||||
languageVersion: ScriptTarget;
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
@@ -2364,9 +2319,9 @@ declare module "typescript" {
|
||||
>getCompilerOptions : () => CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getCurrentDirectory(): string;
|
||||
@@ -2522,9 +2477,9 @@ declare module "typescript" {
|
||||
>getSourceFiles : () => SourceFile[]
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
}
|
||||
interface TypeChecker {
|
||||
@@ -3913,6 +3868,9 @@ declare module "typescript" {
|
||||
watch?: boolean;
|
||||
>watch : boolean
|
||||
|
||||
stripInternal?: boolean;
|
||||
>stripInternal : boolean
|
||||
|
||||
[option: string]: string | number | boolean;
|
||||
>option : string
|
||||
}
|
||||
@@ -3959,8 +3917,8 @@ declare module "typescript" {
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
filenames: string[];
|
||||
>filenames : string[]
|
||||
fileNames: string[];
|
||||
>fileNames : string[]
|
||||
|
||||
errors: Diagnostic[];
|
||||
>errors : Diagnostic[]
|
||||
@@ -3993,6 +3951,9 @@ declare module "typescript" {
|
||||
error?: DiagnosticMessage;
|
||||
>error : DiagnosticMessage
|
||||
>DiagnosticMessage : DiagnosticMessage
|
||||
|
||||
experimental?: boolean;
|
||||
>experimental : boolean
|
||||
}
|
||||
const enum CharacterCodes {
|
||||
>CharacterCodes : CharacterCodes
|
||||
@@ -4375,17 +4336,17 @@ declare module "typescript" {
|
||||
interface CompilerHost {
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
>getSourceFile : (filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
>getSourceFile : (fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) => SourceFile
|
||||
>fileName : string
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
>onError : (message: string) => void
|
||||
>message : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
>getDefaultLibFilename : (options: CompilerOptions) => string
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
>getDefaultLibFileName : (options: CompilerOptions) => string
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
@@ -4393,9 +4354,9 @@ declare module "typescript" {
|
||||
>getCancellationToken : () => CancellationToken
|
||||
>CancellationToken : CancellationToken
|
||||
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
>writeFile : (filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) => void
|
||||
>filename : string
|
||||
writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
>writeFile : (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) => void
|
||||
>fileName : string
|
||||
>data : string
|
||||
>writeByteOrderMark : boolean
|
||||
>onError : (message: string) => void
|
||||
@@ -4524,14 +4485,26 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function getLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
>getLineAndCharacterOfPosition : (lineStarts: number[], position: number) => { line: number; character: number; }
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
>getLineStarts : (sourceFile: SourceFile) => number[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
>computeLineAndCharacterOfPosition : (lineStarts: number[], position: number) => { line: number; character: number; }
|
||||
>lineStarts : number[]
|
||||
>position : number
|
||||
|
||||
@@ -4542,18 +4515,13 @@ declare module "typescript" {
|
||||
>character : number
|
||||
|
||||
};
|
||||
function positionToLineAndCharacter(text: string, pos: number): {
|
||||
>positionToLineAndCharacter : (text: string, pos: number) => { line: number; character: number; }
|
||||
>text : string
|
||||
>pos : number
|
||||
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (sourceFile: SourceFile, position: number) => LineAndCharacter
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>position : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
line: number;
|
||||
>line : number
|
||||
|
||||
character: number;
|
||||
>character : number
|
||||
|
||||
};
|
||||
function isWhiteSpace(ch: number): boolean;
|
||||
>isWhiteSpace : (ch: number) => boolean
|
||||
>ch : number
|
||||
@@ -4640,14 +4608,29 @@ declare module "typescript" {
|
||||
>SyntaxKind : SyntaxKind
|
||||
>NodeFlags : NodeFlags
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateSourceFile : (sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
>isEvalOrArgumentsIdentifier : (node: Node) => boolean
|
||||
>node : Node
|
||||
>Node : Node
|
||||
|
||||
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
>createSourceFile : (filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean) => SourceFile
|
||||
>filename : string
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean) => SourceFile
|
||||
>fileName : string
|
||||
>sourceText : string
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
@@ -4861,6 +4844,30 @@ declare module "typescript" {
|
||||
getNamedDeclarations(): Declaration[];
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
}
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
@@ -4947,8 +4954,8 @@ declare module "typescript" {
|
||||
getCurrentDirectory(): string;
|
||||
>getCurrentDirectory : () => string
|
||||
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
>getDefaultLibFilename : (options: CompilerOptions) => string
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
>getDefaultLibFileName : (options: CompilerOptions) => string
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
@@ -5137,9 +5144,9 @@ declare module "typescript" {
|
||||
>getProgram : () => Program
|
||||
>Program : Program
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
dispose(): void;
|
||||
@@ -5729,11 +5736,11 @@ declare module "typescript" {
|
||||
>DocumentRegistry : DocumentRegistry
|
||||
|
||||
/**
|
||||
* Request a stored SourceFile with a given filename and compilationSettings.
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -5742,9 +5749,9 @@ declare module "typescript" {
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
>acquireDocument : (filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile
|
||||
>filename : string
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
>acquireDocument : (fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
@@ -5753,7 +5760,7 @@ declare module "typescript" {
|
||||
>SourceFile : SourceFile
|
||||
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given filename
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
@@ -5761,7 +5768,7 @@ declare module "typescript" {
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -5772,11 +5779,11 @@ declare module "typescript" {
|
||||
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
||||
* was not found in the registry and a new one was created.
|
||||
*/
|
||||
updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateDocument : (sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateDocument : (sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
@@ -5792,12 +5799,12 @@ declare module "typescript" {
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param filename The name of the file to be released
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(filename: string, compilationSettings: CompilerOptions): void;
|
||||
>releaseDocument : (filename: string, compilationSettings: CompilerOptions) => void
|
||||
>filename : string
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
>releaseDocument : (fileName: string, compilationSettings: CompilerOptions) => void
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
}
|
||||
@@ -5997,9 +6004,9 @@ declare module "typescript" {
|
||||
throwIfCancellationRequested(): void;
|
||||
>throwIfCancellationRequested : () => void
|
||||
}
|
||||
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
>createLanguageServiceSourceFile : (filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile
|
||||
>filename : string
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
>createLanguageServiceSourceFile : (fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile
|
||||
>fileName : string
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
>IScriptSnapshot : IScriptSnapshot
|
||||
>scriptTarget : ScriptTarget
|
||||
|
||||
@@ -15,40 +15,40 @@ declare var path: any;
|
||||
|
||||
import ts = require("typescript");
|
||||
|
||||
function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
var files: ts.Map<{ version: number }> = {};
|
||||
|
||||
// initialize the list of files
|
||||
rootFilenames.forEach(filename => {
|
||||
files[filename] = { version: 0 };
|
||||
rootFileNames.forEach(fileName => {
|
||||
files[fileName] = { version: 0 };
|
||||
});
|
||||
|
||||
// Create the language service host to allow the LS to communicate with the host
|
||||
var servicesHost: ts.LanguageServiceHost = {
|
||||
getScriptFileNames: () => rootFilenames,
|
||||
getScriptVersion: (filename) => files[filename] && files[filename].version.toString(),
|
||||
getScriptSnapshot: (filename) => {
|
||||
if (!fs.existsSync(filename)) {
|
||||
getScriptFileNames: () => rootFileNames,
|
||||
getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(),
|
||||
getScriptSnapshot: (fileName) => {
|
||||
if (!fs.existsSync(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return ts.ScriptSnapshot.fromString(fs.readFileSync(filename).toString());
|
||||
return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString());
|
||||
},
|
||||
getCurrentDirectory: () => process.cwd(),
|
||||
getCompilationSettings: () => options,
|
||||
getDefaultLibFilename: (options) => ts.getDefaultLibFilePath(options),
|
||||
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
|
||||
};
|
||||
|
||||
// Create the language service files
|
||||
var services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry())
|
||||
|
||||
// Now let's watch the files
|
||||
rootFilenames.forEach(filename => {
|
||||
rootFileNames.forEach(fileName => {
|
||||
// First time around, emit all files
|
||||
emitFile(filename);
|
||||
emitFile(fileName);
|
||||
|
||||
// Add a watch on the file to handle next change
|
||||
fs.watchFile(filename,
|
||||
fs.watchFile(fileName,
|
||||
{ persistent: true, interval: 250 },
|
||||
(curr, prev) => {
|
||||
// Check timestamp
|
||||
@@ -57,22 +57,22 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
}
|
||||
|
||||
// Update the version to signal a change in the file
|
||||
files[filename].version++;
|
||||
files[fileName].version++;
|
||||
|
||||
// write the changes to disk
|
||||
emitFile(filename);
|
||||
emitFile(fileName);
|
||||
});
|
||||
});
|
||||
|
||||
function emitFile(filename: string) {
|
||||
var output = services.getEmitOutput(filename);
|
||||
function emitFile(fileName: string) {
|
||||
var output = services.getEmitOutput(fileName);
|
||||
|
||||
if (output.emitOutputStatus === ts.EmitReturnStatus.Succeeded) {
|
||||
console.log(`Emitting ${filename}`);
|
||||
console.log(`Emitting ${fileName}`);
|
||||
}
|
||||
else {
|
||||
console.log(`Emitting ${filename} failed`);
|
||||
logErrors(filename);
|
||||
console.log(`Emitting ${fileName} failed`);
|
||||
logErrors(fileName);
|
||||
}
|
||||
|
||||
output.outputFiles.forEach(o => {
|
||||
@@ -80,15 +80,15 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
});
|
||||
}
|
||||
|
||||
function logErrors(filename: string) {
|
||||
function logErrors(fileName: string) {
|
||||
var allDiagnostics = services.getCompilerOptionsDiagnostics()
|
||||
.concat(services.getSyntacticDiagnostics(filename))
|
||||
.concat(services.getSemanticDiagnostics(filename));
|
||||
.concat(services.getSyntacticDiagnostics(fileName))
|
||||
.concat(services.getSemanticDiagnostics(fileName));
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
if (diagnostic.file) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(` Error ${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
}
|
||||
else {
|
||||
console.log(` Error: ${diagnostic.messageText}`);
|
||||
@@ -99,7 +99,7 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
|
||||
// Initialize files constituting the program as all .ts files in the current directory
|
||||
var currentDirectoryFiles = fs.readdirSync(process.cwd()).
|
||||
filter(filename=> filename.length >= 3 && filename.substr(filename.length - 3, 3) === ".ts");
|
||||
filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts");
|
||||
|
||||
// Start the watcher
|
||||
watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });
|
||||
@@ -782,7 +782,7 @@ declare module "typescript" {
|
||||
exportName: Identifier;
|
||||
}
|
||||
interface FileReference extends TextRange {
|
||||
filename: string;
|
||||
fileName: string;
|
||||
}
|
||||
interface CommentRange extends TextRange {
|
||||
hasTrailingNewLine?: boolean;
|
||||
@@ -790,30 +790,19 @@ declare module "typescript" {
|
||||
interface SourceFile extends Declaration {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
endOfFileToken: Node;
|
||||
filename: string;
|
||||
fileName: string;
|
||||
text: string;
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getLineStarts(): number[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
amdDependencies: string[];
|
||||
amdModuleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
parseDiagnostics: Diagnostic[];
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
hasNoDefaultLib: boolean;
|
||||
externalModuleIndicator: Node;
|
||||
nodeCount: number;
|
||||
identifierCount: number;
|
||||
symbolCount: number;
|
||||
languageVersion: ScriptTarget;
|
||||
identifiers: Map<string>;
|
||||
}
|
||||
interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface Program extends ScriptReferenceHost {
|
||||
@@ -863,7 +852,7 @@ declare module "typescript" {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getCompilerHost(): CompilerHost;
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
}
|
||||
interface TypeChecker {
|
||||
getEmitResolver(): EmitResolver;
|
||||
@@ -1256,6 +1245,7 @@ declare module "typescript" {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
stripInternal?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
const enum ModuleKind {
|
||||
@@ -1275,7 +1265,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
filenames: string[];
|
||||
fileNames: string[];
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
interface CommandLineOption {
|
||||
@@ -1286,6 +1276,7 @@ declare module "typescript" {
|
||||
description?: DiagnosticMessage;
|
||||
paramType?: DiagnosticMessage;
|
||||
error?: DiagnosticMessage;
|
||||
experimental?: boolean;
|
||||
}
|
||||
const enum CharacterCodes {
|
||||
nullCharacter = 0,
|
||||
@@ -1416,10 +1407,10 @@ declare module "typescript" {
|
||||
isCancellationRequested(): boolean;
|
||||
}
|
||||
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(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
@@ -1460,15 +1451,14 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
character: number;
|
||||
};
|
||||
function positionToLineAndCharacter(text: string, pos: number): {
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
character: number;
|
||||
};
|
||||
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
||||
function isWhiteSpace(ch: number): boolean;
|
||||
function isLineBreak(ch: number): boolean;
|
||||
function isOctalDigit(ch: number): boolean;
|
||||
@@ -1484,8 +1474,10 @@ declare module "typescript" {
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function isLeftHandSideExpression(expr: Expression): boolean;
|
||||
function isAssignmentOperator(token: SyntaxKind): boolean;
|
||||
}
|
||||
@@ -1543,6 +1535,11 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
@@ -1580,7 +1577,7 @@ declare module "typescript" {
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
log?(s: string): void;
|
||||
trace?(s: string): void;
|
||||
error?(s: string): void;
|
||||
@@ -1614,7 +1611,7 @@ declare module "typescript" {
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
|
||||
getEmitOutput(fileName: string): EmitOutput;
|
||||
getProgram(): Program;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
dispose(): void;
|
||||
}
|
||||
interface ClassifiedSpan {
|
||||
@@ -1851,11 +1848,11 @@ declare module "typescript" {
|
||||
*/
|
||||
interface DocumentRegistry {
|
||||
/**
|
||||
* Request a stored SourceFile with a given filename and compilationSettings.
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -1864,9 +1861,9 @@ declare module "typescript" {
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given filename
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
@@ -1874,7 +1871,7 @@ declare module "typescript" {
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -1885,17 +1882,17 @@ declare module "typescript" {
|
||||
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
||||
* was not found in the registry and a new one was created.
|
||||
*/
|
||||
updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
/**
|
||||
* Informs the DocumentRegistry that a file is not needed any longer.
|
||||
*
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param filename The name of the file to be released
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(filename: string, compilationSettings: CompilerOptions): void;
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
}
|
||||
class ScriptElementKind {
|
||||
static unknown: string;
|
||||
@@ -1966,7 +1963,7 @@ declare module "typescript" {
|
||||
isCancellationRequested(): boolean;
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
var disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
function createDocumentRegistry(): DocumentRegistry;
|
||||
@@ -1989,63 +1986,63 @@ declare module "typescript" {
|
||||
* Please log a "breaking change" issue for any API breaking change affecting this issue
|
||||
*/
|
||||
var ts = require("typescript");
|
||||
function watch(rootFilenames, options) {
|
||||
function watch(rootFileNames, options) {
|
||||
var files = {};
|
||||
// initialize the list of files
|
||||
rootFilenames.forEach(function (filename) {
|
||||
files[filename] = { version: 0 };
|
||||
rootFileNames.forEach(function (fileName) {
|
||||
files[fileName] = { version: 0 };
|
||||
});
|
||||
// Create the language service host to allow the LS to communicate with the host
|
||||
var servicesHost = {
|
||||
getScriptFileNames: function () { return rootFilenames; },
|
||||
getScriptVersion: function (filename) { return files[filename] && files[filename].version.toString(); },
|
||||
getScriptSnapshot: function (filename) {
|
||||
if (!fs.existsSync(filename)) {
|
||||
getScriptFileNames: function () { return rootFileNames; },
|
||||
getScriptVersion: function (fileName) { return files[fileName] && files[fileName].version.toString(); },
|
||||
getScriptSnapshot: function (fileName) {
|
||||
if (!fs.existsSync(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
return ts.ScriptSnapshot.fromString(fs.readFileSync(filename).toString());
|
||||
return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString());
|
||||
},
|
||||
getCurrentDirectory: function () { return process.cwd(); },
|
||||
getCompilationSettings: function () { return options; },
|
||||
getDefaultLibFilename: function (options) { return ts.getDefaultLibFilePath(options); }
|
||||
getDefaultLibFileName: function (options) { return ts.getDefaultLibFilePath(options); }
|
||||
};
|
||||
// Create the language service files
|
||||
var services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry());
|
||||
// Now let's watch the files
|
||||
rootFilenames.forEach(function (filename) {
|
||||
rootFileNames.forEach(function (fileName) {
|
||||
// First time around, emit all files
|
||||
emitFile(filename);
|
||||
emitFile(fileName);
|
||||
// Add a watch on the file to handle next change
|
||||
fs.watchFile(filename, { persistent: true, interval: 250 }, function (curr, prev) {
|
||||
fs.watchFile(fileName, { persistent: true, interval: 250 }, function (curr, prev) {
|
||||
// Check timestamp
|
||||
if (+curr.mtime <= +prev.mtime) {
|
||||
return;
|
||||
}
|
||||
// Update the version to signal a change in the file
|
||||
files[filename].version++;
|
||||
files[fileName].version++;
|
||||
// write the changes to disk
|
||||
emitFile(filename);
|
||||
emitFile(fileName);
|
||||
});
|
||||
});
|
||||
function emitFile(filename) {
|
||||
var output = services.getEmitOutput(filename);
|
||||
function emitFile(fileName) {
|
||||
var output = services.getEmitOutput(fileName);
|
||||
if (output.emitOutputStatus === 0 /* Succeeded */) {
|
||||
console.log("Emitting " + filename);
|
||||
console.log("Emitting " + fileName);
|
||||
}
|
||||
else {
|
||||
console.log("Emitting " + filename + " failed");
|
||||
logErrors(filename);
|
||||
console.log("Emitting " + fileName + " failed");
|
||||
logErrors(fileName);
|
||||
}
|
||||
output.outputFiles.forEach(function (o) {
|
||||
fs.writeFileSync(o.name, o.text, "utf8");
|
||||
});
|
||||
}
|
||||
function logErrors(filename) {
|
||||
var allDiagnostics = services.getCompilerOptionsDiagnostics().concat(services.getSyntacticDiagnostics(filename)).concat(services.getSemanticDiagnostics(filename));
|
||||
function logErrors(fileName) {
|
||||
var allDiagnostics = services.getCompilerOptionsDiagnostics().concat(services.getSyntacticDiagnostics(fileName)).concat(services.getSemanticDiagnostics(fileName));
|
||||
allDiagnostics.forEach(function (diagnostic) {
|
||||
if (diagnostic.file) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(" Error " + diagnostic.file.filename + " (" + lineChar.line + "," + lineChar.character + "): " + diagnostic.messageText);
|
||||
console.log(" Error " + diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + diagnostic.messageText);
|
||||
}
|
||||
else {
|
||||
console.log(" Error: " + diagnostic.messageText);
|
||||
@@ -2054,6 +2051,6 @@ function watch(rootFilenames, options) {
|
||||
}
|
||||
}
|
||||
// Initialize files constituting the program as all .ts files in the current directory
|
||||
var currentDirectoryFiles = fs.readdirSync(process.cwd()).filter(function (filename) { return filename.length >= 3 && filename.substr(filename.length - 3, 3) === ".ts"; });
|
||||
var currentDirectoryFiles = fs.readdirSync(process.cwd()).filter(function (fileName) { return fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts"; });
|
||||
// Start the watcher
|
||||
watch(currentDirectoryFiles, { module: 1 /* CommonJS */ });
|
||||
|
||||
@@ -21,9 +21,9 @@ declare var path: any;
|
||||
import ts = require("typescript");
|
||||
>ts : typeof ts
|
||||
|
||||
function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
>watch : (rootFilenames: string[], options: ts.CompilerOptions) => void
|
||||
>rootFilenames : string[]
|
||||
function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>watch : (rootFileNames: string[], options: ts.CompilerOptions) => void
|
||||
>rootFileNames : string[]
|
||||
>options : ts.CompilerOptions
|
||||
>ts : unknown
|
||||
>CompilerOptions : ts.CompilerOptions
|
||||
@@ -36,19 +36,19 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
>{} : { [x: string]: undefined; }
|
||||
|
||||
// initialize the list of files
|
||||
rootFilenames.forEach(filename => {
|
||||
>rootFilenames.forEach(filename => { files[filename] = { version: 0 }; }) : void
|
||||
>rootFilenames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
|
||||
>rootFilenames : string[]
|
||||
rootFileNames.forEach(fileName => {
|
||||
>rootFileNames.forEach(fileName => { files[fileName] = { version: 0 }; }) : void
|
||||
>rootFileNames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
|
||||
>rootFileNames : string[]
|
||||
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
|
||||
>filename => { files[filename] = { version: 0 }; } : (filename: string) => void
|
||||
>filename : string
|
||||
>fileName => { files[fileName] = { version: 0 }; } : (fileName: string) => void
|
||||
>fileName : string
|
||||
|
||||
files[filename] = { version: 0 };
|
||||
>files[filename] = { version: 0 } : { version: number; }
|
||||
>files[filename] : { version: number; }
|
||||
files[fileName] = { version: 0 };
|
||||
>files[fileName] = { version: 0 } : { version: number; }
|
||||
>files[fileName] : { version: number; }
|
||||
>files : ts.Map<{ version: number; }>
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>{ version: 0 } : { version: number; }
|
||||
>version : number
|
||||
|
||||
@@ -59,61 +59,61 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
>servicesHost : ts.LanguageServiceHost
|
||||
>ts : unknown
|
||||
>LanguageServiceHost : ts.LanguageServiceHost
|
||||
>{ getScriptFileNames: () => rootFilenames, getScriptVersion: (filename) => files[filename] && files[filename].version.toString(), getScriptSnapshot: (filename) => { if (!fs.existsSync(filename)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(filename).toString()); }, getCurrentDirectory: () => process.cwd(), getCompilationSettings: () => options, getDefaultLibFilename: (options) => ts.getDefaultLibFilePath(options), } : { getScriptFileNames: () => string[]; getScriptVersion: (filename: string) => string; getScriptSnapshot: (filename: string) => ts.IScriptSnapshot; getCurrentDirectory: () => any; getCompilationSettings: () => ts.CompilerOptions; getDefaultLibFilename: (options: ts.CompilerOptions) => string; }
|
||||
>{ getScriptFileNames: () => rootFileNames, getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(), getScriptSnapshot: (fileName) => { if (!fs.existsSync(fileName)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); }, getCurrentDirectory: () => process.cwd(), getCompilationSettings: () => options, getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options), } : { getScriptFileNames: () => string[]; getScriptVersion: (fileName: string) => string; getScriptSnapshot: (fileName: string) => ts.IScriptSnapshot; getCurrentDirectory: () => any; getCompilationSettings: () => ts.CompilerOptions; getDefaultLibFileName: (options: ts.CompilerOptions) => string; }
|
||||
|
||||
getScriptFileNames: () => rootFilenames,
|
||||
getScriptFileNames: () => rootFileNames,
|
||||
>getScriptFileNames : () => string[]
|
||||
>() => rootFilenames : () => string[]
|
||||
>rootFilenames : string[]
|
||||
>() => rootFileNames : () => string[]
|
||||
>rootFileNames : string[]
|
||||
|
||||
getScriptVersion: (filename) => files[filename] && files[filename].version.toString(),
|
||||
>getScriptVersion : (filename: string) => string
|
||||
>(filename) => files[filename] && files[filename].version.toString() : (filename: string) => string
|
||||
>filename : string
|
||||
>files[filename] && files[filename].version.toString() : string
|
||||
>files[filename] : { version: number; }
|
||||
getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(),
|
||||
>getScriptVersion : (fileName: string) => string
|
||||
>(fileName) => files[fileName] && files[fileName].version.toString() : (fileName: string) => string
|
||||
>fileName : string
|
||||
>files[fileName] && files[fileName].version.toString() : string
|
||||
>files[fileName] : { version: number; }
|
||||
>files : ts.Map<{ version: number; }>
|
||||
>filename : string
|
||||
>files[filename].version.toString() : string
|
||||
>files[filename].version.toString : (radix?: number) => string
|
||||
>files[filename].version : number
|
||||
>files[filename] : { version: number; }
|
||||
>fileName : string
|
||||
>files[fileName].version.toString() : string
|
||||
>files[fileName].version.toString : (radix?: number) => string
|
||||
>files[fileName].version : number
|
||||
>files[fileName] : { version: number; }
|
||||
>files : ts.Map<{ version: number; }>
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>version : number
|
||||
>toString : (radix?: number) => string
|
||||
|
||||
getScriptSnapshot: (filename) => {
|
||||
>getScriptSnapshot : (filename: string) => ts.IScriptSnapshot
|
||||
>(filename) => { if (!fs.existsSync(filename)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(filename).toString()); } : (filename: string) => ts.IScriptSnapshot
|
||||
>filename : string
|
||||
getScriptSnapshot: (fileName) => {
|
||||
>getScriptSnapshot : (fileName: string) => ts.IScriptSnapshot
|
||||
>(fileName) => { if (!fs.existsSync(fileName)) { return undefined; } return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()); } : (fileName: string) => ts.IScriptSnapshot
|
||||
>fileName : string
|
||||
|
||||
if (!fs.existsSync(filename)) {
|
||||
>!fs.existsSync(filename) : boolean
|
||||
>fs.existsSync(filename) : any
|
||||
if (!fs.existsSync(fileName)) {
|
||||
>!fs.existsSync(fileName) : boolean
|
||||
>fs.existsSync(fileName) : any
|
||||
>fs.existsSync : any
|
||||
>fs : any
|
||||
>existsSync : any
|
||||
>filename : string
|
||||
>fileName : string
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
|
||||
return ts.ScriptSnapshot.fromString(fs.readFileSync(filename).toString());
|
||||
>ts.ScriptSnapshot.fromString(fs.readFileSync(filename).toString()) : ts.IScriptSnapshot
|
||||
return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString());
|
||||
>ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString()) : ts.IScriptSnapshot
|
||||
>ts.ScriptSnapshot.fromString : (text: string) => ts.IScriptSnapshot
|
||||
>ts.ScriptSnapshot : typeof ts.ScriptSnapshot
|
||||
>ts : typeof ts
|
||||
>ScriptSnapshot : typeof ts.ScriptSnapshot
|
||||
>fromString : (text: string) => ts.IScriptSnapshot
|
||||
>fs.readFileSync(filename).toString() : any
|
||||
>fs.readFileSync(filename).toString : any
|
||||
>fs.readFileSync(filename) : any
|
||||
>fs.readFileSync(fileName).toString() : any
|
||||
>fs.readFileSync(fileName).toString : any
|
||||
>fs.readFileSync(fileName) : any
|
||||
>fs.readFileSync : any
|
||||
>fs : any
|
||||
>readFileSync : any
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>toString : any
|
||||
|
||||
},
|
||||
@@ -130,8 +130,8 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
>() => options : () => ts.CompilerOptions
|
||||
>options : ts.CompilerOptions
|
||||
|
||||
getDefaultLibFilename: (options) => ts.getDefaultLibFilePath(options),
|
||||
>getDefaultLibFilename : (options: ts.CompilerOptions) => string
|
||||
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
|
||||
>getDefaultLibFileName : (options: ts.CompilerOptions) => string
|
||||
>(options) => ts.getDefaultLibFilePath(options) : (options: ts.CompilerOptions) => string
|
||||
>options : ts.CompilerOptions
|
||||
>ts.getDefaultLibFilePath(options) : string
|
||||
@@ -156,27 +156,27 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
>createDocumentRegistry : () => ts.DocumentRegistry
|
||||
|
||||
// Now let's watch the files
|
||||
rootFilenames.forEach(filename => {
|
||||
>rootFilenames.forEach(filename => { // First time around, emit all files emitFile(filename); // Add a watch on the file to handle next change fs.watchFile(filename, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[filename].version++; // write the changes to disk emitFile(filename); }); }) : void
|
||||
>rootFilenames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
|
||||
>rootFilenames : string[]
|
||||
rootFileNames.forEach(fileName => {
|
||||
>rootFileNames.forEach(fileName => { // First time around, emit all files emitFile(fileName); // Add a watch on the file to handle next change fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }); }) : void
|
||||
>rootFileNames.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
|
||||
>rootFileNames : string[]
|
||||
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
|
||||
>filename => { // First time around, emit all files emitFile(filename); // Add a watch on the file to handle next change fs.watchFile(filename, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[filename].version++; // write the changes to disk emitFile(filename); }); } : (filename: string) => void
|
||||
>filename : string
|
||||
>fileName => { // First time around, emit all files emitFile(fileName); // Add a watch on the file to handle next change fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }); } : (fileName: string) => void
|
||||
>fileName : string
|
||||
|
||||
// First time around, emit all files
|
||||
emitFile(filename);
|
||||
>emitFile(filename) : void
|
||||
>emitFile : (filename: string) => void
|
||||
>filename : string
|
||||
emitFile(fileName);
|
||||
>emitFile(fileName) : void
|
||||
>emitFile : (fileName: string) => void
|
||||
>fileName : string
|
||||
|
||||
// Add a watch on the file to handle next change
|
||||
fs.watchFile(filename,
|
||||
>fs.watchFile(filename, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[filename].version++; // write the changes to disk emitFile(filename); }) : any
|
||||
fs.watchFile(fileName,
|
||||
>fs.watchFile(fileName, { persistent: true, interval: 250 }, (curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); }) : any
|
||||
>fs.watchFile : any
|
||||
>fs : any
|
||||
>watchFile : any
|
||||
>filename : string
|
||||
>fileName : string
|
||||
|
||||
{ persistent: true, interval: 250 },
|
||||
>{ persistent: true, interval: 250 } : { persistent: boolean; interval: number; }
|
||||
@@ -184,7 +184,7 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
>interval : number
|
||||
|
||||
(curr, prev) => {
|
||||
>(curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[filename].version++; // write the changes to disk emitFile(filename); } : (curr: any, prev: any) => void
|
||||
>(curr, prev) => { // Check timestamp if (+curr.mtime <= +prev.mtime) { return; } // Update the version to signal a change in the file files[fileName].version++; // write the changes to disk emitFile(fileName); } : (curr: any, prev: any) => void
|
||||
>curr : any
|
||||
>prev : any
|
||||
|
||||
@@ -204,34 +204,34 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
}
|
||||
|
||||
// Update the version to signal a change in the file
|
||||
files[filename].version++;
|
||||
>files[filename].version++ : number
|
||||
>files[filename].version : number
|
||||
>files[filename] : { version: number; }
|
||||
files[fileName].version++;
|
||||
>files[fileName].version++ : number
|
||||
>files[fileName].version : number
|
||||
>files[fileName] : { version: number; }
|
||||
>files : ts.Map<{ version: number; }>
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>version : number
|
||||
|
||||
// write the changes to disk
|
||||
emitFile(filename);
|
||||
>emitFile(filename) : void
|
||||
>emitFile : (filename: string) => void
|
||||
>filename : string
|
||||
emitFile(fileName);
|
||||
>emitFile(fileName) : void
|
||||
>emitFile : (fileName: string) => void
|
||||
>fileName : string
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
function emitFile(filename: string) {
|
||||
>emitFile : (filename: string) => void
|
||||
>filename : string
|
||||
function emitFile(fileName: string) {
|
||||
>emitFile : (fileName: string) => void
|
||||
>fileName : string
|
||||
|
||||
var output = services.getEmitOutput(filename);
|
||||
var output = services.getEmitOutput(fileName);
|
||||
>output : ts.EmitOutput
|
||||
>services.getEmitOutput(filename) : ts.EmitOutput
|
||||
>services.getEmitOutput(fileName) : ts.EmitOutput
|
||||
>services.getEmitOutput : (fileName: string) => ts.EmitOutput
|
||||
>services : ts.LanguageService
|
||||
>getEmitOutput : (fileName: string) => ts.EmitOutput
|
||||
>filename : string
|
||||
>fileName : string
|
||||
|
||||
if (output.emitOutputStatus === ts.EmitReturnStatus.Succeeded) {
|
||||
>output.emitOutputStatus === ts.EmitReturnStatus.Succeeded : boolean
|
||||
@@ -244,25 +244,25 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
>EmitReturnStatus : typeof ts.EmitReturnStatus
|
||||
>Succeeded : ts.EmitReturnStatus
|
||||
|
||||
console.log(`Emitting ${filename}`);
|
||||
>console.log(`Emitting ${filename}`) : any
|
||||
console.log(`Emitting ${fileName}`);
|
||||
>console.log(`Emitting ${fileName}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
>filename : string
|
||||
>fileName : string
|
||||
}
|
||||
else {
|
||||
console.log(`Emitting ${filename} failed`);
|
||||
>console.log(`Emitting ${filename} failed`) : any
|
||||
console.log(`Emitting ${fileName} failed`);
|
||||
>console.log(`Emitting ${fileName} failed`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
>filename : string
|
||||
>fileName : string
|
||||
|
||||
logErrors(filename);
|
||||
>logErrors(filename) : void
|
||||
>logErrors : (filename: string) => void
|
||||
>filename : string
|
||||
logErrors(fileName);
|
||||
>logErrors(fileName) : void
|
||||
>logErrors : (fileName: string) => void
|
||||
>fileName : string
|
||||
}
|
||||
|
||||
output.outputFiles.forEach(o => {
|
||||
@@ -290,43 +290,43 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
});
|
||||
}
|
||||
|
||||
function logErrors(filename: string) {
|
||||
>logErrors : (filename: string) => void
|
||||
>filename : string
|
||||
function logErrors(fileName: string) {
|
||||
>logErrors : (fileName: string) => void
|
||||
>fileName : string
|
||||
|
||||
var allDiagnostics = services.getCompilerOptionsDiagnostics()
|
||||
>allDiagnostics : ts.Diagnostic[]
|
||||
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(filename)) .concat(services.getSemanticDiagnostics(filename)) : ts.Diagnostic[]
|
||||
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(filename)) .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(filename)) : ts.Diagnostic[]
|
||||
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) .concat(services.getSemanticDiagnostics(fileName)) : ts.Diagnostic[]
|
||||
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) : ts.Diagnostic[]
|
||||
>services.getCompilerOptionsDiagnostics() .concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>services.getCompilerOptionsDiagnostics() : ts.Diagnostic[]
|
||||
>services.getCompilerOptionsDiagnostics : () => ts.Diagnostic[]
|
||||
>services : ts.LanguageService
|
||||
>getCompilerOptionsDiagnostics : () => ts.Diagnostic[]
|
||||
|
||||
.concat(services.getSyntacticDiagnostics(filename))
|
||||
.concat(services.getSyntacticDiagnostics(fileName))
|
||||
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>services.getSyntacticDiagnostics(filename) : ts.Diagnostic[]
|
||||
>services.getSyntacticDiagnostics(fileName) : ts.Diagnostic[]
|
||||
>services.getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[]
|
||||
>services : ts.LanguageService
|
||||
>getSyntacticDiagnostics : (fileName: string) => ts.Diagnostic[]
|
||||
>filename : string
|
||||
>fileName : string
|
||||
|
||||
.concat(services.getSemanticDiagnostics(filename));
|
||||
.concat(services.getSemanticDiagnostics(fileName));
|
||||
>concat : { <U extends ts.Diagnostic[]>(...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; }
|
||||
>services.getSemanticDiagnostics(filename) : ts.Diagnostic[]
|
||||
>services.getSemanticDiagnostics(fileName) : ts.Diagnostic[]
|
||||
>services.getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[]
|
||||
>services : ts.LanguageService
|
||||
>getSemanticDiagnostics : (fileName: string) => ts.Diagnostic[]
|
||||
>filename : string
|
||||
>fileName : string
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
>allDiagnostics.forEach(diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(` Error ${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`); } else { console.log(` Error: ${diagnostic.messageText}`); } }) : void
|
||||
>allDiagnostics.forEach(diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`); } else { console.log(` Error: ${diagnostic.messageText}`); } }) : void
|
||||
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>allDiagnostics : ts.Diagnostic[]
|
||||
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(` Error ${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`); } else { console.log(` Error: ${diagnostic.messageText}`); } } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`); } else { console.log(` Error: ${diagnostic.messageText}`); } } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic : ts.Diagnostic
|
||||
|
||||
if (diagnostic.file) {
|
||||
@@ -337,25 +337,25 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition : (position: number) => ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.file : ts.SourceFile
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (position: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.start : number
|
||||
>diagnostic : ts.Diagnostic
|
||||
>start : number
|
||||
|
||||
console.log(` Error ${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
>console.log(` Error ${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`) : any
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
>console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
>diagnostic.file.filename : string
|
||||
>diagnostic.file.fileName : string
|
||||
>diagnostic.file : ts.SourceFile
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>lineChar.line : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>line : number
|
||||
@@ -383,7 +383,7 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
// Initialize files constituting the program as all .ts files in the current directory
|
||||
var currentDirectoryFiles = fs.readdirSync(process.cwd()).
|
||||
>currentDirectoryFiles : any
|
||||
>fs.readdirSync(process.cwd()). filter(filename=> filename.length >= 3 && filename.substr(filename.length - 3, 3) === ".ts") : any
|
||||
>fs.readdirSync(process.cwd()). filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts") : any
|
||||
>fs.readdirSync(process.cwd()). filter : any
|
||||
>fs.readdirSync(process.cwd()) : any
|
||||
>fs.readdirSync : any
|
||||
@@ -394,29 +394,29 @@ var currentDirectoryFiles = fs.readdirSync(process.cwd()).
|
||||
>process : any
|
||||
>cwd : any
|
||||
|
||||
filter(filename=> filename.length >= 3 && filename.substr(filename.length - 3, 3) === ".ts");
|
||||
filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts");
|
||||
>filter : any
|
||||
>filename=> filename.length >= 3 && filename.substr(filename.length - 3, 3) === ".ts" : (filename: any) => boolean
|
||||
>filename : any
|
||||
>filename.length >= 3 && filename.substr(filename.length - 3, 3) === ".ts" : boolean
|
||||
>filename.length >= 3 : boolean
|
||||
>filename.length : any
|
||||
>filename : any
|
||||
>fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts" : (fileName: any) => boolean
|
||||
>fileName : any
|
||||
>fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts" : boolean
|
||||
>fileName.length >= 3 : boolean
|
||||
>fileName.length : any
|
||||
>fileName : any
|
||||
>length : any
|
||||
>filename.substr(filename.length - 3, 3) === ".ts" : boolean
|
||||
>filename.substr(filename.length - 3, 3) : any
|
||||
>filename.substr : any
|
||||
>filename : any
|
||||
>fileName.substr(fileName.length - 3, 3) === ".ts" : boolean
|
||||
>fileName.substr(fileName.length - 3, 3) : any
|
||||
>fileName.substr : any
|
||||
>fileName : any
|
||||
>substr : any
|
||||
>filename.length - 3 : number
|
||||
>filename.length : any
|
||||
>filename : any
|
||||
>fileName.length - 3 : number
|
||||
>fileName.length : any
|
||||
>fileName : any
|
||||
>length : any
|
||||
|
||||
// Start the watcher
|
||||
watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });
|
||||
>watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }) : void
|
||||
>watch : (rootFilenames: string[], options: ts.CompilerOptions) => void
|
||||
>watch : (rootFileNames: string[], options: ts.CompilerOptions) => void
|
||||
>currentDirectoryFiles : any
|
||||
>{ module: ts.ModuleKind.CommonJS } : { [x: string]: ts.ModuleKind; module: ts.ModuleKind; }
|
||||
>module : ts.ModuleKind
|
||||
@@ -2436,8 +2436,8 @@ declare module "typescript" {
|
||||
>FileReference : FileReference
|
||||
>TextRange : TextRange
|
||||
|
||||
filename: string;
|
||||
>filename : string
|
||||
fileName: string;
|
||||
>fileName : string
|
||||
}
|
||||
interface CommentRange extends TextRange {
|
||||
>CommentRange : CommentRange
|
||||
@@ -2459,32 +2459,12 @@ declare module "typescript" {
|
||||
>endOfFileToken : Node
|
||||
>Node : Node
|
||||
|
||||
filename: string;
|
||||
>filename : string
|
||||
fileName: string;
|
||||
>fileName : string
|
||||
|
||||
text: string;
|
||||
>text : string
|
||||
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (position: number) => LineAndCharacter
|
||||
>position : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
|
||||
amdDependencies: string[];
|
||||
>amdDependencies : string[]
|
||||
|
||||
@@ -2495,22 +2475,6 @@ declare module "typescript" {
|
||||
>referencedFiles : FileReference[]
|
||||
>FileReference : FileReference
|
||||
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
>referenceDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
parseDiagnostics: Diagnostic[];
|
||||
>parseDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
>semanticDiagnostics : Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
hasNoDefaultLib: boolean;
|
||||
>hasNoDefaultLib : boolean
|
||||
|
||||
@@ -2518,15 +2482,6 @@ declare module "typescript" {
|
||||
>externalModuleIndicator : Node
|
||||
>Node : Node
|
||||
|
||||
nodeCount: number;
|
||||
>nodeCount : number
|
||||
|
||||
identifierCount: number;
|
||||
>identifierCount : number
|
||||
|
||||
symbolCount: number;
|
||||
>symbolCount : number
|
||||
|
||||
languageVersion: ScriptTarget;
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
@@ -2542,9 +2497,9 @@ declare module "typescript" {
|
||||
>getCompilerOptions : () => CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getCurrentDirectory(): string;
|
||||
@@ -2700,9 +2655,9 @@ declare module "typescript" {
|
||||
>getSourceFiles : () => SourceFile[]
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
}
|
||||
interface TypeChecker {
|
||||
@@ -4091,6 +4046,9 @@ declare module "typescript" {
|
||||
watch?: boolean;
|
||||
>watch : boolean
|
||||
|
||||
stripInternal?: boolean;
|
||||
>stripInternal : boolean
|
||||
|
||||
[option: string]: string | number | boolean;
|
||||
>option : string
|
||||
}
|
||||
@@ -4137,8 +4095,8 @@ declare module "typescript" {
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
filenames: string[];
|
||||
>filenames : string[]
|
||||
fileNames: string[];
|
||||
>fileNames : string[]
|
||||
|
||||
errors: Diagnostic[];
|
||||
>errors : Diagnostic[]
|
||||
@@ -4171,6 +4129,9 @@ declare module "typescript" {
|
||||
error?: DiagnosticMessage;
|
||||
>error : DiagnosticMessage
|
||||
>DiagnosticMessage : DiagnosticMessage
|
||||
|
||||
experimental?: boolean;
|
||||
>experimental : boolean
|
||||
}
|
||||
const enum CharacterCodes {
|
||||
>CharacterCodes : CharacterCodes
|
||||
@@ -4553,17 +4514,17 @@ declare module "typescript" {
|
||||
interface CompilerHost {
|
||||
>CompilerHost : CompilerHost
|
||||
|
||||
getSourceFile(filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
>getSourceFile : (filename: string, languageVersion: ScriptTarget, onError?: (message: string) => void) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
>getSourceFile : (fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) => SourceFile
|
||||
>fileName : string
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
>onError : (message: string) => void
|
||||
>message : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
>getDefaultLibFilename : (options: CompilerOptions) => string
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
>getDefaultLibFileName : (options: CompilerOptions) => string
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
@@ -4571,9 +4532,9 @@ declare module "typescript" {
|
||||
>getCancellationToken : () => CancellationToken
|
||||
>CancellationToken : CancellationToken
|
||||
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
>writeFile : (filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) => void
|
||||
>filename : string
|
||||
writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
>writeFile : (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) => void
|
||||
>fileName : string
|
||||
>data : string
|
||||
>writeByteOrderMark : boolean
|
||||
>onError : (message: string) => void
|
||||
@@ -4702,14 +4663,26 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function getLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
>getLineAndCharacterOfPosition : (lineStarts: number[], position: number) => { line: number; character: number; }
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
>getLineStarts : (sourceFile: SourceFile) => number[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
>computeLineAndCharacterOfPosition : (lineStarts: number[], position: number) => { line: number; character: number; }
|
||||
>lineStarts : number[]
|
||||
>position : number
|
||||
|
||||
@@ -4720,18 +4693,13 @@ declare module "typescript" {
|
||||
>character : number
|
||||
|
||||
};
|
||||
function positionToLineAndCharacter(text: string, pos: number): {
|
||||
>positionToLineAndCharacter : (text: string, pos: number) => { line: number; character: number; }
|
||||
>text : string
|
||||
>pos : number
|
||||
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (sourceFile: SourceFile, position: number) => LineAndCharacter
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>position : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
line: number;
|
||||
>line : number
|
||||
|
||||
character: number;
|
||||
>character : number
|
||||
|
||||
};
|
||||
function isWhiteSpace(ch: number): boolean;
|
||||
>isWhiteSpace : (ch: number) => boolean
|
||||
>ch : number
|
||||
@@ -4818,14 +4786,29 @@ declare module "typescript" {
|
||||
>SyntaxKind : SyntaxKind
|
||||
>NodeFlags : NodeFlags
|
||||
|
||||
function getSyntacticDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
>getSyntacticDiagnostics : (sourceFile: SourceFile) => Diagnostic[]
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateSourceFile : (sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
>isEvalOrArgumentsIdentifier : (node: Node) => boolean
|
||||
>node : Node
|
||||
>Node : Node
|
||||
|
||||
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
>createSourceFile : (filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean) => SourceFile
|
||||
>filename : string
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
>createSourceFile : (fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean) => SourceFile
|
||||
>fileName : string
|
||||
>sourceText : string
|
||||
>languageVersion : ScriptTarget
|
||||
>ScriptTarget : ScriptTarget
|
||||
@@ -5039,6 +5022,30 @@ declare module "typescript" {
|
||||
getNamedDeclarations(): Declaration[];
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
>getSyntacticDiagnostics : () => Diagnostic[]
|
||||
>Diagnostic : Diagnostic
|
||||
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>update : (newText: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>newText : string
|
||||
>textChangeRange : TextChangeRange
|
||||
>TextChangeRange : TextChangeRange
|
||||
>SourceFile : SourceFile
|
||||
}
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
@@ -5125,8 +5132,8 @@ declare module "typescript" {
|
||||
getCurrentDirectory(): string;
|
||||
>getCurrentDirectory : () => string
|
||||
|
||||
getDefaultLibFilename(options: CompilerOptions): string;
|
||||
>getDefaultLibFilename : (options: CompilerOptions) => string
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
>getDefaultLibFileName : (options: CompilerOptions) => string
|
||||
>options : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
|
||||
@@ -5315,9 +5322,9 @@ declare module "typescript" {
|
||||
>getProgram : () => Program
|
||||
>Program : Program
|
||||
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
>getSourceFile : (filename: string) => SourceFile
|
||||
>filename : string
|
||||
getSourceFile(fileName: string): SourceFile;
|
||||
>getSourceFile : (fileName: string) => SourceFile
|
||||
>fileName : string
|
||||
>SourceFile : SourceFile
|
||||
|
||||
dispose(): void;
|
||||
@@ -5907,11 +5914,11 @@ declare module "typescript" {
|
||||
>DocumentRegistry : DocumentRegistry
|
||||
|
||||
/**
|
||||
* Request a stored SourceFile with a given filename and compilationSettings.
|
||||
* Request a stored SourceFile with a given fileName and compilationSettings.
|
||||
* The first call to acquire will call createLanguageServiceSourceFile to generate
|
||||
* the SourceFile if was not found in the registry.
|
||||
*
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -5920,9 +5927,9 @@ declare module "typescript" {
|
||||
* @parm version Current version of the file. Only used if the file was not found
|
||||
* in the registry and a new one was created.
|
||||
*/
|
||||
acquireDocument(filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
>acquireDocument : (filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile
|
||||
>filename : string
|
||||
acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string): SourceFile;
|
||||
>acquireDocument : (fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string) => SourceFile
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
@@ -5931,7 +5938,7 @@ declare module "typescript" {
|
||||
>SourceFile : SourceFile
|
||||
|
||||
/**
|
||||
* Request an updated version of an already existing SourceFile with a given filename
|
||||
* Request an updated version of an already existing SourceFile with a given fileName
|
||||
* and compilationSettings. The update will intern call updateLanguageServiceSourceFile
|
||||
* to get an updated SourceFile.
|
||||
*
|
||||
@@ -5939,7 +5946,7 @@ declare module "typescript" {
|
||||
* registry originally.
|
||||
*
|
||||
* @param sourceFile The original sourceFile object to update
|
||||
* @param filename The name of the file requested
|
||||
* @param fileName The name of the file requested
|
||||
* @param compilationSettings Some compilation settings like target affects the
|
||||
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
|
||||
* multiple copies of the same file for different compilation settings.
|
||||
@@ -5950,11 +5957,11 @@ declare module "typescript" {
|
||||
* @parm textChangeRange Change ranges since the last snapshot. Only used if the file
|
||||
* was not found in the registry and a new one was created.
|
||||
*/
|
||||
updateDocument(sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateDocument : (sourceFile: SourceFile, filename: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
updateDocument(sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
>updateDocument : (sourceFile: SourceFile, fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange) => SourceFile
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>filename : string
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
@@ -5970,12 +5977,12 @@ declare module "typescript" {
|
||||
* Note: It is not allowed to call release on a SourceFile that was not acquired from
|
||||
* this registry originally.
|
||||
*
|
||||
* @param filename The name of the file to be released
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(filename: string, compilationSettings: CompilerOptions): void;
|
||||
>releaseDocument : (filename: string, compilationSettings: CompilerOptions) => void
|
||||
>filename : string
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
>releaseDocument : (fileName: string, compilationSettings: CompilerOptions) => void
|
||||
>fileName : string
|
||||
>compilationSettings : CompilerOptions
|
||||
>CompilerOptions : CompilerOptions
|
||||
}
|
||||
@@ -6175,9 +6182,9 @@ declare module "typescript" {
|
||||
throwIfCancellationRequested(): void;
|
||||
>throwIfCancellationRequested : () => void
|
||||
}
|
||||
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
>createLanguageServiceSourceFile : (filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile
|
||||
>filename : string
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
>createLanguageServiceSourceFile : (fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean) => SourceFile
|
||||
>fileName : string
|
||||
>scriptSnapshot : IScriptSnapshot
|
||||
>IScriptSnapshot : IScriptSnapshot
|
||||
>scriptTarget : ScriptTarget
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile1.js
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
var x = 5;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
}
|
||||
return Bar;
|
||||
})();
|
||||
Filename : tests/cases/fourslash/inputFile1.d.ts
|
||||
FileName : tests/cases/fourslash/inputFile1.d.ts
|
||||
declare var x: number;
|
||||
declare class Bar {
|
||||
x: string;
|
||||
@@ -14,14 +14,14 @@ declare class Bar {
|
||||
}
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile2.js
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
var x1 = "hello world";
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
Filename : tests/cases/fourslash/inputFile2.d.ts
|
||||
FileName : tests/cases/fourslash/inputFile2.d.ts
|
||||
declare var x1: string;
|
||||
declare class Foo {
|
||||
x: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : declSingleFile.js
|
||||
FileName : declSingleFile.js
|
||||
var x = 5;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
@@ -12,7 +12,7 @@ var Foo = (function () {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
Filename : declSingleFile.d.ts
|
||||
FileName : declSingleFile.d.ts
|
||||
declare var x: number;
|
||||
declare class Bar {
|
||||
x: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : declSingleFile.js
|
||||
FileName : declSingleFile.js
|
||||
var x = 5;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : JSGeneratedWithSemanticErrors
|
||||
Filename : declSingleFile.js
|
||||
FileName : declSingleFile.js
|
||||
var x = 5;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : declSingleFile.js.map
|
||||
{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../tests/cases/fourslash/inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : declSingleFile.js
|
||||
FileName : declSingleFile.js.map
|
||||
{"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../tests/cases/fourslash/inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : declSingleFile.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile.js
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var x;
|
||||
var M = (function () {
|
||||
function M() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile2.js
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
var x;
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : outputDir/singleFile.js
|
||||
FileName : outputDir/singleFile.js
|
||||
var x;
|
||||
var Bar = (function () {
|
||||
function Bar() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile3.js
|
||||
FileName : tests/cases/fourslash/inputFile3.js
|
||||
exports.foo = 10;
|
||||
exports.bar = "hello world";
|
||||
Filename : tests/cases/fourslash/inputFile3.d.ts
|
||||
FileName : tests/cases/fourslash/inputFile3.d.ts
|
||||
export declare var foo: number;
|
||||
export declare var bar: string;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile.js.map
|
||||
{"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : tests/cases/fourslash/inputFile.js
|
||||
FileName : tests/cases/fourslash/inputFile.js.map
|
||||
{"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : sample/outDir/inputFile1.js.map
|
||||
{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile1.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : sample/outDir/inputFile1.js
|
||||
FileName : sample/outDir/inputFile1.js.map
|
||||
{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile1.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : sample/outDir/inputFile1.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
@@ -10,8 +10,8 @@ var M = (function () {
|
||||
})();
|
||||
//# sourceMappingURL=inputFile1.js.map
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : sample/outDir/inputFile2.js.map
|
||||
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,aAAa,CAAC;AAC1B,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,EAAE,CAAC;AACd,CAAC"}Filename : sample/outDir/inputFile2.js
|
||||
FileName : sample/outDir/inputFile2.js.map
|
||||
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,aAAa,CAAC;AAC1B,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,EAAE,CAAC;AACd,CAAC"}FileName : sample/outDir/inputFile2.js
|
||||
var intro = "hello world";
|
||||
if (intro !== undefined) {
|
||||
var k = 10;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile.js.map
|
||||
{"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : tests/cases/fourslash/inputFile.js
|
||||
FileName : tests/cases/fourslash/inputFile.js.map
|
||||
{"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile1.js.map
|
||||
{"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : tests/cases/fourslash/inputFile1.js
|
||||
FileName : tests/cases/fourslash/inputFile1.js.map
|
||||
{"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js
|
||||
var x = 109;
|
||||
var foo = "hello world";
|
||||
var M = (function () {
|
||||
@@ -10,8 +10,8 @@ var M = (function () {
|
||||
})();
|
||||
//# sourceMappingURL=inputFile1.js.map
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile2.js.map
|
||||
{"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":["C","C.constructor"],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : tests/cases/fourslash/inputFile2.js
|
||||
FileName : tests/cases/fourslash/inputFile2.js.map
|
||||
{"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":["C","C.constructor"],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile2.js
|
||||
var bar = "hello world Typescript";
|
||||
var C = (function () {
|
||||
function C() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile2.js
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
var x1 = "hello world";
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile2.js
|
||||
FileName : tests/cases/fourslash/inputFile2.js
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
@@ -10,6 +10,6 @@ var Foo = (function () {
|
||||
exports.Foo = Foo;
|
||||
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile3.js
|
||||
FileName : tests/cases/fourslash/inputFile3.js
|
||||
var x = "hello";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : declSingle.js
|
||||
FileName : declSingle.js
|
||||
var x = "hello";
|
||||
var x1 = 1000;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : JSGeneratedWithSemanticErrors
|
||||
Filename : tests/cases/fourslash/inputFile1.js
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
// File contains early errors. All outputs should be skipped.
|
||||
const uninitialized_const_error;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : EmitErrorsEncountered
|
||||
Filename : tests/cases/fourslash/inputFile.js
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var M;
|
||||
(function (M) {
|
||||
var C = (function () {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : EmitErrorsEncountered
|
||||
Filename : tests/cases/fourslash/inputFile.js
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
EmitOutputStatus : JSGeneratedWithSemanticErrors
|
||||
Filename : tests/cases/fourslash/inputFile.js
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var x = "hello world";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
EmitOutputStatus : DeclarationGenerationSkipped
|
||||
Filename : tests/cases/fourslash/inputFile.js
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var x = "hello world";
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile1.js
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
// File to emit, does not contain semantic errors
|
||||
// expected to be emitted correctelly regardless of the semantic errors in the other file
|
||||
var noErrors = true;
|
||||
Filename : tests/cases/fourslash/inputFile1.d.ts
|
||||
FileName : tests/cases/fourslash/inputFile1.d.ts
|
||||
declare var noErrors: boolean;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : DeclarationGenerationSkipped
|
||||
Filename : out.js
|
||||
FileName : out.js
|
||||
// File to emit, does not contain semantic errors, but --out is passed
|
||||
// expected to not generate declarations because of the semantic errors in the other file
|
||||
var noErrors = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile1.js
|
||||
FileName : tests/cases/fourslash/inputFile1.js
|
||||
// File to emit, does not contain syntactic errors
|
||||
// expected to be emitted correctelly regardless of the syntactic errors in the other file
|
||||
var noErrors = true;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : out.js
|
||||
FileName : out.js
|
||||
// File to emit, does not contain syntactic errors, but --out is passed
|
||||
// expected to not generate outputs because of the syntactic errors in the other file.
|
||||
var noErrors = true;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile.js
|
||||
FileName : tests/cases/fourslash/inputFile.js
|
||||
var x;
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [stripInternal1.ts]
|
||||
|
||||
class C {
|
||||
foo(): void { }
|
||||
// @internal
|
||||
bar(): void { }
|
||||
}
|
||||
|
||||
//// [stripInternal1.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
// @internal
|
||||
C.prototype.bar = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
|
||||
|
||||
//// [stripInternal1.d.ts]
|
||||
declare class C {
|
||||
foo(): void;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/stripInternal1.ts ===
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
foo(): void { }
|
||||
>foo : () => void
|
||||
|
||||
// @internal
|
||||
bar(): void { }
|
||||
>bar : () => void
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// @module: commonjs
|
||||
// @includebuiltfile: typescript.d.ts
|
||||
// @stripInternal:true
|
||||
|
||||
/*
|
||||
* Note: This test is a public API sample. The sample sources can be found
|
||||
@@ -12,9 +13,9 @@ declare var console: any;
|
||||
|
||||
import ts = require("typescript");
|
||||
|
||||
export function compile(filenames: string[], options: ts.CompilerOptions): void {
|
||||
export function compile(fileNames: string[], options: ts.CompilerOptions): void {
|
||||
var host = ts.createCompilerHost(options);
|
||||
var program = ts.createProgram(filenames, options, host);
|
||||
var program = ts.createProgram(fileNames, options, host);
|
||||
var checker = ts.createTypeChecker(program, /*produceDiagnostics*/ true);
|
||||
var result = program.emitFiles();
|
||||
|
||||
@@ -24,7 +25,7 @@ export function compile(filenames: string[], options: ts.CompilerOptions): void
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(`${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
});
|
||||
|
||||
console.log(`Process exiting with code '${result.emitResultStatus}'.`);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// @module: commonjs
|
||||
// @includebuiltfile: typescript.d.ts
|
||||
// @stripInternal:true
|
||||
|
||||
/*
|
||||
* Note: This test is a public API sample. The sample sources can be found
|
||||
@@ -51,14 +52,14 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
|
||||
function report(node: ts.Node, message: string) {
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
console.log(`${sourceFile.filename} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
}
|
||||
}
|
||||
|
||||
var filenames = process.argv.slice(2);
|
||||
filenames.forEach(filename => {
|
||||
var fileNames = process.argv.slice(2);
|
||||
fileNames.forEach(fileName => {
|
||||
// Parse a file
|
||||
var sourceFile = ts.createSourceFile(filename, fs.readFileSync(filename).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
|
||||
var sourceFile = ts.createSourceFile(fileName, fs.readFileSync(fileName).toString(), ts.ScriptTarget.ES6, /*setParentNodes */ true);
|
||||
|
||||
// delint it
|
||||
delint(sourceFile);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// @module: commonjs
|
||||
// @includebuiltfile: typescript.d.ts
|
||||
// @stripInternal:true
|
||||
|
||||
/*
|
||||
* Note: This test is a public API sample. The sample sources can be found
|
||||
@@ -26,16 +27,16 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
|
||||
// Create a compilerHost object to allow the compiler to read and write files
|
||||
var compilerHost = {
|
||||
getSourceFile: (filename, target) => {
|
||||
return files[filename] !== undefined ?
|
||||
ts.createSourceFile(filename, files[filename], target) : undefined;
|
||||
getSourceFile: (fileName, target) => {
|
||||
return files[fileName] !== undefined ?
|
||||
ts.createSourceFile(fileName, files[fileName], target) : undefined;
|
||||
},
|
||||
writeFile: (name, text, writeByteOrderMark) => {
|
||||
outputs.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
|
||||
},
|
||||
getDefaultLibFilename: () => "lib.d.ts",
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
useCaseSensitiveFileNames: () => false,
|
||||
getCanonicalFileName: (filename) => filename,
|
||||
getCanonicalFileName: (fileName) => fileName,
|
||||
getCurrentDirectory: () => "",
|
||||
getNewLine: () => "\n"
|
||||
};
|
||||
@@ -55,7 +56,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
}
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) { return e.file.filename + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; })
|
||||
errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + e.messageText; })
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// @module: commonjs
|
||||
// @includebuiltfile: typescript.d.ts
|
||||
// @stripInternal:true
|
||||
|
||||
/*
|
||||
* Note: This test is a public API sample. The sample sources can be found
|
||||
@@ -14,40 +15,40 @@ declare var path: any;
|
||||
|
||||
import ts = require("typescript");
|
||||
|
||||
function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
var files: ts.Map<{ version: number }> = {};
|
||||
|
||||
// initialize the list of files
|
||||
rootFilenames.forEach(filename => {
|
||||
files[filename] = { version: 0 };
|
||||
rootFileNames.forEach(fileName => {
|
||||
files[fileName] = { version: 0 };
|
||||
});
|
||||
|
||||
// Create the language service host to allow the LS to communicate with the host
|
||||
var servicesHost: ts.LanguageServiceHost = {
|
||||
getScriptFileNames: () => rootFilenames,
|
||||
getScriptVersion: (filename) => files[filename] && files[filename].version.toString(),
|
||||
getScriptSnapshot: (filename) => {
|
||||
if (!fs.existsSync(filename)) {
|
||||
getScriptFileNames: () => rootFileNames,
|
||||
getScriptVersion: (fileName) => files[fileName] && files[fileName].version.toString(),
|
||||
getScriptSnapshot: (fileName) => {
|
||||
if (!fs.existsSync(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return ts.ScriptSnapshot.fromString(fs.readFileSync(filename).toString());
|
||||
return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString());
|
||||
},
|
||||
getCurrentDirectory: () => process.cwd(),
|
||||
getCompilationSettings: () => options,
|
||||
getDefaultLibFilename: (options) => ts.getDefaultLibFilePath(options),
|
||||
getDefaultLibFileName: (options) => ts.getDefaultLibFilePath(options),
|
||||
};
|
||||
|
||||
// Create the language service files
|
||||
var services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry())
|
||||
|
||||
// Now let's watch the files
|
||||
rootFilenames.forEach(filename => {
|
||||
rootFileNames.forEach(fileName => {
|
||||
// First time around, emit all files
|
||||
emitFile(filename);
|
||||
emitFile(fileName);
|
||||
|
||||
// Add a watch on the file to handle next change
|
||||
fs.watchFile(filename,
|
||||
fs.watchFile(fileName,
|
||||
{ persistent: true, interval: 250 },
|
||||
(curr, prev) => {
|
||||
// Check timestamp
|
||||
@@ -56,22 +57,22 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
}
|
||||
|
||||
// Update the version to signal a change in the file
|
||||
files[filename].version++;
|
||||
files[fileName].version++;
|
||||
|
||||
// write the changes to disk
|
||||
emitFile(filename);
|
||||
emitFile(fileName);
|
||||
});
|
||||
});
|
||||
|
||||
function emitFile(filename: string) {
|
||||
var output = services.getEmitOutput(filename);
|
||||
function emitFile(fileName: string) {
|
||||
var output = services.getEmitOutput(fileName);
|
||||
|
||||
if (output.emitOutputStatus === ts.EmitReturnStatus.Succeeded) {
|
||||
console.log(`Emitting ${filename}`);
|
||||
console.log(`Emitting ${fileName}`);
|
||||
}
|
||||
else {
|
||||
console.log(`Emitting ${filename} failed`);
|
||||
logErrors(filename);
|
||||
console.log(`Emitting ${fileName} failed`);
|
||||
logErrors(fileName);
|
||||
}
|
||||
|
||||
output.outputFiles.forEach(o => {
|
||||
@@ -79,15 +80,15 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
});
|
||||
}
|
||||
|
||||
function logErrors(filename: string) {
|
||||
function logErrors(fileName: string) {
|
||||
var allDiagnostics = services.getCompilerOptionsDiagnostics()
|
||||
.concat(services.getSyntacticDiagnostics(filename))
|
||||
.concat(services.getSemanticDiagnostics(filename));
|
||||
.concat(services.getSyntacticDiagnostics(fileName))
|
||||
.concat(services.getSemanticDiagnostics(fileName));
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
if (diagnostic.file) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(` Error ${diagnostic.file.filename} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${diagnostic.messageText}`);
|
||||
}
|
||||
else {
|
||||
console.log(` Error: ${diagnostic.messageText}`);
|
||||
@@ -98,7 +99,7 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) {
|
||||
|
||||
// Initialize files constituting the program as all .ts files in the current directory
|
||||
var currentDirectoryFiles = fs.readdirSync(process.cwd()).
|
||||
filter(filename=> filename.length >= 3 && filename.substr(filename.length - 3, 3) === ".ts");
|
||||
filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts");
|
||||
|
||||
// Start the watcher
|
||||
watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });
|
||||
@@ -0,0 +1,8 @@
|
||||
// @declaration:true
|
||||
// @stripInternal:true
|
||||
|
||||
class C {
|
||||
foo(): void { }
|
||||
// @internal
|
||||
bar(): void { }
|
||||
}
|
||||
@@ -24,8 +24,8 @@ module ts {
|
||||
}
|
||||
|
||||
function assertSameDiagnostics(file1: SourceFile, file2: SourceFile) {
|
||||
var diagnostics1 = file1.getSyntacticDiagnostics();
|
||||
var diagnostics2 = file2.getSyntacticDiagnostics();
|
||||
var diagnostics1 = getSyntacticDiagnostics(file1);
|
||||
var diagnostics2 = getSyntacticDiagnostics(file2);
|
||||
|
||||
assert.equal(diagnostics1.length, diagnostics2.length, "diagnostics1.length !== diagnostics2.length");
|
||||
for (var i = 0, n = diagnostics1.length; i < n; i++) {
|
||||
@@ -68,8 +68,8 @@ module ts {
|
||||
// There should be no reused nodes between two trees that are fully parsed.
|
||||
assert.isTrue(reusedElements(oldTree, newTree) === 0);
|
||||
|
||||
assert.equal(newTree.filename, incrementalNewTree.filename, "newTree.filename !== incrementalNewTree.filename");
|
||||
assert.equal(newTree.text, incrementalNewTree.text, "newTree.filename !== incrementalNewTree.filename");
|
||||
assert.equal(newTree.fileName, incrementalNewTree.fileName, "newTree.fileName !== incrementalNewTree.fileName");
|
||||
assert.equal(newTree.text, incrementalNewTree.text, "newTree.text !== incrementalNewTree.text");
|
||||
|
||||
if (expectedReusedElements !== -1) {
|
||||
var actualReusedCount = reusedElements(oldTree, incrementalNewTree);
|
||||
@@ -781,7 +781,7 @@ module m3 { }\
|
||||
" }\r\n" +
|
||||
" \r\n" +
|
||||
" return {\r\n" +
|
||||
" getEmitOutput: (filename): Bar => null,\r\n" +
|
||||
" getEmitOutput: (fileName): Bar => null,\r\n" +
|
||||
" };\r\n" +
|
||||
" }";
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('PreProcessFile:', function () {
|
||||
var resultImportedFile = resultImportedFiles[i];
|
||||
var expectedImportedFile = expectedImportedFiles[i];
|
||||
|
||||
assert.equal(resultImportedFile.filename, expectedImportedFile.filename, "Imported file path does not match expected. Expected: " + expectedImportedFile.filename + ". Actual: " + resultImportedFile.filename + ".");
|
||||
assert.equal(resultImportedFile.fileName, expectedImportedFile.fileName, "Imported file path does not match expected. Expected: " + expectedImportedFile.fileName + ". Actual: " + resultImportedFile.fileName + ".");
|
||||
|
||||
assert.equal(resultImportedFile.pos, expectedImportedFile.pos, "Imported file position does not match expected. Expected: " + expectedImportedFile.pos + ". Actual: " + resultImportedFile.pos + ".");
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('PreProcessFile:', function () {
|
||||
var resultReferencedFile = resultReferencedFiles[i];
|
||||
var expectedReferencedFile = expectedReferencedFiles[i];
|
||||
|
||||
assert.equal(resultReferencedFile.filename, expectedReferencedFile.filename, "Referenced file path does not match expected. Expected: " + expectedReferencedFile.filename + ". Actual: " + resultReferencedFile.filename + ".");
|
||||
assert.equal(resultReferencedFile.fileName, expectedReferencedFile.fileName, "Referenced file path does not match expected. Expected: " + expectedReferencedFile.fileName + ". Actual: " + resultReferencedFile.fileName + ".");
|
||||
|
||||
assert.equal(resultReferencedFile.pos, expectedReferencedFile.pos, "Referenced file position does not match expected. Expected: " + expectedReferencedFile.pos + ". Actual: " + resultReferencedFile.pos + ".");
|
||||
|
||||
@@ -47,8 +47,8 @@ describe('PreProcessFile:', function () {
|
||||
it("Correctly return referenced files from triple slash", function () {
|
||||
test("///<reference path = \"refFile1.ts\" />" + "\n" + "///<reference path =\"refFile2.ts\"/>" + "\n" + "///<reference path=\"refFile3.ts\" />" + "\n" + "///<reference path= \"..\\refFile4d.ts\" />", true,
|
||||
{
|
||||
referencedFiles: [{ filename: "refFile1.ts", pos: 0, end: 37 }, { filename: "refFile2.ts", pos: 38, end: 73 },
|
||||
{ filename: "refFile3.ts", pos: 74, end: 109 }, { filename: "..\\refFile4d.ts", pos: 110, end: 150 }],
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 37 }, { fileName: "refFile2.ts", pos: 38, end: 73 },
|
||||
{ fileName: "refFile3.ts", pos: 74, end: 109 }, { fileName: "..\\refFile4d.ts", pos: 110, end: 150 }],
|
||||
importedFiles: <ts.FileReference[]>[],
|
||||
isLibFile: false
|
||||
});
|
||||
@@ -67,8 +67,8 @@ describe('PreProcessFile:', function () {
|
||||
test("import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");", true,
|
||||
{
|
||||
referencedFiles: <ts.FileReference[]>[],
|
||||
importedFiles: [{ filename: "r1.ts", pos: 20, end: 25 }, { filename: "r2.ts", pos: 49, end: 54 }, { filename: "r3.ts", pos: 78, end: 83 },
|
||||
{ filename: "r4.ts", pos: 106, end: 111 }, { filename: "r5.ts", pos: 138, end: 143 }],
|
||||
importedFiles: [{ fileName: "r1.ts", pos: 20, end: 25 }, { fileName: "r2.ts", pos: 49, end: 54 }, { fileName: "r3.ts", pos: 78, end: 83 },
|
||||
{ fileName: "r4.ts", pos: 106, end: 111 }, { fileName: "r5.ts", pos: 138, end: 143 }],
|
||||
isLibFile: false
|
||||
});
|
||||
}),
|
||||
@@ -86,7 +86,7 @@ describe('PreProcessFile:', function () {
|
||||
test("import i1 require(\"r1.ts\"); import = require(\"r2.ts\") import i3= require(\"r3.ts\"); import i5", true,
|
||||
{
|
||||
referencedFiles: <ts.FileReference[]>[],
|
||||
importedFiles: [{ filename: "r3.ts", pos: 73, end: 78 }],
|
||||
importedFiles: [{ fileName: "r3.ts", pos: 73, end: 78 }],
|
||||
isLibFile: false
|
||||
});
|
||||
}),
|
||||
@@ -94,8 +94,8 @@ describe('PreProcessFile:', function () {
|
||||
it("Correctly return referenced files and import files", function () {
|
||||
test("///<reference path=\"refFile1.ts\" />" + "\n" + "///<reference path =\"refFile2.ts\"/>" + "\n" + "import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\");", true,
|
||||
{
|
||||
referencedFiles: [{ filename: "refFile1.ts", pos: 0, end: 35 }, { filename: "refFile2.ts", pos: 36, end: 71 }],
|
||||
importedFiles: [{ filename: "r1.ts", pos: 92, end: 97 }, { filename: "r2.ts", pos: 121, end: 126 }],
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 35 }, { fileName: "refFile2.ts", pos: 36, end: 71 }],
|
||||
importedFiles: [{ fileName: "r1.ts", pos: 92, end: 97 }, { fileName: "r2.ts", pos: 121, end: 126 }],
|
||||
isLibFile: false
|
||||
});
|
||||
}),
|
||||
@@ -103,8 +103,8 @@ describe('PreProcessFile:', function () {
|
||||
it("Correctly return referenced files and import files even with some invalid syntax", function () {
|
||||
test("///<reference path=\"refFile1.ts\" />" + "\n" + "///<reference path \"refFile2.ts\"/>" + "\n" + "import i1 = require(\"r1.ts\"); import = require(\"r2.ts\"); import i2 = require(\"r3.ts\");", true,
|
||||
{
|
||||
referencedFiles: [{ filename: "refFile1.ts", pos: 0, end: 35 }],
|
||||
importedFiles: [{ filename: "r1.ts", pos: 91, end: 96 }, { filename: "r3.ts", pos: 148, end: 153 }],
|
||||
referencedFiles: [{ fileName: "refFile1.ts", pos: 0, end: 35 }],
|
||||
importedFiles: [{ fileName: "r1.ts", pos: 91, end: 96 }, { fileName: "r3.ts", pos: 148, end: 153 }],
|
||||
isLibFile: false
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user