@@ -2819,7 +2819,7 @@ Actual: ${stringify(fullActual)}`);
2819
2819
}
2820
2820
}
2821
2821
2822
- private getDocumentHighlightsAtCurrentPosition ( fileNamesToSearch : string [ ] ) {
2822
+ private getDocumentHighlightsAtCurrentPosition ( fileNamesToSearch : ReadonlyArray < string > ) {
2823
2823
const filesToSearch = fileNamesToSearch . map ( name => ts . combinePaths ( this . basePath , name ) ) ;
2824
2824
return this . languageService . getDocumentHighlights ( this . activeFile . fileName , this . currentCaretPosition , filesToSearch ) ;
2825
2825
}
@@ -2843,9 +2843,8 @@ Actual: ${stringify(fullActual)}`);
2843
2843
this . rangesByText ( ) . forEach ( ranges => this . verifyRangesAreDocumentHighlights ( ranges ) ) ;
2844
2844
}
2845
2845
2846
- public verifyDocumentHighlightsOf ( startRange : Range , ranges : Range [ ] ) {
2847
- ts . Debug . assert ( ts . contains ( ranges , startRange ) ) ;
2848
- const fileNames = unique ( ranges , range => range . fileName ) ;
2846
+ public verifyDocumentHighlightsOf ( startRange : Range , ranges : Range [ ] , options : FourSlashInterface . VerifyDocumentHighlightsOptions | undefined ) {
2847
+ const fileNames = options && options . filesToSearch || unique ( ranges , range => range . fileName ) ;
2849
2848
this . goToRangeStart ( startRange ) ;
2850
2849
this . verifyDocumentHighlights ( ranges , fileNames ) ;
2851
2850
}
@@ -2868,7 +2867,7 @@ Actual: ${stringify(fullActual)}`);
2868
2867
}
2869
2868
}
2870
2869
2871
- private verifyDocumentHighlights ( expectedRanges : Range [ ] , fileNames : string [ ] = [ this . activeFile . fileName ] ) {
2870
+ private verifyDocumentHighlights ( expectedRanges : Range [ ] , fileNames : ReadonlyArray < string > = [ this . activeFile . fileName ] ) {
2872
2871
const documentHighlights = this . getDocumentHighlightsAtCurrentPosition ( fileNames ) || [ ] ;
2873
2872
2874
2873
for ( const dh of documentHighlights ) {
@@ -2880,10 +2879,7 @@ Actual: ${stringify(fullActual)}`);
2880
2879
for ( const fileName of fileNames ) {
2881
2880
const expectedRangesInFile = expectedRanges . filter ( r => r . fileName === fileName ) ;
2882
2881
const highlights = ts . find ( documentHighlights , dh => dh . fileName === fileName ) ;
2883
- if ( ! highlights ) {
2884
- this . raiseError ( `verifyDocumentHighlights failed - found no highlights in ${ fileName } ` ) ;
2885
- }
2886
- const spansInFile = highlights . highlightSpans . sort ( ( s1 , s2 ) => s1 . textSpan . start - s2 . textSpan . start ) ;
2882
+ const spansInFile = highlights ? highlights . highlightSpans . sort ( ( s1 , s2 ) => s1 . textSpan . start - s2 . textSpan . start ) : [ ] ;
2887
2883
2888
2884
if ( expectedRangesInFile . length !== spansInFile . length ) {
2889
2885
this . raiseError ( `verifyDocumentHighlights failed - In ${ fileName } , expected ${ expectedRangesInFile . length } highlights, got ${ spansInFile . length } ` ) ;
@@ -4272,8 +4268,8 @@ namespace FourSlashInterface {
4272
4268
this . state . verifyRangesWithSameTextAreDocumentHighlights ( ) ;
4273
4269
}
4274
4270
4275
- public documentHighlightsOf ( startRange : FourSlash . Range , ranges : FourSlash . Range [ ] ) {
4276
- this . state . verifyDocumentHighlightsOf ( startRange , ranges ) ;
4271
+ public documentHighlightsOf ( startRange : FourSlash . Range , ranges : FourSlash . Range [ ] , options ?: VerifyDocumentHighlightsOptions ) {
4272
+ this . state . verifyDocumentHighlightsOf ( startRange , ranges , options ) ;
4277
4273
}
4278
4274
4279
4275
public noDocumentHighlights ( startRange : FourSlash . Range ) {
@@ -4622,6 +4618,10 @@ namespace FourSlashInterface {
4622
4618
insertText ?: string ;
4623
4619
}
4624
4620
4621
+ export interface VerifyDocumentHighlightsOptions {
4622
+ filesToSearch ?: ReadonlyArray < string > ;
4623
+ }
4624
+
4625
4625
export interface NewContentOptions {
4626
4626
// Exactly one of these should be defined.
4627
4627
newFileContent ?: string ;
0 commit comments