Skip to content

Commit

Permalink
Fix find all references calls to Roslyn (#10807)
Browse files Browse the repository at this point in the history
Fixes integration test failures in Find All References.

Roslyns LSP types got much more spec compliant in
dotnet/roslyn#73911 and we were never sending
the `Context` property in our request, so deserialization failed on
their end.
  • Loading branch information
phil-allen-msft authored Aug 28, 2024
2 parents f35b6c6 + ec671db commit 5eb9d0c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.

using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using StreamJsonRpc;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Endpoints;

internal partial class RazorCustomMessageTarget
{
[JsonRpcMethod(CustomMessageNames.RazorReferencesEndpointName, UseSingleObjectParameterDeserialization = true)]
public async Task<VSInternalReferenceItem[]?> ReferencesAsync(DelegatedPositionParams request, CancellationToken cancellationToken)
{
var delegationDetails = await GetProjectedRequestDetailsAsync(request, cancellationToken).ConfigureAwait(false);
if (delegationDetails is null)
{
return default;
}

var referenceParams = new ReferenceParams()
{
TextDocument = new VSTextDocumentIdentifier()
{
Uri = delegationDetails.Value.ProjectedUri,
ProjectContext = null,
},
Position = request.ProjectedPosition,
Context = new ReferenceContext(),
};

var response = await _requestInvoker.ReinvokeRequestOnServerAsync<ReferenceParams, VSInternalReferenceItem[]?>(
delegationDetails.Value.TextBuffer,
Methods.TextDocumentReferencesName,
delegationDetails.Value.LanguageServerName,
referenceParams,
cancellationToken).ConfigureAwait(false);

if (response is null)
{
return default;
}

return response.Response;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ internal partial class RazorCustomMessageTarget
public Task<SumType<Location[], VSInternalReferenceItem[]>> ImplementationAsync(DelegatedPositionParams request, CancellationToken cancellationToken)
=> DelegateTextDocumentPositionAndProjectContextAsync<SumType<Location[], VSInternalReferenceItem[]>>(request, Methods.TextDocumentImplementationName, cancellationToken);

[JsonRpcMethod(CustomMessageNames.RazorReferencesEndpointName, UseSingleObjectParameterDeserialization = true)]
public Task<VSInternalReferenceItem[]?> ReferencesAsync(DelegatedPositionParams request, CancellationToken cancellationToken)
=> DelegateTextDocumentPositionAndProjectContextAsync<VSInternalReferenceItem[]>(request, Methods.TextDocumentReferencesName, cancellationToken);

[JsonRpcMethod(CustomMessageNames.RazorSignatureHelpEndpointName, UseSingleObjectParameterDeserialization = true)]
public Task<SignatureHelp?> SignatureHelpAsync(DelegatedPositionParams request, CancellationToken cancellationToken)
=> DelegateTextDocumentPositionAndProjectContextAsync<SignatureHelp>(request, Methods.TextDocumentSignatureHelpName, cancellationToken);
Expand Down

0 comments on commit 5eb9d0c

Please sign in to comment.