fourslash: Add 'goToMarkerOrRange' helper (#28057)
This commit is contained in:
parent
d3d4f83f89
commit
1930f8a790
1 changed files with 10 additions and 15 deletions
|
@ -1181,12 +1181,7 @@ namespace FourSlash {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (const start of toArray<string | Range>(starts)) {
|
for (const start of toArray<string | Range>(starts)) {
|
||||||
if (typeof start === "string") {
|
this.goToMarkerOrRange(start);
|
||||||
this.goToMarker(start);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.goToRangeStart(start);
|
|
||||||
}
|
|
||||||
const fullActual = ts.map<ts.ReferencedSymbol, ReferenceGroupJson>(this.findReferencesAtCaret(), ({ definition, references }, i) => {
|
const fullActual = ts.map<ts.ReferencedSymbol, ReferenceGroupJson>(this.findReferencesAtCaret(), ({ definition, references }, i) => {
|
||||||
const text = definition.displayParts.map(d => d.text).join("");
|
const text = definition.displayParts.map(d => d.text).join("");
|
||||||
return {
|
return {
|
||||||
|
@ -1203,15 +1198,7 @@ namespace FourSlash {
|
||||||
}
|
}
|
||||||
|
|
||||||
public verifyNoReferences(markerNameOrRange?: string | Range) {
|
public verifyNoReferences(markerNameOrRange?: string | Range) {
|
||||||
if (markerNameOrRange) {
|
if (markerNameOrRange) this.goToMarkerOrRange(markerNameOrRange);
|
||||||
if (ts.isString(markerNameOrRange)) {
|
|
||||||
this.goToMarker(markerNameOrRange);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.goToRangeStart(markerNameOrRange);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const refs = this.getReferencesAtCaret();
|
const refs = this.getReferencesAtCaret();
|
||||||
if (refs && refs.length) {
|
if (refs && refs.length) {
|
||||||
this.raiseError(`Expected getReferences to fail, but saw references: ${stringify(refs)}`);
|
this.raiseError(`Expected getReferences to fail, but saw references: ${stringify(refs)}`);
|
||||||
|
@ -2053,6 +2040,14 @@ Actual: ${stringify(fullActual)}`);
|
||||||
this.goToPosition(len);
|
this.goToPosition(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private goToMarkerOrRange(markerOrRange: string | Range) {
|
||||||
|
if (typeof markerOrRange === "string") {
|
||||||
|
this.goToMarker(markerOrRange);
|
||||||
|
} else {
|
||||||
|
this.goToRangeStart(markerOrRange);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public goToRangeStart({ fileName, pos }: Range) {
|
public goToRangeStart({ fileName, pos }: Range) {
|
||||||
this.openFile(fileName);
|
this.openFile(fileName);
|
||||||
this.goToPosition(pos);
|
this.goToPosition(pos);
|
||||||
|
|
Loading…
Reference in a new issue