1 |
|
2 |
|
3 |
|
4 | export interface Message {
|
5 | jsonrpc: string;
|
6 | }
|
7 |
|
8 |
|
9 |
|
10 | export interface RequestMessage extends Message {
|
11 | |
12 |
|
13 |
|
14 | id: number | string | null;
|
15 | |
16 |
|
17 |
|
18 | method: string;
|
19 | |
20 |
|
21 |
|
22 | params?: any[] | object;
|
23 | }
|
24 |
|
25 |
|
26 |
|
27 | export declare namespace ErrorCodes {
|
28 | const ParseError: -32700;
|
29 | const InvalidRequest: -32600;
|
30 | const MethodNotFound: -32601;
|
31 | const InvalidParams: -32602;
|
32 | const InternalError: -32603;
|
33 | |
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | const jsonrpcReservedErrorRangeStart: -32099;
|
43 |
|
44 | const serverErrorStart: -32099;
|
45 | |
46 |
|
47 |
|
48 | const MessageWriteError: -32099;
|
49 | |
50 |
|
51 |
|
52 | const MessageReadError: -32098;
|
53 | |
54 |
|
55 |
|
56 |
|
57 | const PendingResponseRejected: -32097;
|
58 | |
59 |
|
60 |
|
61 | const ConnectionInactive: -32096;
|
62 | |
63 |
|
64 |
|
65 |
|
66 | const ServerNotInitialized: -32002;
|
67 | const UnknownErrorCode: -32001;
|
68 | |
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | const jsonrpcReservedErrorRangeEnd: -32000;
|
75 |
|
76 | const serverErrorEnd: -32000;
|
77 | }
|
78 | type integer = number;
|
79 | export type ErrorCodes = integer;
|
80 | export interface ResponseErrorLiteral<D = void> {
|
81 | |
82 |
|
83 |
|
84 | code: number;
|
85 | |
86 |
|
87 |
|
88 | message: string;
|
89 | |
90 |
|
91 |
|
92 |
|
93 | data?: D;
|
94 | }
|
95 |
|
96 |
|
97 |
|
98 |
|
99 | export declare class ResponseError<D = void> extends Error {
|
100 | readonly code: number;
|
101 | readonly data: D | undefined;
|
102 | constructor(code: number, message: string, data?: D);
|
103 | toJson(): ResponseErrorLiteral<D>;
|
104 | }
|
105 | /**
|
106 | * A response message.
|
107 | */
|
108 | export interface ResponseMessage extends Message {
|
109 | |
110 |
|
111 |
|
112 | id: number | string | null;
|
113 | |
114 |
|
115 |
|
116 |
|
117 | result?: string | number | boolean | object | any[] | null;
|
118 | |
119 |
|
120 |
|
121 | error?: ResponseErrorLiteral<any>;
|
122 | }
|
123 |
|
124 |
|
125 |
|
126 | export type LSPMessageType = 'send-request' | 'receive-request' | 'send-response' | 'receive-response' | 'send-notification' | 'receive-notification';
|
127 | export interface LSPLogMessage {
|
128 | type: LSPMessageType;
|
129 | message: RequestMessage | ResponseMessage | NotificationMessage;
|
130 | timestamp: number;
|
131 | }
|
132 | export declare class ParameterStructures {
|
133 | private readonly kind;
|
134 | |
135 |
|
136 |
|
137 |
|
138 | static readonly auto: ParameterStructures;
|
139 | |
140 |
|
141 |
|
142 |
|
143 | static readonly byPosition: ParameterStructures;
|
144 | |
145 |
|
146 |
|
147 |
|
148 |
|
149 | static readonly byName: ParameterStructures;
|
150 | private constructor();
|
151 | static is(value: any): value is ParameterStructures;
|
152 | toString(): string;
|
153 | }
|
154 | /**
|
155 | * An interface to type messages.
|
156 | */
|
157 | export interface MessageSignature {
|
158 | readonly method: string;
|
159 | readonly numberOfParams: number;
|
160 | readonly parameterStructures: ParameterStructures;
|
161 | }
|
162 |
|
163 |
|
164 |
|
165 | export declare abstract class AbstractMessageSignature implements MessageSignature {
|
166 | readonly method: string;
|
167 | readonly numberOfParams: number;
|
168 | constructor(method: string, numberOfParams: number);
|
169 | get parameterStructures(): ParameterStructures;
|
170 | }
|
171 | /**
|
172 | * End marker interface for request and notification types.
|
173 | */
|
174 | export interface _EM {
|
175 | _$endMarker$_: number;
|
176 | }
|
177 |
|
178 |
|
179 |
|
180 | export declare class RequestType0<R, E> extends AbstractMessageSignature {
|
181 | |
182 |
|
183 |
|
184 | readonly _: [R, E, _EM] | undefined;
|
185 | constructor(method: string);
|
186 | }
|
187 | export declare class RequestType<P, R, E> extends AbstractMessageSignature {
|
188 | private _parameterStructures;
|
189 | |
190 |
|
191 |
|
192 | readonly _: [P, R, E, _EM] | undefined;
|
193 | constructor(method: string, _parameterStructures?: ParameterStructures);
|
194 | get parameterStructures(): ParameterStructures;
|
195 | }
|
196 | export declare class RequestType1<P1, R, E> extends AbstractMessageSignature {
|
197 | private _parameterStructures;
|
198 | |
199 |
|
200 |
|
201 | readonly _: [P1, R, E, _EM] | undefined;
|
202 | constructor(method: string, _parameterStructures?: ParameterStructures);
|
203 | get parameterStructures(): ParameterStructures;
|
204 | }
|
205 | export declare class RequestType2<P1, P2, R, E> extends AbstractMessageSignature {
|
206 | |
207 |
|
208 |
|
209 | readonly _: [P1, P2, R, E, _EM] | undefined;
|
210 | constructor(method: string);
|
211 | }
|
212 | export declare class RequestType3<P1, P2, P3, R, E> extends AbstractMessageSignature {
|
213 | |
214 |
|
215 |
|
216 | readonly _: [P1, P2, P3, R, E, _EM] | undefined;
|
217 | constructor(method: string);
|
218 | }
|
219 | export declare class RequestType4<P1, P2, P3, P4, R, E> extends AbstractMessageSignature {
|
220 | |
221 |
|
222 |
|
223 | readonly _: [P1, P2, P3, P4, R, E, _EM] | undefined;
|
224 | constructor(method: string);
|
225 | }
|
226 | export declare class RequestType5<P1, P2, P3, P4, P5, R, E> extends AbstractMessageSignature {
|
227 | |
228 |
|
229 |
|
230 | readonly _: [P1, P2, P3, P4, P5, R, E, _EM] | undefined;
|
231 | constructor(method: string);
|
232 | }
|
233 | export declare class RequestType6<P1, P2, P3, P4, P5, P6, R, E> extends AbstractMessageSignature {
|
234 | |
235 |
|
236 |
|
237 | readonly _: [P1, P2, P3, P4, P5, P6, R, E, _EM] | undefined;
|
238 | constructor(method: string);
|
239 | }
|
240 | export declare class RequestType7<P1, P2, P3, P4, P5, P6, P7, R, E> extends AbstractMessageSignature {
|
241 | |
242 |
|
243 |
|
244 | readonly _: [P1, P2, P3, P4, P5, P6, P7, R, E, _EM] | undefined;
|
245 | constructor(method: string);
|
246 | }
|
247 | export declare class RequestType8<P1, P2, P3, P4, P5, P6, P7, P8, R, E> extends AbstractMessageSignature {
|
248 | |
249 |
|
250 |
|
251 | readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, R, E, _EM] | undefined;
|
252 | constructor(method: string);
|
253 | }
|
254 | export declare class RequestType9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E> extends AbstractMessageSignature {
|
255 | |
256 |
|
257 |
|
258 | readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E, _EM] | undefined;
|
259 | constructor(method: string);
|
260 | }
|
261 | /**
|
262 | * Notification Message
|
263 | */
|
264 | export interface NotificationMessage extends Message {
|
265 | |
266 |
|
267 |
|
268 | method: string;
|
269 | |
270 |
|
271 |
|
272 | params?: any[] | object;
|
273 | }
|
274 | export declare class NotificationType<P> extends AbstractMessageSignature {
|
275 | private _parameterStructures;
|
276 | |
277 |
|
278 |
|
279 | readonly _: [P, _EM] | undefined;
|
280 | constructor(method: string, _parameterStructures?: ParameterStructures);
|
281 | get parameterStructures(): ParameterStructures;
|
282 | }
|
283 | export declare class NotificationType0 extends AbstractMessageSignature {
|
284 | |
285 |
|
286 |
|
287 | readonly _: [_EM] | undefined;
|
288 | constructor(method: string);
|
289 | }
|
290 | export declare class NotificationType1<P1> extends AbstractMessageSignature {
|
291 | private _parameterStructures;
|
292 | |
293 |
|
294 |
|
295 | readonly _: [P1, _EM] | undefined;
|
296 | constructor(method: string, _parameterStructures?: ParameterStructures);
|
297 | get parameterStructures(): ParameterStructures;
|
298 | }
|
299 | export declare class NotificationType2<P1, P2> extends AbstractMessageSignature {
|
300 | |
301 |
|
302 |
|
303 | readonly _: [P1, P2, _EM] | undefined;
|
304 | constructor(method: string);
|
305 | }
|
306 | export declare class NotificationType3<P1, P2, P3> extends AbstractMessageSignature {
|
307 | |
308 |
|
309 |
|
310 | readonly _: [P1, P2, P3, _EM] | undefined;
|
311 | constructor(method: string);
|
312 | }
|
313 | export declare class NotificationType4<P1, P2, P3, P4> extends AbstractMessageSignature {
|
314 | |
315 |
|
316 |
|
317 | readonly _: [P1, P2, P3, P4, _EM] | undefined;
|
318 | constructor(method: string);
|
319 | }
|
320 | export declare class NotificationType5<P1, P2, P3, P4, P5> extends AbstractMessageSignature {
|
321 | |
322 |
|
323 |
|
324 | readonly _: [P1, P2, P3, P4, P5, _EM] | undefined;
|
325 | constructor(method: string);
|
326 | }
|
327 | export declare class NotificationType6<P1, P2, P3, P4, P5, P6> extends AbstractMessageSignature {
|
328 | |
329 |
|
330 |
|
331 | readonly _: [P1, P2, P3, P4, P5, P6, _EM] | undefined;
|
332 | constructor(method: string);
|
333 | }
|
334 | export declare class NotificationType7<P1, P2, P3, P4, P5, P6, P7> extends AbstractMessageSignature {
|
335 | |
336 |
|
337 |
|
338 | readonly _: [P1, P2, P3, P4, P5, P6, P7, _EM] | undefined;
|
339 | constructor(method: string);
|
340 | }
|
341 | export declare class NotificationType8<P1, P2, P3, P4, P5, P6, P7, P8> extends AbstractMessageSignature {
|
342 | |
343 |
|
344 |
|
345 | readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, _EM] | undefined;
|
346 | constructor(method: string);
|
347 | }
|
348 | export declare class NotificationType9<P1, P2, P3, P4, P5, P6, P7, P8, P9> extends AbstractMessageSignature {
|
349 | |
350 |
|
351 |
|
352 | readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, P9, _EM] | undefined;
|
353 | constructor(method: string);
|
354 | }
|
355 | export declare namespace Message {
|
356 | |
357 |
|
358 |
|
359 | function isRequest(message: Message | undefined): message is RequestMessage;
|
360 | |
361 |
|
362 |
|
363 | function isNotification(message: Message | undefined): message is NotificationMessage;
|
364 | |
365 |
|
366 |
|
367 | function isResponse(message: Message | undefined): message is ResponseMessage;
|
368 | }
|
369 | export {};
|