2 * A language server message
4 export interface Message {
10 export interface RequestMessage extends Message {
14 id: number | string | null;
16 * The method to be invoked.
20 * The method's params.
22 params?: any[] | object;
25 * Predefined error codes.
27 export declare namespace ErrorCodes {
28 const ParseError: number;
29 const InvalidRequest: number;
30 const MethodNotFound: number;
31 const InvalidParams: number;
32 const InternalError: number;
34 * This is the start range of JSON RPC reserved error codes.
35 * It doesn't denote a real error code. No application error codes should
36 * be defined between the start and end range. For backwards
37 * compatibility the `ServerNotInitialized` and the `UnknownErrorCode`
38 * are left in the range.
42 const jsonrpcReservedErrorRangeStart: number;
43 /** @deprecated use jsonrpcReservedErrorRangeStart */
44 const serverErrorStart: number;
45 const MessageWriteError: number;
46 const MessageReadError: number;
47 const ServerNotInitialized: number;
48 const UnknownErrorCode: number;
50 * This is the end range of JSON RPC reserved error codes.
51 * It doesn't denote a real error code.
55 const jsonrpcReservedErrorRangeEnd = -32000;
56 /** @deprecated use jsonrpcReservedErrorRangeEnd */
57 const serverErrorEnd: number;
59 export interface ResponseErrorLiteral<D> {
61 * A number indicating the error type that occured.
65 * A string providing a short decription of the error.
69 * A Primitive or Structured value that contains additional
70 * information about the error. Can be omitted.
75 * An error object return in a response in case a request
78 export declare class ResponseError<D> extends Error {
79 readonly code: number;
80 readonly data: D | undefined;
81 constructor(code: number, message: string, data?: D);
82 toJson(): ResponseErrorLiteral<D>;
87 export interface ResponseMessage extends Message {
91 id: number | string | null;
93 * The result of a request. This member is REQUIRED on success.
94 * This member MUST NOT exist if there was an error invoking the method.
96 result?: string | number | boolean | object | any[] | null;
98 * The error object in case a request fails.
100 error?: ResponseErrorLiteral<any>;
105 export declare type LSPMessageType = 'send-request' | 'receive-request' | 'send-response' | 'receive-response' | 'send-notification' | 'receive-notification';
106 export interface LSPLogMessage {
107 type: LSPMessageType;
108 message: RequestMessage | ResponseMessage | NotificationMessage;
111 export declare class ParameterStructures {
112 private readonly kind;
114 * The parameter structure is automatically inferred on the number of parameters
115 * and the parameter type in case of a single param.
117 static readonly auto: ParameterStructures;
119 * Forces `byPosition` parameter structure. This is useful if you have a single
120 * parameter which has a literal type.
122 static readonly byPosition: ParameterStructures;
124 * Forces `byName` parameter structure. This is only useful when having a single
125 * parameter. The library will report errors if used with a different number of
128 static readonly byName: ParameterStructures;
129 private constructor();
130 static is(value: any): value is ParameterStructures;
134 * An interface to type messages.
136 export interface MessageSignature {
137 readonly method: string;
138 readonly numberOfParams: number;
139 readonly parameterStructures: ParameterStructures;
142 * An abstract implementation of a MessageType.
144 export declare abstract class AbstractMessageSignature implements MessageSignature {
145 readonly method: string;
146 readonly numberOfParams: number;
147 constructor(method: string, numberOfParams: number);
148 get parameterStructures(): ParameterStructures;
151 * End marker interface for request and notification types.
153 export interface _EM {
154 _$endMarker$_: number;
157 * Classes to type request response pairs
159 export declare class RequestType0<R, E> extends AbstractMessageSignature {
161 * Clients must not use this property. It is here to ensure correct typing.
163 readonly _: [R, E, _EM] | undefined;
164 constructor(method: string);
166 export declare class RequestType<P, R, E> extends AbstractMessageSignature {
167 private _parameterStructures;
169 * Clients must not use this property. It is here to ensure correct typing.
171 readonly _: [P, R, E, _EM] | undefined;
172 constructor(method: string, _parameterStructures?: ParameterStructures);
173 get parameterStructures(): ParameterStructures;
175 export declare class RequestType1<P1, R, E> extends AbstractMessageSignature {
176 private _parameterStructures;
178 * Clients must not use this property. It is here to ensure correct typing.
180 readonly _: [P1, R, E, _EM] | undefined;
181 constructor(method: string, _parameterStructures?: ParameterStructures);
182 get parameterStructures(): ParameterStructures;
184 export declare class RequestType2<P1, P2, R, E> extends AbstractMessageSignature {
186 * Clients must not use this property. It is here to ensure correct typing.
188 readonly _: [P1, P2, R, E, _EM] | undefined;
189 constructor(method: string);
191 export declare class RequestType3<P1, P2, P3, R, E> extends AbstractMessageSignature {
193 * Clients must not use this property. It is here to ensure correct typing.
195 readonly _: [P1, P2, P3, R, E, _EM] | undefined;
196 constructor(method: string);
198 export declare class RequestType4<P1, P2, P3, P4, R, E> extends AbstractMessageSignature {
200 * Clients must not use this property. It is here to ensure correct typing.
202 readonly _: [P1, P2, P3, P4, R, E, _EM] | undefined;
203 constructor(method: string);
205 export declare class RequestType5<P1, P2, P3, P4, P5, R, E> extends AbstractMessageSignature {
207 * Clients must not use this property. It is here to ensure correct typing.
209 readonly _: [P1, P2, P3, P4, P5, R, E, _EM] | undefined;
210 constructor(method: string);
212 export declare class RequestType6<P1, P2, P3, P4, P5, P6, R, E> extends AbstractMessageSignature {
214 * Clients must not use this property. It is here to ensure correct typing.
216 readonly _: [P1, P2, P3, P4, P5, P6, R, E, _EM] | undefined;
217 constructor(method: string);
219 export declare class RequestType7<P1, P2, P3, P4, P5, P6, P7, R, E> extends AbstractMessageSignature {
221 * Clients must not use this property. It is here to ensure correct typing.
223 readonly _: [P1, P2, P3, P4, P5, P6, P7, R, E, _EM] | undefined;
224 constructor(method: string);
226 export declare class RequestType8<P1, P2, P3, P4, P5, P6, P7, P8, R, E> extends AbstractMessageSignature {
228 * Clients must not use this property. It is here to ensure correct typing.
230 readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, R, E, _EM] | undefined;
231 constructor(method: string);
233 export declare class RequestType9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E> extends AbstractMessageSignature {
235 * Clients must not use this property. It is here to ensure correct typing.
237 readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E, _EM] | undefined;
238 constructor(method: string);
241 * Notification Message
243 export interface NotificationMessage extends Message {
245 * The method to be invoked.
249 * The notification's params.
251 params?: [] | object;
253 export declare class NotificationType<P> extends AbstractMessageSignature {
254 private _parameterStructures;
256 * Clients must not use this property. It is here to ensure correct typing.
258 readonly _: [P, _EM] | undefined;
259 constructor(method: string, _parameterStructures?: ParameterStructures);
260 get parameterStructures(): ParameterStructures;
262 export declare class NotificationType0 extends AbstractMessageSignature {
264 * Clients must not use this property. It is here to ensure correct typing.
266 readonly _: [_EM] | undefined;
267 constructor(method: string);
269 export declare class NotificationType1<P1> extends AbstractMessageSignature {
270 private _parameterStructures;
272 * Clients must not use this property. It is here to ensure correct typing.
274 readonly _: [P1, _EM] | undefined;
275 constructor(method: string, _parameterStructures?: ParameterStructures);
276 get parameterStructures(): ParameterStructures;
278 export declare class NotificationType2<P1, P2> extends AbstractMessageSignature {
280 * Clients must not use this property. It is here to ensure correct typing.
282 readonly _: [P1, P2, _EM] | undefined;
283 constructor(method: string);
285 export declare class NotificationType3<P1, P2, P3> extends AbstractMessageSignature {
287 * Clients must not use this property. It is here to ensure correct typing.
289 readonly _: [P1, P2, P3, _EM] | undefined;
290 constructor(method: string);
292 export declare class NotificationType4<P1, P2, P3, P4> extends AbstractMessageSignature {
294 * Clients must not use this property. It is here to ensure correct typing.
296 readonly _: [P1, P2, P3, P4, _EM] | undefined;
297 constructor(method: string);
299 export declare class NotificationType5<P1, P2, P3, P4, P5> extends AbstractMessageSignature {
301 * Clients must not use this property. It is here to ensure correct typing.
303 readonly _: [P1, P2, P3, P4, P5, _EM] | undefined;
304 constructor(method: string);
306 export declare class NotificationType6<P1, P2, P3, P4, P5, P6> extends AbstractMessageSignature {
308 * Clients must not use this property. It is here to ensure correct typing.
310 readonly _: [P1, P2, P3, P4, P5, P6, _EM] | undefined;
311 constructor(method: string);
313 export declare class NotificationType7<P1, P2, P3, P4, P5, P6, P7> extends AbstractMessageSignature {
315 * Clients must not use this property. It is here to ensure correct typing.
317 readonly _: [P1, P2, P3, P4, P5, P6, P7, _EM] | undefined;
318 constructor(method: string);
320 export declare class NotificationType8<P1, P2, P3, P4, P5, P6, P7, P8> extends AbstractMessageSignature {
322 * Clients must not use this property. It is here to ensure correct typing.
324 readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, _EM] | undefined;
325 constructor(method: string);
327 export declare class NotificationType9<P1, P2, P3, P4, P5, P6, P7, P8, P9> extends AbstractMessageSignature {
329 * Clients must not use this property. It is here to ensure correct typing.
331 readonly _: [P1, P2, P3, P4, P5, P6, P7, P8, P9, _EM] | undefined;
332 constructor(method: string);
335 * Tests if the given message is a request message
337 export declare function isRequestMessage(message: Message | undefined): message is RequestMessage;
339 * Tests if the given message is a notification message
341 export declare function isNotificationMessage(message: Message | undefined): message is NotificationMessage;
343 * Tests if the given message is a response message
345 export declare function isResponseMessage(message: Message | undefined): message is ResponseMessage;