@@ -31,7 +31,7 @@ class C1 { int n = true; }
3131" ) ;
3232
3333 var line = - 1 ;
34- var highlights = await GetSemanticHighlightsForLineAsync ( testFile , line ) ;
34+ var highlights = await GetSemanticHighlightsForLineAsync ( testFile , line , versionedText : null ) ;
3535
3636 Assert . Empty ( highlights ) ;
3737 }
@@ -47,7 +47,7 @@ class C1 { int n = true; }
4747" ) ;
4848
4949 var line = 3 ;
50- var highlights = await GetSemanticHighlightsForLineAsync ( testFile , line ) ;
50+ var highlights = await GetSemanticHighlightsForLineAsync ( testFile , line , versionedText : null ) ;
5151
5252 AssertSyntax ( highlights , testFile . Content . Code , line ,
5353 Keyword ( "class" ) ,
@@ -90,6 +90,42 @@ class C1 { int n = true; }
9090 ) ;
9191 }
9292
93+ [ Fact ]
94+ public async Task SemanticHighlightEntireFileWithVersionedText ( )
95+ {
96+ var testFile = new TestFile ( "a.cs" , @"
97+ namespace N1
98+ {
99+ class C1 { int n = true; }
100+ }
101+ " ) ;
102+ var versionedText = @"
103+ namespace N1
104+ {
105+ class C { int n = false; }
106+ }
107+ " ;
108+
109+ var highlights = await GetSemanticHighlightsForFileAsync ( testFile , versionedText ) ;
110+
111+ AssertSyntax ( highlights , versionedText , 0 ,
112+ Keyword ( "namespace" ) ,
113+ NamespaceName ( "N1" ) ,
114+ Punctuation ( "{" ) ,
115+ Keyword ( "class" ) ,
116+ ClassName ( "C" ) ,
117+ Punctuation ( "{" ) ,
118+ Keyword ( "int" ) ,
119+ Field ( "n" ) ,
120+ Operator ( "=" ) ,
121+ Keyword ( "false" ) ,
122+ Punctuation ( ";" ) ,
123+ Punctuation ( "}" ) ,
124+ Punctuation ( "}" )
125+ ) ;
126+ }
127+
128+
93129 [ Fact ]
94130 public async Task SemanticHighlightStringInterpolation ( )
95131 {
@@ -317,28 +353,34 @@ record struct R1(string S, int I);
317353
318354 private Task < SemanticHighlightSpan [ ] > GetSemanticHighlightsForFileAsync ( TestFile testFile )
319355 {
320- return GetSemanticHighlightsAsync ( testFile , range : null ) ;
356+ return GetSemanticHighlightsAsync ( testFile , range : null , versionedText : null ) ;
357+ }
358+
359+ private Task < SemanticHighlightSpan [ ] > GetSemanticHighlightsForFileAsync ( TestFile testFile , string versionedText )
360+ {
361+ return GetSemanticHighlightsAsync ( testFile , range : null , versionedText ) ;
321362 }
322363
323- private Task < SemanticHighlightSpan [ ] > GetSemanticHighlightsForLineAsync ( TestFile testFile , int line )
364+ private Task < SemanticHighlightSpan [ ] > GetSemanticHighlightsForLineAsync ( TestFile testFile , int line , string versionedText )
324365 {
325366 var range = new Range ( )
326367 {
327368 Start = new Point ( ) { Column = 0 , Line = line } ,
328369 End = new Point ( ) { Column = 0 , Line = line + 1 }
329370 } ;
330371
331- return GetSemanticHighlightsAsync ( testFile , range ) ;
372+ return GetSemanticHighlightsAsync ( testFile , range , versionedText ) ;
332373 }
333374
334- private async Task < SemanticHighlightSpan [ ] > GetSemanticHighlightsAsync ( TestFile testFile , Range range )
375+ private async Task < SemanticHighlightSpan [ ] > GetSemanticHighlightsAsync ( TestFile testFile , Range range , string versionedText )
335376 {
336377 SharedOmniSharpTestHost . AddFilesToWorkspace ( testFile ) ;
337378 var requestHandler = GetRequestHandler ( SharedOmniSharpTestHost ) ;
338379 var request = new SemanticHighlightRequest
339380 {
340381 FileName = testFile . FileName ,
341- Range = range
382+ Range = range ,
383+ VersionedText = versionedText ,
342384 } ;
343385
344386 var response = await requestHandler . Handle ( request ) ;
0 commit comments