IDisposable IHandlersManager.Add(string method, JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options) => Add(method, handlerFactory(_resolverContext), options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .AddHandler(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions options) => AddHandler(method, handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .AddHandler(IJsonRpcHandler handler, JsonRpcHandlerOptions options) => AddHandler(handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnJsonNotification( string method, Action <JToken, CancellationToken> handler, JsonRpcHandlerOptions options ) => OnJsonNotification(method, handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnNotification <TParams>( string method, Func <TParams, CancellationToken, Task> handler, JsonRpcHandlerOptions options ) => OnNotification(method, handler, options);
public LspHandlerDescriptorDisposable Add(IJsonRpcHandler handler, JsonRpcHandlerOptions options) { var(descriptors, compositeDisposable) = AddHandler(handler, options); return(new LspHandlerDescriptorDisposable(descriptors, compositeDisposable)); }
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnRequest <TResponse>( string method, Func <CancellationToken, Task <TResponse> > handler, JsonRpcHandlerOptions options ) => OnRequest(method, handler, options);
public ILanguageServerRegistry AddHandler(string method, Func <IServiceProvider, IJsonRpcHandler> handlerFunc, JsonRpcHandlerOptions options = null) => this;
public ILanguageServerRegistry AddHandler <T>(Func <IServiceProvider, T> handlerFunc, JsonRpcHandlerOptions options = null) where T : IJsonRpcHandler { var sp = new ServiceCollection() .AddSingleton( Substitute .For <Func <CodeActionParams, CancellationToken, Task <CommandOrCodeActionContainer> > >() ) .AddSingleton(Substitute.For <IServerWorkDoneManager>()) .AddSingleton(Substitute.For <Action <CodeActionCapability> >()) .AddSingleton(new CodeActionRegistrationOptions()) .BuildServiceProvider(); Handlers.Add(handlerFunc(sp)); return(this); }
public ILanguageServerRegistry AddHandler(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions options = null) { Handlers.Add(handler); return(this); }
public ILanguageServerRegistry AddHandler <T>(JsonRpcHandlerOptions options = null) where T : IJsonRpcHandler => this;
public LspHandlerDescriptorDisposable Add(string method, Func <IServiceProvider, IJsonRpcHandler> handlerFunc, JsonRpcHandlerOptions options) { var handler = handlerFunc(_serviceProvider); var descriptor = GetDescriptor(method, handler.GetType(), handler, options); _handlers.Add(descriptor); var cd = new CompositeDisposable(); if (descriptor.Handler is ITextDocumentIdentifier textDocumentIdentifier) { cd.Add(_textDocumentIdentifiers.Add(textDocumentIdentifier)); } return(new LspHandlerDescriptorDisposable(new[] { descriptor }, cd)); }
public JsonRpcHandlerInstanceDescription(string method, IJsonRpcHandler handlerInstance, JsonRpcHandlerOptions options) : base(options) { Method = method; HandlerInstance = handlerInstance; }
IDisposable IHandlersManager.Add(string method, Type handlerType, JsonRpcHandlerOptions options) => Add(method, _resolverContext.Resolve(handlerType) as IJsonRpcHandler, options);
IDisposable IHandlersManager.Add(string method, JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options) => Add(method, handlerFactory(_serviceProvider), options);
public LspHandlerDescriptorDisposable Add(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions options) { var(descriptors, cd) = AddHandler(method, handler, options); return(new LspHandlerDescriptorDisposable(descriptors, cd)); }
IDisposable IHandlersManager.Add(string method, Type handlerType, JsonRpcHandlerOptions options) => Add(method, ActivatorUtilities.CreateInstance(_serviceProvider, handlerType) as IJsonRpcHandler, options);
public LspHandlerDescriptorDisposable Add(JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options) { var(descriptors, compositeDisposable) = AddHandler(handlerFactory(_serviceProvider), null); return(new LspHandlerDescriptorDisposable(descriptors, compositeDisposable)); }
internal static RequestHandlers ConfigureCompositionHost(ILanguageServer server, CompositionHost compositionHost) { var projectSystems = compositionHost.GetExports <IProjectSystem>(); var documentSelectors = projectSystems .GroupBy(x => x.Language) .Select(x => ( language: x.Key, selector: new DocumentSelector(x .SelectMany(z => z.Extensions) .Distinct() .SelectMany(z => { if (x.Key == LanguageNames.CSharp && z == ".cs") { return(new[] { new DocumentFilter() { Pattern = $"**/*{z}" }, new DocumentFilter() { Scheme = "csharp" } }); } return(new[] { new DocumentFilter() { Pattern = $"**/*{z}" }, }); }) ) )) .ToArray(); var logger = compositionHost.GetExport <ILoggerFactory>().CreateLogger <LanguageServerHost>(); logger.LogTrace( "Configured Document Selectors {@DocumentSelectors}", documentSelectors.Select(x => new { x.language, x.selector }) ); var omnisharpRequestHandlers = compositionHost.GetExports <Lazy <IRequestHandler, OmniSharpRequestHandlerMetadata> >(); // TODO: Get these with metadata so we can attach languages // This will then let us build up a better document filter, and add handles foreach type of handler // This will mean that we will have a strategy to create handlers from the interface type var handlers = new RequestHandlers(omnisharpRequestHandlers, documentSelectors); logger.LogTrace("--- Handler Definitions ---"); foreach (var handlerCollection in handlers) { foreach (var handler in handlerCollection) { logger.LogTrace( "Handler: {Language}:{DocumentSelector}:{Handler}", handlerCollection.Language, handlerCollection.DocumentSelector.ToString(), handler.GetType().FullName ); } } // the goal here is add interoperability between omnisharp and LSP // This way an existing client (say vscode) that is using the custom omnisharp protocol can migrate to the new one // and not loose any functionality. server.Register(r => { var defaultOptions = new JsonRpcHandlerOptions() { RequestProcessType = RequestProcessType.Parallel }; var interop = InitializeInterop(compositionHost); foreach (var osHandler in interop) { var method = $"o#/{osHandler.Key.Trim('/').ToLowerInvariant()}"; r.OnJsonRequest(method, CreateInteropHandler(osHandler.Value), defaultOptions); logger.LogTrace("O# Handler: {Method}", method); }
public LspHandlerDescriptorDisposable Add(string method, JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options) { var(descriptors, cd) = AddHandler(method, handlerFactory(_serviceProvider), options); return(new LspHandlerDescriptorDisposable(descriptors, cd)); }
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnRequest <TParams>( string method, Func <TParams, Task> handler, JsonRpcHandlerOptions options ) => OnRequest(method, handler, options);
public LspHandlerDescriptorDisposable Add(string method, Type handlerType, JsonRpcHandlerOptions options) { var(descriptors, cd) = AddHandler(method, ActivatorUtilities.CreateInstance(_serviceProvider, handlerType) as IJsonRpcHandler, options); return(new LspHandlerDescriptorDisposable(descriptors, cd)); }
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnNotification <TParams>( string method, Action <TParams> handler, JsonRpcHandlerOptions options ) => OnNotification(method, handler, options);
IDisposable IHandlersManager.Add(IJsonRpcHandler handler, JsonRpcHandlerOptions options) => Add(handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnNotification(string method, Func <Task> handler, JsonRpcHandlerOptions options) => OnNotification(method, handler, options);
IDisposable IHandlersManager.Add(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions options) => Add(method, handler, options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .AddHandler(JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions options) => AddHandler(handlerFunc, options);
IDisposable IHandlersManager.Add(JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options) => Add(handlerFactory(_serviceProvider), options);
IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .AddHandler <TTHandler>(JsonRpcHandlerOptions options) => AddHandler <TTHandler>(options);
IDisposable IHandlersManager.Add(JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options) => Add(handlerFactory(_resolverContext), options);