From 1930f8a790aa2afeb49ee6287edfed5b381c26eb Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 22 Oct 2018 11:44:39 -0700 Subject: [PATCH] fourslash: Add 'goToMarkerOrRange' helper (#28057) --- src/harness/fourslash.ts | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a75a78e2a6..a9d2bc8a00 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1181,12 +1181,7 @@ namespace FourSlash { })); for (const start of toArray(starts)) { - if (typeof start === "string") { - this.goToMarker(start); - } - else { - this.goToRangeStart(start); - } + this.goToMarkerOrRange(start); const fullActual = ts.map(this.findReferencesAtCaret(), ({ definition, references }, i) => { const text = definition.displayParts.map(d => d.text).join(""); return { @@ -1203,15 +1198,7 @@ namespace FourSlash { } public verifyNoReferences(markerNameOrRange?: string | Range) { - if (markerNameOrRange) { - if (ts.isString(markerNameOrRange)) { - this.goToMarker(markerNameOrRange); - } - else { - this.goToRangeStart(markerNameOrRange); - } - } - + if (markerNameOrRange) this.goToMarkerOrRange(markerNameOrRange); const refs = this.getReferencesAtCaret(); if (refs && refs.length) { this.raiseError(`Expected getReferences to fail, but saw references: ${stringify(refs)}`); @@ -2053,6 +2040,14 @@ Actual: ${stringify(fullActual)}`); this.goToPosition(len); } + private goToMarkerOrRange(markerOrRange: string | Range) { + if (typeof markerOrRange === "string") { + this.goToMarker(markerOrRange); + } else { + this.goToRangeStart(markerOrRange); + } + } + public goToRangeStart({ fileName, pos }: Range) { this.openFile(fileName); this.goToPosition(pos);