MCPcopy Index your code
hub / github.com/microsoft/vscode-languageserver-node / _createConnection

Function _createConnection

server/src/main.ts:1495–1728  ·  view source on GitHub ↗
(
	input?: NodeJS.ReadableStream | MessageReader, output?: NodeJS.WritableStream | MessageWriter, strategy?: ConnectionStrategy,
	factories?: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace>
)

Source from the content-addressed store, hash-verified

1493}
1494
1495function _createConnection<PConsole = _, PTracer = _, PTelemetry = _, PClient = _, PWindow = _, PWorkspace = _>(
1496 input?: NodeJS.ReadableStream | MessageReader, output?: NodeJS.WritableStream | MessageWriter, strategy?: ConnectionStrategy,
1497 factories?: Features<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace>
1498): Connection<PConsole, PTracer, PTelemetry, PClient, PWindow, PWorkspace> {
1499 if (!input && !output && process.argv.length > 2) {
1500 let port: number | undefined = void 0;
1501 let pipeName: string | undefined = void 0;
1502 let argv = process.argv.slice(2);
1503 for (let i = 0; i < argv.length; i++) {
1504 let arg = argv[i];
1505 if (arg === '--node-ipc') {
1506 input = new IPCMessageReader(process);
1507 output = new IPCMessageWriter(process);
1508 break;
1509 } else if (arg === '--stdio') {
1510 input = process.stdin;
1511 output = process.stdout;
1512 break;
1513 } else if (arg === '--socket') {
1514 port = parseInt(argv[i + 1]);
1515 break;
1516 } else if (arg === '--pipe') {
1517 pipeName = argv[i + 1];
1518 break;
1519 }
1520 else {
1521 var args = arg.split('=');
1522 if (args[0] === '--socket') {
1523 port = parseInt(args[1]);
1524 break;
1525 } else if (args[0] === '--pipe') {
1526 pipeName = args[1];
1527 break;
1528 }
1529 }
1530 }
1531 if (port) {
1532 let transport = createServerSocketTransport(port);
1533 input = transport[0];
1534 output = transport[1];
1535 } else if (pipeName) {
1536 let transport = createServerPipeTransport(pipeName);
1537 input = transport[0];
1538 output = transport[1];
1539 }
1540 }
1541 var commandLineMessage = "Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}'";
1542 if (!input) {
1543 throw new Error("Connection input stream is not set. " + commandLineMessage);
1544 }
1545 if (!output) {
1546 throw new Error("Connection output stream is not set. " + commandLineMessage);
1547 }
1548
1549 // Backwards compatibility
1550 if (Is.func((input as NodeJS.ReadableStream).read) && Is.func((input as NodeJS.ReadableStream).on)) {
1551 let inputStream = <NodeJS.ReadableStream>input;
1552 inputStream.on('end', () => {

Callers 1

createConnectionFunction · 0.85

Calls 15

createProtocolConnectionFunction · 0.85
asThenableFunction · 0.85
exitMethod · 0.80
rawAttachMethod · 0.80
listenMethod · 0.65
sendRequestMethod · 0.65
onRequestMethod · 0.65
sendNotificationMethod · 0.65
onNotificationMethod · 0.65
disposeMethod · 0.65

Tested by

no test coverage detected