@@ -1102,20 +1102,30 @@ namespace FourSlash {
11021102 }
11031103
11041104 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+ } ) ) ;
11061113
11071114 for ( const startRange of toArray ( startRanges ) ) {
11081115 this . goToRangeStart ( startRange ) ;
1109- const fullActual = ts . map ( this . findReferencesAtCaret ( ) , ( { definition, references } ) => ( {
1110- definition : definition . displayParts . map ( d => d . text ) . join ( "" ) ,
1111- ranges : references
1112- } ) ) ;
1116+ const fullActual = ts . map < ts . ReferencedSymbol , ReferenceGroupJson > ( this . findReferencesAtCaret ( ) , ( { definition, references } , i ) => {
1117+ const text = definition . displayParts . map ( d => d . text ) . join ( "" ) ;
1118+ return {
1119+ definition : typeof fullExpected [ i ] . definition === "string" ? text : { text, range : definition . textSpan } ,
1120+ references,
1121+ } ;
1122+ } ) ;
11131123 this . assertObjectsEqual ( fullActual , fullExpected ) ;
11141124 }
11151125
11161126 function rangeToReferenceEntry ( r : Range ) : ts . ReferenceEntry {
11171127 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 } ;
1128+ const result : ts . ReferenceEntry = { fileName : r . fileName , textSpan : textSpanFromRange ( r ) , isWriteAccess : ! ! isWriteAccess , isDefinition : ! ! isDefinition } ;
11191129 if ( isInString !== undefined ) {
11201130 result . isInString = isInString ;
11211131 }
@@ -1139,7 +1149,7 @@ namespace FourSlash {
11391149 }
11401150 }
11411151
1142- public verifySingleReferenceGroup ( definition : string , ranges ?: Range [ ] ) {
1152+ public verifySingleReferenceGroup ( definition : FourSlashInterface . ReferenceGroupDefinition , ranges ?: Range [ ] ) {
11431153 ranges = ranges || this . getRanges ( ) ;
11441154 this . verifyReferenceGroups ( ranges , [ { definition, ranges } ] ) ;
11451155 }
@@ -4080,7 +4090,7 @@ namespace FourSlashInterface {
40804090 this . state . verifyNoReferences ( markerNameOrRange ) ;
40814091 }
40824092
4083- public singleReferenceGroup ( definition : string , ranges ?: FourSlash . Range [ ] ) {
4093+ public singleReferenceGroup ( definition : ReferenceGroupDefinition , ranges ?: FourSlash . Range [ ] ) {
40844094 this . state . verifySingleReferenceGroup ( definition , ranges ) ;
40854095 }
40864096
@@ -4592,10 +4602,12 @@ namespace FourSlashInterface {
45924602 }
45934603
45944604 export interface ReferenceGroup {
4595- definition : string ;
4605+ definition : ReferenceGroupDefinition ;
45964606 ranges : FourSlash . Range [ ] ;
45974607 }
45984608
4609+ export type ReferenceGroupDefinition = string | { text : string , range : FourSlash . Range } ;
4610+
45994611 export interface ApplyRefactorOptions {
46004612 refactorName : string ;
46014613 actionName : string ;
0 commit comments