Пример #1
0
 public static IDisposable OnTextDocumentSync(
     this ILanguageServerRegistry registry,
     TextDocumentSyncKind kind,
     Func <DidOpenTextDocumentParams, CancellationToken, Task <Unit> > onOpenHandler,
     Func <DidCloseTextDocumentParams, CancellationToken, Task <Unit> > onCloseHandler,
     Func <DidChangeTextDocumentParams, CancellationToken, Task <Unit> > onChangeHandler,
     Func <DidSaveTextDocumentParams, CancellationToken, Task <Unit> > onSaveHandler,
     Func <Uri, TextDocumentAttributes> getTextDocumentAttributes,
     TextDocumentSaveRegistrationOptions registrationOptions = null,
     Action <SynchronizationCapability> setCapability        = null)
 {
     registrationOptions = registrationOptions ?? new TextDocumentSaveRegistrationOptions();
     return(registry.AddHandlers(new DelegatingHandler(onOpenHandler, onCloseHandler, onChangeHandler, onSaveHandler, getTextDocumentAttributes, setCapability, registrationOptions, kind)));
 }
Пример #2
0
 public static IDisposable OnCallHierarchy(
     this ILanguageServerRegistry registry,
     Func <CallHierarchyPrepareParams, CancellationToken, Task <Container <CallHierarchyItem> > > handler,
     Func <CallHierarchyIncomingCallsParams, CancellationToken, Task <Container <CallHierarchyIncomingCall> > >
     incomingHandler,
     Func <CallHierarchyOutgoingCallsParams, CancellationToken, Task <Container <CallHierarchyOutgoingCall> > >
     outgoingHandler,
     CallHierarchyRegistrationOptions registrationOptions = null,
     Action <CallHierarchyCapability> setCapability       = null)
 {
     registrationOptions ??= new CallHierarchyRegistrationOptions();
     return(registry.AddHandlers(new DelegatingHandler(handler, incomingHandler, outgoingHandler,
                                                       registry.ProgressManager,
                                                       setCapability, registrationOptions)));
 }
        public static IDisposable OnCodeLens(
            this ILanguageServerRegistry registry,
            Func <CodeLensParams, CancellationToken, Task <CodeLensContainer> > handler,
            Func <CodeLens, CancellationToken, Task <CodeLens> > resolveHandler = null,
            Func <CodeLens, bool> canResolve = null,
            CodeLensRegistrationOptions registrationOptions = null,
            Action <CodeLensCapability> setCapability       = null)
        {
            var codeLensRegistrationOptions = new CodeLensRegistrationOptions();

            codeLensRegistrationOptions.ResolveProvider = canResolve != null && resolveHandler != null;
            if (registrationOptions != null)
            {
                codeLensRegistrationOptions.DocumentSelector = registrationOptions.DocumentSelector;
            }
            return(registry.AddHandlers(new DelegatingHandler(handler, resolveHandler, registry.ProgressManager, canResolve, setCapability, codeLensRegistrationOptions)));
        }
Пример #4
0
 public static ILanguageServerRegistry OnTextDocumentSync(this ILanguageServerRegistry registry,
                                                          TextDocumentSyncKind kind,
                                                          Func <DocumentUri, TextDocumentAttributes> getTextDocumentAttributes,
                                                          Action <DidOpenTextDocumentParams, SynchronizationCapability> onOpenHandler,
                                                          Action <DidCloseTextDocumentParams, SynchronizationCapability> onCloseHandler,
                                                          Action <DidChangeTextDocumentParams, SynchronizationCapability> onChangeHandler,
                                                          Action <DidSaveTextDocumentParams, SynchronizationCapability> onSaveHandler,
                                                          TextDocumentSaveRegistrationOptions registrationOptions)
 {
     registrationOptions ??= new TextDocumentSaveRegistrationOptions();
     return(registry.AddHandlers(new DelegatingHandler(
                                     (r, c, ct) => onOpenHandler(r, c),
                                     (r, c, ct) => onCloseHandler(r, c),
                                     (r, c, ct) => onChangeHandler(r, c),
                                     (r, c, ct) => onSaveHandler(r, c),
                                     getTextDocumentAttributes, registrationOptions, kind)));
 }
Пример #5
0
        public static ILanguageServerRegistry OnSemanticTokens(this ILanguageServerRegistry registry,
                                                               Func <SemanticTokensBuilder, ITextDocumentIdentifierParams, SemanticTokensCapability, CancellationToken, Task> tokenize,
                                                               Func <ITextDocumentIdentifierParams, SemanticTokensCapability, CancellationToken, Task <SemanticTokensDocument> > getSemanticTokensDocument,
                                                               SemanticTokensRegistrationOptions registrationOptions)
        {
            registrationOptions ??= new SemanticTokensRegistrationOptions()
            {
                Full = new SemanticTokensCapabilityRequestFull()
            };
            registrationOptions.Range ??= new SemanticTokensCapabilityRequestRange();
            if (registrationOptions?.Full?.IsValue == true)
            {
                registrationOptions.Full.Value.Delta = true;
            }

            return(registry.AddHandlers(
                       new DelegatingHandlerBase(tokenize, getSemanticTokensDocument, registrationOptions)));
        }
Пример #6
0
 public static IDisposable OnInitialized(this ILanguageServerRegistry registry, Func <InitializedParams, Task <Unit> > handler)
 {
     return(registry.AddHandlers(new DelegatingHandler(handler)));
 }
 public static IDisposable OnTelemetryEvent(
     this ILanguageServerRegistry registry,
     Func <TelemetryEventParams, CancellationToken, Task <Unit> > handler)
 {
     return(registry.AddHandlers(new DelegatingHandler(handler)));
 }
 public static IDisposable OnShutdown(this ILanguageServerRegistry registry, Func <Task <Unit> > handler)
 {
     return(registry.AddHandlers(new DelegatingHandler(handler)));
 }
 public static IDisposable OnInitialize(this ILanguageServerRegistry registry, Func <InitializeParams, CancellationToken, Task <InitializeResult> > handler)
 {
     return(registry.AddHandlers(new DelegatingHandler(handler)));
 }
 public static IDisposable OnWorkDoneProgressCancel(
     this ILanguageServerRegistry registry,
     Func <WorkDoneProgressCancelParams, CancellationToken, Task <Unit> > handler)
 {
     return(registry.AddHandlers(new DelegatingHandler(handler)));
 }
 public static IDisposable OnExit(this ILanguageServerRegistry registry, Action handler)
 {
     return(registry.AddHandlers(new DelegatingHandler(handler)));
 }
 public static IDisposable OnShowMessageRequest(
     this ILanguageServerRegistry registry,
     Func <ShowMessageRequestParams, CancellationToken, Task <MessageActionItem> > handler)
 {
     return(registry.AddHandlers(new DelegatingHandler(handler)));
 }