massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-json / node_modules / vscode-jsonrpc / lib / common / connection.d.ts
1 import { Message, RequestType, RequestType0, RequestType1, RequestType2, RequestType3, RequestType4, RequestType5, RequestType6, RequestType7, RequestType8, RequestType9, ResponseMessage, ResponseError, NotificationMessage, NotificationType, NotificationType0, NotificationType1, NotificationType2, NotificationType3, NotificationType4, NotificationType5, NotificationType6, NotificationType7, NotificationType8, NotificationType9, _EM, ParameterStructures } from './messages';
2 import type { Disposable } from './disposable';
3 import { Event } from './events';
4 import { CancellationToken, AbstractCancellationTokenSource } from './cancellation';
5 import { MessageReader } from './messageReader';
6 import { MessageWriter } from './messageWriter';
7 export declare type ProgressToken = number | string;
8 interface ProgressParams<T> {
9     /**
10      * The progress token provided by the client or server.
11      */
12     token: ProgressToken;
13     /**
14      * The progress data.
15      */
16     value: T;
17 }
18 export declare class ProgressType<PR> {
19     /**
20      * Clients must not use these properties. They are here to ensure correct typing.
21      * in TypeScript
22      */
23     readonly __?: [PR, _EM];
24     readonly _pr?: PR;
25     constructor();
26 }
27 export declare type HandlerResult<R, E> = R | ResponseError<E> | Thenable<R> | Thenable<ResponseError<E>> | Thenable<R | ResponseError<E>>;
28 export interface StarRequestHandler {
29     (method: string, params: any[] | object | undefined, token: CancellationToken): HandlerResult<any, any>;
30 }
31 export interface GenericRequestHandler<R, E> {
32     (...params: any[]): HandlerResult<R, E>;
33 }
34 export interface RequestHandler0<R, E> {
35     (token: CancellationToken): HandlerResult<R, E>;
36 }
37 export interface RequestHandler<P, R, E> {
38     (params: P, token: CancellationToken): HandlerResult<R, E>;
39 }
40 export interface RequestHandler1<P1, R, E> {
41     (p1: P1, token: CancellationToken): HandlerResult<R, E>;
42 }
43 export interface RequestHandler2<P1, P2, R, E> {
44     (p1: P1, p2: P2, token: CancellationToken): HandlerResult<R, E>;
45 }
46 export interface RequestHandler3<P1, P2, P3, R, E> {
47     (p1: P1, p2: P2, p3: P3, token: CancellationToken): HandlerResult<R, E>;
48 }
49 export interface RequestHandler4<P1, P2, P3, P4, R, E> {
50     (p1: P1, p2: P2, p3: P3, p4: P4, token: CancellationToken): HandlerResult<R, E>;
51 }
52 export interface RequestHandler5<P1, P2, P3, P4, P5, R, E> {
53     (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, token: CancellationToken): HandlerResult<R, E>;
54 }
55 export interface RequestHandler6<P1, P2, P3, P4, P5, P6, R, E> {
56     (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, token: CancellationToken): HandlerResult<R, E>;
57 }
58 export interface RequestHandler7<P1, P2, P3, P4, P5, P6, P7, R, E> {
59     (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, token: CancellationToken): HandlerResult<R, E>;
60 }
61 export interface RequestHandler8<P1, P2, P3, P4, P5, P6, P7, P8, R, E> {
62     (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, token: CancellationToken): HandlerResult<R, E>;
63 }
64 export interface RequestHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E> {
65     (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, token: CancellationToken): HandlerResult<R, E>;
66 }
67 export interface StarNotificationHandler {
68     (method: string, params: any[] | object | undefined): void;
69 }
70 export interface GenericNotificationHandler {
71     (...params: any[]): void;
72 }
73 export interface NotificationHandler0 {
74     (): void;
75 }
76 export interface NotificationHandler<P> {
77     (params: P): void;
78 }
79 export interface NotificationHandler1<P1> {
80     (p1: P1): void;
81 }
82 export interface NotificationHandler2<P1, P2> {
83     (p1: P1, p2: P2): void;
84 }
85 export interface NotificationHandler3<P1, P2, P3> {
86     (p1: P1, p2: P2, p3: P3): void;
87 }
88 export interface NotificationHandler4<P1, P2, P3, P4> {
89     (p1: P1, p2: P2, p3: P3, p4: P4): void;
90 }
91 export interface NotificationHandler5<P1, P2, P3, P4, P5> {
92     (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): void;
93 }
94 export interface NotificationHandler6<P1, P2, P3, P4, P5, P6> {
95     (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): void;
96 }
97 export interface NotificationHandler7<P1, P2, P3, P4, P5, P6, P7> {
98     (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): void;
99 }
100 export interface NotificationHandler8<P1, P2, P3, P4, P5, P6, P7, P8> {
101     (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): void;
102 }
103 export interface NotificationHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9> {
104     (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): void;
105 }
106 export interface Logger {
107     error(message: string): void;
108     warn(message: string): void;
109     info(message: string): void;
110     log(message: string): void;
111 }
112 export declare const NullLogger: Logger;
113 export declare enum Trace {
114     Off = 0,
115     Messages = 1,
116     Verbose = 2
117 }
118 export declare type TraceValues = 'off' | 'messages' | 'verbose';
119 export declare namespace Trace {
120     function fromString(value: string): Trace;
121     function toString(value: Trace): TraceValues;
122 }
123 export declare enum TraceFormat {
124     Text = "text",
125     JSON = "json"
126 }
127 export declare namespace TraceFormat {
128     function fromString(value: string): TraceFormat;
129 }
130 export interface TraceOptions {
131     sendNotification?: boolean;
132     traceFormat?: TraceFormat;
133 }
134 export interface SetTraceParams {
135     value: TraceValues;
136 }
137 export declare namespace SetTraceNotification {
138     const type: NotificationType<SetTraceParams>;
139 }
140 export interface LogTraceParams {
141     message: string;
142     verbose?: string;
143 }
144 export declare namespace LogTraceNotification {
145     const type: NotificationType<LogTraceParams>;
146 }
147 export interface Tracer {
148     log(dataObject: any): void;
149     log(message: string, data?: string): void;
150 }
151 export declare enum ConnectionErrors {
152     /**
153      * The connection is closed.
154      */
155     Closed = 1,
156     /**
157      * The connection got disposed.
158      */
159     Disposed = 2,
160     /**
161      * The connection is already in listening mode.
162      */
163     AlreadyListening = 3
164 }
165 export declare class ConnectionError extends Error {
166     readonly code: ConnectionErrors;
167     constructor(code: ConnectionErrors, message: string);
168 }
169 export declare type ConnectionStrategy = {
170     cancelUndispatched?: (message: Message, next: (message: Message) => ResponseMessage | undefined) => ResponseMessage | undefined;
171 };
172 export declare namespace ConnectionStrategy {
173     function is(value: any): value is ConnectionStrategy;
174 }
175 export declare type CancellationId = number | string;
176 export interface CancellationReceiverStrategy {
177     createCancellationTokenSource(id: CancellationId): AbstractCancellationTokenSource;
178     dispose?(): void;
179 }
180 export declare namespace CancellationReceiverStrategy {
181     const Message: CancellationReceiverStrategy;
182     function is(value: any): value is CancellationReceiverStrategy;
183 }
184 export interface CancellationSenderStrategy {
185     sendCancellation(conn: MessageConnection, id: CancellationId): void;
186     cleanup(id: CancellationId): void;
187     dispose?(): void;
188 }
189 export declare namespace CancellationSenderStrategy {
190     const Message: CancellationSenderStrategy;
191     function is(value: any): value is CancellationSenderStrategy;
192 }
193 export interface CancellationStrategy {
194     receiver: CancellationReceiverStrategy;
195     sender: CancellationSenderStrategy;
196 }
197 export declare namespace CancellationStrategy {
198     const Message: CancellationStrategy;
199     function is(value: any): value is CancellationStrategy;
200 }
201 export interface ConnectionOptions {
202     cancellationStrategy?: CancellationStrategy;
203     connectionStrategy?: ConnectionStrategy;
204 }
205 export declare namespace ConnectionOptions {
206     function is(value: any): value is ConnectionOptions;
207 }
208 export interface MessageConnection {
209     sendRequest<R, E>(type: RequestType0<R, E>, token?: CancellationToken): Promise<R>;
210     sendRequest<P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken): Promise<R>;
211     sendRequest<P1, R, E>(type: RequestType1<P1, R, E>, p1: P1, token?: CancellationToken): Promise<R>;
212     sendRequest<P1, P2, R, E>(type: RequestType2<P1, P2, R, E>, p1: P1, p2: P2, token?: CancellationToken): Promise<R>;
213     sendRequest<P1, P2, P3, R, E>(type: RequestType3<P1, P2, P3, R, E>, p1: P1, p2: P2, p3: P3, token?: CancellationToken): Promise<R>;
214     sendRequest<P1, P2, P3, P4, R, E>(type: RequestType4<P1, P2, P3, P4, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, token?: CancellationToken): Promise<R>;
215     sendRequest<P1, P2, P3, P4, P5, R, E>(type: RequestType5<P1, P2, P3, P4, P5, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, token?: CancellationToken): Promise<R>;
216     sendRequest<P1, P2, P3, P4, P5, P6, R, E>(type: RequestType6<P1, P2, P3, P4, P5, P6, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, token?: CancellationToken): Promise<R>;
217     sendRequest<P1, P2, P3, P4, P5, P6, P7, R, E>(type: RequestType7<P1, P2, P3, P4, P5, P6, P7, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, token?: CancellationToken): Promise<R>;
218     sendRequest<P1, P2, P3, P4, P5, P6, P7, P8, R, E>(type: RequestType8<P1, P2, P3, P4, P5, P6, P7, P8, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, token?: CancellationToken): Promise<R>;
219     sendRequest<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>(type: RequestType9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, token?: CancellationToken): Promise<R>;
220     sendRequest<R>(method: string, r0?: ParameterStructures | any, ...rest: any[]): Promise<R>;
221     onRequest<R, E>(type: RequestType0<R, E>, handler: RequestHandler0<R, E>): Disposable;
222     onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): Disposable;
223     onRequest<P1, R, E>(type: RequestType1<P1, R, E>, handler: RequestHandler1<P1, R, E>): Disposable;
224     onRequest<P1, P2, R, E>(type: RequestType2<P1, P2, R, E>, handler: RequestHandler2<P1, P2, R, E>): Disposable;
225     onRequest<P1, P2, P3, R, E>(type: RequestType3<P1, P2, P3, R, E>, handler: RequestHandler3<P1, P2, P3, R, E>): Disposable;
226     onRequest<P1, P2, P3, P4, R, E>(type: RequestType4<P1, P2, P3, P4, R, E>, handler: RequestHandler4<P1, P2, P3, P4, R, E>): Disposable;
227     onRequest<P1, P2, P3, P4, P5, R, E>(type: RequestType5<P1, P2, P3, P4, P5, R, E>, handler: RequestHandler5<P1, P2, P3, P4, P5, R, E>): Disposable;
228     onRequest<P1, P2, P3, P4, P5, P6, R, E>(type: RequestType6<P1, P2, P3, P4, P5, P6, R, E>, handler: RequestHandler6<P1, P2, P3, P4, P5, P6, R, E>): Disposable;
229     onRequest<P1, P2, P3, P4, P5, P6, P7, R, E>(type: RequestType7<P1, P2, P3, P4, P5, P6, P7, R, E>, handler: RequestHandler7<P1, P2, P3, P4, P5, P6, P7, R, E>): Disposable;
230     onRequest<P1, P2, P3, P4, P5, P6, P7, P8, R, E>(type: RequestType8<P1, P2, P3, P4, P5, P6, P7, P8, R, E>, handler: RequestHandler8<P1, P2, P3, P4, P5, P6, P7, P8, R, E>): Disposable;
231     onRequest<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>(type: RequestType9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>, handler: RequestHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>): Disposable;
232     onRequest<R, E>(method: string, handler: GenericRequestHandler<R, E>): Disposable;
233     onRequest(handler: StarRequestHandler): Disposable;
234     sendNotification(type: NotificationType0): void;
235     sendNotification<P>(type: NotificationType<P>, params?: P): void;
236     sendNotification<P1>(type: NotificationType1<P1>, p1: P1): void;
237     sendNotification<P1, P2>(type: NotificationType2<P1, P2>, p1: P1, p2: P2): void;
238     sendNotification<P1, P2, P3>(type: NotificationType3<P1, P2, P3>, p1: P1, p2: P2, p3: P3): void;
239     sendNotification<P1, P2, P3, P4>(type: NotificationType4<P1, P2, P3, P4>, p1: P1, p2: P2, p3: P3, p4: P4): void;
240     sendNotification<P1, P2, P3, P4, P5>(type: NotificationType5<P1, P2, P3, P4, P5>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): void;
241     sendNotification<P1, P2, P3, P4, P5, P6>(type: NotificationType6<P1, P2, P3, P4, P5, P6>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): void;
242     sendNotification<P1, P2, P3, P4, P5, P6, P7>(type: NotificationType7<P1, P2, P3, P4, P5, P6, P7>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): void;
243     sendNotification<P1, P2, P3, P4, P5, P6, P7, P8>(type: NotificationType8<P1, P2, P3, P4, P5, P6, P7, P8>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): void;
244     sendNotification<P1, P2, P3, P4, P5, P6, P7, P8, P9>(type: NotificationType9<P1, P2, P3, P4, P5, P6, P7, P8, P9>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): void;
245     sendNotification(method: string, r0?: ParameterStructures | any, ...rest: any[]): void;
246     onNotification(type: NotificationType0, handler: NotificationHandler0): Disposable;
247     onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): Disposable;
248     onNotification<P1>(type: NotificationType1<P1>, handler: NotificationHandler1<P1>): Disposable;
249     onNotification<P1, P2>(type: NotificationType2<P1, P2>, handler: NotificationHandler2<P1, P2>): Disposable;
250     onNotification<P1, P2, P3>(type: NotificationType3<P1, P2, P3>, handler: NotificationHandler3<P1, P2, P3>): Disposable;
251     onNotification<P1, P2, P3, P4>(type: NotificationType4<P1, P2, P3, P4>, handler: NotificationHandler4<P1, P2, P3, P4>): Disposable;
252     onNotification<P1, P2, P3, P4, P5>(type: NotificationType5<P1, P2, P3, P4, P5>, handler: NotificationHandler5<P1, P2, P3, P4, P5>): Disposable;
253     onNotification<P1, P2, P3, P4, P5, P6>(type: NotificationType6<P1, P2, P3, P4, P5, P6>, handler: NotificationHandler6<P1, P2, P3, P4, P5, P6>): Disposable;
254     onNotification<P1, P2, P3, P4, P5, P6, P7>(type: NotificationType7<P1, P2, P3, P4, P5, P6, P7>, handler: NotificationHandler7<P1, P2, P3, P4, P5, P6, P7>): Disposable;
255     onNotification<P1, P2, P3, P4, P5, P6, P7, P8>(type: NotificationType8<P1, P2, P3, P4, P5, P6, P7, P8>, handler: NotificationHandler8<P1, P2, P3, P4, P5, P6, P7, P8>): Disposable;
256     onNotification<P1, P2, P3, P4, P5, P6, P7, P8, P9>(type: NotificationType9<P1, P2, P3, P4, P5, P6, P7, P8, P9>, handler: NotificationHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9>): Disposable;
257     onNotification(method: string, handler: GenericNotificationHandler): Disposable;
258     onNotification(handler: StarNotificationHandler): Disposable;
259     onUnhandledNotification: Event<NotificationMessage>;
260     onProgress<P>(type: ProgressType<P>, token: string | number, handler: NotificationHandler<P>): Disposable;
261     sendProgress<P>(type: ProgressType<P>, token: string | number, value: P): void;
262     onUnhandledProgress: Event<ProgressParams<any>>;
263     trace(value: Trace, tracer: Tracer, sendNotification?: boolean): void;
264     trace(value: Trace, tracer: Tracer, traceOptions?: TraceOptions): void;
265     onError: Event<[Error, Message | undefined, number | undefined]>;
266     onClose: Event<void>;
267     listen(): void;
268     end(): void;
269     onDispose: Event<void>;
270     dispose(): void;
271     inspect(): void;
272 }
273 export declare function createMessageConnection(messageReader: MessageReader, messageWriter: MessageWriter, _logger?: Logger, options?: ConnectionOptions): MessageConnection;
274 export {};