|
12 | 12 | namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Razor; |
13 | 13 |
|
14 | 14 | [Method(SemanticRangesMethodName)] |
15 | | -internal class SemanticTokensRangesHandler : ILspServiceDocumentRequestHandler<SemanticTokensRangesParams, SemanticTokens> |
| 15 | +internal sealed class SemanticTokensRangesHandler( |
| 16 | + IGlobalOptionService globalOptions, |
| 17 | + SemanticTokensRefreshQueue semanticTokensRefreshQueue) |
| 18 | + : ILspServiceDocumentRequestHandler<SemanticTokensRangesParams, SemanticTokens> |
16 | 19 | { |
17 | 20 | public const string SemanticRangesMethodName = "roslyn/semanticTokenRanges"; |
18 | | - private readonly IGlobalOptionService _globalOptions; |
19 | | - private readonly SemanticTokensRefreshQueue _semanticTokenRefreshQueue; |
| 21 | + |
| 22 | + private readonly IGlobalOptionService _globalOptions = globalOptions; |
| 23 | + private readonly SemanticTokensRefreshQueue _semanticTokenRefreshQueue = semanticTokensRefreshQueue; |
20 | 24 |
|
21 | 25 | public bool MutatesSolutionState => false; |
22 | 26 |
|
23 | 27 | public bool RequiresLSPSolution => true; |
24 | 28 |
|
25 | | - public SemanticTokensRangesHandler( |
26 | | - IGlobalOptionService globalOptions, |
27 | | - SemanticTokensRefreshQueue semanticTokensRefreshQueue) |
28 | | - { |
29 | | - _globalOptions = globalOptions; |
30 | | - _semanticTokenRefreshQueue = semanticTokensRefreshQueue; |
31 | | - } |
32 | | - |
33 | 29 | public TextDocumentIdentifier GetTextDocumentIdentifier(SemanticTokensRangesParams request) |
34 | 30 | { |
35 | 31 | Contract.ThrowIfNull(request.TextDocument); |
36 | 32 | return request.TextDocument; |
37 | 33 | } |
38 | 34 |
|
39 | 35 | public async Task<SemanticTokens> HandleRequestAsync( |
40 | | - SemanticTokensRangesParams request, |
41 | | - RequestContext context, |
42 | | - CancellationToken cancellationToken) |
| 36 | + SemanticTokensRangesParams request, |
| 37 | + RequestContext context, |
| 38 | + CancellationToken cancellationToken) |
43 | 39 | { |
44 | 40 | Contract.ThrowIfNull(request.TextDocument, "TextDocument is null."); |
45 | | - if (request.Ranges.Length == 0) |
46 | | - return new SemanticTokens { Data = [] }; |
47 | 41 |
|
48 | | - var tokensData = await SemanticTokensHelpers.HandleRequestHelperAsync(_globalOptions, _semanticTokenRefreshQueue, request.Ranges, context, cancellationToken).ConfigureAwait(false); |
| 42 | + var tokensData = await SemanticTokensHelpers.HandleRequestHelperAsync( |
| 43 | + _globalOptions, _semanticTokenRefreshQueue, request.Ranges, context, cancellationToken).ConfigureAwait(false); |
49 | 44 | return new SemanticTokens { Data = tokensData }; |
50 | 45 | } |
51 | 46 | } |
0 commit comments