This commit is contained in:
David Wengier 2024-07-17 12:22:11 +10:00
Родитель 57c32ad5c5
Коммит c80b84acc5
3 изменённых файлов: 12 добавлений и 39 удалений

Просмотреть файл

@ -22,6 +22,6 @@
<ServiceHubService Include="Microsoft.VisualStudio.Razor.ClientInitialization" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteClientInitializationService+Factory" /> <ServiceHubService Include="Microsoft.VisualStudio.Razor.ClientInitialization" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteClientInitializationService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.UriPresentation" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteUriPresentationService+Factory" /> <ServiceHubService Include="Microsoft.VisualStudio.Razor.UriPresentation" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteUriPresentationService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.FoldingRange" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteFoldingRangeService+Factory" /> <ServiceHubService Include="Microsoft.VisualStudio.Razor.FoldingRange" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteFoldingRangeService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.SignatureHelp" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteSignatureHelpServiceFactory" /> <ServiceHubService Include="Microsoft.VisualStudio.Razor.SignatureHelp" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteSignatureHelpService+Factory" />
</ItemGroup> </ItemGroup>
</Project> </Project>

Просмотреть файл

@ -10,22 +10,23 @@ using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces; using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text;
using Microsoft.ServiceHub.Framework;
using Roslyn.LanguageServer.Protocol; using Roslyn.LanguageServer.Protocol;
using ExternalHandlers = Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.Handlers;
namespace Microsoft.CodeAnalysis.Remote.Razor; namespace Microsoft.CodeAnalysis.Remote.Razor;
using SignatureHelp = Roslyn.LanguageServer.Protocol.SignatureHelp; using SignatureHelp = Roslyn.LanguageServer.Protocol.SignatureHelp;
internal sealed class RemoteSignatureHelpService( internal sealed class RemoteSignatureHelpService(in ServiceArgs args) : RazorDocumentServiceBase(in args), IRemoteSignatureHelpService
IServiceBroker serviceBroker,
DocumentSnapshotFactory documentSnapshotFactory,
IFilePathService filePathService,
IRazorDocumentMappingService documentMappingService)
: RazorDocumentServiceBase(serviceBroker, documentSnapshotFactory), IRemoteSignatureHelpService
{ {
private readonly IFilePathService _filePathService = filePathService; internal sealed class Factory : FactoryBase<IRemoteSignatureHelpService>
private readonly IRazorDocumentMappingService _documentMappingService = documentMappingService; {
protected override IRemoteSignatureHelpService CreateService(in ServiceArgs args)
=> new RemoteSignatureHelpService(in args);
}
private readonly IFilePathService _filePathService = args.ExportProvider.GetExportedValue<IFilePathService>();
private readonly IRazorDocumentMappingService _documentMappingService = args.ExportProvider.GetExportedValue<IRazorDocumentMappingService>();
public ValueTask<SignatureHelp?> GetSignatureHelpAsync(JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo, JsonSerializableDocumentId documentId, Position position, CancellationToken cancellationToken) public ValueTask<SignatureHelp?> GetSignatureHelpAsync(JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo, JsonSerializableDocumentId documentId, Position position, CancellationToken cancellationToken)
=> RunServiceAsync( => RunServiceAsync(
@ -44,7 +45,7 @@ internal sealed class RemoteSignatureHelpService(
if (_documentMappingService.TryMapToGeneratedDocumentPosition(codeDocument.GetCSharpDocument(), absoluteIndex, out var mappedPosition, out _)) if (_documentMappingService.TryMapToGeneratedDocumentPosition(codeDocument.GetCSharpDocument(), absoluteIndex, out var mappedPosition, out _))
{ {
return await ExternalAccess.Razor.Cohost.Handlers.SignatureHelp.GetSignatureHelpAsync(generatedDocument, mappedPosition, supportsVisualStudioExtensions: true, cancellationToken).ConfigureAwait(false); return await ExternalHandlers.SignatureHelp.GetSignatureHelpAsync(generatedDocument, mappedPosition, supportsVisualStudioExtensions: true, cancellationToken).ConfigureAwait(false);
} }
return null; return null;

Просмотреть файл

@ -1,28 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
using Microsoft.ServiceHub.Framework;
using Microsoft.VisualStudio.Composition;
namespace Microsoft.CodeAnalysis.Remote.Razor;
internal sealed class RemoteSignatureHelpServiceFactory : RazorServiceFactoryBase<IRemoteSignatureHelpService>
{
// WARNING: We must always have a parameterless constructor in order to be properly handled by ServiceHub.
public RemoteSignatureHelpServiceFactory()
: base(RazorServices.JsonDescriptors)
{
}
protected override IRemoteSignatureHelpService CreateService(IServiceBroker serviceBroker, ExportProvider exportProvider)
{
var documentSnapshotFactory = exportProvider.GetExportedValue<DocumentSnapshotFactory>();
var filePathService = exportProvider.GetExportedValue<IFilePathService>();
var documentMappingService = exportProvider.GetExportedValue<IRazorDocumentMappingService>();
return new RemoteSignatureHelpService(serviceBroker, documentSnapshotFactory, filePathService, documentMappingService);
}
}