Skip to content

Commit 9c9a6cb

Browse files
committed
Razor EA changes to better support the dataTipRange LSP message in cohosting
The razor side will come after this change is published and consumable by razor.
1 parent 8559c14 commit 9c9a6cb

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/LanguageServer/Protocol/Handler/DataTips/DataTipRangeHandler.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.CodeAnalysis.Debugging;
1010
using Microsoft.CodeAnalysis.Host.Mef;
1111
using Microsoft.CodeAnalysis.Shared.Extensions;
12+
using Microsoft.CodeAnalysis.Text;
1213
using Roslyn.LanguageServer.Protocol;
1314

1415
namespace Microsoft.CodeAnalysis.LanguageServer.Handler;
@@ -26,14 +27,14 @@ internal sealed class DataTipRangeHandler()
2627
public TextDocumentIdentifier GetTextDocumentIdentifier(TextDocumentPositionParams request)
2728
=> request.TextDocument;
2829

29-
public async Task<VSInternalDataTip?> HandleRequestAsync(TextDocumentPositionParams request, RequestContext context, CancellationToken cancellationToken)
30-
{
31-
var document = context.GetRequiredDocument();
30+
public Task<VSInternalDataTip?> HandleRequestAsync(TextDocumentPositionParams request, RequestContext context, CancellationToken cancellationToken)
31+
=> GetDataTipRangeAsync(context.GetRequiredDocument(), ProtocolConversions.PositionToLinePosition(request.Position), cancellationToken);
3232

33+
public static async Task<VSInternalDataTip?> GetDataTipRangeAsync(Document document, LinePosition linePosition, CancellationToken cancellationToken)
34+
{
3335
var service = document.GetRequiredLanguageService<ILanguageDebugInfoService>();
3436

3537
var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
36-
var linePosition = ProtocolConversions.PositionToLinePosition(request.Position);
3738
var position = text.Lines.GetPosition(linePosition);
3839
var info = await service.GetDataTipInfoAsync(document, position, includeKind: true, cancellationToken).ConfigureAwait(false);
3940
if (info.IsDefault)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
using Microsoft.CodeAnalysis.LanguageServer.Handler;
8+
using Microsoft.CodeAnalysis.Text;
9+
using Roslyn.LanguageServer.Protocol;
10+
11+
namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.Handlers;
12+
13+
internal static class DataTipRange
14+
{
15+
public static async Task<VSInternalDataTip?> GetDataTipRangeAsync(Document document, LinePosition linePosition, CancellationToken cancellationToken)
16+
{
17+
return await DataTipRangeHandler.GetDataTipRangeAsync(document, linePosition, cancellationToken).ConfigureAwait(false);
18+
}
19+
}

0 commit comments

Comments
 (0)