massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-json / node_modules / vscode-languageserver-protocol / lib / common / connection.d.ts
1 import { Message, NotificationMessage, CancellationToken, RequestHandler0, RequestHandler, GenericRequestHandler, NotificationHandler0, NotificationHandler, GenericNotificationHandler, ProgressType, Trace, Tracer, TraceOptions, Disposable, Event, MessageReader, MessageWriter, Logger, ConnectionStrategy, ConnectionOptions, RequestType0, RequestType, NotificationType0, NotificationType } from 'vscode-jsonrpc';
2 import { ProtocolRequestType, ProtocolRequestType0, ProtocolNotificationType, ProtocolNotificationType0 } from './messages';
3 export interface ProtocolConnection {
4     /**
5      * Sends a request and returns a promise resolving to the result of the request.
6      *
7      * @param type The type of request to sent.
8      * @param token An optional cancellation token.
9      * @returns A promise resolving to the request's result.
10      */
11     sendRequest<R, PR, E, RO>(type: ProtocolRequestType0<R, PR, E, RO>, token?: CancellationToken): Promise<R>;
12     sendRequest<R, E>(type: RequestType0<R, E>, token?: CancellationToken): Promise<R>;
13     /**
14      * Sends a request and returns a promise resolving to the result of the request.
15      *
16      * @param type The type of request to sent.
17      * @param params The request's parameter.
18      * @param token An optional cancellation token.
19      * @returns A promise resolving to the request's result.
20      */
21     sendRequest<P, R, PR, E, RO>(type: ProtocolRequestType<P, R, PR, E, RO>, params: P, token?: CancellationToken): Promise<R>;
22     sendRequest<P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken): Promise<R>;
23     /**
24      * Sends a request and returns a promise resolving to the result of the request.
25      *
26      * @param method the request's method name.
27      * @param token An optional cancellation token.
28      * @returns A promise resolving to the request's result.
29      */
30     sendRequest<R>(method: string, token?: CancellationToken): Promise<R>;
31     /**
32      * Sends a request and returns a promise resolving to the result of the request.
33      *
34      * @param method the request's method name.
35      * @param params The request's parameter.
36      * @param token An optional cancellation token.
37      * @returns A promise resolving to the request's result.
38      */
39     sendRequest<R>(method: string, param: any, token?: CancellationToken): Promise<R>;
40     /**
41      * Installs a request handler.
42      *
43      * @param type The request type to install the handler for.
44      * @param handler The actual handler.
45      */
46     onRequest<R, PR, E, RO>(type: ProtocolRequestType0<R, PR, E, RO>, handler: RequestHandler0<R, E>): Disposable;
47     onRequest<R, E>(type: RequestType0<R, E>, handler: RequestHandler0<R, E>): Disposable;
48     /**
49      * Installs a request handler.
50      *
51      * @param type The request type to install the handler for.
52      * @param handler The actual handler.
53      */
54     onRequest<P, R, PR, E, RO>(type: ProtocolRequestType<P, R, PR, E, RO>, handler: RequestHandler<P, R, E>): Disposable;
55     onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): Disposable;
56     /**
57      * Installs a request handler.
58      *
59      * @param methods The method name to install the handler for.
60      * @param handler The actual handler.
61      */
62     onRequest<R, E>(method: string, handler: GenericRequestHandler<R, E>): Disposable;
63     /**
64      * Sends a notification.
65      *
66      * @param type the notification's type to send.
67      */
68     sendNotification(type: NotificationType0): void;
69     sendNotification<RO>(type: ProtocolNotificationType0<RO>): void;
70     /**
71      * Sends a notification.
72      *
73      * @param type the notification's type to send.
74      * @param params the notification's parameters.
75      */
76     sendNotification<P, RO>(type: ProtocolNotificationType<P, RO>, params?: P): void;
77     sendNotification<P>(type: NotificationType<P>, params?: P): void;
78     /**
79      * Sends a notification.
80      *
81      * @param method the notification's method name.
82      */
83     sendNotification(method: string): void;
84     /**
85      * Sends a notification.
86      *
87      * @param method the notification's method name.
88      * @param params the notification's parameters.
89      */
90     sendNotification(method: string, params: any): void;
91     /**
92      * Installs a notification handler.
93      *
94      * @param type The notification type to install the handler for.
95      * @param handler The actual handler.
96      */
97     onNotification<RO>(type: ProtocolNotificationType0<RO>, handler: NotificationHandler0): Disposable;
98     onNotification(type: NotificationType0, handler: NotificationHandler0): Disposable;
99     /**
100      * Installs a notification handler.
101      *
102      * @param type The notification type to install the handler for.
103      * @param handler The actual handler.
104      */
105     onNotification<P, RO>(type: ProtocolNotificationType<P, RO>, handler: NotificationHandler<P>): Disposable;
106     onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): Disposable;
107     /**
108      * Installs a notification handler.
109      *
110      * @param methods The method name to install the handler for.
111      * @param handler The actual handler.
112      */
113     onNotification(method: string, handler: GenericNotificationHandler): Disposable;
114     /**
115      * Installs a progress handler for a given token.
116      * @param type the progress type
117      * @param token the token
118      * @param handler the handler
119      */
120     onProgress<P>(type: ProgressType<P>, token: string | number, handler: NotificationHandler<P>): Disposable;
121     /**
122      * Sends progress.
123      * @param type the progress type
124      * @param token the token to use
125      * @param value the progress value
126      */
127     sendProgress<P>(type: ProgressType<P>, token: string | number, value: P): void;
128     /**
129      * Enables tracing mode for the connection.
130      */
131     trace(value: Trace, tracer: Tracer, sendNotification?: boolean): void;
132     trace(value: Trace, tracer: Tracer, traceOptions?: TraceOptions): void;
133     /**
134      * An event emitter firing when an error occurs on the connection.
135      */
136     onError: Event<[Error, Message | undefined, number | undefined]>;
137     /**
138      * An event emitter firing when the connection got closed.
139      */
140     onClose: Event<void>;
141     /**
142      * An event emiiter firing when the connection receives a notification that is not
143      * handled.
144      */
145     onUnhandledNotification: Event<NotificationMessage>;
146     /**
147      * An event emitter firing when the connection got disposed.
148      */
149     onDispose: Event<void>;
150     /**
151      * Ends the connection.
152      */
153     end(): void;
154     /**
155      * Actively disposes the connection.
156      */
157     dispose(): void;
158     /**
159      * Turns the connection into listening mode
160      */
161     listen(): void;
162 }
163 export declare function createProtocolConnection(input: MessageReader, output: MessageWriter, logger?: Logger, options?: ConnectionStrategy | ConnectionOptions): ProtocolConnection;