Skip to content

Commit f91a123

Browse files
committed
PR feedback
1 parent 2069e1c commit f91a123

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/harness/fourslash.ts

+9-12
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ namespace FourSlash {
17001700
public goToImplementation(implIndex?: number) {
17011701
const implementations = this.languageService.getImplementationAtPosition(this.activeFile.fileName, this.currentCaretPosition);
17021702
if (!implementations || !implementations.length) {
1703-
this.raiseError("goToImplementation failed - expected to at least one implementation location but got 0");
1703+
this.raiseError("goToImplementation failed - expected to find at least one implementation location but got 0");
17041704
}
17051705

17061706
if (implIndex === undefined && implementations.length > 1) {
@@ -1719,7 +1719,7 @@ namespace FourSlash {
17191719
public verifyRangesInImplementationList() {
17201720
const implementations: ImplementationLocationInformation[] = this.languageService.getImplementationAtPosition(this.activeFile.fileName, this.currentCaretPosition);
17211721
if (!implementations || !implementations.length) {
1722-
this.raiseError("verifyRangesInImplementationList failed - expected to at least one implementation location but got 0");
1722+
this.raiseError("verifyRangesInImplementationList failed - expected to find at least one implementation location but got 0");
17231723
}
17241724

17251725
for (let i = 0; i < implementations.length; i++) {
@@ -1735,22 +1735,19 @@ namespace FourSlash {
17351735
const ranges = this.getRanges();
17361736

17371737
if (!ranges || !ranges.length) {
1738-
this.raiseError("verifyRangesInImplementationList failed - expected to at least one range in test source");
1738+
this.raiseError("verifyRangesInImplementationList failed - expected to find at least one range in test source");
17391739
}
17401740

17411741
const unsatisfiedRanges: Range[] = [];
17421742

17431743
for (const range of ranges) {
1744-
let rangeIsPresent = false;
17451744
const length = range.end - range.start;
1746-
for (const impl of implementations) {
1747-
if (range.fileName === impl.fileName && range.start === impl.textSpan.start && length === impl.textSpan.length) {
1748-
impl.matched = true;
1749-
rangeIsPresent = true;
1750-
break;
1751-
}
1745+
const matchingImpl = ts.find(implementations, impl =>
1746+
range.fileName === impl.fileName && range.start === impl.textSpan.start && length === impl.textSpan.length);
1747+
if (matchingImpl) {
1748+
matchingImpl.matched = true;
17521749
}
1753-
if (!rangeIsPresent) {
1750+
else {
17541751
unsatisfiedRanges.push(range);
17551752
}
17561753
}
@@ -1765,7 +1762,7 @@ namespace FourSlash {
17651762
}
17661763
}
17671764

1768-
if (unsatisfiedRanges.length) {
1765+
if (unmatchedImplementations.length) {
17691766
error += "\nUnmatched implementations:";
17701767
for (const impl of unmatchedImplementations) {
17711768
const end = impl.textSpan.start + impl.textSpan.length;

0 commit comments

Comments
 (0)