From 45ac06a0f217e19e9d86c78cdf5abd455b9d3eb6 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 16 Jan 2015 12:02:12 -0800 Subject: [PATCH 01/17] move line map related function out of SourceFile --- src/compiler/emitter.ts | 10 +++++----- src/compiler/parser.ts | 17 ----------------- src/compiler/scanner.ts | 17 ++++++++++++----- src/compiler/tsc.ts | 4 ++-- src/compiler/types.ts | 7 +++---- src/compiler/utilities.ts | 2 +- src/harness/fourslash.ts | 2 +- src/harness/harnessLanguageService.ts | 4 ++-- src/services/services.ts | 21 +++++++++++++++++---- 9 files changed, 43 insertions(+), 41 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d82e577971d..a0c0dc45b15 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -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,15 +169,15 @@ 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 firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos); var firstCommentLineIndent: number; for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, /*character*/1); + var nextLineStart = 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); } @@ -1644,7 +1644,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(); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5ae44e5ff39..19efe77a278 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -501,7 +501,6 @@ module ts { var identifiers: Map; var identifierCount = 0; var nodeCount = 0; - var lineStarts: number[]; var syntacticDiagnostics: Diagnostic[]; var scanner: Scanner; var token: SyntaxKind; @@ -593,7 +592,6 @@ module ts { sourceText = text; parsingContext = 0; identifiers = {}; - lineStarts = undefined; syntacticDiagnostics = undefined; contextFlags = 0; parseErrorBeforeNextFinishedNode = false; @@ -612,9 +610,6 @@ module ts { sourceFile.filename = normalizePath(filename); sourceFile.text = sourceText; - sourceFile.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; - sourceFile.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter; - sourceFile.getLineStarts = getLineStarts; sourceFile.getSyntacticDiagnostics = getSyntacticDiagnostics; sourceFile.update = update; @@ -1072,18 +1067,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; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 2a0363f7f78..2f475cb6768 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -278,12 +278,20 @@ module ts { return result; } - export function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number { + 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); 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; diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 9d038920693..443abf5e57c 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -68,7 +68,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; } @@ -82,7 +82,7 @@ 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 + "): "; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9ebab8dc220..9d899ccd21d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -881,10 +881,6 @@ module ts { 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 @@ -920,6 +916,9 @@ module ts { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; + + // 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 { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7494ec9f6cb..b451cac5423 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -109,7 +109,7 @@ 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); + var loc = getLineAndCharacterOfPosition(file, node.pos); return file.filename + "(" + loc.line + "," + loc.character + ")"; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index cfc83af76e5..d320ceb0d98 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -391,7 +391,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(''); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 97885bdd20e..9cebfb2078b 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -292,7 +292,7 @@ module Harness.LanguageService { assert.isTrue(line >= 1); assert.isTrue(col >= 1); - return ts.getPositionFromLineAndCharacter(script.lineMap, line, col); + return ts.computePositionFromLineAndCharacter(script.lineMap, line, col); } /** @@ -303,7 +303,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); diff --git a/src/services/services.ts b/src/services/services.ts index 1618fb6e276..62d55bb1d61 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -61,6 +61,9 @@ module ts { scriptSnapshot: IScriptSnapshot; getNamedDeclarations(): Declaration[]; + getLineAndCharacterFromPosition(pos: number): LineAndCharacter; + getLineStarts(): number[]; + getPositionFromLineAndCharacter(line: number, character: number): number; } /** @@ -721,18 +724,16 @@ module ts { public filename: string; public text: string; public scriptSnapshot: IScriptSnapshot; + public lineMap: number[]; public statements: NodeArray; 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[]; @@ -753,6 +754,18 @@ module ts { private namedDeclarations: Declaration[]; + 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; From c40977c5fb2fad48f398695c15d0fa634352403c Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 16 Jan 2015 12:32:37 -0800 Subject: [PATCH 02/17] move getSyntacticDiagnostics out of SourceFile --- src/compiler/parser.ts | 22 ++++++++++------------ src/compiler/program.ts | 2 +- src/compiler/types.ts | 10 +++++++--- src/harness/fourslash.ts | 4 ++-- src/services/services.ts | 2 +- tests/cases/unittests/incrementalParser.ts | 4 ++-- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 19efe77a278..fc0086eb7dc 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -356,6 +356,16 @@ 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; + } + + export function isEvalOrArgumentsIdentifier(node: Node): boolean { return node.kind === SyntaxKind.Identifier && ((node).text === "eval" || (node).text === "arguments"); @@ -610,7 +620,6 @@ module ts { sourceFile.filename = normalizePath(filename); sourceFile.text = sourceText; - sourceFile.getSyntacticDiagnostics = getSyntacticDiagnostics; sourceFile.update = update; processReferenceComments(sourceFile); @@ -4724,17 +4733,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 { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index fc3cc0682d1..67d05b2c571 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -245,7 +245,7 @@ module ts { else { files.push(file); } - forEach(file.getSyntacticDiagnostics(), e => { + forEach(getSyntacticDiagnostics(file), e => { errors.push(e); }); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9d899ccd21d..9f127cf2e5b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -903,12 +903,15 @@ module ts { // 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[]; + //getSyntacticDiagnostics(): Diagnostic[]; // File level diagnostics reported by the binder. semanticDiagnostics: Diagnostic[]; + // 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; @@ -917,7 +920,8 @@ module ts { languageVersion: ScriptTarget; identifiers: Map; - // Stores a line map for the file. This field should never be used directly to obtain line map, use getLineMap function instead. + // Stores a line map for the file. + // This field should never be used directly to obtain line map, use getLineMap function instead. lineMap: number[]; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d320ceb0d98..2a2a9cd1c2b 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1384,7 +1384,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); @@ -1392,7 +1392,7 @@ module FourSlash { var referenceSourceFile = ts.createLanguageServiceSourceFile( this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*isOpen:*/ false, /*setNodeParents:*/ false); - var referenceSyntaxDiagnostics = referenceSourceFile.getSyntacticDiagnostics(); + var referenceSyntaxDiagnostics = ts.getSyntacticDiagnostics(referenceSourceFile); Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics); Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile); diff --git a/src/services/services.ts b/src/services/services.ts index 62d55bb1d61..e72fb7d3239 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -731,13 +731,13 @@ module ts { // These methods will have their implementation provided by the implementation the // compiler actually exports off of SourceFile. - 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[]; diff --git a/tests/cases/unittests/incrementalParser.ts b/tests/cases/unittests/incrementalParser.ts index a3875cf8e8c..80ca539b019 100644 --- a/tests/cases/unittests/incrementalParser.ts +++ b/tests/cases/unittests/incrementalParser.ts @@ -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++) { From cf8c21893a07774c48b6051e48f399905e8421e6 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 16 Jan 2015 16:22:11 -0800 Subject: [PATCH 03/17] moved update function out of SourceFile --- src/compiler/parser.ts | 784 +++++++++++++++++++-------------------- src/compiler/types.ts | 11 - src/services/services.ts | 2 +- 3 files changed, 392 insertions(+), 405 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index fc0086eb7dc..c5eecd19d04 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -365,6 +365,358 @@ module ts { return sourceFile.syntacticDiagnostics; } + function moveElementEntirelyPastChangeRange(element: IncrementalElement, delta: number) { + if (element.length) { + visitArray(element); + } + else { + visitNode(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) + // + // ? $ : <...> <...> + // + // 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 update(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(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 && @@ -505,16 +857,27 @@ module ts { } } } - export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false): SourceFile { - var parsingContext: ParsingContext; - var identifiers: Map; + return parseSourceFile(filename, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); + } + + function parseSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: SyntaxCursor, setParentNodes = false): SourceFile { + var parsingContext: ParsingContext = 0; + var identifiers: Map = {}; var identifierCount = 0; var nodeCount = 0; - var syntacticDiagnostics: Diagnostic[]; var scanner: Scanner; var token: SyntaxKind; - var syntaxCursor: SyntaxCursor; + + var 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 @@ -562,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 @@ -591,401 +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 = {}; - syntacticDiagnostics = undefined; - contextFlags = 0; - parseErrorBeforeNextFinishedNode = false; + processReferenceComments(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.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(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(element); - } - else { - visitNode(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) - // - // ? $ : <...> <...> - // - // 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) { @@ -4670,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; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9f127cf2e5b..82b0a526def 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -881,17 +881,6 @@ module ts { filename: string; text: string; - // 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[]; diff --git a/src/services/services.ts b/src/services/services.ts index e72fb7d3239..79a652bb094 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1587,7 +1587,7 @@ module ts { if (version !== sourceFile.version || isOpen != sourceFile.isOpen) { // 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 = update(sourceFile, scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange); setSourceFileFields(newSourceFile, scriptSnapshot, version, isOpen); return newSourceFile; } From edc65e1753a3e8ae1911a0b9e07b4f2f613de762 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 16 Jan 2015 18:19:47 -0800 Subject: [PATCH 04/17] addressed CR feedback: renamed update to updateSourceFile --- src/compiler/parser.ts | 2 +- src/services/services.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c5eecd19d04..9ad9067d6fa 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -658,7 +658,7 @@ module ts { // 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 update(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange): SourceFile { + 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; diff --git a/src/services/services.ts b/src/services/services.ts index 79a652bb094..1b94899a1f5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1587,7 +1587,7 @@ module ts { if (version !== sourceFile.version || isOpen != sourceFile.isOpen) { // Once incremental parsing is ready, then just call into this function. if (!disableIncrementalParsing) { - var newSourceFile = update(sourceFile, scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange); + var newSourceFile = updateSourceFile(sourceFile, scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange); setSourceFileFields(newSourceFile, scriptSnapshot, version, isOpen); return newSourceFile; } From e15f9349f9b4237c336a8c50d8b188f94fb22af0 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 22 Jan 2015 11:10:12 -0800 Subject: [PATCH 05/17] moved all methods of SourceFile to the part exposed on the services layer --- src/services/services.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 1b94899a1f5..55aa3d7b7cc 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -64,6 +64,8 @@ module ts { getLineAndCharacterFromPosition(pos: number): LineAndCharacter; getLineStarts(): number[]; getPositionFromLineAndCharacter(line: number, character: number): number; + getSyntacticDiagnostics(): Diagnostic[]; + update(newText: string, textChangeRange: TextChangeRange): SourceFile; } /** @@ -729,10 +731,6 @@ module ts { public statements: NodeArray; public endOfFileToken: Node; - // These methods will have their implementation provided by the implementation the - // compiler actually exports off of SourceFile. - public update: (newText: string, textChangeRange: TextChangeRange) => SourceFile; - public amdDependencies: string[]; public amdModuleName: string; public referencedFiles: FileReference[]; @@ -754,6 +752,14 @@ 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); } From ff11ca9ee1e05d092d681d00e6cde6b0e0ae2502 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 30 Jan 2015 10:32:07 -0800 Subject: [PATCH 06/17] Update path to test262 and rwc tests files in the runners --- Jakefile | 14 +++++++++----- src/harness/harness.ts | 29 ++++++++++++++++++++--------- src/harness/rwcRunner.ts | 7 +++++-- src/harness/test262Runner.ts | 7 +++++-- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/Jakefile b/Jakefile index 15661debff6..3a4f3af9677 100644 --- a/Jakefile +++ b/Jakefile @@ -451,14 +451,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 = internalTests + "baselines/rwc/local/"; +var refRwcBaseline = internalTests + "baselines/rwc/reference/"; -var localTest262Baseline = "tests/baselines/test262/local/"; -var refTest262Baseline = "tests/baselines/test262/reference/"; +var localTest262Baseline = internalTests + "baselines/test262/local/"; +var refTest262Baseline = internalTests + "baselines/test262/reference/"; desc("Builds the test infrastructure using the built compiler"); task("tests", ["local", run].concat(libraryTargets)); @@ -491,11 +493,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); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index df73e52a605..d6734ce28b2 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1557,21 +1557,32 @@ 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; } } @@ -1625,7 +1636,7 @@ module Harness { return; } - var refFilename = referencePath(relativeFilename, opts && opts.Subfolder); + var refFilename = referencePath(relativeFilename, opts && opts.Baselinefolder, opts && opts.Subfolder); if (actual === null) { actual = ''; @@ -1663,7 +1674,7 @@ module Harness { opts?: BaselineOptions): void { var actual = undefined; - var actualFilename = localPath(relativeFilename, opts && opts.Subfolder); + var actualFilename = localPath(relativeFilename, opts && opts.Baselinefolder, opts && opts.Subfolder); if (runImmediately) { actual = generateActual(actualFilename, generateContent); diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index b506cdd66b6..17b524bf0cd 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -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; @@ -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 diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index 24be77922f9..0091da5e911 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -3,7 +3,7 @@ /// 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; From e5be1c4a5dd8c56f4d770f1fef73088c42a75507 Mon Sep 17 00:00:00 2001 From: Yui T Date: Mon, 2 Feb 2015 12:52:26 -0800 Subject: [PATCH 07/17] Address pull request --- Jakefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Jakefile b/Jakefile index 3a4f3af9677..f663e162a16 100644 --- a/Jakefile +++ b/Jakefile @@ -456,11 +456,11 @@ var internalTests = "internal/" var localBaseline = "tests/baselines/local/"; var refBaseline = "tests/baselines/reference/"; -var localRwcBaseline = internalTests + "baselines/rwc/local/"; -var refRwcBaseline = internalTests + "baselines/rwc/reference/"; +var localRwcBaseline = path.join(internalTests, "baselines/rwc/local"); +var refRwcBaseline = path.join(internalTests, "baselines/rwc/reference"); -var localTest262Baseline = internalTests + "baselines/test262/local/"; -var refTest262Baseline = internalTests + "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)); @@ -511,8 +511,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/")); } } From 091038eca1e644673db3dd1c340783fe9dc3cebd Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 2 Feb 2015 19:15:43 -0800 Subject: [PATCH 08/17] Change the default LS target to ES5 from ES6 --- src/services/services.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 978bc2ad36b..c659d08fb3e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1418,9 +1418,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, }; } From 45defa87418a9dd9da62c28510d302b3961d0a7e Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 3 Feb 2015 11:33:56 -0800 Subject: [PATCH 09/17] updated tests --- .../baselines/reference/APISample_compile.js | 25 ++-- .../reference/APISample_compile.types | 111 +++++++++++------- tests/baselines/reference/APISample_linter.js | 25 ++-- .../reference/APISample_linter.types | 111 +++++++++++------- .../reference/APISample_transform.js | 25 ++-- .../reference/APISample_transform.types | 111 +++++++++++------- .../baselines/reference/APISample_watcher.js | 25 ++-- .../reference/APISample_watcher.types | 111 +++++++++++------- 8 files changed, 336 insertions(+), 208 deletions(-) diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index f70ee02415a..f6a86d4c245 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -725,17 +725,13 @@ declare module "typescript" { endOfFileToken: Node; 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[]; + syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -743,6 +739,7 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; + lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1393,15 +1390,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,6 +1413,8 @@ declare module "typescript" { function createNode(kind: SyntaxKind): Node; function forEachChild(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 isLeftHandSideExpression(expr: Expression): boolean; @@ -1476,6 +1474,11 @@ declare module "typescript" { scriptSnapshot: IScriptSnapshot; nameTable: Map; 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 diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 090c42a7216..4ef90c6d114 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -90,11 +90,11 @@ export function compile(filenames: string[], options: ts.CompilerOptions): void 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 @@ -2209,26 +2209,6 @@ declare module "typescript" { 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[] @@ -2245,14 +2225,14 @@ declare module "typescript" { parseDiagnostics: Diagnostic[]; >parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - getSyntacticDiagnostics(): Diagnostic[]; ->getSyntacticDiagnostics : () => Diagnostic[] >Diagnostic : Diagnostic semanticDiagnostics: Diagnostic[]; >semanticDiagnostics : Diagnostic[] +>Diagnostic : Diagnostic + + syntacticDiagnostics: Diagnostic[]; +>syntacticDiagnostics : Diagnostic[] >Diagnostic : Diagnostic hasNoDefaultLib: boolean; @@ -2278,6 +2258,9 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map + + lineMap: number[]; +>lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -4446,14 +4429,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 +4459,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,6 +4552,21 @@ 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 @@ -4783,6 +4788,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 diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index b3905862c67..aef5c70349b 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -754,17 +754,13 @@ declare module "typescript" { endOfFileToken: Node; 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[]; + syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -772,6 +768,7 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; + lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1422,15 +1419,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,6 +1442,8 @@ declare module "typescript" { function createNode(kind: SyntaxKind): Node; function forEachChild(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 isLeftHandSideExpression(expr: Expression): boolean; @@ -1505,6 +1503,11 @@ declare module "typescript" { scriptSnapshot: IScriptSnapshot; nameTable: Map; 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 diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 5f613ec140c..957ccd3c01e 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -227,9 +227,9 @@ 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 @@ -2339,26 +2339,6 @@ declare module "typescript" { 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[] @@ -2375,14 +2355,14 @@ declare module "typescript" { parseDiagnostics: Diagnostic[]; >parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - getSyntacticDiagnostics(): Diagnostic[]; ->getSyntacticDiagnostics : () => Diagnostic[] >Diagnostic : Diagnostic semanticDiagnostics: Diagnostic[]; >semanticDiagnostics : Diagnostic[] +>Diagnostic : Diagnostic + + syntacticDiagnostics: Diagnostic[]; +>syntacticDiagnostics : Diagnostic[] >Diagnostic : Diagnostic hasNoDefaultLib: boolean; @@ -2408,6 +2388,9 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map + + lineMap: number[]; +>lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -4576,14 +4559,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 +4589,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,6 +4682,21 @@ 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 @@ -4913,6 +4918,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 diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 06546d2fdbc..33cea1ea0af 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -755,17 +755,13 @@ declare module "typescript" { endOfFileToken: Node; 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[]; + syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -773,6 +769,7 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; + lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1423,15 +1420,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,6 +1443,8 @@ declare module "typescript" { function createNode(kind: SyntaxKind): Node; function forEachChild(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 isLeftHandSideExpression(expr: Expression): boolean; @@ -1506,6 +1504,11 @@ declare module "typescript" { scriptSnapshot: IScriptSnapshot; nameTable: Map; 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 diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index f92c2f36774..c091af5effb 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -210,11 +210,11 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) { >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 @@ -2287,26 +2287,6 @@ declare module "typescript" { 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[] @@ -2323,14 +2303,14 @@ declare module "typescript" { parseDiagnostics: Diagnostic[]; >parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - getSyntacticDiagnostics(): Diagnostic[]; ->getSyntacticDiagnostics : () => Diagnostic[] >Diagnostic : Diagnostic semanticDiagnostics: Diagnostic[]; >semanticDiagnostics : Diagnostic[] +>Diagnostic : Diagnostic + + syntacticDiagnostics: Diagnostic[]; +>syntacticDiagnostics : Diagnostic[] >Diagnostic : Diagnostic hasNoDefaultLib: boolean; @@ -2356,6 +2336,9 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map + + lineMap: number[]; +>lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -4524,14 +4507,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 +4537,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,6 +4630,21 @@ 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 @@ -4861,6 +4866,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 diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 9a7064117bf..7c70ee1532e 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -792,17 +792,13 @@ declare module "typescript" { endOfFileToken: Node; 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[]; + syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -810,6 +806,7 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; + lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1460,15 +1457,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,6 +1480,8 @@ declare module "typescript" { function createNode(kind: SyntaxKind): Node; function forEachChild(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 isLeftHandSideExpression(expr: Expression): boolean; @@ -1543,6 +1541,11 @@ declare module "typescript" { scriptSnapshot: IScriptSnapshot; nameTable: Map; 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 diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 938db86d09e..c3d03259385 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -337,11 +337,11 @@ 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 @@ -2465,26 +2465,6 @@ declare module "typescript" { 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[] @@ -2501,14 +2481,14 @@ declare module "typescript" { parseDiagnostics: Diagnostic[]; >parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - getSyntacticDiagnostics(): Diagnostic[]; ->getSyntacticDiagnostics : () => Diagnostic[] >Diagnostic : Diagnostic semanticDiagnostics: Diagnostic[]; >semanticDiagnostics : Diagnostic[] +>Diagnostic : Diagnostic + + syntacticDiagnostics: Diagnostic[]; +>syntacticDiagnostics : Diagnostic[] >Diagnostic : Diagnostic hasNoDefaultLib: boolean; @@ -2534,6 +2514,9 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map + + lineMap: number[]; +>lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -4702,14 +4685,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 +4715,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,6 +4808,21 @@ 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 @@ -5039,6 +5044,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 From 0ca03048cff58fd8dac52006ad830e1c89323830 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 3 Feb 2015 12:46:01 -0800 Subject: [PATCH 10/17] Move the code to actually emit higher up in the function. Now it it precedes all the other function declarations, and is much easier to debug. --- src/compiler/emitter.ts | 117 ++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b15a493de92..8b4e5c3521b 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -358,6 +358,65 @@ module ts { 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; + } + } + }); + } + + 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, + } + function createAndSetNewTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter { var writer = createTextWriter(newLine); writer.trackSymbol = trackSymbol; @@ -1402,10 +1461,6 @@ 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 @@ -1422,60 +1477,6 @@ module ts { referencePathsOutput += "/// " + 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[] { From 838b9b699827a822dd9b3eb34cb2f596b27b5e2b Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 3 Feb 2015 13:15:28 -0800 Subject: [PATCH 11/17] Provide an experimental flag that allows us to emit declarations except for nodes marked with '@internal'. --- src/compiler/commandLineParser.ts | 6 +++++ .../diagnosticInformationMap.generated.ts | 1 + src/compiler/diagnosticMessages.json | 4 +++ src/compiler/emitter.ts | 24 +++++++++++++++--- src/compiler/tsc.ts | 2 +- src/compiler/types.ts | 2 ++ src/harness/harness.ts | 5 +++- tests/baselines/reference/stripInternal1.js | 25 +++++++++++++++++++ .../baselines/reference/stripInternal1.types | 12 +++++++++ tests/cases/compiler/stripInternal1.ts | 8 ++++++ 10 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/stripInternal1.js create mode 100644 tests/baselines/reference/stripInternal1.types create mode 100644 tests/cases/compiler/stripInternal1.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 23bbba5c6ca..a46f9168644 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -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", diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index dc7ef322c9b..4b10b50e31e 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5ee826812f2..456c97a7c77 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -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", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 8b4e5c3521b..edf9d9ae4c8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -355,6 +355,7 @@ module ts { var reportedDeclarationError = false; var emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments; + var emit = compilerOptions.stripInternal ? stripInternal : emitNode; var aliasDeclarationEmitInfo: AliasDeclarationEmitInfo[] = []; @@ -383,7 +384,7 @@ module ts { }); } - emitNode(root); + emitSourceFile(root); } else { // Emit references corresponding to this file @@ -405,7 +406,7 @@ module ts { }); } - emitNode(sourceFile); + emitSourceFile(sourceFile); } }); } @@ -417,6 +418,23 @@ module ts { 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 = createTextWriter(newLine); writer.trackSymbol = trackSymbol; @@ -522,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]); } } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 52a9fb110db..960ce706040 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -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(a.name.toLowerCase(), b.name.toLowerCase())); // We want our descriptions to align at the same column in our output, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c8572c6b5c1..3675310895b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1476,6 +1476,7 @@ module ts { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } @@ -1514,6 +1515,7 @@ module ts { 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 { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 85bd02c1179..86f0ad14333 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1015,6 +1015,9 @@ module Harness { options.removeComments = setting.value === 'false'; break; + case 'stripinternal': + options.stripInternal = !!setting.value; + case 'usecasesensitivefilenames': useCaseSensitiveFileNames = setting.value === 'true'; break; @@ -1454,7 +1457,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[] { diff --git a/tests/baselines/reference/stripInternal1.js b/tests/baselines/reference/stripInternal1.js new file mode 100644 index 00000000000..9deadf1fc31 --- /dev/null +++ b/tests/baselines/reference/stripInternal1.js @@ -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; +} diff --git a/tests/baselines/reference/stripInternal1.types b/tests/baselines/reference/stripInternal1.types new file mode 100644 index 00000000000..8452de45596 --- /dev/null +++ b/tests/baselines/reference/stripInternal1.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/stripInternal1.ts === + +class C { +>C : C + + foo(): void { } +>foo : () => void + + // @internal + bar(): void { } +>bar : () => void +} diff --git a/tests/cases/compiler/stripInternal1.ts b/tests/cases/compiler/stripInternal1.ts new file mode 100644 index 00000000000..77f65e6119c --- /dev/null +++ b/tests/cases/compiler/stripInternal1.ts @@ -0,0 +1,8 @@ +// @declaration:true +// @stripInternal:true + +class C { + foo(): void { } + // @internal + bar(): void { } +} \ No newline at end of file From c8ec14776264892cfa1510ef3a5fd5ed5558fb4c Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 3 Feb 2015 13:46:14 -0800 Subject: [PATCH 12/17] Address code review --- src/harness/harness.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 5bc8bc5fb13..525e7c413e2 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1569,29 +1569,29 @@ module Harness { Baselinefolder?: string; } - export function localPath(fileName: string, baselinefolder?: string, subfolder?: string) { - if (baselinefolder === undefined) { + 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); + return baselinePath(fileName, 'local', baselineFolder, subfolder); } } - function referencePath(fileName: string, baselinefolder?: string, subfolder?: string) { - if (baselinefolder === undefined) { + 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); + return baselinePath(fileName, 'reference', baselineFolder, subfolder); } } - function baselinePath(fileName: string, type: string, baselinefolder: string, subfolder?: string) { + function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) { if (subfolder !== undefined) { - return Harness.userSpecifiedroot + baselinefolder + '/' + subfolder + '/' + type + '/' + fileName; + return Harness.userSpecifiedroot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName; } else { - return Harness.userSpecifiedroot + baselinefolder + '/' + type + '/' + fileName; + return Harness.userSpecifiedroot + baselineFolder + '/' + type + '/' + fileName; } } From 2ee134c6b3c0ece87591e8abc9db833ebb7675cc Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 3 Feb 2015 13:47:46 -0800 Subject: [PATCH 13/17] Remove certain lazyily initialized fields from the public DTS. These should not be accessed directly. They should be obtained by calling into the appropriate helper functions. --- Jakefile | 10 ++++-- src/compiler/types.ts | 35 ++++++++++--------- .../baselines/reference/APISample_compile.js | 7 ++-- .../reference/APISample_compile.types | 25 ++++--------- tests/baselines/reference/APISample_linter.js | 7 ++-- .../reference/APISample_linter.types | 25 ++++--------- .../reference/APISample_transform.js | 7 ++-- .../reference/APISample_transform.types | 25 ++++--------- .../baselines/reference/APISample_watcher.js | 7 ++-- .../reference/APISample_watcher.types | 25 ++++--------- tests/cases/compiler/APISample_compile.ts | 1 + tests/cases/compiler/APISample_linter.ts | 1 + tests/cases/compiler/APISample_transform.ts | 1 + tests/cases/compiler/APISample_watcher.ts | 1 + 14 files changed, 63 insertions(+), 114 deletions(-) diff --git a/Jakefile b/Jakefile index 15661debff6..6ab9155f8b3 100644 --- a/Jakefile +++ b/Jakefile @@ -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 diff --git a/src/compiler/types.ts b/src/compiler/types.ts index eb68bab7b74..a6fb7cdf7ef 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -891,22 +891,6 @@ module ts { amdModuleName: string; referencedFiles: FileReference[]; - // Diagnostics reported about the "///; + // @internal + // Diagnostics reported about the "///; - lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1186,6 +1181,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1216,6 +1212,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 4ef90c6d114..064170cd70f 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -2219,22 +2219,6 @@ declare module "typescript" { >referencedFiles : FileReference[] >FileReference : FileReference - referenceDiagnostics: Diagnostic[]; ->referenceDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - parseDiagnostics: Diagnostic[]; ->parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - semanticDiagnostics: Diagnostic[]; ->semanticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - syntacticDiagnostics: Diagnostic[]; ->syntacticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - hasNoDefaultLib: boolean; >hasNoDefaultLib : boolean @@ -2258,9 +2242,6 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map - - lineMap: number[]; ->lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -3818,6 +3799,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -3898,6 +3882,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index aef5c70349b..aa12cb40cb3 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -757,10 +757,6 @@ declare module "typescript" { amdDependencies: string[]; amdModuleName: string; referencedFiles: FileReference[]; - referenceDiagnostics: Diagnostic[]; - parseDiagnostics: Diagnostic[]; - semanticDiagnostics: Diagnostic[]; - syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -768,7 +764,6 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; - lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1215,6 +1210,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1245,6 +1241,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 957ccd3c01e..7065704f422 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -2349,22 +2349,6 @@ declare module "typescript" { >referencedFiles : FileReference[] >FileReference : FileReference - referenceDiagnostics: Diagnostic[]; ->referenceDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - parseDiagnostics: Diagnostic[]; ->parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - semanticDiagnostics: Diagnostic[]; ->semanticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - syntacticDiagnostics: Diagnostic[]; ->syntacticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - hasNoDefaultLib: boolean; >hasNoDefaultLib : boolean @@ -2388,9 +2372,6 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map - - lineMap: number[]; ->lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -3948,6 +3929,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -4028,6 +4012,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 33cea1ea0af..58535e42601 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -758,10 +758,6 @@ declare module "typescript" { amdDependencies: string[]; amdModuleName: string; referencedFiles: FileReference[]; - referenceDiagnostics: Diagnostic[]; - parseDiagnostics: Diagnostic[]; - semanticDiagnostics: Diagnostic[]; - syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -769,7 +765,6 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; - lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1216,6 +1211,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1246,6 +1242,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index c091af5effb..5d90818f635 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -2297,22 +2297,6 @@ declare module "typescript" { >referencedFiles : FileReference[] >FileReference : FileReference - referenceDiagnostics: Diagnostic[]; ->referenceDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - parseDiagnostics: Diagnostic[]; ->parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - semanticDiagnostics: Diagnostic[]; ->semanticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - syntacticDiagnostics: Diagnostic[]; ->syntacticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - hasNoDefaultLib: boolean; >hasNoDefaultLib : boolean @@ -2336,9 +2320,6 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map - - lineMap: number[]; ->lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -3896,6 +3877,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -3976,6 +3960,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 7c70ee1532e..cd8b44bfe2d 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -795,10 +795,6 @@ declare module "typescript" { amdDependencies: string[]; amdModuleName: string; referencedFiles: FileReference[]; - referenceDiagnostics: Diagnostic[]; - parseDiagnostics: Diagnostic[]; - semanticDiagnostics: Diagnostic[]; - syntacticDiagnostics: Diagnostic[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; nodeCount: number; @@ -806,7 +802,6 @@ declare module "typescript" { symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; - lineMap: number[]; } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; @@ -1253,6 +1248,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1283,6 +1279,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index c3d03259385..7050f0497d9 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -2475,22 +2475,6 @@ declare module "typescript" { >referencedFiles : FileReference[] >FileReference : FileReference - referenceDiagnostics: Diagnostic[]; ->referenceDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - parseDiagnostics: Diagnostic[]; ->parseDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - semanticDiagnostics: Diagnostic[]; ->semanticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - - syntacticDiagnostics: Diagnostic[]; ->syntacticDiagnostics : Diagnostic[] ->Diagnostic : Diagnostic - hasNoDefaultLib: boolean; >hasNoDefaultLib : boolean @@ -2514,9 +2498,6 @@ declare module "typescript" { identifiers: Map; >identifiers : Map >Map : Map - - lineMap: number[]; ->lineMap : number[] } interface ScriptReferenceHost { >ScriptReferenceHost : ScriptReferenceHost @@ -4074,6 +4055,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -4154,6 +4138,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/cases/compiler/APISample_compile.ts b/tests/cases/compiler/APISample_compile.ts index d2ad7853a19..004e22dcb0c 100644 --- a/tests/cases/compiler/APISample_compile.ts +++ b/tests/cases/compiler/APISample_compile.ts @@ -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 diff --git a/tests/cases/compiler/APISample_linter.ts b/tests/cases/compiler/APISample_linter.ts index 8a796fe6fc8..1942923a81d 100644 --- a/tests/cases/compiler/APISample_linter.ts +++ b/tests/cases/compiler/APISample_linter.ts @@ -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 diff --git a/tests/cases/compiler/APISample_transform.ts b/tests/cases/compiler/APISample_transform.ts index 4d79ff827cd..b0a6c7d37ea 100644 --- a/tests/cases/compiler/APISample_transform.ts +++ b/tests/cases/compiler/APISample_transform.ts @@ -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 diff --git a/tests/cases/compiler/APISample_watcher.ts b/tests/cases/compiler/APISample_watcher.ts index 119c66697b2..3c65b59801d 100644 --- a/tests/cases/compiler/APISample_watcher.ts +++ b/tests/cases/compiler/APISample_watcher.ts @@ -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 From c9ef4db99ac93bb1c166aa9af495453eeceea279 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 3 Feb 2015 15:03:50 -0800 Subject: [PATCH 14/17] Make more sourcefile data internal. --- src/compiler/types.ts | 12 +++++++++--- tests/baselines/reference/APISample_compile.js | 3 --- tests/baselines/reference/APISample_compile.types | 9 --------- tests/baselines/reference/APISample_linter.js | 3 --- tests/baselines/reference/APISample_linter.types | 9 --------- tests/baselines/reference/APISample_transform.js | 3 --- tests/baselines/reference/APISample_transform.types | 9 --------- tests/baselines/reference/APISample_watcher.js | 3 --- tests/baselines/reference/APISample_watcher.types | 9 --------- 9 files changed, 9 insertions(+), 51 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a6fb7cdf7ef..ad97e452c70 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -893,11 +893,17 @@ module ts { 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; + + // @internal + nodeCount: number; + + // @internal + identifierCount: number; + + // @internal + symbolCount: number; // @internal // Diagnostics reported about the "///; } diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 064170cd70f..a9188898790 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -2226,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 diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index aa12cb40cb3..e9c4e6243b0 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -759,9 +759,6 @@ declare module "typescript" { referencedFiles: FileReference[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; - nodeCount: number; - identifierCount: number; - symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; } diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 7065704f422..2c00938b7ce 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -2356,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 diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 58535e42601..dc89d8c74af 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -760,9 +760,6 @@ declare module "typescript" { referencedFiles: FileReference[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; - nodeCount: number; - identifierCount: number; - symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; } diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 5d90818f635..8736724ecee 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -2304,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 diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index cd8b44bfe2d..b112566eb1b 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -797,9 +797,6 @@ declare module "typescript" { referencedFiles: FileReference[]; hasNoDefaultLib: boolean; externalModuleIndicator: Node; - nodeCount: number; - identifierCount: number; - symbolCount: number; languageVersion: ScriptTarget; identifiers: Map; } diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 7050f0497d9..e46a7e1bf41 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -2482,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 From 2e73d45bd49f066c46785cf69a632a5615d2daad Mon Sep 17 00:00:00 2001 From: Yui T Date: Tue, 3 Feb 2015 15:16:29 -0800 Subject: [PATCH 15/17] Update API baselines --- tests/baselines/reference/APISample_compile.js | 2 ++ tests/baselines/reference/APISample_compile.types | 6 ++++++ tests/baselines/reference/APISample_linter.js | 2 ++ tests/baselines/reference/APISample_linter.types | 6 ++++++ tests/baselines/reference/APISample_transform.js | 2 ++ tests/baselines/reference/APISample_transform.types | 6 ++++++ tests/baselines/reference/APISample_watcher.js | 2 ++ tests/baselines/reference/APISample_watcher.types | 6 ++++++ 8 files changed, 32 insertions(+) diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index f6a86d4c245..9f581cf34ab 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -1186,6 +1186,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1216,6 +1217,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 4ef90c6d114..6a057658f5a 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -3818,6 +3818,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -3898,6 +3901,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index aef5c70349b..5fd4716b8e9 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -1215,6 +1215,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1245,6 +1246,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 957ccd3c01e..ffbe61d41a5 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -3948,6 +3948,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -4028,6 +4031,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 33cea1ea0af..6b5828ccb4a 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -1216,6 +1216,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1246,6 +1247,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index c091af5effb..293927b9ea9 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -3896,6 +3896,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -3976,6 +3979,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 7c70ee1532e..c2cf2c89033 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -1253,6 +1253,7 @@ declare module "typescript" { target?: ScriptTarget; version?: boolean; watch?: boolean; + stripInternal?: boolean; [option: string]: string | number | boolean; } const enum ModuleKind { @@ -1283,6 +1284,7 @@ declare module "typescript" { description?: DiagnosticMessage; paramType?: DiagnosticMessage; error?: DiagnosticMessage; + experimental?: boolean; } const enum CharacterCodes { nullCharacter = 0, diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index c3d03259385..d9135591898 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -4074,6 +4074,9 @@ declare module "typescript" { watch?: boolean; >watch : boolean + stripInternal?: boolean; +>stripInternal : boolean + [option: string]: string | number | boolean; >option : string } @@ -4154,6 +4157,9 @@ declare module "typescript" { error?: DiagnosticMessage; >error : DiagnosticMessage >DiagnosticMessage : DiagnosticMessage + + experimental?: boolean; +>experimental : boolean } const enum CharacterCodes { >CharacterCodes : CharacterCodes From 95702a89a7440a4033915848cd04349fe43a909a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 3 Feb 2015 16:08:46 -0800 Subject: [PATCH 16/17] Fix spelling of 'Filename' to be 'FileName'. --- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 8 +- src/compiler/commandLineParser.ts | 20 +- src/compiler/core.ts | 14 +- .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/emitter.ts | 20 +- src/compiler/parser.ts | 14 +- src/compiler/program.ts | 80 ++--- src/compiler/tsc.ts | 56 +-- src/compiler/types.ts | 18 +- src/compiler/utilities.ts | 8 +- src/harness/fourslash.ts | 32 +- src/harness/harness.ts | 108 +++--- src/harness/harnessLanguageService.ts | 2 +- src/harness/loggedIO.ts | 14 +- src/harness/projectsRunner.ts | 66 ++-- src/harness/runnerbase.ts | 2 +- src/harness/rwcRunner.ts | 6 +- src/services/navigationBar.ts | 6 +- src/services/services.ts | 302 ++++++++-------- src/services/shims.ts | 10 +- .../baselines/reference/APISample_compile.js | 52 +-- .../reference/APISample_compile.types | 116 +++---- tests/baselines/reference/APISample_linter.js | 56 +-- .../reference/APISample_linter.types | 132 +++---- .../reference/APISample_transform.js | 62 ++-- .../reference/APISample_transform.types | 162 ++++----- .../baselines/reference/APISample_watcher.js | 134 +++---- .../reference/APISample_watcher.types | 326 +++++++++--------- ...etEmitOutputDeclarationMultiFiles.baseline | 8 +- ...etEmitOutputDeclarationSingleFile.baseline | 4 +- .../getEmitOutputExternalModule.baseline | 2 +- .../getEmitOutputExternalModule2.baseline | 2 +- .../reference/getEmitOutputMapRoots.baseline | 4 +- .../reference/getEmitOutputNoErrors.baseline | 2 +- .../getEmitOutputOnlyOneFile.baseline | 2 +- .../getEmitOutputSingleFile.baseline | 2 +- .../getEmitOutputSingleFile2.baseline | 4 +- .../reference/getEmitOutputSourceMap.baseline | 4 +- .../getEmitOutputSourceMap2.baseline | 8 +- .../getEmitOutputSourceRoot.baseline | 4 +- ...getEmitOutputSourceRootMultiFiles.baseline | 8 +- .../getEmitOutputWithDeclarationFile.baseline | 2 +- ...getEmitOutputWithDeclarationFile2.baseline | 4 +- ...getEmitOutputWithDeclarationFile3.baseline | 2 +- ...mitOutputWithEarlySyntacticErrors.baseline | 2 +- .../getEmitOutputWithEmitterErrors.baseline | 2 +- .../getEmitOutputWithEmitterErrors2.baseline | 2 +- .../getEmitOutputWithSemanticErrors.baseline | 2 +- .../getEmitOutputWithSemanticErrors2.baseline | 2 +- ...ithSemanticErrorsForMultipleFiles.baseline | 4 +- ...thSemanticErrorsForMultipleFiles2.baseline | 2 +- ...thSyntacticErrorsForMultipleFiles.baseline | 2 +- ...hSyntacticErrorsForMultipleFiles2.baseline | 2 +- .../getEmitOutputWithSyntaxErrors.baseline | 2 +- tests/cases/compiler/APISample_compile.ts | 6 +- tests/cases/compiler/APISample_linter.ts | 8 +- tests/cases/compiler/APISample_transform.ts | 12 +- tests/cases/compiler/APISample_watcher.ts | 48 +-- tests/cases/unittests/incrementalParser.ts | 6 +- .../unittests/services/preProcessFile.ts | 22 +- 62 files changed, 1009 insertions(+), 1009 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index fe52e26ddd1..c97e1f34772 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -471,7 +471,7 @@ module ts { break; case SyntaxKind.SourceFile: if (isExternalModule(node)) { - bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((node).filename) + '"', /*isBlockScopeContainer*/ true); + bindAnonymousDeclaration(node, SymbolFlags.ValueModule, '"' + removeFileExtension((node).fileName) + '"', /*isBlockScopeContainer*/ true); break; } case SyntaxKind.Block: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f44c9b118f8..6aa4862abc5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -538,7 +538,7 @@ module ts { } var moduleReferenceLiteral = 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); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index a46f9168644..4ba2da757e5 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -164,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 = {}; var optionNameMap: Map = {}; @@ -178,7 +178,7 @@ module ts { parseStrings(commandLine); return { options, - filenames, + fileNames, errors }; @@ -232,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; } @@ -259,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 { @@ -271,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) { @@ -285,7 +285,7 @@ module ts { return { options: getCompilerOptions(), - filenames: getFiles(), + fileNames: getFiles(), errors }; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 894f0eadd16..87094150baf 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -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"; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 4b10b50e31e..7bf95dcc846 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.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()' 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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 456c97a7c77..b4944f56d77 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -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 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 086a402efb2..a4521977802 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -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; @@ -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)); }); } @@ -1481,7 +1481,7 @@ module ts { 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 @@ -1735,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) { @@ -1857,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", diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 9ad9067d6fa..866d66d5151 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -667,7 +667,7 @@ module ts { 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) + return parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion,/*syntaxCursor*/ undefined, /*setNodeParents*/ true) } var syntaxCursor = createSyntaxCursor(sourceFile); @@ -713,7 +713,7 @@ module ts { // 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) + var result = parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true) return result; } @@ -857,11 +857,11 @@ 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 { + return parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes); } - function parseSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: SyntaxCursor, setParentNodes = false): SourceFile { + function parseSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: SyntaxCursor, setParentNodes = false): SourceFile { var parsingContext: ParsingContext = 0; var identifiers: Map = {}; var identifierCount = 0; @@ -876,8 +876,8 @@ module ts { sourceFile.parseDiagnostics = []; sourceFile.semanticDiagnostics = []; sourceFile.languageVersion = languageVersion; - sourceFile.filename = normalizePath(filename); - sourceFile.flags = fileExtensionIs(sourceFile.filename, ".d.ts") ? NodeFlags.DeclarationFile : 0; + 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 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index dde63394b94..e764e20f29f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -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); } @@ -252,13 +252,13 @@ module ts { } 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++) { diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 5a7bd2ba913..cf71869ab14 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -88,7 +88,7 @@ module ts { if (diagnostic.file) { var loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); - output += diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): "; + output += diagnostic.file.fileName + "(" + loc.line + "," + 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); }); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a6fb7cdf7ef..beae064ce40 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -872,7 +872,7 @@ module ts { } export interface FileReference extends TextRange { - filename: string; + fileName: string; } export interface CommentRange extends TextRange { @@ -884,7 +884,7 @@ module ts { statements: NodeArray; endOfFileToken: Node; - filename: string; + fileName: string; text: string; amdDependencies: string[]; @@ -925,7 +925,7 @@ module ts { export interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } @@ -994,7 +994,7 @@ module ts { getCompilerHost(): CompilerHost; getSourceFiles(): SourceFile[]; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; } export interface TypeChecker { @@ -1498,14 +1498,14 @@ module ts { export interface ParsedCommandLine { options: CompilerOptions; - filenames: string[]; + fileNames: string[]; errors: Diagnostic[]; } export interface CommandLineOption { name: string; type: string | Map; // "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 @@ -1653,10 +1653,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; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a333af5f383..f95952dc5c5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -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. @@ -110,7 +110,7 @@ module ts { export function nodePosToString(node: Node): string { var file = getSourceFileOfNode(node); var loc = getLineAndCharacterOfPosition(file, node.pos); - return file.filename + "(" + loc.line + "," + loc.character + ")"; + return file.fileName + "(" + loc.line + "," + 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 }; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index f0804b414be..b3c9c118e97 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -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 = {}; // Map between inputFile's filename and its content for easily looking up when resolving references + private inputFiles: ts.Map = {}; // 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(''); + var fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), '').substr(1); + var fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf(".")); + this.scenarioActions.push(''); }); // Open the first file by default @@ -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(''); + var fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), '').substr(1); + this.scenarioActions.push(''); } public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) { @@ -730,7 +730,7 @@ module FourSlash { var localFiles = this.testData.files.map(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; } }); @@ -1143,8 +1143,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"; }); @@ -2131,7 +2131,7 @@ module FourSlash { } } else if (typeof indexOrName === 'string') { var name = 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; @@ -2203,13 +2203,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()); @@ -2296,8 +2296,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; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 8aec6957a88..a854436c5bf 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -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') { @@ -1066,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); @@ -1148,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 { @@ -1184,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, @@ -1199,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; @@ -1210,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) || @@ -1236,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; }); @@ -1307,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 @@ -1323,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(); @@ -1336,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); @@ -1366,7 +1366,7 @@ module Harness { } export interface HarnessDiagnostic { - filename: string; + fileName: string; start: number; end: number; line: number; @@ -1481,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); @@ -1588,7 +1588,7 @@ module Harness { } 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 @@ -1607,11 +1607,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(); @@ -1623,13 +1623,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) { @@ -1637,15 +1637,15 @@ module Harness { return; } - var refFilename = referencePath(relativeFilename, opts && opts.Subfolder); + var refFileName = referencePath(relativeFileName, opts && opts.Subfolder); if (actual === null) { actual = ''; } var expected = ''; - if (IO.fileExists(refFilename)) { - expected = IO.readFile(refFilename); + if (IO.fileExists(refFileName)) { + expected = IO.readFile(refFileName); } var lineEndingSensitive = opts && opts.LineEndingSensitive; @@ -1658,34 +1658,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 = undefined; - var actualFilename = localPath(relativeFilename, opts && opts.Subfolder); + var actualFileName = localPath(relativeFileName, 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); } } } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 5c6b0ff35b3..d7510c7879e 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -210,7 +210,7 @@ module Harness.LanguageService { return ""; } - public getDefaultLibFilename(): string { + public getDefaultLibFileName(): string { return ""; } diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 57035262581..d9418c0e6ae 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -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 { (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(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; diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 9b16e93d8eb..fac5219f5c1 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -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) }; diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index d22048db996..49ca796448a 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -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; diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index b506cdd66b6..3121dced768 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -56,7 +56,7 @@ module RWC { runWithIOLog(ioLog, () => { harnessCompiler.reset(); // Load the files - ts.forEach(opts.filenames, fileName => { + ts.forEach(opts.fileNames, fileName => { inputFiles.push(getHarnessCompilerInputUnit(fileName)); }); @@ -183,7 +183,7 @@ class RWCRunner extends RunnerBase { } } - private runTest(jsonFilename: string) { - RWC.runRWCTest(jsonFilename); + private runTest(jsonFileName: string) { + RWC.runRWCTest(jsonFileName); } } \ No newline at end of file diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 423ee5e58a6..771fe48219f 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -404,9 +404,9 @@ module ts.NavigationBar { } hasGlobalNode = true; - var rootName = isExternalModule(node) ? - "\"" + escapeString(getBaseFilename(removeFileExtension(normalizePath(node.filename)))) + "\"" : - "" + var rootName = isExternalModule(node) + ? "\"" + escapeString(getBaseFileName(removeFileExtension(normalizePath(node.fileName)))) + "\"" + : "" return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, diff --git a/src/services/services.ts b/src/services/services.ts index a7525709a05..630e5567beb 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -718,7 +718,7 @@ 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[]; @@ -867,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; @@ -921,7 +921,7 @@ module ts { getProgram(): Program; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; dispose(): void; } @@ -1192,11 +1192,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. @@ -1206,13 +1206,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. * @@ -1220,7 +1220,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. @@ -1233,7 +1233,7 @@ module ts { */ updateDocument( sourceFile: SourceFile, - filename: string, + fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, @@ -1245,10 +1245,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 @@ -1369,7 +1369,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; // symbols by entry name map @@ -1385,7 +1385,7 @@ module ts { // Information about a specific host file. interface HostFileInformation { - hostFilename: string; + hostFileName: string; version: string; scriptSnapshot: IScriptSnapshot; } @@ -1468,17 +1468,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; + private fileNameToEntry: Map; 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 @@ -1489,64 +1489,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); } } @@ -1556,7 +1556,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; @@ -1569,26 +1569,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); @@ -1598,18 +1598,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; } } @@ -1618,8 +1618,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; @@ -1663,7 +1663,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 { @@ -1704,17 +1704,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: [] @@ -1727,7 +1727,7 @@ module ts { function updateDocument( sourceFile: SourceFile, - filename: string, + fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, @@ -1736,23 +1736,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]; } } @@ -1804,7 +1804,7 @@ module ts { var importPath = scanner.getTokenValue(); var pos = scanner.getTokenPos(); importedFiles.push({ - filename: importPath, + fileName: importPath, pos: pos, end: pos + importPath.length }); @@ -1997,7 +1997,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 @@ -2012,14 +2012,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; } @@ -2052,14 +2052,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() }); @@ -2068,9 +2068,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); } } } @@ -2080,13 +2080,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; } @@ -2097,7 +2097,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)) { @@ -2105,17 +2105,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 { @@ -2125,14 +2125,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; } } @@ -2162,30 +2162,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. @@ -2256,13 +2256,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); @@ -2317,7 +2317,7 @@ module ts { // Clear the current activeCompletionSession for this session activeCompletionSession = { - filename: filename, + fileName: fileName, position: position, entries: [], symbols: {}, @@ -2583,17 +2583,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; } @@ -2606,7 +2606,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, @@ -3149,11 +3149,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) { @@ -3173,10 +3173,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 }]; @@ -3229,7 +3229,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, @@ -3285,11 +3285,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) { @@ -3424,7 +3424,7 @@ module ts { if (shouldHighlightNextKeyword) { result.push({ - fileName: filename, + fileName: fileName, textSpan: createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), isWriteAccess: false }); @@ -4152,7 +4152,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 }); @@ -4537,7 +4537,7 @@ module ts { } return { - fileName: node.getSourceFile().filename, + fileName: node.getSourceFile().fileName, textSpan: createTextSpanFromBounds(start, end), isWriteAccess: isWriteAccess(node) }; @@ -4579,7 +4579,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]; @@ -4593,7 +4593,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 ? (container.name).text : "", @@ -4653,17 +4653,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 }); @@ -4812,16 +4812,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; @@ -4873,16 +4873,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[] { @@ -5178,15 +5178,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); @@ -5238,11 +5238,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(); @@ -5284,7 +5284,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 @@ -5293,9 +5293,9 @@ module ts { // anything away. synchronizeHostData(); - filename = normalizeSlashes(filename); + fileName = normalizeSlashes(fileName); - var sourceFile = getValidSourceFile(filename); + var sourceFile = getValidSourceFile(fileName); cancellationToken.throwIfCancellationRequested(); @@ -5836,7 +5836,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. "); diff --git a/src/services/shims.ts b/src/services/shims.ts index c9f33914e09..c5b2b24108d 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -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 }); diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index f1b1a8e8953..85d51d2610f 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -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,7 +723,7 @@ declare module "typescript" { interface SourceFile extends Declaration { statements: NodeArray; endOfFileToken: Node; - filename: string; + fileName: string; text: string; amdDependencies: string[]; amdModuleName: string; @@ -738,7 +738,7 @@ declare module "typescript" { } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } interface Program extends ScriptReferenceHost { @@ -788,7 +788,7 @@ declare module "typescript" { getCompilerOptions(): CompilerOptions; getCompilerHost(): CompilerHost; getSourceFiles(): SourceFile[]; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; } interface TypeChecker { getEmitResolver(): EmitResolver; @@ -1201,7 +1201,7 @@ declare module "typescript" { } interface ParsedCommandLine { options: CompilerOptions; - filenames: string[]; + fileNames: string[]; errors: Diagnostic[]; } interface CommandLineOption { @@ -1343,10 +1343,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; @@ -1413,7 +1413,7 @@ declare module "typescript" { 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; } @@ -1513,7 +1513,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 +1547,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 { @@ -1783,11 +1783,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. @@ -1796,9 +1796,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. * @@ -1806,7 +1806,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. @@ -1817,17 +1817,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; @@ -1898,7 +1898,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; @@ -1921,15 +1921,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); diff --git a/tests/baselines/reference/APISample_compile.types b/tests/baselines/reference/APISample_compile.types index 064170cd70f..0da89537ce0 100644 --- a/tests/baselines/reference/APISample_compile.types +++ b/tests/baselines/reference/APISample_compile.types @@ -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,11 +80,11 @@ 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); @@ -99,16 +99,16 @@ export function compile(filenames: string[], options: ts.CompilerOptions): void >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,8 +2203,8 @@ declare module "typescript" { >endOfFileToken : Node >Node : Node - filename: string; ->filename : string + fileName: string; +>fileName : string text: string; >text : string @@ -2250,9 +2250,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; @@ -2408,9 +2408,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 { @@ -3848,8 +3848,8 @@ declare module "typescript" { >options : CompilerOptions >CompilerOptions : CompilerOptions - filenames: string[]; ->filenames : string[] + fileNames: string[]; +>fileNames : string[] errors: Diagnostic[]; >errors : Diagnostic[] @@ -4267,17 +4267,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 @@ -4285,9 +4285,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 @@ -4559,9 +4559,9 @@ declare module "typescript" { >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 @@ -4885,8 +4885,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 @@ -5075,9 +5075,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; @@ -5664,11 +5664,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. @@ -5677,9 +5677,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 @@ -5688,7 +5688,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. * @@ -5696,7 +5696,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. @@ -5707,11 +5707,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 @@ -5727,12 +5727,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 } @@ -5932,9 +5932,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 diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index aa12cb40cb3..c458ad78f7f 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -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,7 +752,7 @@ declare module "typescript" { interface SourceFile extends Declaration { statements: NodeArray; endOfFileToken: Node; - filename: string; + fileName: string; text: string; amdDependencies: string[]; amdModuleName: string; @@ -767,7 +767,7 @@ declare module "typescript" { } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } interface Program extends ScriptReferenceHost { @@ -817,7 +817,7 @@ declare module "typescript" { getCompilerOptions(): CompilerOptions; getCompilerHost(): CompilerHost; getSourceFiles(): SourceFile[]; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; } interface TypeChecker { getEmitResolver(): EmitResolver; @@ -1230,7 +1230,7 @@ declare module "typescript" { } interface ParsedCommandLine { options: CompilerOptions; - filenames: string[]; + fileNames: string[]; errors: Diagnostic[]; } interface CommandLineOption { @@ -1372,10 +1372,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; @@ -1442,7 +1442,7 @@ declare module "typescript" { 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; } @@ -1542,7 +1542,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 +1576,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 { @@ -1812,11 +1812,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. @@ -1825,9 +1825,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. * @@ -1835,7 +1835,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. @@ -1846,17 +1846,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; @@ -1927,7 +1927,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; @@ -1982,14 +1982,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); }); diff --git a/tests/baselines/reference/APISample_linter.types b/tests/baselines/reference/APISample_linter.types index 7065704f422..7202e0b4dd6 100644 --- a/tests/baselines/reference/APISample_linter.types +++ b/tests/baselines/reference/APISample_linter.types @@ -235,14 +235,14 @@ export function delint(sourceFile: ts.SourceFile) { >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,8 +2333,8 @@ declare module "typescript" { >endOfFileToken : Node >Node : Node - filename: string; ->filename : string + fileName: string; +>fileName : string text: string; >text : string @@ -2380,9 +2380,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; @@ -2538,9 +2538,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 { @@ -3978,8 +3978,8 @@ declare module "typescript" { >options : CompilerOptions >CompilerOptions : CompilerOptions - filenames: string[]; ->filenames : string[] + fileNames: string[]; +>fileNames : string[] errors: Diagnostic[]; >errors : Diagnostic[] @@ -4397,17 +4397,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 @@ -4415,9 +4415,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 @@ -4689,9 +4689,9 @@ declare module "typescript" { >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 @@ -5015,8 +5015,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 @@ -5205,9 +5205,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; @@ -5794,11 +5794,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. @@ -5807,9 +5807,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 @@ -5818,7 +5818,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. * @@ -5826,7 +5826,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. @@ -5837,11 +5837,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 @@ -5857,12 +5857,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 } @@ -6062,9 +6062,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 diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 58535e42601..c2449b5af67 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -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,7 +753,7 @@ declare module "typescript" { interface SourceFile extends Declaration { statements: NodeArray; endOfFileToken: Node; - filename: string; + fileName: string; text: string; amdDependencies: string[]; amdModuleName: string; @@ -768,7 +768,7 @@ declare module "typescript" { } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } interface Program extends ScriptReferenceHost { @@ -818,7 +818,7 @@ declare module "typescript" { getCompilerOptions(): CompilerOptions; getCompilerHost(): CompilerHost; getSourceFiles(): SourceFile[]; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; } interface TypeChecker { getEmitResolver(): EmitResolver; @@ -1231,7 +1231,7 @@ declare module "typescript" { } interface ParsedCommandLine { options: CompilerOptions; - filenames: string[]; + fileNames: string[]; errors: Diagnostic[]; } interface CommandLineOption { @@ -1373,10 +1373,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; @@ -1443,7 +1443,7 @@ declare module "typescript" { 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,7 +1543,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 +1577,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 +1813,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 +1826,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 +1836,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 +1847,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 +1928,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; @@ -1962,15 +1962,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"; } }; @@ -1989,7 +1989,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; }) }; } diff --git a/tests/baselines/reference/APISample_transform.types b/tests/baselines/reference/APISample_transform.types index 5d90818f635..9c5de4cccfb 100644 --- a/tests/baselines/reference/APISample_transform.types +++ b/tests/baselines/reference/APISample_transform.types @@ -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,29 +185,29 @@ 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 : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[] >errors : ts.Diagnostic[] >map : (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 : (pos: number) => ts.LineAndCharacter @@ -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,8 +2281,8 @@ declare module "typescript" { >endOfFileToken : Node >Node : Node - filename: string; ->filename : string + fileName: string; +>fileName : string text: string; >text : string @@ -2328,9 +2328,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; @@ -2486,9 +2486,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 { @@ -3926,8 +3926,8 @@ declare module "typescript" { >options : CompilerOptions >CompilerOptions : CompilerOptions - filenames: string[]; ->filenames : string[] + fileNames: string[]; +>fileNames : string[] errors: Diagnostic[]; >errors : Diagnostic[] @@ -4345,17 +4345,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 @@ -4363,9 +4363,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 @@ -4637,9 +4637,9 @@ declare module "typescript" { >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 @@ -4963,8 +4963,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 @@ -5153,9 +5153,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; @@ -5742,11 +5742,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. @@ -5755,9 +5755,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 @@ -5766,7 +5766,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. * @@ -5774,7 +5774,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. @@ -5785,11 +5785,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 @@ -5805,12 +5805,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 } @@ -6010,9 +6010,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 diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index cd8b44bfe2d..5167674d375 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -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,7 +790,7 @@ declare module "typescript" { interface SourceFile extends Declaration { statements: NodeArray; endOfFileToken: Node; - filename: string; + fileName: string; text: string; amdDependencies: string[]; amdModuleName: string; @@ -805,7 +805,7 @@ declare module "typescript" { } interface ScriptReferenceHost { getCompilerOptions(): CompilerOptions; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; getCurrentDirectory(): string; } interface Program extends ScriptReferenceHost { @@ -855,7 +855,7 @@ declare module "typescript" { getCompilerOptions(): CompilerOptions; getCompilerHost(): CompilerHost; getSourceFiles(): SourceFile[]; - getSourceFile(filename: string): SourceFile; + getSourceFile(fileName: string): SourceFile; } interface TypeChecker { getEmitResolver(): EmitResolver; @@ -1268,7 +1268,7 @@ declare module "typescript" { } interface ParsedCommandLine { options: CompilerOptions; - filenames: string[]; + fileNames: string[]; errors: Diagnostic[]; } interface CommandLineOption { @@ -1410,10 +1410,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; @@ -1480,7 +1480,7 @@ declare module "typescript" { 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; } @@ -1580,7 +1580,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 +1614,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 { @@ -1850,11 +1850,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. @@ -1863,9 +1863,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. * @@ -1873,7 +1873,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. @@ -1884,17 +1884,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; @@ -1965,7 +1965,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; @@ -1988,63 +1988,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); @@ -2053,6 +2053,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 */ }); diff --git a/tests/baselines/reference/APISample_watcher.types b/tests/baselines/reference/APISample_watcher.types index 7050f0497d9..583b6c4fc8f 100644 --- a/tests/baselines/reference/APISample_watcher.types +++ b/tests/baselines/reference/APISample_watcher.types @@ -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 : { (...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 : { (...items: U[]): ts.Diagnostic[]; (...items: ts.Diagnostic[]): ts.Diagnostic[]; } +>services.getCompilerOptionsDiagnostics() .concat(services.getSyntacticDiagnostics(fileName)) : ts.Diagnostic[] >services.getCompilerOptionsDiagnostics() .concat : { (...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 : { (...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 : { (...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) { @@ -346,16 +346,16 @@ function watch(rootFilenames: string[], options: ts.CompilerOptions) { >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,8 +2459,8 @@ declare module "typescript" { >endOfFileToken : Node >Node : Node - filename: string; ->filename : string + fileName: string; +>fileName : string text: string; >text : string @@ -2506,9 +2506,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; @@ -2664,9 +2664,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 { @@ -4104,8 +4104,8 @@ declare module "typescript" { >options : CompilerOptions >CompilerOptions : CompilerOptions - filenames: string[]; ->filenames : string[] + fileNames: string[]; +>fileNames : string[] errors: Diagnostic[]; >errors : Diagnostic[] @@ -4523,17 +4523,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 @@ -4541,9 +4541,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 @@ -4815,9 +4815,9 @@ declare module "typescript" { >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 @@ -5141,8 +5141,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 @@ -5331,9 +5331,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; @@ -5920,11 +5920,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. @@ -5933,9 +5933,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 @@ -5944,7 +5944,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. * @@ -5952,7 +5952,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. @@ -5963,11 +5963,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 @@ -5983,12 +5983,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 } @@ -6188,9 +6188,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 diff --git a/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline b/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline index 4b89414059c..111448faa61 100644 --- a/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline +++ b/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline @@ -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; diff --git a/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline b/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline index 545c37a0728..a54108eb379 100644 --- a/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline +++ b/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline @@ -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; diff --git a/tests/baselines/reference/getEmitOutputExternalModule.baseline b/tests/baselines/reference/getEmitOutputExternalModule.baseline index 33360cbed61..6c1b0552a49 100644 --- a/tests/baselines/reference/getEmitOutputExternalModule.baseline +++ b/tests/baselines/reference/getEmitOutputExternalModule.baseline @@ -1,5 +1,5 @@ EmitOutputStatus : Succeeded -Filename : declSingleFile.js +FileName : declSingleFile.js var x = 5; var Bar = (function () { function Bar() { diff --git a/tests/baselines/reference/getEmitOutputExternalModule2.baseline b/tests/baselines/reference/getEmitOutputExternalModule2.baseline index ede5474d8cc..5613592b414 100644 --- a/tests/baselines/reference/getEmitOutputExternalModule2.baseline +++ b/tests/baselines/reference/getEmitOutputExternalModule2.baseline @@ -1,5 +1,5 @@ EmitOutputStatus : JSGeneratedWithSemanticErrors -Filename : declSingleFile.js +FileName : declSingleFile.js var x = 5; var Bar = (function () { function Bar() { diff --git a/tests/baselines/reference/getEmitOutputMapRoots.baseline b/tests/baselines/reference/getEmitOutputMapRoots.baseline index 93dab28e6fc..733897879df 100644 --- a/tests/baselines/reference/getEmitOutputMapRoots.baseline +++ b/tests/baselines/reference/getEmitOutputMapRoots.baseline @@ -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 () { diff --git a/tests/baselines/reference/getEmitOutputNoErrors.baseline b/tests/baselines/reference/getEmitOutputNoErrors.baseline index 47ba1435319..b8eddab6a9c 100644 --- a/tests/baselines/reference/getEmitOutputNoErrors.baseline +++ b/tests/baselines/reference/getEmitOutputNoErrors.baseline @@ -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() { diff --git a/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline b/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline index 1f61d57c81e..6be2d3e1d04 100644 --- a/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline +++ b/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline @@ -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() { diff --git a/tests/baselines/reference/getEmitOutputSingleFile.baseline b/tests/baselines/reference/getEmitOutputSingleFile.baseline index dd8f2be8079..b5fc4214d7c 100644 --- a/tests/baselines/reference/getEmitOutputSingleFile.baseline +++ b/tests/baselines/reference/getEmitOutputSingleFile.baseline @@ -1,5 +1,5 @@ EmitOutputStatus : Succeeded -Filename : outputDir/singleFile.js +FileName : outputDir/singleFile.js var x; var Bar = (function () { function Bar() { diff --git a/tests/baselines/reference/getEmitOutputSingleFile2.baseline b/tests/baselines/reference/getEmitOutputSingleFile2.baseline index 2f5dbe3daf8..fcbd145361d 100644 --- a/tests/baselines/reference/getEmitOutputSingleFile2.baseline +++ b/tests/baselines/reference/getEmitOutputSingleFile2.baseline @@ -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; diff --git a/tests/baselines/reference/getEmitOutputSourceMap.baseline b/tests/baselines/reference/getEmitOutputSourceMap.baseline index 75ee2a26617..c095c2f7542 100644 --- a/tests/baselines/reference/getEmitOutputSourceMap.baseline +++ b/tests/baselines/reference/getEmitOutputSourceMap.baseline @@ -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 () { diff --git a/tests/baselines/reference/getEmitOutputSourceMap2.baseline b/tests/baselines/reference/getEmitOutputSourceMap2.baseline index 2c132d8cd66..021b3918712 100644 --- a/tests/baselines/reference/getEmitOutputSourceMap2.baseline +++ b/tests/baselines/reference/getEmitOutputSourceMap2.baseline @@ -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; diff --git a/tests/baselines/reference/getEmitOutputSourceRoot.baseline b/tests/baselines/reference/getEmitOutputSourceRoot.baseline index 9252163165b..38621490fe7 100644 --- a/tests/baselines/reference/getEmitOutputSourceRoot.baseline +++ b/tests/baselines/reference/getEmitOutputSourceRoot.baseline @@ -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 () { diff --git a/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline b/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline index 5c26a1920f9..46e8a782a97 100644 --- a/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline +++ b/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline @@ -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() { diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline index be0ac935601..51ea0ffba1a 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline @@ -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() { diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline index 92a1ea1fe7a..c42cf8974cb 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline @@ -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"; diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline index f960a05f151..83837faece8 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile3.baseline @@ -1,5 +1,5 @@ EmitOutputStatus : Succeeded -Filename : declSingle.js +FileName : declSingle.js var x = "hello"; var x1 = 1000; diff --git a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline index 889902d98a2..e38f6a2021c 100644 --- a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline @@ -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; diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline index f16e3810592..359faef5fc1 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline @@ -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 () { diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline index 4befff0466c..2465f832b37 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline @@ -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() { diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline index fed9a4d2089..a1a721704a3 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline @@ -1,4 +1,4 @@ EmitOutputStatus : JSGeneratedWithSemanticErrors -Filename : tests/cases/fourslash/inputFile.js +FileName : tests/cases/fourslash/inputFile.js var x = "hello world"; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline index a2e296b85e2..d9cf2b1eedd 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline @@ -1,4 +1,4 @@ EmitOutputStatus : DeclarationGenerationSkipped -Filename : tests/cases/fourslash/inputFile.js +FileName : tests/cases/fourslash/inputFile.js var x = "hello world"; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline index c6396314824..91865045420 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline @@ -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; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline index 41b16b40e65..8b3a8ce8526 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles2.baseline @@ -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; diff --git a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline index bf27703890b..0edb4e3bb61 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline @@ -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; diff --git a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline index e1ed630f2f4..21f60cf9eeb 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline @@ -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; diff --git a/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline b/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline index 3353e1b9b9f..53c09d5fe28 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline @@ -1,4 +1,4 @@ EmitOutputStatus : Succeeded -Filename : tests/cases/fourslash/inputFile.js +FileName : tests/cases/fourslash/inputFile.js var x; diff --git a/tests/cases/compiler/APISample_compile.ts b/tests/cases/compiler/APISample_compile.ts index 004e22dcb0c..757574c0d7d 100644 --- a/tests/cases/compiler/APISample_compile.ts +++ b/tests/cases/compiler/APISample_compile.ts @@ -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}'.`); diff --git a/tests/cases/compiler/APISample_linter.ts b/tests/cases/compiler/APISample_linter.ts index 1942923a81d..c95d6273d4e 100644 --- a/tests/cases/compiler/APISample_linter.ts +++ b/tests/cases/compiler/APISample_linter.ts @@ -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); diff --git a/tests/cases/compiler/APISample_transform.ts b/tests/cases/compiler/APISample_transform.ts index b0a6c7d37ea..c3e214b0e37 100644 --- a/tests/cases/compiler/APISample_transform.ts +++ b/tests/cases/compiler/APISample_transform.ts @@ -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; }) }; } diff --git a/tests/cases/compiler/APISample_watcher.ts b/tests/cases/compiler/APISample_watcher.ts index 3c65b59801d..f29e72604d5 100644 --- a/tests/cases/compiler/APISample_watcher.ts +++ b/tests/cases/compiler/APISample_watcher.ts @@ -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 }); \ No newline at end of file diff --git a/tests/cases/unittests/incrementalParser.ts b/tests/cases/unittests/incrementalParser.ts index 97809b86dae..1b5e1a665ab 100644 --- a/tests/cases/unittests/incrementalParser.ts +++ b/tests/cases/unittests/incrementalParser.ts @@ -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" + " }"; diff --git a/tests/cases/unittests/services/preProcessFile.ts b/tests/cases/unittests/services/preProcessFile.ts index 88aa0f5e9ed..e0d397838e0 100644 --- a/tests/cases/unittests/services/preProcessFile.ts +++ b/tests/cases/unittests/services/preProcessFile.ts @@ -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("///" + "\n" + "///" + "\n" + "///" + "\n" + "///", 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: [], 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: [], - 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: [], - 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("///" + "\n" + "///" + "\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("///" + "\n" + "///" + "\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 }) }); From c80a6da18e7e1bba49349636309699ed6fed673f Mon Sep 17 00:00:00 2001 From: jbondc Date: Wed, 4 Feb 2015 08:52:45 -0500 Subject: [PATCH 17/17] Add 'jake tsc' to only build the compiler for quick testing. --- Jakefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Jakefile b/Jakefile index 767387c5d86..dc8070fd751 100644 --- a/Jakefile +++ b/Jakefile @@ -382,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() {