@@ -8,10 +8,6 @@ import { RequestType } from 'vscode-languageclient';
8
8
import { RazorLanguageServerClient } from '../razorLanguageServerClient' ;
9
9
import { ProvideSemanticTokensResponse } from './provideSemanticTokensResponse' ;
10
10
import { SerializableSemanticTokensParams } from './serializableSemanticTokensParams' ;
11
- import { RazorDocumentSynchronizer } from '../document/razorDocumentSynchronizer' ;
12
- import { RazorDocumentManager } from '../document/razorDocumentManager' ;
13
- import { RazorLanguageServiceClient } from '../razorLanguageServiceClient' ;
14
- import { RazorLogger } from '../razorLogger' ;
15
11
16
12
export class SemanticTokensRangeHandler {
17
13
private static readonly getSemanticTokensRangeEndpoint = 'razor/provideSemanticTokensRange' ;
@@ -20,18 +16,9 @@ export class SemanticTokensRangeHandler {
20
16
ProvideSemanticTokensResponse ,
21
17
any
22
18
> = new RequestType ( SemanticTokensRangeHandler . getSemanticTokensRangeEndpoint ) ;
23
- private emptySemanticTokensResponse : ProvideSemanticTokensResponse = new ProvideSemanticTokensResponse (
24
- new Array < Array < number > > ( ) ,
25
- - 1
26
- ) ;
19
+ private emptyTokensInResponse : Array < Array < number > > = new Array < Array < number > > ( ) ;
27
20
28
- constructor (
29
- private readonly documentSynchronizer : RazorDocumentSynchronizer ,
30
- protected readonly serverClient : RazorLanguageServerClient ,
31
- protected readonly serviceClient : RazorLanguageServiceClient ,
32
- protected readonly documentManager : RazorDocumentManager ,
33
- protected readonly logger : RazorLogger
34
- ) { }
21
+ constructor ( private readonly serverClient : RazorLanguageServerClient ) { }
35
22
36
23
public async register ( ) {
37
24
await this . serverClient . onRequestWithParams <
@@ -49,33 +36,13 @@ export class SemanticTokensRangeHandler {
49
36
_semanticTokensParams : SerializableSemanticTokensParams ,
50
37
_cancellationToken : vscode . CancellationToken
51
38
) : Promise < ProvideSemanticTokensResponse > {
52
- let version = - 1 ;
53
- try {
54
- const razorDocumentUri = vscode . Uri . parse ( _semanticTokensParams . textDocument . uri ) ;
55
- const razorDocument = await this . documentManager . getDocument ( razorDocumentUri ) ;
56
- if ( razorDocument === undefined ) {
57
- return this . emptySemanticTokensResponse ;
58
- }
59
-
60
- const textDocument = await vscode . workspace . openTextDocument ( razorDocumentUri ) ;
61
- version = textDocument . version ;
62
- const synchronized = await this . documentSynchronizer . trySynchronizeProjectedDocument (
63
- textDocument ,
64
- razorDocument . csharpDocument ,
65
- version ,
66
- _cancellationToken
67
- ) ;
68
- if ( ! synchronized ) {
69
- return this . emptySemanticTokensResponse ;
70
- }
71
- } catch ( error ) {
72
- this . logger . logWarning ( `${ SemanticTokensRangeHandler . getSemanticTokensRangeEndpoint } failed with ${ error } ` ) ;
73
- }
74
-
75
39
// This is currently a no-op since (1) the default C# semantic tokens experience is already powerful and
76
40
// (2) there seems to be an issue with the semantic tokens execute command - possibly either O# not
77
41
// returning tokens, or an issue with the command itself:
78
42
// https://github.com/dotnet/razor/issues/6922
79
- return new ProvideSemanticTokensResponse ( new Array < Array < number > > ( ) , version ) ;
43
+ return new ProvideSemanticTokensResponse (
44
+ this . emptyTokensInResponse ,
45
+ _semanticTokensParams . requiredHostDocumentVersion
46
+ ) ;
80
47
}
81
48
}
0 commit comments