public IDisposable Register(Action <ILanguageServerRegistry> registryAction)
        {
            var manager = new CompositeHandlersManager(_collection);

            registryAction(new LangaugeServerRegistry(_serviceProvider, manager, _textDocumentIdentifiers));
            return(RegisterHandlers(manager.GetDisposable()));
        }
示例#2
0
        public void Should_Add_Named_Handler_Type_To_Parent()
        {
            var parent = Substitute.For <IHandlersManager>();

            parent.Add(Arg.Any <string>(), Arg.Any <Type>(), Arg.Any <JsonRpcHandlerOptions>()).Returns(Disposable.Empty);

            var manager = new CompositeHandlersManager(parent);

            manager.Add("mymethod", Substitute.For <Type>(), new JsonRpcHandlerOptions());

            parent.Received(0).Add(Arg.Any <Type>(), Arg.Any <JsonRpcHandlerOptions>());
            parent.Received(1).Add("mymethod", Arg.Any <Type>(), Arg.Any <JsonRpcHandlerOptions>());
            manager.GetDisposable().Count.Should().Be(1);
        }
示例#3
0
        public IDisposable Register(Action <ILanguageServerRegistry> registryAction)
        {
            var manager = new CompositeHandlersManager(_handlersManager.Value);

            registryAction(new LangaugeServerRegistry(ResolverContext, manager, _textDocumentIdentifiers));

            var result = manager.GetDisposable();

            if (_instancesHasStarted.Started)
            {
                LanguageServerHelpers.InitHandlers(ResolverContext.Resolve <ILanguageServer>(), result, _supportedCapabilities.Value);
            }

            return(LanguageServerHelpers.RegisterHandlers(_hasStarted, Client, _workDoneManager.Value, _supportedCapabilities.Value, result));
        }
示例#4
0
        public IDisposable Register(Action <ILanguageClientRegistry> registryAction)
        {
            var manager = new CompositeHandlersManager(_handlersManager.Value);

            registryAction(new LangaugeClientRegistry(ResolverContext, manager, _textDocumentIdentifiers));
            var result = manager.GetDisposable();

            if (_instanceHasStarted.Started)
            {
                if (_languageClient == null)
                {
                    throw new NotSupportedException("Language client has not yet started... you shouldn't be here.");
                }
                LanguageClientHelpers.InitHandlers(_languageClient, result);
            }

            return(result);
        }