Skip to content

Commit d404238

Browse files
committed
Move LSP client integration down to editor features to support VSMac
1 parent 36ad9bf commit d404238

23 files changed

+132
-5
lines changed

src/EditorFeatures/Core/Implementation/LanguageServer/AbstractInProcLanguageClient.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
using System.Threading.Tasks;
1111
using Microsoft.CodeAnalysis;
1212
using Microsoft.CodeAnalysis.Diagnostics;
13+
using Microsoft.CodeAnalysis.Editor.Implementation.LanguageServer;
1314
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
15+
using Microsoft.CodeAnalysis.Host;
1416
using Microsoft.CodeAnalysis.LanguageServer;
1517
using Microsoft.CodeAnalysis.Options;
1618
using Microsoft.CodeAnalysis.Shared.TestHooks;
@@ -37,7 +39,11 @@ internal abstract partial class AbstractInProcLanguageClient : ILanguageClient,
3739
private readonly AbstractRequestDispatcherFactory _requestDispatcherFactory;
3840
private readonly ILspWorkspaceRegistrationService _lspWorkspaceRegistrationService;
3941

42+
<<<<<<< HEAD
4043
protected readonly IGlobalOptionService GlobalOptions;
44+
=======
45+
protected readonly HostWorkspaceServices WorkspaceServices;
46+
>>>>>>> 85406c0cb03 (Move LSP client integration down to editor features to support VSMac)
4147

4248
/// <summary>
4349
/// Created when <see cref="ActivateAsync"/> is called.
@@ -82,7 +88,11 @@ public event AsyncEventHandler<EventArgs>? StopAsync { add { } remove { } }
8288

8389
public AbstractInProcLanguageClient(
8490
AbstractRequestDispatcherFactory requestDispatcherFactory,
91+
<<<<<<< HEAD
8592
IGlobalOptionService globalOptions,
93+
=======
94+
ILspWorkspaceServicesProvider workspaceServicesProvider,
95+
>>>>>>> 85406c0cb03 (Move LSP client integration down to editor features to support VSMac)
8696
IDiagnosticService? diagnosticService,
8797
IAsynchronousOperationListenerProvider listenerProvider,
8898
ILspWorkspaceRegistrationService lspWorkspaceRegistrationService,
@@ -91,13 +101,18 @@ public AbstractInProcLanguageClient(
91101
string? diagnosticsClientName)
92102
{
93103
_requestDispatcherFactory = requestDispatcherFactory;
104+
<<<<<<< HEAD
94105
GlobalOptions = globalOptions;
106+
=======
107+
>>>>>>> 85406c0cb03 (Move LSP client integration down to editor features to support VSMac)
95108
_diagnosticService = diagnosticService;
96109
_listenerProvider = listenerProvider;
97110
_lspWorkspaceRegistrationService = lspWorkspaceRegistrationService;
98111
_diagnosticsClientName = diagnosticsClientName;
99112
_lspLoggerFactory = lspLoggerFactory;
100113
_threadingContext = threadingContext;
114+
115+
WorkspaceServices = workspaceServicesProvider.GetHostWorkspaceServices();
101116
}
102117

103118
public async Task<Connection?> ActivateAsync(CancellationToken cancellationToken)

src/EditorFeatures/Core/Implementation/LanguageServer/AlwaysActivateInProcLanguageClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.ComponentModel.Composition;
88
using Microsoft.CodeAnalysis.Diagnostics;
99
using Microsoft.CodeAnalysis.Editor;
10+
using Microsoft.CodeAnalysis.Editor.Implementation.LanguageServer;
1011
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
1112
using Microsoft.CodeAnalysis.Host.Mef;
1213
using Microsoft.CodeAnalysis.LanguageServer;
@@ -56,7 +57,7 @@ public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapa
5657
var serverCapabilities = new VSInternalServerCapabilities();
5758

5859
// If the LSP editor feature flag is enabled advertise support for LSP features here so they are available locally and remote.
59-
var isLspEditorEnabled = Workspace.Services.GetRequiredService<IExperimentationService>().IsExperimentEnabled(DefaultWorkspaceContextService.LspEditorFeatureFlagName);
60+
var isLspEditorEnabled = WorkspaceServices.GetRequiredService<IExperimentationService>().IsExperimentEnabled(DefaultWorkspaceContextService.LspEditorFeatureFlagName);
6061
if (isLspEditorEnabled)
6162
{
6263
serverCapabilities = (VSInternalServerCapabilities)_defaultCapabilitiesProvider.GetCapabilities(clientCapabilities);

src/EditorFeatures/Core/Implementation/LanguageServer/Handlers/CodeActions/CodeActionResolveHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
2626
/// system allows the basic code action data to be computed quickly, and the
2727
/// complex data, such as edits and commands, to be computed only when necessary
2828
/// (i.e. when hovering/previewing a code action).
29+
///
30+
/// TODO - This must be moved to the MS.CA.LanguageServer.Protocol project once the
31+
/// EditorFeatures references in <see cref="RunCodeActionHandler"/> are removed.
32+
/// See https://github.com/dotnet/roslyn/issues/55142
2933
/// </summary>
3034
internal class CodeActionResolveHandler : IRequestHandler<LSP.CodeAction, LSP.CodeAction>
3135
{

src/EditorFeatures/Core/Implementation/LanguageServer/Handlers/CodeActions/CodeActionsHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
1717
/// Handles the initial request for code actions. Leaves the Edit and Command properties
1818
/// of the returned VSCodeActions blank, as these properties should be populated by the
1919
/// CodeActionsResolveHandler only when the user requests them.
20+
///
21+
/// TODO - This must be moved to the MS.CA.LanguageServer.Protocol project once the
22+
/// EditorFeatures references in <see cref="RunCodeActionHandler"/> are removed.
23+
/// See https://github.com/dotnet/roslyn/issues/55142
2024
/// </summary>
2125
internal class CodeActionsHandler : IRequestHandler<LSP.CodeActionParams, LSP.CodeAction[]>
2226
{

src/EditorFeatures/Core/Implementation/LanguageServer/Handlers/CodeActions/RunCodeActionHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
2323
/// TO-DO: Currently, any ApplyChangesOperation that adds or removes a document must also be
2424
/// applied as a command due to an LSP bug (see https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1147293/).
2525
/// Commands must be applied from the UI thread in VS.
26+
///
27+
/// TODO - This must be moved to the MS.CA.LanguageServer.Protocol project once the
28+
/// UI thread dependencies are resolved and <see cref="IThreadingContext"/> references are removed.
29+
/// See https://github.com/dotnet/roslyn/issues/55142
2630
/// </summary>
2731
internal class RunCodeActionHandler : AbstractExecuteWorkspaceCommandHandler
2832
{

src/EditorFeatures/Core/Implementation/LanguageServer/Handlers/Completion/CompletionHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
2626
{
2727
/// <summary>
2828
/// Handle a completion request.
29+
///
30+
/// TODO - This must be moved to the MS.CA.LanguageServer.Protocol project once the
31+
/// references to VS Icon types are removed.
32+
/// See https://github.com/dotnet/roslyn/issues/55142
2933
/// </summary>
3034
internal class CompletionHandler : IRequestHandler<LSP.CompletionParams, LSP.CompletionList?>
3135
{

src/EditorFeatures/Core/Implementation/LanguageServer/Handlers/Completion/CompletionResolveHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler
1818
{
1919
/// <summary>
2020
/// Handle a completion resolve request to add description.
21+
///
22+
/// TODO - This must be moved to the MS.CA.LanguageServer.Protocol project once the
23+
/// references to VS icon types and classified text runs are removed.
24+
/// See https://github.com/dotnet/roslyn/issues/55142
2125
/// </summary>
2226
internal class CompletionResolveHandler : IRequestHandler<LSP.CompletionItem, LSP.CompletionItem>
2327
{

src/EditorFeatures/Core/Implementation/LanguageServer/Handlers/Hover/HoverHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
namespace Microsoft.CodeAnalysis.LanguageServer.Handler
2121
{
22+
/// <summary>
23+
/// TODO - This must be moved to the MS.CA.LanguageServer.Protocol project once it
24+
/// no longer references VS icon or classified text run types.
25+
/// See https://github.com/dotnet/roslyn/issues/55142
26+
/// </summary>
2227
[ExportRoslynLanguagesLspRequestHandlerProvider, Shared]
2328
[ProvidesMethod(Methods.TextDocumentHoverName)]
2429
internal class HoverHandler : AbstractStatelessRequestHandler<TextDocumentPositionParams, Hover?>

src/EditorFeatures/Core/Implementation/LanguageServer/Handlers/References/FindAllReferencesHandler.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
namespace Microsoft.CodeAnalysis.LanguageServer.Handler
2020
{
21+
/// <summary>
22+
/// TODO - This must be moved to the MS.CA.LanguageServer.Protocol project once
23+
/// the <see cref="IFindUsagesService"/> is moved down to the features layer and
24+
/// we no longer reference VS classified text runs.
25+
/// See https://github.com/dotnet/roslyn/issues/55142
26+
/// </summary>
2127
[ExportRoslynLanguagesLspRequestHandlerProvider, Shared]
2228
[ProvidesMethod(LSP.Methods.TextDocumentReferencesName)]
2329
internal class FindAllReferencesHandler : AbstractStatelessRequestHandler<LSP.ReferenceParams, LSP.VSInternalReferenceItem[]?>

src/EditorFeatures/Core/Implementation/LanguageServer/Handlers/Rename/RenameHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
namespace Microsoft.CodeAnalysis.LanguageServer.Handler
1818
{
19+
/// <summary>
20+
/// TODO - This must be moved to the MS.CA.LanguageServer.Protocol project once
21+
/// we no longer reference the <see cref="IInlineRenameService"/>
22+
/// See https://github.com/dotnet/roslyn/issues/55142
23+
/// </summary>
1924
[ExportRoslynLanguagesLspRequestHandlerProvider, Shared]
2025
[ProvidesMethod(LSP.Methods.TextDocumentRenameName)]
2126
internal class RenameHandler : AbstractStatelessRequestHandler<LSP.RenameParams, WorkspaceEdit?>

0 commit comments

Comments
 (0)