internal LanguageServer(Stream input, IOutputHandler output, LspReciever reciever, IRequestProcessIdentifier requestProcessIdentifier, ILoggerFactory loggerFactory)
        {
            // TODO: This might not be the best
            loggerFactory.AddProvider(new LanguageServerLoggerProvider(this));

            _reciever                 = reciever;
            _loggerFactory            = loggerFactory;
            _handlerMactherCollection = new HandlerMatcherCollection
            {
                new TextDocumentMatcher(_loggerFactory.CreateLogger <TextDocumentMatcher>()),
                new ExecuteCommandMatcher(_loggerFactory.CreateLogger <ExecuteCommandMatcher>())
            };

            _requestRouter  = new LspRequestRouter(_collection, loggerFactory, _handlerMactherCollection);
            _responseRouter = new ResponseRouter(output);
            _connection     = new Connection(input, output, reciever, requestProcessIdentifier, _requestRouter, _responseRouter, loggerFactory);

            _exitHandler = new ExitHandler(_shutdownHandler);

            _disposable.Add(
                AddHandlers(this, _shutdownHandler, _exitHandler, new CancelRequestHandler(_requestRouter))
                );
        }
Exemple #2
0
        internal LanguageServer(
            Stream input,
            Stream output,
            LspReciever reciever,
            IRequestProcessIdentifier requestProcessIdentifier,
            ILoggerFactory loggerFactory,
            Serializer serializer,
            bool addDefaultLoggingProvider)
        {
            var outputHandler = new OutputHandler(output, serializer);

            if (addDefaultLoggingProvider)
            {
                loggerFactory.AddProvider(new LanguageServerLoggerProvider(this));
            }

            _reciever                 = reciever;
            _loggerFactory            = loggerFactory;
            _serializer               = serializer;
            _handlerMactherCollection = new HandlerMatcherCollection
            {
                new TextDocumentMatcher(_loggerFactory.CreateLogger <TextDocumentMatcher>(), _collection.TextDocumentSyncHandlers),
                new ExecuteCommandMatcher(_loggerFactory.CreateLogger <ExecuteCommandMatcher>()),
                new ResolveCommandMatcher(_loggerFactory.CreateLogger <ResolveCommandMatcher>()),
                new DocumentLinkCommandMatcher(_loggerFactory.CreateLogger <DocumentLinkCommandMatcher>())
            };

            _requestRouter  = new LspRequestRouter(_collection, loggerFactory, _handlerMactherCollection, _serializer);
            _responseRouter = new ResponseRouter(outputHandler, _serializer);
            _connection     = new Connection(input, outputHandler, reciever, requestProcessIdentifier, _requestRouter, _responseRouter, loggerFactory, serializer);

            _exitHandler = new ExitHandler(_shutdownHandler);

            _disposable.Add(
                AddHandlers(this, _shutdownHandler, _exitHandler, new CancelRequestHandler(_requestRouter))
                );
        }