1
- // Licensed to the .NET Foundation under one or more agreements.
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
- using System . Collections . Immutable ;
5
4
using System . Composition ;
6
5
using System . Threading ;
7
6
using System . Threading . Tasks ;
7
+ using Microsoft . AspNetCore . Razor ;
8
8
using Microsoft . CodeAnalysis ;
9
9
using Microsoft . CodeAnalysis . ExternalAccess . Razor . Cohost ;
10
- using Microsoft . CodeAnalysis . Razor . Formatting ;
11
10
using Microsoft . CodeAnalysis . Razor . Protocol ;
12
11
using Microsoft . CodeAnalysis . Razor . Remote ;
13
- using Microsoft . CodeAnalysis . Razor . Workspaces ;
14
12
using Microsoft . CodeAnalysis . Text ;
15
13
using Microsoft . VisualStudio . Razor . LanguageClient . WrapWithTag ;
16
- using Roslyn . LanguageServer . Protocol ;
17
14
18
15
namespace Microsoft . VisualStudio . Razor . LanguageClient . Cohost ;
19
16
@@ -25,12 +22,10 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
25
22
#pragma warning restore RS0030 // Do not use banned APIs
26
23
internal sealed class CohostWrapWithTagEndpoint (
27
24
IRemoteServiceInvoker remoteServiceInvoker ,
28
- IFilePathService filePathService ,
29
25
IHtmlRequestInvoker requestInvoker )
30
26
: AbstractRazorCohostDocumentRequestHandler < VSInternalWrapWithTagParams , VSInternalWrapWithTagResponse ? >
31
27
{
32
28
private readonly IRemoteServiceInvoker _remoteServiceInvoker = remoteServiceInvoker ;
33
- private readonly IFilePathService _filePathService = filePathService ;
34
29
private readonly IHtmlRequestInvoker _requestInvoker = requestInvoker ;
35
30
36
31
protected override bool MutatesSolutionState => false ;
@@ -47,17 +42,19 @@ internal sealed class CohostWrapWithTagEndpoint(
47
42
{
48
43
// First, check if the position is valid for wrap with tag operation through the remote service
49
44
var range = request . Range . ToLinePositionSpan ( ) ;
50
- var isValidLocation = await _remoteServiceInvoker . TryInvokeAsync < IRemoteWrapWithTagService , RemoteResponse < bool > > (
45
+ var result = await _remoteServiceInvoker . TryInvokeAsync < IRemoteWrapWithTagService , RemoteResponse < LinePositionSpan > > (
51
46
razorDocument . Project . Solution ,
52
- ( service , solutionInfo , cancellationToken ) => service . IsValidWrapWithTagLocationAsync ( solutionInfo , razorDocument . Id , range , cancellationToken ) ,
47
+ ( service , solutionInfo , cancellationToken ) => service . GetValidWrappingRangeAsync ( solutionInfo , razorDocument . Id , range , cancellationToken ) ,
53
48
cancellationToken ) . ConfigureAwait ( false ) ;
54
49
55
50
// If the remote service says it's not a valid location or we should stop handling, return null
56
- if ( ! isValidLocation . Result || isValidLocation . StopHandling )
51
+ if ( result . StopHandling )
57
52
{
58
53
return null ;
59
54
}
60
55
56
+ request . Range = result . Result . ToRange ( ) ;
57
+
61
58
// The location is valid, so delegate to the HTML server
62
59
var htmlResponse = await _requestInvoker . MakeHtmlLspRequestAsync < VSInternalWrapWithTagParams , VSInternalWrapWithTagResponse > (
63
60
razorDocument ,
@@ -89,4 +86,4 @@ internal readonly struct TestAccessor(CohostWrapWithTagEndpoint instance)
89
86
public Task < VSInternalWrapWithTagResponse ? > HandleRequestAsync ( VSInternalWrapWithTagParams request , TextDocument razorDocument , CancellationToken cancellationToken )
90
87
=> instance . HandleRequestAsync ( request , razorDocument , cancellationToken ) ;
91
88
}
92
- }
89
+ }
0 commit comments