From a52197fac4695b5211fc435125c84150ea8c3162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Bj=C3=B6rkstr=C3=B6m?= Date: Sat, 20 Jul 2019 00:45:23 +0300 Subject: [PATCH 1/3] Move registration options to the descriptor - Fixes issue where clients that doesn't support dynamic registrations will not end up with the correct handler matching the document (due to that registration is null). See OmniSharp-Roslyn issue #1505 and #1525 --- src/JsonRpc/JsonRpc.csproj | 6 +++--- src/Protocol/Models/Registration.cs | 2 +- src/Server/Abstractions/ILspHandlerDescriptor.cs | 1 + src/Server/ClientCapabilityProvider.cs | 8 ++++---- src/Server/HandlerCollection.cs | 1 + src/Server/HandlerDescriptor.cs | 3 +++ src/Server/Matchers/ExecuteCommandMatcher.cs | 2 +- src/Server/Matchers/TextDocumentMatcher.cs | 2 +- .../Matchers/ExecuteCommandHandlerMatcherTests.cs | 8 +++++--- .../Matchers/ResolveCommandMatcherTests.cs | 14 ++++++++++++++ vscode-testextension/src/extension.ts | 8 ++++---- 11 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/JsonRpc/JsonRpc.csproj b/src/JsonRpc/JsonRpc.csproj index b0a0dffca..5800dd65b 100644 --- a/src/JsonRpc/JsonRpc.csproj +++ b/src/JsonRpc/JsonRpc.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 AnyCPU @@ -13,7 +13,7 @@ - - + + diff --git a/src/Protocol/Models/Registration.cs b/src/Protocol/Models/Registration.cs index e448a68ef..9158f19c8 100644 --- a/src/Protocol/Models/Registration.cs +++ b/src/Protocol/Models/Registration.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; diff --git a/src/Server/Abstractions/ILspHandlerDescriptor.cs b/src/Server/Abstractions/ILspHandlerDescriptor.cs index 8929e6614..1e6450ad5 100644 --- a/src/Server/Abstractions/ILspHandlerDescriptor.cs +++ b/src/Server/Abstractions/ILspHandlerDescriptor.cs @@ -8,6 +8,7 @@ public interface ILspHandlerDescriptor : IHandlerDescriptor { bool HasRegistration { get; } Type RegistrationType { get; } + object RegisterOptions { get; } Registration Registration { get; } bool HasCapability { get; } diff --git a/src/Server/ClientCapabilityProvider.cs b/src/Server/ClientCapabilityProvider.cs index d5088bafa..3c4274fd3 100644 --- a/src/Server/ClientCapabilityProvider.cs +++ b/src/Server/ClientCapabilityProvider.cs @@ -92,7 +92,7 @@ public TOptions Get(Func action) where TOptions : class { return _collection - .Select(x => x.Registration?.RegisterOptions is TInterface cl ? action(cl) : null) + .Select(x => x.RegisterOptions is TInterface cl ? action(cl) : null) .FirstOrDefault(x => x != null); } @@ -100,13 +100,13 @@ public Supports Can(Func a where TOptions : class { var options = _collection - .Select(x => x.Registration?.RegisterOptions is TInterface cl ? action(cl) : null) + .Select(x => x.RegisterOptions is TInterface cl ? action(cl) : null) .FirstOrDefault(x => x != null); if (options == null) return Supports.OfBoolean(false); return _collection - .Select(x => x.Registration?.RegisterOptions is TInterface cl ? action(cl) : null) + .Select(x => x.RegisterOptions is TInterface cl ? action(cl) : null) .FirstOrDefault(x => x != null); } @@ -114,7 +114,7 @@ public TOptions Reduce(Func, TOpti where TOptions : class { return action(_collection - .Select(x => x.Registration?.RegisterOptions is TInterface cl ? cl : default) + .Select(x => x.RegisterOptions is TInterface cl ? cl : default) .Where(x => x != null)); } } diff --git a/src/Server/HandlerCollection.cs b/src/Server/HandlerCollection.cs index bae97fcf1..21c356a16 100644 --- a/src/Server/HandlerCollection.cs +++ b/src/Server/HandlerCollection.cs @@ -193,6 +193,7 @@ private HandlerDescriptor GetDescriptor(string method, Type handlerType, IJsonRp @interface, @params, registrationType, + registrationOptions, registration, capabilityType, () => { diff --git a/src/Server/HandlerDescriptor.cs b/src/Server/HandlerDescriptor.cs index 3e417b406..e1c3cefa8 100644 --- a/src/Server/HandlerDescriptor.cs +++ b/src/Server/HandlerDescriptor.cs @@ -22,6 +22,7 @@ public HandlerDescriptor( Type handlerType, Type @params, Type registrationType, + object registerOptions, Registration registration, Type capabilityType, Action disposeAction) @@ -35,6 +36,7 @@ public HandlerDescriptor( Params = @params; Response = Response; RegistrationType = registrationType; + RegisterOptions = registerOptions; Registration = registration; CapabilityType = capabilityType; @@ -65,6 +67,7 @@ public HandlerDescriptor( public bool HasRegistration => RegistrationType != null; public Type RegistrationType { get; } + public object RegisterOptions { get; } public Registration Registration { get; } public bool HasCapability => CapabilityType != null; diff --git a/src/Server/Matchers/ExecuteCommandMatcher.cs b/src/Server/Matchers/ExecuteCommandMatcher.cs index 781cbe063..4c1caa60b 100644 --- a/src/Server/Matchers/ExecuteCommandMatcher.cs +++ b/src/Server/Matchers/ExecuteCommandMatcher.cs @@ -28,7 +28,7 @@ public IEnumerable FindHandler(object parameters, IEnumer _logger.LogTrace("Registration options {OptionsName}", executeCommandParams.GetType().FullName); foreach (var descriptor in descriptors) { - if (descriptor.Registration?.RegisterOptions is ExecuteCommandRegistrationOptions registrationOptions && registrationOptions.Commands.Any(x => x == executeCommandParams.Command)) + if (descriptor.RegisterOptions is ExecuteCommandRegistrationOptions registrationOptions && registrationOptions.Commands.Any(x => x == executeCommandParams.Command)) { _logger.LogTrace("Checking handler {Method}:{Handler}", executeCommandParams.Command, diff --git a/src/Server/Matchers/TextDocumentMatcher.cs b/src/Server/Matchers/TextDocumentMatcher.cs index 80d12d603..55d0da682 100644 --- a/src/Server/Matchers/TextDocumentMatcher.cs +++ b/src/Server/Matchers/TextDocumentMatcher.cs @@ -75,7 +75,7 @@ private IEnumerable GetHandler(IEnumerable(); var executeCommandHandler = Substitute.For().With(new Container("Command")); + var registrationsOptions = new ExecuteCommandRegistrationOptions() { + Commands = new Container("Command") + }; // When var result = handlerMatcher.FindHandler(new ExecuteCommandParams { Command = "Command" }, @@ -68,10 +71,9 @@ public void Should_Return_Handler_Descriptor() executeCommandHandler.GetType(), typeof(ExecuteCommandParams), typeof(ExecuteCommandRegistrationOptions), + registrationsOptions, new Registration() { - RegisterOptions = new ExecuteCommandRegistrationOptions() { - Commands = new Container("Command") - } + RegisterOptions = registrationsOptions }, typeof(ExecuteCommandCapability), () => { }) diff --git a/test/Lsp.Tests/Matchers/ResolveCommandMatcherTests.cs b/test/Lsp.Tests/Matchers/ResolveCommandMatcherTests.cs index 11dd71872..3fcdc1987 100644 --- a/test/Lsp.Tests/Matchers/ResolveCommandMatcherTests.cs +++ b/test/Lsp.Tests/Matchers/ResolveCommandMatcherTests.cs @@ -68,6 +68,7 @@ public void Should_Not_Throw_Given_Another_Descriptor() null, null, null, + null, () => { }); var handlerMatcher = new ResolveCommandPipeline( new RequestContext() { Descriptor = handlerDescriptor }, @@ -101,6 +102,7 @@ public void Should_Return_CodeLensResolve_Descriptor() null, null, null, + null, () => { }), new HandlerDescriptor(DocumentNames.CodeLensResolve, "Key2", @@ -110,6 +112,7 @@ public void Should_Return_CodeLensResolve_Descriptor() null, null, null, + null, () => { }), }) .ToArray(); @@ -138,6 +141,7 @@ public void Should_Handle_Null_Data() null, null, null, + null, () => { }), }) .ToArray(); @@ -168,6 +172,7 @@ public void Should_Handle_Simple_Json_Data() null, null, null, + null, () => { }), }) .ToArray(); @@ -200,6 +205,7 @@ public void Should_Return_CompletionResolve_Descriptor() null, null, null, + null, () => { }), new HandlerDescriptor(DocumentNames.CompletionResolve, "Key2", @@ -209,6 +215,7 @@ public void Should_Return_CompletionResolve_Descriptor() null, null, null, + null, () => { }), }) .ToArray(); @@ -248,6 +255,7 @@ public void Should_Deal_WithHandlers_That_Not_Also_Resolvers() null, null, null, + null, () => { }), new HandlerDescriptor(DocumentNames.CompletionResolve, "Key2", @@ -257,6 +265,7 @@ public void Should_Deal_WithHandlers_That_Not_Also_Resolvers() null, null, null, + null, () => { }), }) .ToArray(); @@ -292,6 +301,7 @@ public void Should_Deal_WithHandlers_That_Not_Also_Resolvers2() null, null, null, + null, () => { }), new HandlerDescriptor(DocumentNames.CompletionResolve, "Key2", @@ -301,6 +311,7 @@ public void Should_Deal_WithHandlers_That_Not_Also_Resolvers2() null, null, null, + null, () => { }), }) .ToArray(); @@ -328,6 +339,7 @@ public async Task Should_Update_CompletionItems_With_HandlerType() null, null, null, + null, () => { }); var handlerMatcher = new ResolveCommandPipeline( new RequestContext() { Descriptor = descriptor }, @@ -370,6 +382,7 @@ public async Task Should_Update_CodeLensContainer_With_HandlerType() null, null, null, + null, () => { }); var handlerMatcher = new ResolveCommandPipeline( new RequestContext() { Descriptor = descriptor }, @@ -412,6 +425,7 @@ public async Task Should_Update_CodeLens_Removing_HandlerType() null, null, null, + null, () => { }); var handlerMatcher = new ResolveCommandPipeline( new RequestContext() { Descriptor = descriptor }, diff --git a/vscode-testextension/src/extension.ts b/vscode-testextension/src/extension.ts index 43b463e29..f0650a9bf 100644 --- a/vscode-testextension/src/extension.ts +++ b/vscode-testextension/src/extension.ts @@ -15,16 +15,16 @@ export function activate(context: ExtensionContext) { // The server is implemented in node // let serverExe = 'dotnet'; - let serverExe = 'D:\\development\\omnisharp\\omnisharp-roslyn\\bin\\Debug\\OmniSharp.Stdio.Driver\\net461\\OmniSharp.exe'; + let serverExe = 'C:/Users/mb/src/gh/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio.Driver/win7-x64/OmniSharp.exe'; // let serverExe = context.asAbsolutePath('D:/Development/Omnisharp/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio/win7-x64/OmniSharp.exe'); // The debug options for the server - // let debugOptions = { execArgv: ['-lsp', '-d' };5 + // let debugOptions = { execArgv: ['-lsp', '-d' }; // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used let serverOptions: ServerOptions = { - run: { command: serverExe, args: ['-lsp', '-d'] }, - debug: { command: serverExe, args: ['-lsp', '-d'] } + run: { command: serverExe, args: ['-lsp'] }, + debug: { command: serverExe, args: ['-lsp'] } } // Options to control the language client From bb2b4bd3a12943fe34c98bc983d8fd4ff2324ea3 Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Fri, 19 Jul 2019 18:39:39 -0400 Subject: [PATCH 2/3] Added id and AllowsDynamicRegistration to descriptor, removed registration and create the registrations on demand as needed --- src/JsonRpc/RequestRouterBase.cs | 2 +- .../Abstractions/ILspHandlerDescriptor.cs | 5 ++-- src/Server/ClientCapabilityProvider.cs | 8 +++--- src/Server/HandlerCollection.cs | 12 +------- src/Server/HandlerDescriptor.cs | 14 ++++++---- src/Server/ISupportedCapabilities.cs | 1 - src/Server/LanguageServer.cs | 8 ++++-- src/Server/Matchers/ExecuteCommandMatcher.cs | 2 +- src/Server/Matchers/TextDocumentMatcher.cs | 2 +- src/Server/SupportedCapabilities.cs | 10 ------- .../ExecuteCommandHandlerMatcherTests.cs | 4 +-- .../Matchers/ResolveCommandMatcherTests.cs | 28 +++++++++---------- 12 files changed, 40 insertions(+), 56 deletions(-) diff --git a/src/JsonRpc/RequestRouterBase.cs b/src/JsonRpc/RequestRouterBase.cs index c599654b0..d0d082bdb 100644 --- a/src/JsonRpc/RequestRouterBase.cs +++ b/src/JsonRpc/RequestRouterBase.cs @@ -65,7 +65,7 @@ public async Task RouteNotification(TDescriptor descriptor, Notification notific @params = notification.Params?.ToObject(descriptor.Params, _serializer.JsonSerializer); } - await HandleNotification(mediator, descriptor, @params ?? EmptyRequest.Instance, token); + await HandleNotification(mediator, descriptor, @params ?? Activator.CreateInstance(descriptor.Params), token); } } catch (Exception e) diff --git a/src/Server/Abstractions/ILspHandlerDescriptor.cs b/src/Server/Abstractions/ILspHandlerDescriptor.cs index 1e6450ad5..313bfc90f 100644 --- a/src/Server/Abstractions/ILspHandlerDescriptor.cs +++ b/src/Server/Abstractions/ILspHandlerDescriptor.cs @@ -6,10 +6,11 @@ namespace OmniSharp.Extensions.LanguageServer.Server.Abstractions { public interface ILspHandlerDescriptor : IHandlerDescriptor { + Guid Id { get; } bool HasRegistration { get; } Type RegistrationType { get; } - object RegisterOptions { get; } - Registration Registration { get; } + object RegistrationOptions { get; } + bool AllowsDynamicRegistration { get; } bool HasCapability { get; } Type CapabilityType { get; } diff --git a/src/Server/ClientCapabilityProvider.cs b/src/Server/ClientCapabilityProvider.cs index 3c4274fd3..59fd1b233 100644 --- a/src/Server/ClientCapabilityProvider.cs +++ b/src/Server/ClientCapabilityProvider.cs @@ -92,7 +92,7 @@ public TOptions Get(Func action) where TOptions : class { return _collection - .Select(x => x.RegisterOptions is TInterface cl ? action(cl) : null) + .Select(x => x.RegistrationOptions is TInterface cl ? action(cl) : null) .FirstOrDefault(x => x != null); } @@ -100,13 +100,13 @@ public Supports Can(Func a where TOptions : class { var options = _collection - .Select(x => x.RegisterOptions is TInterface cl ? action(cl) : null) + .Select(x => x.RegistrationOptions is TInterface cl ? action(cl) : null) .FirstOrDefault(x => x != null); if (options == null) return Supports.OfBoolean(false); return _collection - .Select(x => x.RegisterOptions is TInterface cl ? action(cl) : null) + .Select(x => x.RegistrationOptions is TInterface cl ? action(cl) : null) .FirstOrDefault(x => x != null); } @@ -114,7 +114,7 @@ public TOptions Reduce(Func, TOpti where TOptions : class { return action(_collection - .Select(x => x.RegisterOptions is TInterface cl ? cl : default) + .Select(x => x.RegistrationOptions is TInterface cl ? cl : default) .Where(x => x != null)); } } diff --git a/src/Server/HandlerCollection.cs b/src/Server/HandlerCollection.cs index 21c356a16..122cf4bef 100644 --- a/src/Server/HandlerCollection.cs +++ b/src/Server/HandlerCollection.cs @@ -145,7 +145,6 @@ private HandlerDescriptor GetDescriptor(string method, Type handlerType, IJsonRp Type @params = null; object registrationOptions = null; - Registration registration = null; if (@interface.GetTypeInfo().IsGenericType) { @params = @interface.GetTypeInfo().GetGenericArguments()[0]; @@ -156,15 +155,6 @@ private HandlerDescriptor GetDescriptor(string method, Type handlerType, IJsonRp registrationOptions = GetRegistrationMethod .MakeGenericMethod(registrationType) .Invoke(null, new object[] { handler }); - - if (_supportedCapabilities.AllowsDynamicRegistration(capabilityType)) - { - registration = new Registration() { - Id = Guid.NewGuid().ToString(), - Method = method, - RegisterOptions = registrationOptions - }; - } } var key = "default"; @@ -194,7 +184,7 @@ private HandlerDescriptor GetDescriptor(string method, Type handlerType, IJsonRp @params, registrationType, registrationOptions, - registration, + registrationType != null && _supportedCapabilities.AllowsDynamicRegistration(capabilityType), capabilityType, () => { _handlers.RemoveWhere(d => d.Handler == handler); diff --git a/src/Server/HandlerDescriptor.cs b/src/Server/HandlerDescriptor.cs index e1c3cefa8..044c64e6e 100644 --- a/src/Server/HandlerDescriptor.cs +++ b/src/Server/HandlerDescriptor.cs @@ -22,12 +22,13 @@ public HandlerDescriptor( Type handlerType, Type @params, Type registrationType, - object registerOptions, - Registration registration, + object registrationOptions, + bool allowsDynamicRegistration, Type capabilityType, Action disposeAction) { _disposeAction = disposeAction; + Id = Guid.NewGuid(); Method = method; Key = key; ImplementationType = handler.GetType(); @@ -36,8 +37,8 @@ public HandlerDescriptor( Params = @params; Response = Response; RegistrationType = registrationType; - RegisterOptions = registerOptions; - Registration = registration; + RegistrationOptions = registrationOptions; + AllowsDynamicRegistration = allowsDynamicRegistration; CapabilityType = capabilityType; var requestInterface = @params?.GetInterfaces() @@ -65,10 +66,11 @@ public HandlerDescriptor( public Type ImplementationType { get; } public Type HandlerType { get; } + public Guid Id { get; } public bool HasRegistration => RegistrationType != null; public Type RegistrationType { get; } - public object RegisterOptions { get; } - public Registration Registration { get; } + public object RegistrationOptions { get; } + public bool AllowsDynamicRegistration { get; } public bool HasCapability => CapabilityType != null; public Type CapabilityType { get; } diff --git a/src/Server/ISupportedCapabilities.cs b/src/Server/ISupportedCapabilities.cs index 896dfb0c6..3dbb57ae4 100644 --- a/src/Server/ISupportedCapabilities.cs +++ b/src/Server/ISupportedCapabilities.cs @@ -6,7 +6,6 @@ namespace OmniSharp.Extensions.LanguageServer.Server { public interface ISupportedCapabilities { - bool AllowsDynamicRegistration(ILspHandlerDescriptor descriptor); bool AllowsDynamicRegistration(Type capabilityType); void SetCapability(ILspHandlerDescriptor descriptor, IJsonRpcHandler handler); } diff --git a/src/Server/LanguageServer.cs b/src/Server/LanguageServer.cs index d2c7e20ca..975ce12b1 100644 --- a/src/Server/LanguageServer.cs +++ b/src/Server/LanguageServer.cs @@ -328,8 +328,12 @@ private IDisposable RegisterHandlers(LspHandlerDescriptorDisposable handlerDispo using (var scope = _serviceProvider.CreateScope()) { var registrations = handlerDisposable.Descriptors - .Select(x => x.Registration) - .Where(x => x != null) + .Where(d => d.AllowsDynamicRegistration) + .Select(d => new Registration() { + Id = d.Id.ToString(), + Method = d.Method, + RegisterOptions = d.RegistrationOptions + }) .ToArray(); // Fire and forget diff --git a/src/Server/Matchers/ExecuteCommandMatcher.cs b/src/Server/Matchers/ExecuteCommandMatcher.cs index 4c1caa60b..3d6171b1b 100644 --- a/src/Server/Matchers/ExecuteCommandMatcher.cs +++ b/src/Server/Matchers/ExecuteCommandMatcher.cs @@ -28,7 +28,7 @@ public IEnumerable FindHandler(object parameters, IEnumer _logger.LogTrace("Registration options {OptionsName}", executeCommandParams.GetType().FullName); foreach (var descriptor in descriptors) { - if (descriptor.RegisterOptions is ExecuteCommandRegistrationOptions registrationOptions && registrationOptions.Commands.Any(x => x == executeCommandParams.Command)) + if (descriptor.RegistrationOptions is ExecuteCommandRegistrationOptions registrationOptions && registrationOptions.Commands.Any(x => x == executeCommandParams.Command)) { _logger.LogTrace("Checking handler {Method}:{Handler}", executeCommandParams.Command, diff --git a/src/Server/Matchers/TextDocumentMatcher.cs b/src/Server/Matchers/TextDocumentMatcher.cs index 55d0da682..da808b82a 100644 --- a/src/Server/Matchers/TextDocumentMatcher.cs +++ b/src/Server/Matchers/TextDocumentMatcher.cs @@ -75,7 +75,7 @@ private IEnumerable GetHandler(IEnumerable supports) } } - public bool AllowsDynamicRegistration(ILspHandlerDescriptor descriptor) - { - if (descriptor.HasCapability && _supports.TryGetValue(descriptor.CapabilityType, out var capability)) - { - if (capability is DynamicCapability dc) - return dc.DynamicRegistration; - } - return false; - } - public bool AllowsDynamicRegistration(Type capabilityType) { if (_supports.TryGetValue(capabilityType, out var capability)) diff --git a/test/Lsp.Tests/Matchers/ExecuteCommandHandlerMatcherTests.cs b/test/Lsp.Tests/Matchers/ExecuteCommandHandlerMatcherTests.cs index 805a81e13..348ccb48a 100644 --- a/test/Lsp.Tests/Matchers/ExecuteCommandHandlerMatcherTests.cs +++ b/test/Lsp.Tests/Matchers/ExecuteCommandHandlerMatcherTests.cs @@ -72,9 +72,7 @@ public void Should_Return_Handler_Descriptor() typeof(ExecuteCommandParams), typeof(ExecuteCommandRegistrationOptions), registrationsOptions, - new Registration() { - RegisterOptions = registrationsOptions - }, + true, typeof(ExecuteCommandCapability), () => { }) }); diff --git a/test/Lsp.Tests/Matchers/ResolveCommandMatcherTests.cs b/test/Lsp.Tests/Matchers/ResolveCommandMatcherTests.cs index 3fcdc1987..178bd71fa 100644 --- a/test/Lsp.Tests/Matchers/ResolveCommandMatcherTests.cs +++ b/test/Lsp.Tests/Matchers/ResolveCommandMatcherTests.cs @@ -67,7 +67,7 @@ public void Should_Not_Throw_Given_Another_Descriptor() typeof(CodeLensParams), null, null, - null, + false, null, () => { }); var handlerMatcher = new ResolveCommandPipeline( @@ -101,7 +101,7 @@ public void Should_Return_CodeLensResolve_Descriptor() typeof(CodeLens), null, null, - null, + false, null, () => { }), new HandlerDescriptor(DocumentNames.CodeLensResolve, @@ -111,7 +111,7 @@ public void Should_Return_CodeLensResolve_Descriptor() typeof(CodeLens), null, null, - null, + false, null, () => { }), }) @@ -140,7 +140,7 @@ public void Should_Handle_Null_Data() typeof(CompletionItem), null, null, - null, + false, null, () => { }), }) @@ -171,7 +171,7 @@ public void Should_Handle_Simple_Json_Data() typeof(CompletionItem), null, null, - null, + false, null, () => { }), }) @@ -204,7 +204,7 @@ public void Should_Return_CompletionResolve_Descriptor() typeof(CompletionItem), null, null, - null, + false, null, () => { }), new HandlerDescriptor(DocumentNames.CompletionResolve, @@ -214,7 +214,7 @@ public void Should_Return_CompletionResolve_Descriptor() typeof(CompletionItem), null, null, - null, + false, null, () => { }), }) @@ -254,7 +254,7 @@ public void Should_Deal_WithHandlers_That_Not_Also_Resolvers() typeof(CompletionItem), null, null, - null, + false, null, () => { }), new HandlerDescriptor(DocumentNames.CompletionResolve, @@ -264,7 +264,7 @@ public void Should_Deal_WithHandlers_That_Not_Also_Resolvers() typeof(CompletionItem), null, null, - null, + false, null, () => { }), }) @@ -300,7 +300,7 @@ public void Should_Deal_WithHandlers_That_Not_Also_Resolvers2() typeof(CompletionItem), null, null, - null, + false, null, () => { }), new HandlerDescriptor(DocumentNames.CompletionResolve, @@ -310,7 +310,7 @@ public void Should_Deal_WithHandlers_That_Not_Also_Resolvers2() typeof(CompletionItem), null, null, - null, + false, null, () => { }), }) @@ -338,7 +338,7 @@ public async Task Should_Update_CompletionItems_With_HandlerType() typeof(CompletionParams), null, null, - null, + false, null, () => { }); var handlerMatcher = new ResolveCommandPipeline( @@ -381,7 +381,7 @@ public async Task Should_Update_CodeLensContainer_With_HandlerType() typeof(CodeLensParams), null, null, - null, + false, null, () => { }); var handlerMatcher = new ResolveCommandPipeline( @@ -424,7 +424,7 @@ public async Task Should_Update_CodeLens_Removing_HandlerType() typeof(CodeLens), null, null, - null, + false, null, () => { }); var handlerMatcher = new ResolveCommandPipeline( From 60e4f856ae0de1d7dfd324b7317de1cab232691f Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Fri, 19 Jul 2019 18:40:00 -0400 Subject: [PATCH 3/3] Updated extension ts --- vscode-testextension/src/extension.ts | 62 +++++++++++++++++---------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/vscode-testextension/src/extension.ts b/vscode-testextension/src/extension.ts index f0650a9bf..a29f2c5c6 100644 --- a/vscode-testextension/src/extension.ts +++ b/vscode-testextension/src/extension.ts @@ -3,52 +3,70 @@ * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ // tslint:disable -'use strict'; +"use strict"; -import * as path from 'path'; +import * as path from "path"; -import { workspace, Disposable, ExtensionContext } from 'vscode'; -import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind, InitializeParams } from 'vscode-languageclient'; -import { Trace } from 'vscode-jsonrpc'; +import { workspace, Disposable, ExtensionContext } from "vscode"; +import { + LanguageClient, + LanguageClientOptions, + SettingMonitor, + ServerOptions, + TransportKind, + InitializeParams +} from "vscode-languageclient"; +import { Trace } from "vscode-jsonrpc"; export function activate(context: ExtensionContext) { - // The server is implemented in node // let serverExe = 'dotnet'; - let serverExe = 'C:/Users/mb/src/gh/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio.Driver/win7-x64/OmniSharp.exe'; - // let serverExe = context.asAbsolutePath('D:/Development/Omnisharp/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio/win7-x64/OmniSharp.exe'); + + // let serverExe = 'D:\\Development\\Omnisharp\\csharp-language-server-protocol\\sample\\SampleServer\\bin\\Debug\\netcoreapp2.0\\win7-x64\\SampleServer.exe'; + let serverExe = + "D:/Development/Omnisharp/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio.Driver/win7-x64/OmniSharp.exe"; // The debug options for the server - // let debugOptions = { execArgv: ['-lsp', '-d' }; + // let debugOptions = { execArgv: ['-lsp', '-d' };5 // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used let serverOptions: ServerOptions = { - run: { command: serverExe, args: ['-lsp'] }, - debug: { command: serverExe, args: ['-lsp'] } - } + // run: { command: serverExe, args: ['-lsp', '-d'] }, + run: { command: serverExe, args: ["-lsp"] }, + // debug: { command: serverExe, args: ['-lsp', '-d'] } + debug: { command: serverExe, args: ["-lsp"] } + }; // Options to control the language client let clientOptions: LanguageClientOptions = { // Register the server for plain text documents documentSelector: [ { - pattern: '**/*.cs', - }, { - pattern: '**/*.cake', + pattern: "**/*.cs" + }, + { + pattern: "**/*.csx" }, + { + pattern: "**/*.cake" + } ], synchronize: { // Synchronize the setting section 'languageServerExample' to the server - configurationSection: 'languageServerExample', - fileEvents: workspace.createFileSystemWatcher('**/*.cs') + configurationSection: "languageServerExample", + fileEvents: workspace.createFileSystemWatcher("**/*.cs") } - - } + }; // Create the language client and start the client. - const client = new LanguageClient('languageServerExample', 'Language Server Example', serverOptions, clientOptions); - client.trace = Trace.Verbose; - client.clientOptions.errorHandler + const client = new LanguageClient( + "languageServerExample", + "Language Server Example", + serverOptions, + clientOptions + ); + // client.trace = Trace.Verbose; + client.clientOptions.errorHandler; let disposable = client.start(); // Push the disposable to the context's subscriptions so that the