|
10 | 10 | using OmniSharp.Extensions.JsonRpc.Testing;
|
11 | 11 | using OmniSharp.Extensions.LanguageServer.Client;
|
12 | 12 | using OmniSharp.Extensions.LanguageServer.Protocol.Client;
|
| 13 | +using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities; |
13 | 14 | using OmniSharp.Extensions.LanguageServer.Protocol.Server;
|
14 | 15 | using OmniSharp.Extensions.LanguageServer.Server;
|
15 | 16 | using RealLanguageServer = OmniSharp.Extensions.LanguageServer.Server.LanguageServer;
|
@@ -38,7 +39,7 @@ protected virtual void ConfigureServerInputOutput(PipeReader clientOutput, PipeW
|
38 | 39 | options.WithInput(clientOutput).WithOutput(serverInput);
|
39 | 40 | }
|
40 | 41 |
|
41 |
| - protected virtual async Task<(ILanguageClient client, ILanguageServer server)> Initialize( |
| 42 | + protected internal virtual (ILanguageClient client, ILanguageServer server) Create( |
42 | 43 | Action<LanguageClientOptions> clientOptionsAction,
|
43 | 44 | Action<LanguageServerOptions> serverOptionsAction)
|
44 | 45 | {
|
@@ -70,11 +71,37 @@ protected virtual void ConfigureServerInputOutput(PipeReader clientOutput, PipeW
|
70 | 71 | Disposable.Add(_client);
|
71 | 72 | Disposable.Add(_server);
|
72 | 73 |
|
| 74 | + return (_client, _server); |
| 75 | + } |
| 76 | + |
| 77 | + protected internal virtual async Task<(ILanguageClient client, ILanguageServer server)> Initialize( |
| 78 | + Action<LanguageClientOptions> clientOptionsAction, |
| 79 | + Action<LanguageServerOptions> serverOptionsAction) |
| 80 | + { |
| 81 | + (_client, _server) = Create(clientOptionsAction, serverOptionsAction); |
| 82 | + |
73 | 83 | return await ObservableEx.ForkJoin(
|
74 | 84 | Observable.FromAsync(_client.Initialize),
|
75 | 85 | Observable.FromAsync(_server.Initialize),
|
76 | 86 | (a, b) => (_client, _server)
|
77 | 87 | ).ToTask(CancellationToken);
|
78 | 88 | }
|
| 89 | + |
| 90 | + protected virtual async Task<(ILanguageClient client, ILanguageServer server, TestConfigurationProvider configurationProvider)> InitializeWithConfiguration( |
| 91 | + Action<LanguageClientOptions> clientOptionsAction, |
| 92 | + Action<LanguageServerOptions> serverOptionsAction |
| 93 | + ) { |
| 94 | + var (client, server) = Create(options => { |
| 95 | + clientOptionsAction?.Invoke(options); |
| 96 | + options.WithCapability(new DidChangeConfigurationCapability()); |
| 97 | + options.Services.AddSingleton<TestConfigurationProvider>(); |
| 98 | + }, serverOptionsAction); |
| 99 | + |
| 100 | + return await ObservableEx.ForkJoin( |
| 101 | + Observable.FromAsync(client.Initialize), |
| 102 | + Observable.FromAsync(server.Initialize), |
| 103 | + (a, b) => (client, server, client.GetRequiredService<TestConfigurationProvider>()) |
| 104 | + ).ToTask(CancellationToken); |
| 105 | + } |
79 | 106 | }
|
80 | 107 | }
|
0 commit comments