Address PR feedback.

This commit is contained in:
Tien Nguyen 2015-08-05 17:09:01 -07:00
parent 8550c7de4e
commit 71e6f3a947
4 changed files with 33 additions and 12 deletions

View file

@ -2128,8 +2128,7 @@ module FourSlash {
this.raiseError('verifyOccurancesAtPositionListContains failed - found 0 references, expected at least one.');
}
for (let i = 0; i < occurrences.length; i++) {
let occurrence = occurrences[i];
for (let occurrence of occurrences) {
if (occurrence && occurrence.fileName === fileName && occurrence.textSpan.start === start && ts.textSpanEnd(occurrence.textSpan) === end) {
if (typeof isWriteAccess !== "undefined" && occurrence.isWriteAccess !== isWriteAccess) {
this.raiseError('verifyOccurrencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ' + occurrence.isWriteAccess + ', expected: ' + isWriteAccess + '.');
@ -2189,9 +2188,8 @@ module FourSlash {
this.taoInvalidReason = 'verifyDocumentHighlightsAtPositionListCount NYI';
let documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch);
let actualCount = documentHighlights
? documentHighlights.reduce((currentCount, { fileName, highlightSpans }) => {
return currentCount + highlightSpans.length}, 0)
let actualCount = documentHighlights
? documentHighlights.reduce((currentCount, { highlightSpans }) => currentCount + highlightSpans.length, 0)
: 0;
if (expectedCount !== actualCount) {

View file

@ -534,7 +534,7 @@ namespace ts.server {
let request = this.processRequest<protocol.DocumentHighlightsRequest>(CommandNames.DocumentHighlights, args);
let response = this.processResponse<protocol.DocumentHighlightsResponse>(request);
let _self = this;
let self = this;
return response.body.map(convertToDocumentHighlights);
function convertToDocumentHighlights(item: ts.server.protocol.DocumentHighlightsItem): ts.DocumentHighlights {
@ -542,12 +542,12 @@ namespace ts.server {
return {
fileName: file,
highlightSpans: highlightSpans.map(convertHighlightSpan2)
highlightSpans: highlightSpans.map(convertHighlightSpan)
};
function convertHighlightSpan2(span: ts.server.protocol.HighlightSpan): ts.HighlightSpan {
let start = _self.lineOffsetToPosition(file, span.start);
let end = _self.lineOffsetToPosition(file, span.end);
function convertHighlightSpan(span: ts.server.protocol.HighlightSpan): ts.HighlightSpan {
let start = self.lineOffsetToPosition(file, span.start);
let end = self.lineOffsetToPosition(file, span.end);
return {
textSpan: ts.createTextSpanFromBounds(start, end),
kind: span.kind

View file

@ -369,10 +369,10 @@ namespace ts.server {
return {
file: fileName,
highlightSpans: highlightSpans.map(convertHighlightSpan1)
highlightSpans: highlightSpans.map(convertHighlightSpan)
};
function convertHighlightSpan1(highlightSpan: ts.HighlightSpan): ts.server.protocol.HighlightSpan {
function convertHighlightSpan(highlightSpan: ts.HighlightSpan): ts.server.protocol.HighlightSpan {
let { textSpan, kind } = highlightSpan;
let start = compilerService.host.positionToLineOffset(fileName, textSpan.start);
let end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan));

View file

@ -0,0 +1,23 @@
/// <reference path="../fourslash.ts"/>
// @Filename: a.ts
////function foo() {
//// return 1;
////}
// @Filename: b.ts
/////// <reference path="a.ts"/>
////[|foo|]();
let ranges = test.ranges();
for (let r of ranges) {
goTo.position(r.start);
verify.documentHighlightsAtPositionCount(2, ["b.ts"]);
/*for (let range of ranges) {
verify.documentHighlightsAtPositionContains(range, ["a.ts"]);
}*/
}