コード例 #1
0
 public DefaultLanguageServerFacade(
     IResponseRouter requestRouter,
     IResolverContext resolverContext,
     IProgressManager progressManager,
     ILanguageProtocolSettings languageProtocolSettings,
     Lazy <ITextDocumentLanguageServer> textDocument,
     Lazy <IClientLanguageServer> client,
     Lazy <IGeneralLanguageServer> general,
     Lazy <IWindowLanguageServer> window,
     Lazy <IWorkspaceLanguageServer> workspace,
     Lazy <IHandlersManager> handlersManager,
     Lazy <IServerWorkDoneManager> workDoneManager,
     Lazy <ISupportedCapabilities> supportedCapabilities,
     TextDocumentIdentifiers textDocumentIdentifiers,
     IInsanceHasStarted instancesHasStarted
     ) : base(requestRouter, resolverContext, progressManager, languageProtocolSettings)
 {
     _textDocument            = textDocument;
     _client                  = client;
     _general                 = general;
     _window                  = window;
     _workspace               = workspace;
     _handlersManager         = handlersManager;
     _workDoneManager         = workDoneManager;
     _supportedCapabilities   = supportedCapabilities;
     _textDocumentIdentifiers = textDocumentIdentifiers;
     _instancesHasStarted     = instancesHasStarted;
     _hasStarted              = new AsyncSubject <System.Reactive.Unit>();
 }
コード例 #2
0
        internal LanguageServer(
            Connection connection,
            IResponseRouter responseRouter,
            IOptions <LanguageServerOptions> options,
            ILanguageServerConfiguration configuration,
            ServerInfo serverInfo,
            ILspServerReceiver receiver,
            ISerializer serializer,
            IServiceProvider serviceProvider,
            ISupportedCapabilities supportedCapabilities,
            TextDocumentIdentifiers textDocumentIdentifiers,
            IEnumerable <OnLanguageServerInitializeDelegate> initializeDelegates,
            IEnumerable <OnLanguageServerInitializedDelegate> initializedDelegates,
            IEnumerable <OnLanguageServerStartedDelegate> startedDelegates,
            IEnumerable <IOnLanguageServerStarted> startedHandlers,
            IServerWorkDoneManager serverWorkDoneManager,
            ITextDocumentLanguageServer textDocumentLanguageServer,
            IClientLanguageServer clientLanguageServer,
            IGeneralLanguageServer generalLanguageServer,
            IWindowLanguageServer windowLanguageServer,
            IWorkspaceLanguageServer workspaceLanguageServer,
            LanguageProtocolSettingsBag languageProtocolSettingsBag,
            SharedHandlerCollection handlerCollection,
            IProgressManager progressManager,
            ILanguageServerWorkspaceFolderManager workspaceFolderManager, IEnumerable <IOnLanguageServerInitialize> initializeHandlers,
            IEnumerable <IOnLanguageServerInitialized> initializedHandlers
            ) : base(handlerCollection, responseRouter)
        {
            Configuration = configuration;

            _connection              = connection;
            _serverInfo              = serverInfo;
            _serverReceiver          = receiver;
            _serializer              = serializer;
            _supportedCapabilities   = supportedCapabilities;
            _textDocumentIdentifiers = textDocumentIdentifiers;
            _initializeDelegates     = initializeDelegates;
            _initializedDelegates    = initializedDelegates;
            _startedDelegates        = startedDelegates;
            _startedHandlers         = startedHandlers;
            WorkDoneManager          = serverWorkDoneManager;
            _settingsBag             = languageProtocolSettingsBag;
            Services    = serviceProvider;
            _collection = handlerCollection;

            // We need to at least create Window here in case any handler does logging in their constructor
            TextDocument           = textDocumentLanguageServer;
            Client                 = clientLanguageServer;
            General                = generalLanguageServer;
            Window                 = windowLanguageServer;
            Workspace              = workspaceLanguageServer;
            ProgressManager        = progressManager;
            WorkspaceFolderManager = workspaceFolderManager;
            _initializeHandlers    = initializeHandlers;
            _initializedHandlers   = initializedHandlers;
            _concurrency           = options.Value.Concurrency;

            _disposable.Add(_collection.Add(this));
        }
コード例 #3
0
        internal LanguageServer(
            Connection connection,
            IResponseRouter responseRouter,
            IOptions <LanguageServerOptions> options,
            ILanguageServerConfiguration configuration,
            ServerInfo serverInfo,
            ILspServerReceiver receiver,
            ISerializer serializer,
            IResolverContext resolverContext,
            ISupportedCapabilities supportedCapabilities,
            TextDocumentIdentifiers textDocumentIdentifiers,
            IEnumerable <OnLanguageServerInitializeDelegate> initializeDelegates,
            IEnumerable <OnLanguageServerInitializedDelegate> initializedDelegates,
            IEnumerable <OnLanguageServerStartedDelegate> startedDelegates,
            IEnumerable <IOnLanguageServerStarted> startedHandlers,
            IServerWorkDoneManager serverWorkDoneManager,
            ITextDocumentLanguageServer textDocumentLanguageServer,
            IClientLanguageServer clientLanguageServer,
            IGeneralLanguageServer generalLanguageServer,
            IWindowLanguageServer windowLanguageServer,
            IWorkspaceLanguageServer workspaceLanguageServer,
            LanguageProtocolSettingsBag languageProtocolSettingsBag,
            SharedHandlerCollection handlerCollection,
            IProgressManager progressManager,
            ILanguageServerWorkspaceFolderManager workspaceFolderManager, IEnumerable <IOnLanguageServerInitialize> initializeHandlers,
            IEnumerable <IOnLanguageServerInitialized> initializedHandlers,
            IEnumerable <IRegistrationOptionsConverter> registrationOptionsConverters,
            InstanceHasStarted instanceHasStarted
            ) : base(handlerCollection, responseRouter)
        {
            Configuration = configuration;

            _connection              = connection;
            _serverInfo              = serverInfo;
            _serverReceiver          = receiver;
            _serializer              = serializer;
            _supportedCapabilities   = supportedCapabilities;
            _textDocumentIdentifiers = textDocumentIdentifiers;
            _initializeDelegates     = initializeDelegates;
            _initializedDelegates    = initializedDelegates;
            _startedDelegates        = startedDelegates;
            _startedHandlers         = startedHandlers;
            WorkDoneManager          = serverWorkDoneManager;
            _settingsBag             = languageProtocolSettingsBag;
            Services    = _resolverContext = resolverContext;
            _collection = handlerCollection;

            // We need to at least create Window here in case any handler does logging in their constructor
            TextDocument                   = textDocumentLanguageServer;
            Client                         = clientLanguageServer;
            General                        = generalLanguageServer;
            Window                         = windowLanguageServer;
            Workspace                      = workspaceLanguageServer;
            ProgressManager                = progressManager;
            WorkspaceFolderManager         = workspaceFolderManager;
            _initializeHandlers            = initializeHandlers;
            _initializedHandlers           = initializedHandlers;
            _registrationOptionsConverters = registrationOptionsConverters;
            _instanceHasStarted            = instanceHasStarted;
            _concurrency                   = options.Value.Concurrency;

            _capabilityTypes = options
                               .Value.Assemblies
                               .SelectMany(z => z.ExportedTypes)
                               .Where(z => z.IsClass && !z.IsAbstract)
                               .Where(z => typeof(ICapability).IsAssignableFrom(z))
                               .Where(z => z.GetCustomAttributes <CapabilityKeyAttribute>().Any())
                               .ToLookup(z => string.Join(".", z.GetCustomAttribute <CapabilityKeyAttribute>().Keys));

            _disposable.Add(_collection.Add(this));
        }
コード例 #4
0
 public HandlerCollection(ISupportedCapabilities supportedCapabilities,
                          TextDocumentIdentifiers textDocumentIdentifiers)
 {
     _supportedCapabilities   = supportedCapabilities;
     _textDocumentIdentifiers = textDocumentIdentifiers;
 }
 public LangaugeServerRegistry(IServiceProvider serviceProvider, CompositeHandlersManager handlersManager, TextDocumentIdentifiers textDocumentIdentifiers) : base(
         serviceProvider, handlersManager, textDocumentIdentifiers
         )
 {
 }
コード例 #6
0
        internal LanguageServer(LanguageServerOptions options) : base(options)
        {
            var services = options.Services;
            var configurationProvider = new DidChangeConfigurationProvider(this, options.ConfigurationBuilderAction);

            services.AddSingleton <IJsonRpcHandler>(configurationProvider);
            options.RequestProcessIdentifier ??= (options.SupportsContentModified
                ? new RequestProcessIdentifier(RequestProcessType.Parallel)
                : new RequestProcessIdentifier(RequestProcessType.Serial));

            services.AddSingleton <IConfiguration>(configurationProvider);
            services.AddSingleton(Configuration = configurationProvider);

            services.AddLogging(builder => options.LoggingBuilderAction(builder));
            services.AddSingleton <IOptionsMonitor <LoggerFilterOptions>, LanguageServerLoggerFilterOptions>();

            _serverInfo              = options.ServerInfo;
            _serverReceiver          = options.Receiver;
            _serializer              = options.Serializer;
            _supportedCapabilities   = new SupportedCapabilities();
            _textDocumentIdentifiers = new TextDocumentIdentifiers();
            var collection = new SharedHandlerCollection(_supportedCapabilities, _textDocumentIdentifiers);

            services.AddSingleton <IHandlersManager>(collection);
            _collection           = collection;
            _initializeDelegates  = options.InitializeDelegates;
            _initializedDelegates = options.InitializedDelegates;
            _startedDelegates     = options.StartedDelegates;

            services.AddSingleton <IOutputHandler>(_ => new OutputHandler(
                                                       options.Output,
                                                       options.Serializer,
                                                       options.Receiver.ShouldFilterOutput,
                                                       _.GetService <ILogger <OutputHandler> >())
                                                   );
            services.AddSingleton(_collection);
            services.AddSingleton(_textDocumentIdentifiers);
            services.AddSingleton(_serializer);
            services.AddSingleton <OmniSharp.Extensions.JsonRpc.ISerializer>(_serializer);
            services.AddSingleton(options.RequestProcessIdentifier);
            services.AddSingleton <OmniSharp.Extensions.JsonRpc.IReceiver>(options.Receiver);
            services.AddSingleton <ILspServerReceiver>(options.Receiver);

            services.AddTransient <IHandlerMatcher, TextDocumentMatcher>();
            services.AddSingleton <ILanguageServer>(this);
            services.AddTransient <IHandlerMatcher, ExecuteCommandMatcher>();
            services.AddTransient <IHandlerMatcher, ResolveCommandMatcher>();
            services.AddSingleton <LspRequestRouter>();
            services.AddSingleton <IRequestRouter <ILspHandlerDescriptor> >(_ => _.GetRequiredService <LspRequestRouter>());
            services.AddSingleton <IRequestRouter <IHandlerDescriptor> >(_ => _.GetRequiredService <LspRequestRouter>());
            services.AddSingleton <IResponseRouter, ResponseRouter>();
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(ResolveCommandPipeline <,>));

            services.AddSingleton <IProgressManager, ProgressManager>();
            services.AddSingleton <IJsonRpcHandler>(_ => _.GetRequiredService <IProgressManager>() as IJsonRpcHandler);
            services.AddSingleton <IServerWorkDoneManager, ServerWorkDoneManager>();
            services.AddSingleton <IJsonRpcHandler>(_ => _.GetRequiredService <IServerWorkDoneManager>() as IJsonRpcHandler);

            EnsureAllHandlersAreRegistered();

            var serviceProvider = services.BuildServiceProvider();

            _disposable.Add(serviceProvider);
            _serviceProvider = serviceProvider;
            collection.SetServiceProvider(_serviceProvider);

            var requestRouter = _serviceProvider.GetRequiredService <IRequestRouter <ILspHandlerDescriptor> >();

            _responseRouter        = _serviceProvider.GetRequiredService <IResponseRouter>();
            ProgressManager        = _serviceProvider.GetRequiredService <IProgressManager>();
            _serverWorkDoneManager = _serviceProvider.GetRequiredService <IServerWorkDoneManager>();
            _connection            = new Connection(
                options.Input,
                _serviceProvider.GetRequiredService <IOutputHandler>(),
                options.Receiver,
                options.RequestProcessIdentifier,
                _serviceProvider.GetRequiredService <IRequestRouter <IHandlerDescriptor> >(),
                _responseRouter,
                _serviceProvider.GetRequiredService <ILoggerFactory>(),
                options.OnUnhandledException ?? (e => { ForcefulShutdown(); }),
                options.CreateResponseException,
                options.MaximumRequestTimeout,
                options.SupportsContentModified,
                options.Concurrency
                );

            // We need to at least create Window here in case any handler does loggin in their constructor
            TextDocument = new TextDocumentLanguageServer(this, _serviceProvider);
            Client       = new ClientLanguageServer(this, _serviceProvider);
            General      = new GeneralLanguageServer(this, _serviceProvider);
            Window       = new WindowLanguageServer(this, _serviceProvider);
            Workspace    = new WorkspaceLanguageServer(this, _serviceProvider);

            _disposable.Add(_collection.Add(this));

            {
                var serviceHandlers    = _serviceProvider.GetServices <IJsonRpcHandler>().ToArray();
                var serviceIdentifiers = _serviceProvider.GetServices <ITextDocumentIdentifier>().ToArray();
                _disposable.Add(_textDocumentIdentifiers.Add(serviceIdentifiers));
                _disposable.Add(_collection.Add(serviceHandlers));
                options.AddLinks(_collection);
            }
        }
 public LangaugeServerRegistry(IResolverContext resolverContext, CompositeHandlersManager handlersManager, TextDocumentIdentifiers textDocumentIdentifiers) : base(
         resolverContext, handlersManager, textDocumentIdentifiers
         )
 {
 }