Skip to content

Commit f27cc70

Browse files
committed
Merge branch 'master' into inlineSourceMaps
2 parents cacf34a + 97a3e71 commit f27cc70

File tree

277 files changed

+5824
-980
lines changed

Some content is hidden

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

277 files changed

+5824
-980
lines changed

src/compiler/checker.ts

Lines changed: 110 additions & 64 deletions
Large diffs are not rendered by default.

src/compiler/core.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ module ts {
434434
return path.replace(/\\/g, "/");
435435
}
436436

437-
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/")
437+
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files")
438438
export function getRootLength(path: string): number {
439439
if (path.charCodeAt(0) === CharacterCodes.slash) {
440440
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
@@ -448,6 +448,8 @@ module ts {
448448
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
449449
return 2;
450450
}
451+
let idx = path.indexOf('://');
452+
if (idx !== -1) return idx + 3
451453
return 0;
452454
}
453455

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ module ts {
344344
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." },
345345
The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." },
346346
Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." },
347-
The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." },
348-
The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." },
347+
Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." },
348+
An_iterator_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." },
349349
The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." },
350350
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." },
351351
Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" },

src/compiler/diagnosticMessages.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,11 +1367,11 @@
13671367
"category": "Error",
13681368
"code": 2487
13691369
},
1370-
"The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.": {
1370+
"Type must have a '[Symbol.iterator]()' method that returns an iterator.": {
13711371
"category": "Error",
13721372
"code": 2488
13731373
},
1374-
"The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.": {
1374+
"An iterator must have a 'next()' method.": {
13751375
"category": "Error",
13761376
"code": 2489
13771377
},

src/compiler/emitter.ts

Lines changed: 157 additions & 185 deletions
Large diffs are not rendered by default.

src/compiler/utilities.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,19 @@ module ts {
526526
// the *body* of the container.
527527
node = node.parent;
528528
break;
529+
case SyntaxKind.Decorator:
530+
// Decorators are always applied outside of the body of a class or method.
531+
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
532+
// If the decorator's parent is a Parameter, we resolve the this container from
533+
// the grandparent class declaration.
534+
node = node.parent.parent;
535+
}
536+
else if (isClassElement(node.parent)) {
537+
// If the decorator's parent is a class element, we resolve the 'this' container
538+
// from the parent class declaration.
539+
node = node.parent;
540+
}
541+
break;
529542
case SyntaxKind.ArrowFunction:
530543
if (!includeArrowFunctions) {
531544
continue;
@@ -568,6 +581,19 @@ module ts {
568581
// the *body* of the container.
569582
node = node.parent;
570583
break;
584+
case SyntaxKind.Decorator:
585+
// Decorators are always applied outside of the body of a class or method.
586+
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
587+
// If the decorator's parent is a Parameter, we resolve the this container from
588+
// the grandparent class declaration.
589+
node = node.parent.parent;
590+
}
591+
else if (isClassElement(node.parent)) {
592+
// If the decorator's parent is a class element, we resolve the 'this' container
593+
// from the parent class declaration.
594+
node = node.parent;
595+
}
596+
break;
571597
case SyntaxKind.FunctionDeclaration:
572598
case SyntaxKind.FunctionExpression:
573599
case SyntaxKind.ArrowFunction:
@@ -754,6 +780,8 @@ module ts {
754780
return node === (<TemplateSpan>parent).expression;
755781
case SyntaxKind.ComputedPropertyName:
756782
return node === (<ComputedPropertyName>parent).expression;
783+
case SyntaxKind.Decorator:
784+
return true;
757785
default:
758786
if (isExpression(parent)) {
759787
return true;
@@ -919,6 +947,7 @@ module ts {
919947
case SyntaxKind.MethodDeclaration:
920948
case SyntaxKind.GetAccessor:
921949
case SyntaxKind.SetAccessor:
950+
case SyntaxKind.MethodSignature:
922951
case SyntaxKind.IndexSignature:
923952
return true;
924953
default:

src/harness/harnessLanguageService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ module Harness.LanguageService {
336336
getOccurrencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] {
337337
return unwrapJSONCallResult(this.shim.getOccurrencesAtPosition(fileName, position));
338338
}
339+
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): ts.DocumentHighlights[] {
340+
return unwrapJSONCallResult(this.shim.getDocumentHighlights(fileName, position, JSON.stringify(filesToSearch)));
341+
}
339342
getNavigateToItems(searchValue: string): ts.NavigateToItem[] {
340343
return unwrapJSONCallResult(this.shim.getNavigateToItems(searchValue));
341344
}

src/harness/typeWriter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class TypeWriterWalker {
5252
case ts.SyntaxKind.PostfixUnaryExpression:
5353
case ts.SyntaxKind.BinaryExpression:
5454
case ts.SyntaxKind.ConditionalExpression:
55+
case ts.SyntaxKind.SpreadElementExpression:
5556
this.log(node, this.getTypeOfNode(node));
5657
break;
5758

src/server/client.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ module ts.server {
104104
var response: T = JSON.parse(responseBody);
105105
}
106106
catch (e) {
107-
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error detailes: " + e.message);
107+
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error details: " + e.message);
108108
}
109109

110110
// verify the sequence numbers
@@ -446,6 +446,7 @@ module ts.server {
446446
if (!response.body) {
447447
return undefined;
448448
}
449+
449450
var helpItems: protocol.SignatureHelpItems = response.body;
450451
var span = helpItems.applicableSpan;
451452
var start = this.lineOffsetToPosition(fileName, span.start);
@@ -465,6 +466,29 @@ module ts.server {
465466
}
466467

467468
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
469+
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
470+
var args: protocol.FileLocationRequestArgs = {
471+
file: fileName,
472+
line: lineOffset.line,
473+
offset: lineOffset.offset,
474+
};
475+
476+
var request = this.processRequest<protocol.OccurrencesRequest>(CommandNames.Occurrences, args);
477+
var response = this.processResponse<protocol.OccurrencesResponse>(request);
478+
479+
return response.body.map(entry => {
480+
var fileName = entry.file;
481+
var start = this.lineOffsetToPosition(fileName, entry.start);
482+
var end = this.lineOffsetToPosition(fileName, entry.end);
483+
return {
484+
fileName,
485+
textSpan: ts.createTextSpanFromBounds(start, end),
486+
isWriteAccess: entry.isWriteAccess,
487+
};
488+
});
489+
}
490+
491+
getDocumentHighlights(fileName: string, position: number): DocumentHighlights[] {
468492
throw new Error("Not Implemented Yet.");
469493
}
470494

src/server/editorServices.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ module ts.server {
458458
var info = this.filenameToScriptInfo[args.file];
459459
if (info) {
460460
info.setFormatOptions(args.formatOptions);
461-
this.log("Host configuration update for file " + args.file);
461+
this.log("Host configuration update for file " + args.file, "Info");
462462
}
463463
}
464464
else {
@@ -823,7 +823,6 @@ module ts.server {
823823
*/
824824

825825
closeClientFile(filename: string) {
826-
// TODO: tsconfig check
827826
var info = ts.lookUp(this.filenameToScriptInfo, filename);
828827
if (info) {
829828
this.closeOpenFile(info);
@@ -856,6 +855,9 @@ module ts.server {
856855
}
857856

858857
printProjects() {
858+
if (!this.psLogger.isVerbose()) {
859+
return;
860+
}
859861
this.psLogger.startGroup();
860862
for (var i = 0, len = this.inferredProjects.length; i < len; i++) {
861863
var project = this.inferredProjects[i];

src/server/protocol.d.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,25 @@ declare module ts.server.protocol {
165165
body?: FileSpan[];
166166
}
167167

168+
/**
169+
* Get occurrences request; value of command field is
170+
* "occurrences". Return response giving spans that are relevant
171+
* in the file at a given line and column.
172+
*/
173+
export interface OccurrencesRequest extends FileLocationRequest {
174+
}
175+
176+
export interface OccurrencesResponseItem extends FileSpan {
177+
/**
178+
* True if the occurrence is a write location, false otherwise.
179+
*/
180+
isWriteAccess: boolean;
181+
}
182+
183+
export interface OccurrencesResponse extends Response {
184+
body?: OccurrencesResponseItem[];
185+
}
186+
168187
/**
169188
* Find references request; value of command field is
170189
* "references". Return response giving the file locations that
@@ -405,6 +424,13 @@ declare module ts.server.protocol {
405424
arguments: OpenRequestArgs;
406425
}
407426

427+
/**
428+
* Exit request; value of command field is "exit". Ask the server process
429+
* to exit.
430+
*/
431+
export interface ExitRequest extends Request {
432+
}
433+
408434
/**
409435
* Close request; value of command field is "close". Notify the
410436
* server that the client has closed a previously open file. If

src/server/server.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,20 @@ module ts.server {
177177
super(host, logger);
178178
}
179179

180+
exit() {
181+
this.projectService.log("Exiting...","Info");
182+
this.projectService.closeLog();
183+
process.exit(0);
184+
}
185+
180186
listen() {
181187
rl.on('line',(input: string) => {
182188
var message = input.trim();
183189
this.onMessage(message);
184190
});
185191

186192
rl.on('close',() => {
187-
this.projectService.log("Exiting...");
188-
this.projectService.closeLog();
189-
process.exit(0);
193+
this.exit();
190194
});
191195
}
192196
}

0 commit comments

Comments
 (0)