Example #1
0
        public static ILanguageServerRegistry OnDocumentLink(this ILanguageServerRegistry registry,
                                                             Action <DocumentLinkParams, IObserver <IEnumerable <DocumentLink> > > handler,
                                                             Func <DocumentLink, bool> canResolve,
                                                             Func <DocumentLink, Task <DocumentLink> > resolveHandler,
                                                             DocumentLinkRegistrationOptions registrationOptions)
        {
            registrationOptions ??= new DocumentLinkRegistrationOptions();
            registrationOptions.ResolveProvider = canResolve != null && resolveHandler != null;
            canResolve ??= item => registrationOptions.ResolveProvider;
            resolveHandler ??= (link) => Task.FromException <DocumentLink>(new NotImplementedException());

            return(registry.AddHandler(TextDocumentNames.DocumentLink,
                                       _ => new LanguageProtocolDelegatingHandlers.PartialResults <DocumentLinkParams, DocumentLinkContainer, DocumentLink,
                                                                                                   DocumentLinkRegistrationOptions>(
                                           handler,
                                           registrationOptions,
                                           _.GetRequiredService <IProgressManager>(),
                                           x => new DocumentLinkContainer(x)))
                   .AddHandler(TextDocumentNames.DocumentLinkResolve,
                               new LanguageProtocolDelegatingHandlers.CanBeResolved <DocumentLink, DocumentLinkRegistrationOptions>(
                                   resolveHandler,
                                   canResolve,
                                   registrationOptions))
                   );
        }
Example #2
0
 public static ILanguageServerRegistry OnCallHierarchy(this ILanguageServerRegistry registry,
                                                       Func <CallHierarchyPrepareParams, CallHierarchyCapability, Task <Container <CallHierarchyItem> > > handler,
                                                       Action <CallHierarchyIncomingCallsParams, IObserver <IEnumerable <CallHierarchyIncomingCall> >, CallHierarchyCapability> incomingHandler,
                                                       Action <CallHierarchyOutgoingCallsParams, IObserver <IEnumerable <CallHierarchyOutgoingCall> >, CallHierarchyCapability> outgoingHandler,
                                                       CallHierarchyRegistrationOptions registrationOptions)
 {
     registrationOptions ??= new CallHierarchyRegistrationOptions();
     return
         (registry.AddHandler(TextDocumentNames.PrepareCallHierarchy,
                              new LanguageProtocolDelegatingHandlers.Request <CallHierarchyPrepareParams,
                                                                              Container <CallHierarchyItem>,
                                                                              CallHierarchyCapability,
                                                                              CallHierarchyRegistrationOptions>(handler, registrationOptions))
          .AddHandler(TextDocumentNames.CallHierarchyIncoming,
                      _ => new LanguageProtocolDelegatingHandlers.PartialResults <CallHierarchyIncomingCallsParams,
                                                                                  Container <CallHierarchyIncomingCall>, CallHierarchyIncomingCall,
                                                                                  CallHierarchyCapability,
                                                                                  CallHierarchyRegistrationOptions>(incomingHandler, registrationOptions,
                                                                                                                    _.GetRequiredService <IProgressManager>(), x => new Container <CallHierarchyIncomingCall>(x)))
          .AddHandler(TextDocumentNames.CallHierarchyOutgoing,
                      _ => new LanguageProtocolDelegatingHandlers.PartialResults <CallHierarchyOutgoingCallsParams,
                                                                                  Container <CallHierarchyOutgoingCall>, CallHierarchyOutgoingCall,
                                                                                  CallHierarchyCapability,
                                                                                  CallHierarchyRegistrationOptions>(outgoingHandler, registrationOptions,
                                                                                                                    _.GetRequiredService <IProgressManager>(), x => new Container <CallHierarchyOutgoingCall>(x)))
         );
 }
Example #3
0
 public static ILanguageServerRegistry OnCallHierarchy(
     this ILanguageServerRegistry registry,
     Func <CallHierarchyPrepareParams, CallHierarchyCapability, CancellationToken, Task <Container <CallHierarchyItem> > > handler,
     Func <CallHierarchyIncomingCallsParams, CallHierarchyCapability, CancellationToken, Task <Container <CallHierarchyIncomingCall> > > incomingHandler,
     Func <CallHierarchyOutgoingCallsParams, CallHierarchyCapability, CancellationToken, Task <Container <CallHierarchyOutgoingCall> > > outgoingHandler,
     CallHierarchyRegistrationOptions registrationOptions)
 {
     registrationOptions ??= new CallHierarchyRegistrationOptions();
     return(registry.AddHandler(TextDocumentNames.PrepareCallHierarchy,
                                new LanguageProtocolDelegatingHandlers.Request <CallHierarchyPrepareParams,
                                                                                Container <CallHierarchyItem>,
                                                                                CallHierarchyCapability,
                                                                                CallHierarchyRegistrationOptions>(handler, registrationOptions))
            .AddHandler(TextDocumentNames.CallHierarchyIncoming,
                        new LanguageProtocolDelegatingHandlers.Request <CallHierarchyIncomingCallsParams,
                                                                        Container <CallHierarchyIncomingCall>,
                                                                        CallHierarchyCapability,
                                                                        CallHierarchyRegistrationOptions>(incomingHandler, registrationOptions))
            .AddHandler(TextDocumentNames.CallHierarchyOutgoing,
                        new LanguageProtocolDelegatingHandlers.Request <CallHierarchyOutgoingCallsParams,
                                                                        Container <CallHierarchyOutgoingCall>,
                                                                        CallHierarchyCapability,
                                                                        CallHierarchyRegistrationOptions>(outgoingHandler, registrationOptions))
            );
 }
        public static ILanguageServerRegistry OnCompletion(
            this ILanguageServerRegistry registry,
            Func <CompletionParams, CompletionCapability, CancellationToken, Task <CompletionList> > handler,
            Func <CompletionItem, CompletionCapability, CancellationToken, Task <CompletionItem> >?resolveHandler,
            CompletionRegistrationOptions?registrationOptions
            )
        {
            registrationOptions ??= new CompletionRegistrationOptions();
            registrationOptions.ResolveProvider = true;
            resolveHandler ??= (link, cap, token) => Task.FromResult(link);
            var id = Guid.NewGuid();

            return(registry.AddHandler(
                       TextDocumentNames.Completion,
                       new LanguageProtocolDelegatingHandlers.Request <CompletionParams, CompletionList, CompletionCapability,
                                                                       CompletionRegistrationOptions>(
                           id,
                           handler,
                           registrationOptions
                           )
                       )
                   .AddHandler(
                       TextDocumentNames.CompletionResolve,
                       new LanguageProtocolDelegatingHandlers.CanBeResolved <CompletionItem, CompletionCapability, CompletionRegistrationOptions>(
                           id,
                           resolveHandler,
                           registrationOptions
                           )
                       )
                   );
        }
Example #5
0
        public static ILanguageServerRegistry OnCodeLens(this ILanguageServerRegistry registry,
                                                         Action <CodeLensParams, IObserver <IEnumerable <CodeLens> >, CodeLensCapability, CancellationToken> handler,
                                                         Func <CodeLens, bool> canResolve,
                                                         Func <CodeLens, CodeLensCapability, CancellationToken, Task <CodeLens> > resolveHandler,
                                                         CodeLensRegistrationOptions registrationOptions)
        {
            registrationOptions ??= new CodeLensRegistrationOptions();
            registrationOptions.ResolveProvider = canResolve != null && resolveHandler != null;
            canResolve ??= item => registrationOptions.ResolveProvider;
            resolveHandler ??= (link, cap, token) => Task.FromException <CodeLens>(new NotImplementedException());

            return
                (registry.AddHandler(TextDocumentNames.CodeLens,
                                     _ => new LanguageProtocolDelegatingHandlers.PartialResults <CodeLensParams, CodeLensContainer, CodeLens, CodeLensCapability,
                                                                                                 CodeLensRegistrationOptions>(
                                         handler,
                                         registrationOptions,
                                         _.GetRequiredService <IProgressManager>(),
                                         x => new CodeLensContainer(x)))
                 .AddHandler(TextDocumentNames.CodeLensResolve,
                             new LanguageProtocolDelegatingHandlers.CanBeResolved <CodeLens, CodeLensCapability, CodeLensRegistrationOptions>(
                                 resolveHandler,
                                 canResolve,
                                 registrationOptions))
                );
        }
        public static ILanguageServerRegistry OnDocumentLink(
            this ILanguageServerRegistry registry,
            Func <DocumentLinkParams, DocumentLinkCapability, CancellationToken, Task <DocumentLinkContainer> > handler,
            Func <DocumentLink, DocumentLinkCapability, CancellationToken, Task <DocumentLink> >?resolveHandler,
            DocumentLinkRegistrationOptions?registrationOptions
            )
        {
            registrationOptions ??= new DocumentLinkRegistrationOptions();
            registrationOptions.ResolveProvider = true;
            resolveHandler ??= (link, cap, token) => Task.FromResult(link);
            var id = Guid.NewGuid();

            return(registry.AddHandler(
                       TextDocumentNames.DocumentLink,
                       new LanguageProtocolDelegatingHandlers.Request <DocumentLinkParams, DocumentLinkContainer, DocumentLinkCapability,
                                                                       DocumentLinkRegistrationOptions>(
                           id,
                           handler,
                           registrationOptions
                           )
                       )
                   .AddHandler(
                       TextDocumentNames.DocumentLinkResolve,
                       new LanguageProtocolDelegatingHandlers.CanBeResolved <DocumentLink, DocumentLinkCapability, DocumentLinkRegistrationOptions>(
                           id,
                           resolveHandler,
                           registrationOptions
                           )
                       )
                   );
        }
Example #7
0
        public static ILanguageServerRegistry OnCompletion(
            this ILanguageServerRegistry registry,
            Func <CompletionParams, CompletionCapability, CancellationToken, Task <CompletionList> > handler,
            Func <CompletionItem, bool> canResolve,
            Func <CompletionItem, CompletionCapability, CancellationToken, Task <CompletionItem> > resolveHandler,
            CompletionRegistrationOptions registrationOptions)
        {
            registrationOptions ??= new CompletionRegistrationOptions();
            registrationOptions.ResolveProvider = canResolve != null && resolveHandler != null;
            canResolve ??= item => registrationOptions.ResolveProvider;
            resolveHandler ??= (link, cap, token) => Task.FromException <CompletionItem>(new NotImplementedException());

            return(registry
                   .AddHandler(TextDocumentNames.Completion,
                               new LanguageProtocolDelegatingHandlers.Request <CompletionParams, CompletionList, CompletionCapability,
                                                                               CompletionRegistrationOptions>(
                                   handler,
                                   registrationOptions)
                               )
                   .AddHandler(TextDocumentNames.CompletionResolve,
                               new LanguageProtocolDelegatingHandlers.CanBeResolved <CompletionItem, CompletionCapability, CompletionRegistrationOptions>(
                                   resolveHandler,
                                   canResolve,
                                   registrationOptions)));
        }
Example #8
0
 public static ILanguageServerRegistry OnExecuteCommand <T>(this ILanguageServerRegistry registry, string command, Func <T, Task> handler) =>
 registry.AddHandler(
     _ => new Handler <T>(
         command,
         (arg1, capability, token) => handler(arg1),
         _.GetRequiredService <ISerializer>()
         )
     );
Example #9
0
        public static ILanguageServerRegistry OnDocumentLink(this ILanguageServerRegistry registry,
                                                             Func <DocumentLinkParams, CancellationToken, Task <DocumentLinkContainer> > handler,
                                                             Func <DocumentLink, bool> canResolve,
                                                             Func <DocumentLink, CancellationToken, Task <DocumentLink> > resolveHandler,
                                                             DocumentLinkRegistrationOptions registrationOptions)
        {
            registrationOptions ??= new DocumentLinkRegistrationOptions();
            registrationOptions.ResolveProvider = canResolve != null && resolveHandler != null;
            canResolve ??= item => registrationOptions.ResolveProvider;
            resolveHandler ??= (link, token) => Task.FromException <DocumentLink>(new NotImplementedException());

            return(registry.AddHandler(TextDocumentNames.DocumentLink,
                                       new LanguageProtocolDelegatingHandlers.RequestRegistration <DocumentLinkParams, DocumentLinkContainer,
                                                                                                   DocumentLinkRegistrationOptions>(
                                           handler,
                                           registrationOptions)).AddHandler(TextDocumentNames.DocumentLinkResolve,
                                                                            new LanguageProtocolDelegatingHandlers.CanBeResolved <DocumentLink, DocumentLinkRegistrationOptions>(
                                                                                resolveHandler,
                                                                                canResolve,
                                                                                registrationOptions))
                   );
        }
Example #10
0
        public static ILanguageServerRegistry OnCodeLens(this ILanguageServerRegistry registry,
                                                         Func <CodeLensParams, Task <CodeLensContainer> > handler,
                                                         Func <CodeLens, bool> canResolve,
                                                         Func <CodeLens, Task <CodeLens> > resolveHandler,
                                                         CodeLensRegistrationOptions registrationOptions)
        {
            registrationOptions ??= new CodeLensRegistrationOptions();
            registrationOptions.ResolveProvider = canResolve != null && resolveHandler != null;
            canResolve ??= item => registrationOptions.ResolveProvider;
            resolveHandler ??= (link) => Task.FromException <CodeLens>(new NotImplementedException());

            return(registry.AddHandler(TextDocumentNames.CodeLens,
                                       new LanguageProtocolDelegatingHandlers.RequestRegistration <CodeLensParams, CodeLensContainer,
                                                                                                   CodeLensRegistrationOptions>(
                                           handler,
                                           registrationOptions))
                   .AddHandler(TextDocumentNames.CodeLensResolve,
                               new LanguageProtocolDelegatingHandlers.CanBeResolved <CodeLens, CodeLensRegistrationOptions>(
                                   resolveHandler,
                                   canResolve,
                                   registrationOptions))
                   );
        }
Example #11
0
 public static ILanguageServerRegistry OnExecuteCommand <T>(
     this ILanguageServerRegistry registry, string command, Func <T, ExecuteCommandCapability, CancellationToken, Task> handler
     ) => registry.AddHandler(_ => new Handler <T>(command, handler, _.GetRequiredService <ISerializer>()));