MCPcopy
hub / github.com/microsoft/vscode-languageserver-node / createConnection

Function createConnection

client/src/client.ts:149–188  ·  view source on GitHub ↗
(input: any, output: any, errorHandler: ConnectionErrorHandler, closeHandler: ConnectionCloseHandler)

Source from the content-addressed store, hash-verified

147function createConnection(inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, errorHandler: ConnectionErrorHandler, closeHandler: ConnectionCloseHandler): IConnection;
148function createConnection(reader: MessageReader, writer: MessageWriter, errorHandler: ConnectionErrorHandler, closeHandler: ConnectionCloseHandler): IConnection;
149function createConnection(input: any, output: any, errorHandler: ConnectionErrorHandler, closeHandler: ConnectionCloseHandler): IConnection {
150 let logger = new ConsoleLogger();
151 let connection = createProtocolConnection(input, output, logger);
152 connection.onError((data) => { errorHandler(data[0], data[1], data[2]) });
153 connection.onClose(closeHandler);
154 let result: IConnection = {
155
156 listen: (): void => connection.listen(),
157
158 sendRequest: <R>(type: string | RPCMessageType, ...params: any[]): Thenable<R> => connection.sendRequest(Is.string(type) ? type : type.method, ...params),
159 onRequest: <R, E>(type: string | RPCMessageType, handler: GenericRequestHandler<R, E>): void => connection.onRequest(Is.string(type) ? type : type.method, handler),
160
161 sendNotification: (type: string | RPCMessageType, params?: any): void => connection.sendNotification(Is.string(type) ? type : type.method, params),
162 onNotification: (type: string | RPCMessageType, handler: GenericNotificationHandler): void => connection.onNotification(Is.string(type) ? type : type.method, handler),
163
164 trace: (value: Trace, tracer: Tracer, sendNotification: boolean = false): void => connection.trace(value, tracer, sendNotification),
165
166 initialize: (params: InitializeParams) => connection.sendRequest(InitializeRequest.type, params),
167 shutdown: () => connection.sendRequest(ShutdownRequest.type, undefined),
168 exit: () => connection.sendNotification(ExitNotification.type),
169
170 onLogMessage: (handler: NotificationHandler<LogMessageParams>) => connection.onNotification(LogMessageNotification.type, handler),
171 onShowMessage: (handler: NotificationHandler<ShowMessageParams>) => connection.onNotification(ShowMessageNotification.type, handler),
172 onTelemetry: (handler: NotificationHandler<any>) => connection.onNotification(TelemetryEventNotification.type, handler),
173
174 didChangeConfiguration: (params: DidChangeConfigurationParams) => connection.sendNotification(DidChangeConfigurationNotification.type, params),
175 didChangeWatchedFiles: (params: DidChangeWatchedFilesParams) => connection.sendNotification(DidChangeWatchedFilesNotification.type, params),
176
177 didOpenTextDocument: (params: DidOpenTextDocumentParams) => connection.sendNotification(DidOpenTextDocumentNotification.type, params),
178 didChangeTextDocument: (params: DidChangeTextDocumentParams) => connection.sendNotification(DidChangeTextDocumentNotification.type, params),
179 didCloseTextDocument: (params: DidCloseTextDocumentParams) => connection.sendNotification(DidCloseTextDocumentNotification.type, params),
180 didSaveTextDocument: (params: DidSaveTextDocumentParams) => connection.sendNotification(DidSaveTextDocumentNotification.type, params),
181
182 onDiagnostics: (handler: NotificationHandler<PublishDiagnosticsParams>) => connection.onNotification(PublishDiagnosticsNotification.type, handler),
183
184 dispose: () => connection.dispose()
185 }
186
187 return result;
188}
189
190export interface ExecutableOptions {
191 cwd?: string;

Callers

nothing calls this directly

Calls 10

createProtocolConnectionFunction · 0.85
errorHandlerFunction · 0.85
listenMethod · 0.65
sendRequestMethod · 0.65
onRequestMethod · 0.65
sendNotificationMethod · 0.65
onNotificationMethod · 0.65
traceMethod · 0.65
disposeMethod · 0.65

Tested by

no test coverage detected