public TypeHandlerData()
 {
     foreach (var type in typeof(CompletionParams).Assembly.ExportedTypes.Where(z => z.IsInterface && typeof(IJsonRpcHandler).IsAssignableFrom(z) && !z.IsGenericType)
              .Except(new[] { typeof(ITextDocumentSyncHandler) }))
     {
         Add(LspHandlerTypeDescriptorHelper.GetHandlerTypeDescriptor(type));
     }
 }
 public TypeHandlerData()
 {
     foreach (var type in typeof(CompletionParams).Assembly.ExportedTypes.Where(z => z.IsInterface && typeof(IJsonRpcHandler).IsAssignableFrom(z))
              .Where(z => !z.Name.EndsWith("Manager"))
              .Except(new[] { typeof(ITextDocumentSyncHandler) })
              )
     {
         if (type.IsGenericTypeDefinition && !MethodAttribute.AllFrom(type).Any())
         {
             continue;
         }
         Add(LspHandlerTypeDescriptorHelper.GetHandlerTypeDescriptor(type));
     }
 }
        public void RegisterCapabilities(ServerCapabilities serverCapabilities)
        {
            foreach (var registrationOptions in LspHandlerDescriptorHelpers.GetStaticRegistrationOptions(
                         serverCapabilities
                         ))
            {
                var method = LspHandlerTypeDescriptorHelper.GetMethodForRegistrationOptions(registrationOptions);
                if (method == null)
                {
                    _logger.LogWarning("Unable to find method for given {@RegistrationOptions}", registrationOptions);
                    continue;
                }

                var reg = new Registration {
                    Id              = registrationOptions.Id,
                    Method          = method,
                    RegisterOptions = registrationOptions
                };
                _registrations.AddOrUpdate(registrationOptions.Id, x => reg, (a, b) => reg);
            }

            if (serverCapabilities.Workspace == null)
            {
                _registrationSubject.OnNext(_registrations.Values);
                return;
            }

            foreach (var registrationOptions in LspHandlerDescriptorHelpers.GetStaticRegistrationOptions(
                         serverCapabilities
                         .Workspace
                         ))
            {
                var method = LspHandlerTypeDescriptorHelper.GetMethodForRegistrationOptions(registrationOptions);
                if (method == null)
                {
                    // TODO: Log this
                    continue;
                }

                var reg = new Registration {
                    Id              = registrationOptions.Id,
                    Method          = method,
                    RegisterOptions = registrationOptions
                };
                _registrations.AddOrUpdate(registrationOptions.Id, x => reg, (a, b) => reg);
            }
        }
        private void Register(Registration registration)
        {
            var registrationType = LspHandlerTypeDescriptorHelper.GetRegistrationType(registration.Method);

            if (registrationType == null)
            {
                _registrations.AddOrUpdate(registration.Id, x => registration, (a, b) => registration);
                return;
            }

            var deserializedRegistration = new Registration {
                Id              = registration.Id,
                Method          = registration.Method,
                RegisterOptions = registration.RegisterOptions is JToken token
                    ? token.ToObject(registrationType, _serializer.JsonSerializer)
                    : registration.RegisterOptions
            };

            _registrations.AddOrUpdate(deserializedRegistration.Id, x => deserializedRegistration, (a, b) => deserializedRegistration);
        }
            public TypeHandlerExtensionData()
            {
                foreach (var type in typeof(CompletionParams).Assembly.ExportedTypes
                         .Where(z => z.IsInterface && typeof(IJsonRpcHandler).IsAssignableFrom(z) && !z.IsGenericType)
                         .Except(new[] { typeof(ITextDocumentSyncHandler) }))
                {
                    if (type == typeof(ICompletionResolveHandler) || type == typeof(ICodeLensResolveHandler) || type == typeof(IDocumentLinkResolveHandler))
                    {
                        continue;
                    }
                    var descriptor = LspHandlerTypeDescriptorHelper.GetHandlerTypeDescriptor(type);

                    Add(
                        descriptor,
                        GetOnMethodName(descriptor),
                        GetSendMethodName(descriptor),
                        GetExtensionClass(descriptor),
                        GetExtensionClassName(descriptor).Substring(GetExtensionClassName(descriptor).LastIndexOf('.') + 1)
                        );
                }
            }
            public TypeHandlerExtensionData()
            {
                foreach (var type in typeof(CompletionParams).Assembly.ExportedTypes
                         .Where(z => z.IsInterface && typeof(IJsonRpcHandler).IsAssignableFrom(z))
                         .Where(z => !z.Name.EndsWith("Manager"))
                         .Except(new[] { typeof(ITextDocumentSyncHandler) })
                         )
                {
                    if (type.IsGenericTypeDefinition && !MethodAttribute.AllFrom(type).Any())
                    {
                        continue;
                    }
                    if (type.Name.EndsWith("Manager"))
                    {
                        continue;
                    }
                    if (type == typeof(ICompletionResolveHandler) || type == typeof(ICodeLensResolveHandler) || type == typeof(IDocumentLinkResolveHandler))
                    {
                        continue;
                    }
                    if (type == typeof(ISemanticTokensHandler) || type == typeof(ISemanticTokensDeltaHandler) || type == typeof(ISemanticTokensRangeHandler))
                    {
                        continue;
                    }
                    var descriptor = LspHandlerTypeDescriptorHelper.GetHandlerTypeDescriptor(type);

                    if (descriptor == null)
                    {
                        throw new Exception("");
                    }

                    Add(
                        descriptor,
                        GetOnMethodName(descriptor),
                        GetSendMethodName(descriptor),
                        GetExtensionClass(descriptor),
                        GetExtensionClassName(descriptor).Substring(GetExtensionClassName(descriptor).LastIndexOf('.') + 1)
                        );
                }
            }