예제 #1
0
 public DefinitionHandler(LanguageServerWorkspace workspace, DocumentSelector documentSelector)
 {
     _workspace           = workspace;
     _registrationOptions = new DefinitionRegistrationOptions
     {
         DocumentSelector = documentSelector
     };
 }
예제 #2
0
 public DocumentSymbolsHandler(LanguageServerWorkspace workspace, DocumentSelector documentSelector)
 {
     _workspace           = workspace;
     _registrationOptions = new DocumentSymbolRegistrationOptions
     {
         DocumentSelector = documentSelector,
     };
 }
예제 #3
0
 public SignatureHelpHandler(LanguageServerWorkspace workspace, DocumentSelector documentSelector)
 {
     _workspace           = workspace;
     _registrationOptions = new SignatureHelpRegistrationOptions
     {
         DocumentSelector = documentSelector
     };;
 }
 public DocumentHighlightHandler(LanguageServerWorkspace workspace, DocumentSelector documentSelector)
 {
     _workspace           = workspace;
     _registrationOptions = new DocumentHighlightRegistrationOptions
     {
         DocumentSelector = documentSelector
     };
 }
예제 #5
0
 public TextDocumentSyncHandler(LanguageServerWorkspace workspace, DocumentSelector documentSelector)
 {
     _workspace = workspace;
     _changeRegistrationOptions = new TextDocumentChangeRegistrationOptions
     {
         DocumentSelector = documentSelector,
         SyncKind         = TextDocumentSyncKind.Incremental,
     };
 }
예제 #6
0
 public CompletionHandler(LanguageServerWorkspace workspace, DocumentSelector documentSelector)
 {
     _workspace           = workspace;
     _registrationOptions = new CompletionRegistrationOptions
     {
         DocumentSelector  = documentSelector,
         TriggerCharacters = new Container <string>(".", ":"),
         ResolveProvider   = false
     };
 }
예제 #7
0
 public TextDocumentSyncHandler(LanguageServerWorkspace workspace, TextDocumentRegistrationOptions registrationOptions)
 {
     _workspace           = workspace;
     _registrationOptions = registrationOptions;
 }
예제 #8
0
 public WorkspaceSymbolsHandler(LanguageServerWorkspace workspace)
 {
     _workspace = workspace;
 }
예제 #9
0
        internal LanguageServer(
            Stream input,
            Stream output,
            ILspReciever reciever,
            IRequestProcessIdentifier requestProcessIdentifier,
            ILoggerFactory loggerFactory,
            ISerializer serializer,
            IServiceCollection services,
            IEnumerable <Assembly> assemblies,
            IEnumerable <InitializeDelegate> initializeDelegates,
            IEnumerable <InitializedDelegate> initializedDelegates)
        {
            var outputHandler = new OutputHandler(output, serializer);

            services.AddLogging();
            _reciever              = reciever;
            _serializer            = serializer;
            _supportedCapabilities = new SupportedCapabilities();
            _collection            = new HandlerCollection(_supportedCapabilities);
            _initializeDelegates   = initializeDelegates;
            _initializedDelegates  = initializedDelegates;

            services.AddSingleton <IOutputHandler>(outputHandler);
            services.AddSingleton(_collection);
            services.AddSingleton(_serializer);
            services.AddSingleton <OmniSharp.Extensions.JsonRpc.ISerializer>(_serializer);
            services.AddSingleton(requestProcessIdentifier);
            services.AddSingleton <OmniSharp.Extensions.JsonRpc.IReciever>(reciever);
            services.AddSingleton <ILspReciever>(reciever);
            services.AddSingleton(loggerFactory);

            services.AddJsonRpcMediatR(assemblies);
            services.AddTransient <IHandlerMatcher, TextDocumentMatcher>();
            services.AddSingleton <Protocol.Server.ILanguageServer>(this);
            services.AddSingleton <ILanguageServer>(this);
            services.AddTransient <IHandlerMatcher, ExecuteCommandMatcher>();
            services.AddTransient <IHandlerMatcher, ResolveCommandMatcher>();
            services.AddSingleton <ILspRequestRouter, LspRequestRouter>();
            services.AddSingleton <IRequestRouter>(_ => _.GetRequiredService <ILspRequestRouter>());
            services.AddSingleton <IResponseRouter, ResponseRouter>();
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(ResolveCommandPipeline <,>));

            var foundHandlers = services
                                .Where(x => typeof(IJsonRpcHandler).IsAssignableFrom(x.ServiceType) && x.ServiceType != typeof(IJsonRpcHandler))
                                .ToArray();

            // Handlers are created at the start and maintained as a singleton
            foreach (var handler in foundHandlers)
            {
                services.Remove(handler);

                if (handler.ImplementationFactory != null)
                {
                    services.Add(ServiceDescriptor.Singleton(typeof(IJsonRpcHandler), handler.ImplementationFactory));
                }
                else if (handler.ImplementationInstance != null)
                {
                    services.Add(ServiceDescriptor.Singleton(typeof(IJsonRpcHandler), handler.ImplementationInstance));
                }
                else
                {
                    services.Add(ServiceDescriptor.Singleton(typeof(IJsonRpcHandler), handler.ImplementationType));
                }
            }

            _serviceProvider = services.BuildServiceProvider();

            _requestRouter  = _serviceProvider.GetRequiredService <ILspRequestRouter>();
            _responseRouter = _serviceProvider.GetRequiredService <IResponseRouter>();
            _connection     = ActivatorUtilities.CreateInstance <Connection>(_serviceProvider, input);

            _exitHandler = new ExitHandler(_shutdownHandler);

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

            var handlers = _serviceProvider.GetServices <IJsonRpcHandler>().ToArray();

            _collection.Add(handlers);

            Document  = new LanguageServerDocument(_responseRouter);
            Client    = new LanguageServerClient(_responseRouter);
            Window    = new LanguageServerWindow(_responseRouter);
            Workspace = new LanguageServerWorkspace(_responseRouter);
        }
 public SignatureHelpHandler(LanguageServerWorkspace workspace, TextDocumentRegistrationOptions registrationOptions)
 {
     _workspace           = workspace;
     _registrationOptions = registrationOptions;
 }