How to use the vscode-jsonrpc.IPCMessageReader function in vscode-jsonrpc

To help you get started, we’ve selected a few vscode-jsonrpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / core / src / node / messaging / ipc-bootstrap.ts View on Github external
* Licenses when the conditions for such availability set forth in the Eclipse
 * Public License v. 2.0 are satisfied: GNU General Public License, version 2
 * with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 ********************************************************************************/

import 'reflect-metadata';
import { ConsoleLogger } from 'vscode-ws-jsonrpc/lib/logger';
import { createMessageConnection, IPCMessageReader, IPCMessageWriter, Trace } from 'vscode-jsonrpc';
import { checkParentAlive, ipcEntryPoint, IPCEntryPoint } from './ipc-protocol';

checkParentAlive();

const reader = new IPCMessageReader(process);
const writer = new IPCMessageWriter(process);
const logger = new ConsoleLogger();
const connection = createMessageConnection(reader, writer, logger);
connection.trace(Trace.Off, {
    // tslint:disable-next-line:no-any
    log: (message: any, data?: string) => console.log(message, data)
});

const entryPoint = require(ipcEntryPoint!).default as IPCEntryPoint;
entryPoint(connection);
github chemzqm / wxml-languageserver / src / utils / connectionFromOptions.ts View on Github external
case 'socket':
      // For socket connection, the message connection needs to be
      // established before the server socket starts listening.
      // Do that, and return at the end of this block.
      writer = new stream.PassThrough()
      reader = new stream.PassThrough()
      let server = net
        .createServer(socket => {
          server.close()
          socket.pipe(reader)
          writer.pipe(socket)
        })
        .listen(options.port)
      break
    case 'node-ipc':
      reader = new IPCMessageReader(process)
      writer = new IPCMessageWriter(process)
      break
    case 'stdio':
    default:
      reader = process.stdin
      writer = process.stdout
      break
  }

  return createConnection(reader, writer)
}
github eclipse-theia / theia / packages / core / src / node / messaging / ipc-connection-provider.ts View on Github external
protected createConnection(childProcess: cp.ChildProcess, options: ResolvedIPCConnectionOptions): MessageConnection {
        const reader = new IPCMessageReader(childProcess);
        const writer = new IPCMessageWriter(childProcess);
        const connection = createMessageConnection(reader, writer, {
            error: (message: string) => this.logger.error(`[${options.serverName}: ${childProcess.pid}] ${message}`),
            warn: (message: string) => this.logger.warn(`[${options.serverName}: ${childProcess.pid}] ${message}`),
            info: (message: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}`),
            log: (message: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}`)
        });
        connection.trace(Trace.Off, {
            // tslint:disable-next-line:no-any
            log: (message: any, data?: string) => this.logger.info(`[${options.serverName}: ${childProcess.pid}] ${message}` + (typeof data === 'string' ? ' ' + data : ''))
        });
        return connection;
    }
github stardog-union / stardog-language-servers / utils / testUtils.ts View on Github external
it('performs LSP initialization via IPC', (done) => {
      cp = spawn(
        'ts-node',
        [
          '--compilerOptions',
          JSON.stringify({ module: 'commonjs' }),
          pathToServer,
          '--node-ipc',
        ],
        {
          stdio: [null, null, null, 'ipc'],
        }
      );
      const connection = createProtocolConnection(
        new IPCMessageReader(cp),
        new IPCMessageWriter(cp),
        null
      );
      testInitHandshake(connection, done);
    });
    it('performs LSP initialization via socket', async (done) => {
github graphql / graphiql / packages / graphql-language-service-server / src / startServer.ts View on Github external
socket.close();
              process.exit(0);
            });
            const connection = createMessageConnection(reader, writer, logger);
            addHandlers(connection, logger, options.configDir);
            connection.listen();
          })
          .listen(port);
        return;
      case 'stream':
        reader = new StreamMessageReader(process.stdin);
        writer = new StreamMessageWriter(process.stdout);
        break;
      case 'node':
      default:
        reader = new IPCMessageReader(process);
        writer = new IPCMessageWriter(process);
        break;
    }
    const connection = createMessageConnection(reader, writer, logger);
    addHandlers(connection, logger, options.configDir);
    connection.listen();
  }
});
github stardog-union / stardog-language-servers / packages / stardog-language-utils / src / cli.ts View on Github external
[LspTransportMethod.IPC]: () =>
    createConnection(
      new IPCMessageReader(process),
      new IPCMessageWriter(process)
    ),
  [LspTransportMethod.STDIO]: () =>
github atom / atom-languageclient / lib / auto-languageclient.ts View on Github external
private createRpcConnection(process: LanguageServerProcess): rpc.MessageConnection {
    let reader: rpc.MessageReader;
    let writer: rpc.MessageWriter;
    const connectionType = this.getConnectionType();
    switch (connectionType) {
      case 'ipc':
        reader = new rpc.IPCMessageReader(process as cp.ChildProcess);
        writer = new rpc.IPCMessageWriter(process as cp.ChildProcess);
        break;
      case 'socket':
        reader = new rpc.SocketMessageReader(this.socket);
        writer = new rpc.SocketMessageWriter(this.socket);
        break;
      case 'stdio':
        reader = new rpc.StreamMessageReader(process.stdout);
        writer = new rpc.StreamMessageWriter(process.stdin);
        break;
      default:
        return Utils.assertUnreachable(connectionType);
    }

    return rpc.createMessageConnection(reader, writer, {
      log: (..._args: any[]) => { },
github facebookarchive / flow-language-server / packages / flow-language-server / src / utils / connectionFromOptions.js View on Github external
reader = new stream.PassThrough();
      server = net
        .createServer(socket => {
          server.close();
          socket.pipe(writer);
          reader.pipe(socket);
        })
        .listen(options.port);
      break;
    case 'stdio':
      reader = process.stdin;
      writer = process.stdout;
      break;
    case 'node-ipc':
    default:
      reader = new IPCMessageReader(process);
      writer = new IPCMessageWriter(process);
      break;
  }

  return createConnection(reader, writer);
}
github yitzchak / dicy / packages / client / src / Client.ts View on Github external
createTransport (): [rpc.MessageReader, rpc.MessageWriter] {
    const serverPath = require.resolve('@dicy/server')

    this.server = cp.fork(serverPath, ['--node-ipc'])

    this.server.on('exit', () => {
      delete this.server
      delete this.connection
    })

    return [new rpc.IPCMessageReader(this.server), new rpc.IPCMessageWriter(this.server)]
  }