Skip to content

Commit edffcce

Browse files
committed
Take optional texts to verify parameter for rangesWithSameTextAreRenameLocations
1 parent 35c0499 commit edffcce

File tree

53 files changed

+70
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+70
-126
lines changed

src/harness/fourslash.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,8 +2720,13 @@ Actual: ${stringify(fullActual)}`);
27202720
}
27212721
}
27222722

2723-
public verifyRangesWithSameTextAreRenameLocations() {
2724-
this.rangesByText().forEach(ranges => this.verifyRangesAreRenameLocations(ranges));
2723+
public verifyRangesWithSameTextAreRenameLocations(...texts: string[]) {
2724+
if (texts.length) {
2725+
texts.forEach(text => this.verifyRangesAreRenameLocations(this.rangesByText().get(text)!));
2726+
}
2727+
else {
2728+
this.rangesByText().forEach(ranges => this.verifyRangesAreRenameLocations(ranges));
2729+
}
27252730
}
27262731

27272732
public verifyRangesWithSameTextAreDocumentHighlights() {
@@ -4088,8 +4093,8 @@ namespace FourSlashInterface {
40884093
this.state.verifyRangesAreOccurrences(isWriteAccess, ranges);
40894094
}
40904095

4091-
public rangesWithSameTextAreRenameLocations() {
4092-
this.state.verifyRangesWithSameTextAreRenameLocations();
4096+
public rangesWithSameTextAreRenameLocations(...texts: string[]) {
4097+
this.state.verifyRangesWithSameTextAreRenameLocations(...texts);
40934098
}
40944099

40954100
public rangesAreRenameLocations(options?: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: FourSlash.Range[] }) {

tests/cases/fourslash/findAllRefsOnImportAliases2.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/// <reference path="fourslash.ts" />
22

33
//@Filename: a.ts
4-
////export class [|{| "isWriteAccess": true, "isDefinition": true |}Class|] {}
4+
////[|export class [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}Class|] {}|]
55

66
//@Filename: b.ts
7-
////import { [|Class|] as [|{| "isWriteAccess": true, "isDefinition": true |}C2|] } from "./a";
7+
////[|import { [|{| "declarationRangeIndex": 2 |}Class|] as [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}C2|] } from "./a";|]
88
////var c = new [|C2|]();
99

1010
//@Filename: c.ts
11-
////export { [|Class|] as [|{| "isWriteAccess": true, "isDefinition": true |}C3|] } from "./a";
11+
////[|export { [|{| "declarationRangeIndex": 6 |}Class|] as [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}C3|] } from "./a";|]
1212

1313
const ranges = test.rangesByText();
1414
const classRanges = ranges.get("Class");
@@ -26,4 +26,4 @@ verify.referenceGroups(c2Ranges, [c2s])
2626

2727
verify.referenceGroups(c3Ranges, [c3s]);
2828

29-
verify.rangesWithSameTextAreRenameLocations();
29+
verify.rangesWithSameTextAreRenameLocations("Class", "C2", "C3");

tests/cases/fourslash/fourslash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ declare namespace FourSlashInterface {
229229
referenceGroups(starts: ArrayOrSingle<string> | ArrayOrSingle<Range>, parts: ReadonlyArray<ReferenceGroup>): void;
230230
singleReferenceGroup(definition: ReferencesDefinition, ranges?: Range[]): void;
231231
rangesAreOccurrences(isWriteAccess?: boolean, ranges?: Range[]): void;
232-
rangesWithSameTextAreRenameLocations(): void;
232+
rangesWithSameTextAreRenameLocations(...texts: string[]): void;
233233
rangesAreRenameLocations(options?: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: Range[] });
234234
findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]): void;
235235
noSignatureHelp(...markers: string[]): void;

tests/cases/fourslash/javaScriptClass2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
//// var x = new Foo();
1515
//// x.[|union|];
1616

17-
verify.rangesAreRenameLocations(test.rangesByText().get("union"));
17+
verify.rangesWithSameTextAreRenameLocations("union");

tests/cases/fourslash/jsxSpreadReference.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@
1818
//// var x = <MyClass {...[|n/*src*/n|]}></MyClass>;
1919

2020
verify.goToDefinition("src", "dst");
21-
const [rDef, ...ranges] = test.ranges();
22-
verify.rangesAreRenameLocations(ranges);
21+
verify.rangesWithSameTextAreRenameLocations("nn");

tests/cases/fourslash/renameAcrossMultipleProjects.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@
1111
/////// <reference path="a.ts" />
1212
////[|x|]++;
1313

14-
const [rDef, ...ranges] = test.ranges();
15-
verify.rangesAreRenameLocations(ranges);
14+
verify.rangesWithSameTextAreRenameLocations("x");

tests/cases/fourslash/renameAlias.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
////[|import [|{| "declarationRangeIndex": 0 |}M|] = SomeModule;|]
55
////import C = [|M|].SomeClass;
66

7-
const [rDef, ...ranges] = test.ranges();
8-
verify.rangesAreRenameLocations(ranges);
7+
verify.rangesWithSameTextAreRenameLocations("M");

tests/cases/fourslash/renameAlias2.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
////import M = [|SomeModule|];
55
////import C = M.SomeClass;
66

7-
const [rDef, ...ranges] = test.ranges();
8-
verify.rangesAreRenameLocations(ranges);
7+
verify.rangesWithSameTextAreRenameLocations("SomeModule");

tests/cases/fourslash/renameAlias3.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
////import M = SomeModule;
55
////import C = M.[|SomeClass|];
66

7-
const [rDef, ...ranges] = test.ranges();
8-
verify.rangesAreRenameLocations(ranges);
7+
verify.rangesWithSameTextAreRenameLocations("SomeClass");

tests/cases/fourslash/renameAliasExternalModule.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88
////[|import [|{| "declarationRangeIndex": 0 |}M|] = require("./a");|]
99
////import C = [|M|].SomeClass;
1010

11-
const [rDef, ...ranges] = test.ranges();
12-
verify.rangesAreRenameLocations(ranges);
11+
verify.rangesWithSameTextAreRenameLocations("M");

0 commit comments

Comments
 (0)