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'; import { ProtocolRequestType, ProtocolRequestType0, ProtocolNotificationType, ProtocolNotificationType0 } from './messages'; export interface ProtocolConnection { /** * Sends a request and returns a promise resolving to the result of the request. * * @param type The type of request to sent. * @param token An optional cancellation token. * @returns A promise resolving to the request's result. */ sendRequest(type: ProtocolRequestType0, token?: CancellationToken): Promise; sendRequest(type: RequestType0, token?: CancellationToken): Promise; /** * Sends a request and returns a promise resolving to the result of the request. * * @param type The type of request to sent. * @param params The request's parameter. * @param token An optional cancellation token. * @returns A promise resolving to the request's result. */ sendRequest(type: ProtocolRequestType, params: P, token?: CancellationToken): Promise; sendRequest(type: RequestType, params: P, token?: CancellationToken): Promise; /** * Sends a request and returns a promise resolving to the result of the request. * * @param method the method name. * @param token An optional cancellation token. * @returns A promise resolving to the request's result. */ sendRequest(method: string, token?: CancellationToken): Promise; /** * Sends a request and returns a promise resolving to the result of the request. * * @param method the method name. * @param params The request's parameter. * @param token An optional cancellation token. * @returns A promise resolving to the request's result. */ sendRequest(method: string, param: any, token?: CancellationToken): Promise; /** * Installs a request handler. * * @param type The request type to install the handler for. * @param handler The actual handler. * @returns A disposable to remove the handler. */ onRequest(type: ProtocolRequestType0, handler: RequestHandler0): Disposable; onRequest(type: RequestType0, handler: RequestHandler0): Disposable; /** * Installs a request handler. * * @param type The request type to install the handler for. * @param handler The actual handler. * @returns A disposable to remove the handler. */ onRequest(type: ProtocolRequestType, handler: RequestHandler): Disposable; onRequest(type: RequestType, handler: RequestHandler): Disposable; /** * Installs a request handler. * * @param methods the message method name to install a handler for. * @param handler The actual handler. * @returns A disposable to remove the handler. */ onRequest(method: string, handler: GenericRequestHandler): Disposable; /** * Returns true if the connection has a pending response. * Otherwise false is returned. */ hasPendingResponse(): boolean; /** * Sends a notification. * * @param type the notification's type to send. * @returns A promise that resolves when the notification is written to the * network layer. */ sendNotification(type: NotificationType0): Promise; sendNotification(type: ProtocolNotificationType0): Promise; /** * Sends a notification. * * @param type the notification's type to send. * @param params the notification's parameters. * @returns A promise that resolves when the notification is written to the * network layer. */ sendNotification(type: ProtocolNotificationType, params?: P): Promise; sendNotification

(type: NotificationType

, params?: P): Promise; /** * Sends a notification. * * @param method the notification's method name. * @returns A promise that resolves when the notification is written to the * network layer. */ sendNotification(method: string): Promise; /** * Sends a notification. * * @param method the notification's method name. * @param params the notification's parameters. * @returns A promise that resolves when the notification is written to the * network layer. */ sendNotification(method: string, params: any): Promise; /** * Installs a notification handler. * * @param type The notification type to install the handler for. * @param handler The actual handler. * @returns A disposable to remove the handler. */ onNotification(type: ProtocolNotificationType0, handler: NotificationHandler0): Disposable; onNotification(type: NotificationType0, handler: NotificationHandler0): Disposable; /** * Installs a notification handler. * * @param type The notification type to install the handler for. * @param handler The actual handler. * @returns A disposable to remove the handler. */ onNotification(type: ProtocolNotificationType, handler: NotificationHandler

): Disposable; onNotification

(type: NotificationType

, handler: NotificationHandler

): Disposable; /** * Installs a notification handler. * * @param methods The message method name to install the handler for. * @param handler The actual handler. * @returns A disposable to remove the handler. */ onNotification(method: string, handler: GenericNotificationHandler): Disposable; /** * Installs a progress handler for a given token. * @param type the progress type * @param token the token * @param handler the handler * @returns A disposable to remove the handler. */ onProgress

(type: ProgressType

, token: string | number, handler: NotificationHandler

): Disposable; /** * Sends progress. * @param type the progress type * @param token the token to use * @param value the progress value * @returns A promise that resolves when the progress is written to the * network layer. */ sendProgress

(type: ProgressType

, token: string | number, value: P): Promise; /** * Enables tracing mode for the connection. * @returns A promise that resolves when the trace value is written to the * network layer. */ trace(value: Trace, tracer: Tracer, sendNotification?: boolean): Promise; trace(value: Trace, tracer: Tracer, traceOptions?: TraceOptions): Promise; /** * An event emitter firing when an error occurs on the connection. */ onError: Event<[Error, Message | undefined, number | undefined]>; /** * An event emitter firing when the connection got closed. */ onClose: Event; /** * An event emitter firing when the connection receives a notification that is not * handled. */ onUnhandledNotification: Event; /** * An event emitter firing when the connection got disposed. */ onDispose: Event; /** * Ends the connection. */ end(): void; /** * Actively disposes the connection. */ dispose(): void; /** * Turns the connection into listening mode */ listen(): void; } export declare function createProtocolConnection(input: MessageReader, output: MessageWriter, logger?: Logger, options?: ConnectionStrategy | ConnectionOptions): ProtocolConnection;