public override (IEnumerable <Renor> results, bool hasResponse) GetRequests(JToken container)
        {
            if (_initialized)
            {
                return(base.GetRequests(container));
            }

            var newResults = new List <Renor>();

            // Based on https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#initialize-request
            var(results, hasResponse) = base.GetRequests(container);
            foreach (var item in results)
            {
                if (item.IsRequest && item.Request.Method == LspHelper.GetMethodName <IInitializeHandler>())
                {
                    newResults.Add(item);
                }
                else if (item.IsRequest)
                {
                    newResults.Add(new ServerNotInitialized());
                }
                else if (item.IsResponse)
                {
                    newResults.Add(item);
                }
            }

            return(newResults, hasResponse);
        }
Exemple #2
0
        public IDisposable Add(params IJsonRpcHandler[] handlers)
        {
            var descriptors = new HashSet <HandlerDescriptor>();

            foreach (var handler in handlers)
            {
                foreach (var(method, implementedInterface) in handler.GetType().GetTypeInfo()
                         .ImplementedInterfaces
                         .Select(x => (method: LspHelper.GetMethodName(x), implementedInterface: x))
                         .Where(x => !string.IsNullOrWhiteSpace(x.method)))
                {
                    descriptors.Add(GetDescriptor(method, implementedInterface, handler));
                }
            }

            foreach (var handler in descriptors)
            {
                _handlers.Add(handler);
            }

            return(new ImmutableDisposable(descriptors));
        }