@@ -1102,20 +1102,27 @@ namespace FourSlash {
1102
1102
}
1103
1103
1104
1104
public verifyReferenceGroups ( startRanges : Range | Range [ ] , parts : FourSlashInterface . ReferenceGroup [ ] ) : void {
1105
- const fullExpected = ts . map ( parts , ( { definition, ranges } ) => ( { definition, ranges : ranges . map ( rangeToReferenceEntry ) } ) ) ;
1105
+ interface ReferenceGroupJson {
1106
+ definition : string | { text : string , range : ts . TextSpan } ;
1107
+ references : ts . ReferenceEntry [ ] ;
1108
+ }
1109
+ const fullExpected = ts . map < FourSlashInterface . ReferenceGroup , ReferenceGroupJson > ( parts , ( { definition, ranges } ) => ( {
1110
+ definition : typeof definition === "string" ? definition : { ...definition , range : textSpanFromRange ( definition . range ) } ,
1111
+ references : ranges . map ( rangeToReferenceEntry ) ,
1112
+ } ) ) ;
1106
1113
1107
1114
for ( const startRange of toArray ( startRanges ) ) {
1108
1115
this . goToRangeStart ( startRange ) ;
1109
- const fullActual = ts . map ( this . findReferencesAtCaret ( ) , ( { definition, references } ) => ( {
1110
- definition : definition . displayParts . map ( d => d . text ) . join ( "" ) ,
1111
- ranges : references
1116
+ const fullActual = ts . map < ts . ReferencedSymbol , ReferenceGroupJson > ( this . findReferencesAtCaret ( ) , ( { definition, references } , i ) => ( {
1117
+ definition : typeof fullExpected [ i ] . definition === "string" ? definition . name : { text : definition . name , range : definition . textSpan } ,
1118
+ references,
1112
1119
} ) ) ;
1113
1120
this . assertObjectsEqual ( fullActual , fullExpected ) ;
1114
1121
}
1115
1122
1116
1123
function rangeToReferenceEntry ( r : Range ) : ts . ReferenceEntry {
1117
1124
const { isWriteAccess, isDefinition, isInString } = ( r . marker && r . marker . data ) || { isWriteAccess : false , isDefinition : false , isInString : undefined } ;
1118
- const result : ts . ReferenceEntry = { fileName : r . fileName , textSpan : { start : r . start , length : r . end - r . start } , isWriteAccess : ! ! isWriteAccess , isDefinition : ! ! isDefinition } ;
1125
+ const result : ts . ReferenceEntry = { fileName : r . fileName , textSpan : textSpanFromRange ( r ) , isWriteAccess : ! ! isWriteAccess , isDefinition : ! ! isDefinition } ;
1119
1126
if ( isInString !== undefined ) {
1120
1127
result . isInString = isInString ;
1121
1128
}
@@ -1139,7 +1146,7 @@ namespace FourSlash {
1139
1146
}
1140
1147
}
1141
1148
1142
- public verifySingleReferenceGroup ( definition : string , ranges ?: Range [ ] ) {
1149
+ public verifySingleReferenceGroup ( definition : FourSlashInterface . ReferenceGroupDefinition , ranges ?: Range [ ] ) {
1143
1150
ranges = ranges || this . getRanges ( ) ;
1144
1151
this . verifyReferenceGroups ( ranges , [ { definition, ranges } ] ) ;
1145
1152
}
@@ -4080,7 +4087,7 @@ namespace FourSlashInterface {
4080
4087
this . state . verifyNoReferences ( markerNameOrRange ) ;
4081
4088
}
4082
4089
4083
- public singleReferenceGroup ( definition : string , ranges ?: FourSlash . Range [ ] ) {
4090
+ public singleReferenceGroup ( definition : ReferenceGroupDefinition , ranges ?: FourSlash . Range [ ] ) {
4084
4091
this . state . verifySingleReferenceGroup ( definition , ranges ) ;
4085
4092
}
4086
4093
@@ -4592,10 +4599,12 @@ namespace FourSlashInterface {
4592
4599
}
4593
4600
4594
4601
export interface ReferenceGroup {
4595
- definition : string ;
4602
+ definition : ReferenceGroupDefinition ;
4596
4603
ranges : FourSlash . Range [ ] ;
4597
4604
}
4598
4605
4606
+ export type ReferenceGroupDefinition = string | { text : string , range : FourSlash . Range } ;
4607
+
4599
4608
export interface ApplyRefactorOptions {
4600
4609
refactorName : string ;
4601
4610
actionName : string ;
0 commit comments