Skip to content

Commit c22a471

Browse files
Merge branch 'master' into taggedTemplates
2 parents 9880f93 + d5cfb9d commit c22a471

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+956
-1606
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ build.json
3232
tests/webhost/*.d.ts
3333
tests/webhost/webtsc.js
3434
tests/*.js
35+
tests/*.js.map
3536
tests/*.d.ts
3637
*.config
3738
scripts/debug.bat

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
language: node_js
22

33
node_js:
4-
- '0.10'
4+
- '0.10'
5+
6+
sudo: false
57

68
before_script: npm install -g codeclimate-test-reporter
79

810
after_script:
9-
- cat coverage/lcov.info | codeclimate
11+
- cat coverage/lcov.info | codeclimate
1012

1113
addons:
1214
code_climate:

src/compiler/checker.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6832,7 +6832,6 @@ module ts {
68326832
return;
68336833
}
68346834

6835-
var symbol = getSymbolOfNode(signatureDeclarationNode);
68366835
// TypeScript 1.0 spec (April 2014): 3.7.2.4
68376836
// Every specialized call or construct signature in an object type must be assignable
68386837
// to at least one non-specialized call or construct signature in the same object type
@@ -8960,7 +8959,6 @@ module ts {
89608959
// parent is not source file or it is not reference to internal module
89618960
return false;
89628961
}
8963-
var symbol = getSymbolOfNode(node);
89648962
return isImportResolvedToValue(getSymbolOfNode(node));
89658963
}
89668964

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ module ts {
746746
nodeIsNestedInLabel(label: Identifier, requireIterationStatement: boolean, stopAtFunctionBoundary: boolean): ControlBlockContext;
747747
}
748748

749-
interface ReferencePathMatchResult {
749+
export interface ReferencePathMatchResult {
750750
fileReference?: FileReference
751751
diagnostic?: DiagnosticMessage
752752
isNoDefaultLib?: boolean

src/harness/compilerRunner.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,10 @@ class CompilerBaselineRunner extends RunnerBase {
285285
typeLines.push('=== ' + file.unitName + ' ===\r\n');
286286
for (var i = 0; i < codeLines.length; i++) {
287287
var currentCodeLine = codeLines[i];
288-
var lastLine = typeLines[typeLines.length];
289288
typeLines.push(currentCodeLine + '\r\n');
290289
if (typeMap[file.unitName]) {
291290
var typeInfo = typeMap[file.unitName][i];
292291
if (typeInfo) {
293-
var leadingSpaces = '';
294292
typeInfo.forEach(ty => {
295293
typeLines.push('>' + ty + '\r\n');
296294
});

src/harness/fourslash.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,10 +2074,6 @@ module FourSlash {
20742074
}
20752075
}
20762076

2077-
private getEOF(): number {
2078-
return this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName).getLength();
2079-
}
2080-
20812077
// Get the text of the entire line the caret is currently at
20822078
private getCurrentLineContent() {
20832079
// The current caret position (in line/col terms)
@@ -2193,14 +2189,6 @@ module FourSlash {
21932189
return result;
21942190
}
21952191

2196-
private getCurrentLineNumberZeroBased() {
2197-
return this.getCurrentLineNumberOneBased() - 1;
2198-
}
2199-
2200-
private getCurrentLineNumberOneBased() {
2201-
return this.languageServiceShimHost.positionToZeroBasedLineCol(this.activeFile.fileName, this.currentCaretPosition).line + 1;
2202-
}
2203-
22042192
private getLineColStringAtPosition(position: number) {
22052193
var pos = this.languageServiceShimHost.positionToZeroBasedLineCol(this.activeFile.fileName, position);
22062194
return 'line ' + (pos.line + 1) + ', col ' + pos.character;

src/harness/fourslashRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FourslashRunner extends RunnerBase {
2020
});
2121

2222
this.tests.forEach((fn: string) => {
23-
fn = Harness.Path.switchToForwardSlashes(fn);
23+
fn = ts.normalizeSlashes(fn);
2424
var justName = fn.replace(/^.*[\\\/]/, '');
2525

2626
// Convert to relative path

src/harness/harness.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,11 @@ module Harness.Path {
117117
}
118118

119119
export function filePath(fullPath: string) {
120-
fullPath = switchToForwardSlashes(fullPath);
120+
fullPath = ts.normalizeSlashes(fullPath);
121121
var components = fullPath.split("/");
122122
var path: string[] = components.slice(0, components.length - 1);
123123
return path.join("/") + "/";
124124
}
125-
126-
export function switchToForwardSlashes(path: string) {
127-
return path.replace(/\\/g, "/").replace(/\/\//g, '/');
128-
}
129125
}
130126

131127
module Harness {
@@ -564,7 +560,7 @@ module Harness {
564560
// Register input files
565561
function register(file: { unitName: string; content: string; }) {
566562
if (file.content !== undefined) {
567-
var filename = Path.switchToForwardSlashes(file.unitName);
563+
var filename = ts.normalizeSlashes(file.unitName);
568564
filemap[getCanonicalFileName(filename)] = ts.createSourceFile(filename, file.content, scriptTarget, /*version:*/ "0");
569565
}
570566
};
@@ -782,7 +778,7 @@ module Harness {
782778
var filemap: { [name: string]: ts.SourceFile; } = {};
783779
var register = (file: { unitName: string; content: string; }) => {
784780
if (file.content !== undefined) {
785-
var filename = Path.switchToForwardSlashes(file.unitName);
781+
var filename = ts.normalizeSlashes(file.unitName);
786782
filemap[getCanonicalFileName(filename)] = ts.createSourceFile(filename, file.content, options.target, /*version:*/ "0");
787783
}
788784
};
@@ -1092,7 +1088,6 @@ module Harness {
10921088
/** @param fileResults an array of strings for the fileName and an ITextWriter with its code */
10931089
constructor(fileResults: GeneratedFile[], errors: HarnessDiagnostic[], public program: ts.Program,
10941090
public currentDirectoryForProgram: string, private sourceMapData: ts.SourceMapData[]) {
1095-
var lines: string[] = [];
10961091

10971092
fileResults.forEach(emittedFile => {
10981093
if (isDTS(emittedFile.fileName)) {
@@ -1246,7 +1241,6 @@ module Harness {
12461241

12471242
/** Support class for baseline files */
12481243
export module Baseline {
1249-
var firstRun = true;
12501244

12511245
export interface BaselineOptions {
12521246
LineEndingSensitive?: boolean;
@@ -1287,8 +1281,7 @@ module Harness {
12871281
IO.createDirectory(dirName);
12881282
fileCache[dirName] = true;
12891283
}
1290-
var parentDir = IO.directoryName(actualFilename); // .../tests/baselines/local
1291-
var parentParentDir = IO.directoryName(IO.directoryName(actualFilename)) // .../tests/baselines
1284+
12921285
// Create folders if needed
12931286
createDirectoryStructure(Harness.IO.directoryName(actualFilename));
12941287

src/harness/loggedIO.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ module Playback {
175175
}
176176

177177
function findResultByPath<T>(wrapper: { resolvePath(s: string): string }, logArray: { path: string; result?: T }[], expectedPath: string, defaultValue?: T): T {
178-
var normalizedName = Harness.Path.switchToForwardSlashes(expectedPath).toLowerCase();
178+
var normalizedName = ts.normalizeSlashes(expectedPath).toLowerCase();
179179
// Try to find the result through normal filename
180180
for (var i = 0; i < logArray.length; i++) {
181-
if (Harness.Path.switchToForwardSlashes(logArray[i].path).toLowerCase() === normalizedName) {
181+
if (ts.normalizeSlashes(logArray[i].path).toLowerCase() === normalizedName) {
182182
return logArray[i].result;
183183
}
184184
}
@@ -203,7 +203,7 @@ module Playback {
203203
function pathsAreEquivalent(left: string, right: string, wrapper: { resolvePath(s: string): string }) {
204204
var key = left + '-~~-' + right;
205205
function areSame(a: string, b: string) {
206-
return Harness.Path.switchToForwardSlashes(a).toLowerCase() === Harness.Path.switchToForwardSlashes(b).toLowerCase();
206+
return ts.normalizeSlashes(a).toLowerCase() === ts.normalizeSlashes(b).toLowerCase();
207207
}
208208
function check() {
209209
if (Harness.Path.getFileName(left).toLowerCase() === Harness.Path.getFileName(right).toLowerCase()) {

src/harness/rwcRunner.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module RWC {
2323
function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[], clean?: (s: string) => string) {
2424
// Collect, test, and sort the filenames
2525
function cleanName(fn: string) {
26-
var lastSlash = Harness.Path.switchToForwardSlashes(fn).lastIndexOf('/');
26+
var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/');
2727
return fn.substr(lastSlash + 1).toLowerCase();
2828
}
2929
outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName)));
@@ -52,7 +52,7 @@ module RWC {
5252
var compilerResult: Harness.Compiler.CompilerResult;
5353
var compilerOptions: ts.CompilerOptions;
5454
var baselineOpts: Harness.Baseline.BaselineOptions = { Subfolder: 'rwc' };
55-
var baseName = /(.*)\/(.*).json/.exec(Harness.Path.switchToForwardSlashes(jsonPath))[2];
55+
var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
5656
// Compile .d.ts files
5757
var declFileCompilationResult: {
5858
declInputFiles: { unitName: string; content: string }[];
@@ -99,7 +99,7 @@ module RWC {
9999
}
100100

101101
ts.forEach(ioLog.filesRead, fileRead => {
102-
var resolvedPath = Harness.Path.switchToForwardSlashes(sys.resolvePath(fileRead.path));
102+
var resolvedPath = ts.normalizeSlashes(sys.resolvePath(fileRead.path));
103103
var inInputList = ts.forEach(inputFiles, inputFile=> inputFile.unitName === resolvedPath);
104104
if (!inInputList) {
105105
// Add the file to other files
@@ -117,7 +117,7 @@ module RWC {
117117
});
118118

119119
function getHarnessCompilerInputUnit(fileName: string) {
120-
var resolvedPath = Harness.Path.switchToForwardSlashes(sys.resolvePath(fileName));
120+
var resolvedPath = ts.normalizeSlashes(sys.resolvePath(fileName));
121121
try {
122122
var content = sys.readFile(resolvedPath);
123123
}

src/services/compiler/pathUtils.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@
1616
///<reference path='references.ts' />
1717

1818
module TypeScript {
19-
export function stripStartAndEndQuotes(str: string) {
20-
var firstCharCode = str && str.charCodeAt(0);
21-
if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
22-
return str.substring(1, str.length - 1);
23-
}
24-
25-
return str;
26-
}
27-
28-
var switchToForwardSlashesRegEx = /\\/g;
29-
export function switchToForwardSlashes(path: string) {
30-
return path.replace(switchToForwardSlashesRegEx, "/");
31-
}
32-
3319
function isFileOfExtension(fname: string, ext: string) {
3420
var invariantFname = fname.toLocaleUpperCase();
3521
var invariantExt = ext.toLocaleUpperCase();
@@ -40,34 +26,4 @@ module TypeScript {
4026
export function isDTSFile(fname: string) {
4127
return isFileOfExtension(fname, ".d.ts");
4228
}
43-
44-
export function getPathComponents(path: string) {
45-
return path.split("/");
46-
}
47-
48-
var normalizePathRegEx = /^\\\\[^\\]/;
49-
export function normalizePath(path: string): string {
50-
// If it's a UNC style path (i.e. \\server\share), convert to a URI style (i.e. file://server/share)
51-
if (normalizePathRegEx.test(path)) {
52-
path = "file:" + path;
53-
}
54-
var parts = getPathComponents(switchToForwardSlashes(path));
55-
var normalizedParts: string[] = [];
56-
57-
for (var i = 0; i < parts.length; i++) {
58-
var part = parts[i];
59-
if (part === ".") {
60-
continue;
61-
}
62-
63-
if (normalizedParts.length > 0 && ArrayUtilities.last(normalizedParts) !== ".." && part === "..") {
64-
normalizedParts.pop();
65-
continue;
66-
}
67-
68-
normalizedParts.push(part);
69-
}
70-
71-
return normalizedParts.join("/");
72-
}
7329
}

src/services/formatting/formatter.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ module TypeScript.Services.Formatting {
9696
}
9797
this.previousTokenParent = this.parent().clone(this.indentationNodeContextPool());
9898
position += width(token);
99-
100-
// Extract any trailing comments
101-
if (token.trailingTriviaWidth() !== 0) {
102-
this.processTrivia(token.trailingTrivia(), position);
103-
}
10499
}
105100

106101
private processTrivia(triviaList: ISyntaxTriviaList, fullStart: number) {
@@ -110,7 +105,7 @@ module TypeScript.Services.Formatting {
110105
var trivia = triviaList.syntaxTriviaAt(i);
111106
// For a comment, format it like it is a token. For skipped text, eat it up as a token, but skip the formatting
112107
if (trivia.isComment() || trivia.isSkippedToken()) {
113-
var currentTokenSpan = new TokenSpan(trivia.kind(), position, trivia.fullWidth());
108+
var currentTokenSpan = new TokenSpan(trivia.kind, position, trivia.fullWidth());
114109
if (this.textSpan().containsTextSpan(currentTokenSpan)) {
115110
if (trivia.isComment() && this.previousTokenSpan) {
116111
// Note that formatPair calls TrimWhitespaceInLineRange in between the 2 tokens

src/services/formatting/formattingContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module TypeScript.Services.Formatting {
109109
var block = <BlockSyntax>node.node();
110110

111111
// Now check if they are on the same line
112-
return this.snapshot.getLineNumberFromPosition(end(block.openBraceToken)) ===
112+
return this.snapshot.getLineNumberFromPosition(fullEnd(block.openBraceToken)) ===
113113
this.snapshot.getLineNumberFromPosition(start(block.closeBraceToken));
114114
}
115115
}

src/services/formatting/formattingManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module TypeScript.Services.Formatting {
4646
// Find the outer most parent that this semicolon terminates
4747
var current: ISyntaxElement = semicolonPositionedToken;
4848
while (current.parent !== null &&
49-
end(current.parent) === end(semicolonPositionedToken) &&
49+
fullEnd(current.parent) === fullEnd(semicolonPositionedToken) &&
5050
current.parent.kind !== SyntaxKind.List) {
5151
current = current.parent;
5252
}
@@ -69,7 +69,7 @@ module TypeScript.Services.Formatting {
6969
// Find the outer most parent that this closing brace terminates
7070
var current: ISyntaxElement = closeBracePositionedToken;
7171
while (current.parent !== null &&
72-
end(current.parent) === end(closeBracePositionedToken) &&
72+
fullEnd(current.parent) === fullEnd(closeBracePositionedToken) &&
7373
current.parent.kind !== SyntaxKind.List) {
7474
current = current.parent;
7575
}

src/services/formatting/indentationTrackingWalker.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,14 @@ module TypeScript.Services.Formatting {
9090
this.visitTokenInSpan(token);
9191

9292
// Only track new lines on tokens within the range. Make sure to check that the last trivia is a newline, and not just one of the trivia
93-
var trivia = token.trailingTrivia();
94-
this._lastTriviaWasNewLine = trivia.hasNewLine() && trivia.syntaxTriviaAt(trivia.count() - 1).kind() == SyntaxKind.NewLineTrivia;
93+
var _nextToken = nextToken(token);
94+
if (_nextToken && _nextToken.hasLeadingTrivia()) {
95+
var trivia = _nextToken.leadingTrivia();
96+
this._lastTriviaWasNewLine = trivia.hasNewLine();
97+
}
98+
else {
99+
this._lastTriviaWasNewLine = false;
100+
}
95101
}
96102

97103
// Update the position
@@ -353,7 +359,7 @@ module TypeScript.Services.Formatting {
353359

354360
private forceRecomputeIndentationOfParent(tokenStart: number, newLineAdded: boolean /*as opposed to removed*/): void {
355361
var parent = this._parent;
356-
if (parent.fullStart() === tokenStart) {
362+
if (start(parent.node()) === tokenStart) {
357363
// Temporarily pop the parent before recomputing
358364
this._parent = parent.parent();
359365
var indentation = this.getNodeIndentation(parent.node(), /* newLineInsertedByFormatting */ newLineAdded);

src/services/formatting/multipleTokenIndenter.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,29 @@ module TypeScript.Services.Formatting {
6666
// Process any leading trivia if any
6767
var triviaList = token.leadingTrivia();
6868
if (triviaList) {
69+
var seenNewLine = position === 0;
70+
6971
for (var i = 0, length = triviaList.count(); i < length; i++, position += trivia.fullWidth()) {
7072
var trivia = triviaList.syntaxTriviaAt(i);
73+
74+
// Skip all trivia up to the first newline we see. We consider this trivia to
75+
// 'belong' to the previous token.
76+
if (!seenNewLine) {
77+
if (trivia.kind !== SyntaxKind.NewLineTrivia) {
78+
continue;
79+
}
80+
else {
81+
seenNewLine = true;
82+
continue;
83+
}
84+
}
85+
7186
// Skip this trivia if it is not in the span
7287
if (!this.textSpan().containsTextSpan(new TextSpan(position, trivia.fullWidth()))) {
7388
continue;
7489
}
7590

76-
switch (trivia.kind()) {
91+
switch (trivia.kind) {
7792
case SyntaxKind.MultiLineCommentTrivia:
7893
// We will only indent the first line of the multiline comment if we were planning to indent the next trivia. However,
7994
// subsequent lines will always be indented

0 commit comments

Comments
 (0)