Skip to content

Commit 1930f8a

Browse files
author
Andy
authored
fourslash: Add 'goToMarkerOrRange' helper (#28057)
1 parent d3d4f83 commit 1930f8a

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/harness/fourslash.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,12 +1181,7 @@ namespace FourSlash {
11811181
}));
11821182

11831183
for (const start of toArray<string | Range>(starts)) {
1184-
if (typeof start === "string") {
1185-
this.goToMarker(start);
1186-
}
1187-
else {
1188-
this.goToRangeStart(start);
1189-
}
1184+
this.goToMarkerOrRange(start);
11901185
const fullActual = ts.map<ts.ReferencedSymbol, ReferenceGroupJson>(this.findReferencesAtCaret(), ({ definition, references }, i) => {
11911186
const text = definition.displayParts.map(d => d.text).join("");
11921187
return {
@@ -1203,15 +1198,7 @@ namespace FourSlash {
12031198
}
12041199

12051200
public verifyNoReferences(markerNameOrRange?: string | Range) {
1206-
if (markerNameOrRange) {
1207-
if (ts.isString(markerNameOrRange)) {
1208-
this.goToMarker(markerNameOrRange);
1209-
}
1210-
else {
1211-
this.goToRangeStart(markerNameOrRange);
1212-
}
1213-
}
1214-
1201+
if (markerNameOrRange) this.goToMarkerOrRange(markerNameOrRange);
12151202
const refs = this.getReferencesAtCaret();
12161203
if (refs && refs.length) {
12171204
this.raiseError(`Expected getReferences to fail, but saw references: ${stringify(refs)}`);
@@ -2053,6 +2040,14 @@ Actual: ${stringify(fullActual)}`);
20532040
this.goToPosition(len);
20542041
}
20552042

2043+
private goToMarkerOrRange(markerOrRange: string | Range) {
2044+
if (typeof markerOrRange === "string") {
2045+
this.goToMarker(markerOrRange);
2046+
} else {
2047+
this.goToRangeStart(markerOrRange);
2048+
}
2049+
}
2050+
20562051
public goToRangeStart({ fileName, pos }: Range) {
20572052
this.openFile(fileName);
20582053
this.goToPosition(pos);

0 commit comments

Comments
 (0)