예제 #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))
                   );
        }
예제 #2
0
 public DelegatingHandler(
     Func <DocumentLinkParams, CancellationToken, Task <DocumentLinkContainer> > handler,
     Func <DocumentLink, CancellationToken, Task <DocumentLink> > resolveHandler,
     Func <DocumentLink, bool> canResolve,
     Action <DocumentLinkCapability> setCapability,
     DocumentLinkRegistrationOptions registrationOptions) : base(registrationOptions)
 {
     _handler        = handler;
     _resolveHandler = resolveHandler;
     _canResolve     = canResolve;
     _setCapability  = setCapability;
 }
예제 #3
0
 public static IDisposable OnDocumentLink(
     this ILanguageServerRegistry registry,
     Func <DocumentLinkParams, CancellationToken, Task <DocumentLinkContainer> > handler,
     Func <DocumentLink, CancellationToken, Task <DocumentLink> > resolveHandler = null,
     Func <DocumentLink, bool> canResolve = null,
     DocumentLinkRegistrationOptions registrationOptions = null,
     Action <DocumentLinkCapability> setCapability       = null)
 {
     registrationOptions = registrationOptions ?? new DocumentLinkRegistrationOptions();
     registrationOptions.ResolveProvider = canResolve != null && resolveHandler != null;
     return(registry.AddHandlers(new DelegatingHandler(handler, resolveHandler, canResolve, setCapability, registrationOptions)));
 }
예제 #4
0
        public void SimpleTest(string expected)
        {
            var model = new DocumentLinkRegistrationOptions()
            {
                DocumentSelector = new DocumentSelector(new DocumentFilter()
                {
                    Language = "csharp"
                }),
                ResolveProvider = true
            };
            var result = Fixture.SerializeObject(model);

            result.Should().Be(expected);

            var deresult = new Serializer(ClientVersion.Lsp3).DeserializeObject <DocumentLinkRegistrationOptions>(expected);

            deresult.Should().BeEquivalentTo(model);
        }
예제 #5
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))
                   );
        }
예제 #6
0
 public DocumentLinkHandler(DocumentLinkRegistrationOptions registrationOptions)
 {
     _options = registrationOptions;
 }
 public DocumentLinkHandler(DocumentLinkRegistrationOptions registrationOptions, ProgressManager progressManager)
 {
     _options        = registrationOptions;
     ProgressManager = progressManager;
 }
 public DocumentLinkHandlerBase(DocumentLinkRegistrationOptions registrationOptions, ISerializer serializer) : base(registrationOptions) => _serializer = serializer;
 public DocumentLinkHandler(DocumentLinkRegistrationOptions registrationOptions)
 {
     _options = registrationOptions;
     _options.ResolveProvider = true;
 }