IDisposable IHandlersManager.Add(string method, JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options) => Add(method, handlerFactory(_resolverContext), options);
示例#2
0
 IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .AddHandler(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions options) =>
 AddHandler(method, handler, options);
示例#3
0
 IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .AddHandler(IJsonRpcHandler handler, JsonRpcHandlerOptions options) =>
 AddHandler(handler, options);
示例#4
0
 IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnJsonNotification(
     string method, Action <JToken, CancellationToken> handler, JsonRpcHandlerOptions options
     ) => OnJsonNotification(method, handler, options);
示例#5
0
 IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnNotification <TParams>(
     string method, Func <TParams, CancellationToken, Task> handler, JsonRpcHandlerOptions options
     ) => OnNotification(method, handler, options);
示例#6
0
 public LspHandlerDescriptorDisposable Add(IJsonRpcHandler handler, JsonRpcHandlerOptions options)
 {
     var(descriptors, compositeDisposable) = AddHandler(handler, options);
     return(new LspHandlerDescriptorDisposable(descriptors, compositeDisposable));
 }
示例#7
0
 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));
        }
示例#13
0
 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);
示例#15
0
 IDisposable IHandlersManager.Add(string method, JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options) =>
 Add(method, handlerFactory(_serviceProvider), options);
示例#16
0
 public LspHandlerDescriptorDisposable Add(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions options)
 {
     var(descriptors, cd) = AddHandler(method, handler, options);
     return(new LspHandlerDescriptorDisposable(descriptors, cd));
 }
示例#17
0
 IDisposable IHandlersManager.Add(string method, Type handlerType, JsonRpcHandlerOptions options) =>
 Add(method, ActivatorUtilities.CreateInstance(_serviceProvider, handlerType) as IJsonRpcHandler, options);
示例#18
0
 public LspHandlerDescriptorDisposable Add(JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options)
 {
     var(descriptors, compositeDisposable) = AddHandler(handlerFactory(_serviceProvider), null);
     return(new LspHandlerDescriptorDisposable(descriptors, compositeDisposable));
 }
示例#19
0
        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);
                }
示例#20
0
 public LspHandlerDescriptorDisposable Add(string method, JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options)
 {
     var(descriptors, cd) = AddHandler(method, handlerFactory(_serviceProvider), options);
     return(new LspHandlerDescriptorDisposable(descriptors, cd));
 }
示例#21
0
 IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnRequest <TParams>(
     string method, Func <TParams, Task> handler, JsonRpcHandlerOptions options
     ) => OnRequest(method, handler, options);
示例#22
0
 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));
 }
示例#23
0
 IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnNotification <TParams>(
     string method, Action <TParams> handler, JsonRpcHandlerOptions options
     ) => OnNotification(method, handler, options);
示例#24
0
 IDisposable IHandlersManager.Add(IJsonRpcHandler handler, JsonRpcHandlerOptions options) => Add(handler, options);
示例#25
0
 IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .OnNotification(string method, Func <Task> handler, JsonRpcHandlerOptions options) =>
 OnNotification(method, handler, options);
示例#26
0
 IDisposable IHandlersManager.Add(string method, IJsonRpcHandler handler, JsonRpcHandlerOptions options) => Add(method, handler, options);
示例#27
0
 IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .AddHandler(JsonRpcHandlerFactory handlerFunc, JsonRpcHandlerOptions options) =>
 AddHandler(handlerFunc, options);
示例#28
0
 IDisposable IHandlersManager.Add(JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options) => Add(handlerFactory(_serviceProvider), options);
示例#29
0
 IDebugAdapterClientRegistry IJsonRpcHandlerRegistry <IDebugAdapterClientRegistry> .AddHandler <TTHandler>(JsonRpcHandlerOptions options) => AddHandler <TTHandler>(options);
 IDisposable IHandlersManager.Add(JsonRpcHandlerFactory handlerFactory, JsonRpcHandlerOptions options) => Add(handlerFactory(_resolverContext), options);