How to use the vscode-jsonrpc.StreamMessageReader 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 microsoft / BotFramework-Composer / Composer / packages / tools / language-servers / language-understanding / src / extServer.ts View on Github external
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { StreamMessageReader, StreamMessageWriter } from 'vscode-jsonrpc';

import { start } from './LUServer';

const reader = new StreamMessageReader(process.stdin);
const writer = new StreamMessageWriter(process.stdout);
start(reader, writer);
github ballerina-platform / ballerina-lang / composer / lang-service / src / server.ts View on Github external
function createLSConnection(ballerinaHome: string) : LangServerProcessConnection {
    const childProcess = createServer(ballerinaHome);
    childProcess.on('error', (err) => {
        // log('Error while starting LS', err);
    });
    const reader = new StreamMessageReader(childProcess.stdout);
    const writer = new StreamMessageWriter(childProcess.stdin);
    const messageConntection = createMessageConnection(reader, writer);
    const errorHandler: ConnectionErrorHandler = (err, msg, count) => {
       // log('Error while starting LS', err);
    };
    const closeHandler: ConnectionCloseHandler = () => {
       // log('LS Connection closed');
    };
    const lsConnection = createConnection(messageConntection, errorHandler, closeHandler);
    return {
        childProcess,
        lsConnection
    }
}
github onivim / oni / browser / src / Plugins / Api / LanguageClient / LanguageClient.ts View on Github external
this._process.on("close", (code: number, signal: string) => {
            Log.warn(`[LANGUAGE CLIENT]: Process closed with exit code ${code} and signal ${signal}`)
        })

        const logFunc = (msg: any) => {
            Log.debug(`[LANGUAGE CLIENT - DEBUG] ${msg}`)
        }
        const errFunc = (msg: any) => {
            Log.error(`[LANGUAGE CLIENT - ERROR]: ${msg}`)
            this._statusBar.setStatus(LanguageClientState.Error)
        }
        this._process.stderr.on("data", (this._startOptions.stderrAsLog) ? logFunc : errFunc)

        this._connection = rpc.createMessageConnection(
            (new rpc.StreamMessageReader(this._process.stdout)) as any,
            (new rpc.StreamMessageWriter(this._process.stdin)) as any,
            new LanguageClientLogger())

        this._currentOpenDocumentPath = null
        this._serverCapabilities = null

        this._connection.onNotification(Helpers.ProtocolConstants.Window.LogMessage, (args) => {
            Log.info(JSON.stringify(args))
        })

        this._connection.onNotification(Helpers.ProtocolConstants.Telemetry.Event, (args) => {
            Log.info(JSON.stringify(args))
        })

        this._connection.onNotification(Helpers.ProtocolConstants.Window.ShowMessage, (args) => {
            // TODO: Need alternate paradigm for showing a message
github gfrancischini / vscode-unit-test / src / mochaTestLanguageServer / mochaServer.ts View on Github external
this.testCases.push(...discoveryTestCases);
            })

            findDuplicatesTestCases(discoveryTestCases);

            return {
                testCases: discoveryTestCases
            }
        });

    }
}


const mochaLanguageServer = new MochaTestLanguageServer();
mochaLanguageServer.listen(new StreamMessageReader(process.stdin),
    new StreamMessageWriter(process.stdout));

/**
 * Override default console.log to redirect output from user test cases to the appropriate channel
 */
console.log = function (data: string) {
    mochaLanguageServer.getConnection().dataOutput({ data });
};

/**
 * Find all duplicate test cases and log the information
 * @param testCases
 */
function findDuplicatesTestCases(testCases : Array) {
    const fullTitles = testCases.map((testCase) => {return testCase.fullTitle});
github danr / kakoune-languageclient / src / main.ts View on Github external
process.exit(1)
}

const kak = Kak.Init(Splice, {
  session,
  debug,
})

console.log('spawning')
const child = cp.spawn(server, args, {
  detached: true,
  stdio: 'pipe',
})

const connection = rpc.createMessageConnection(
  new rpc.StreamMessageReader(child.stdout),
  new rpc.StreamMessageWriter(child.stdin)
)

console.log('running')

function OnNotification(
  type: lsp.NotificationType,
  handler: lsp.NotificationHandler<p>
): void {
  return connection.onNotification(type, handler)
}

OnNotification(lsp.ShowMessageNotification.type, params =&gt; {
  if (debug_connection) {
    console.group('notification', params.type)
    console.log(params.message)</p>
github graphql / graphiql / packages / graphql-language-service-server / src / startServer.ts View on Github external
.createServer(client => {
            client.setEncoding('utf8');
            reader = new SocketMessageReader(client);
            writer = new SocketMessageWriter(client);
            client.on('end', () => {
              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 eclipse-theia / theia / packages / plugin-ext / src / plugin / languages-contribution-ext.ts View on Github external
export function createConnection(childProcess: ChildProcess): Connection {
    const reader = new StreamMessageReader(childProcess.stdout);
    const writer = new StreamMessageWriter(childProcess.stdin);
    return {
        reader, writer,
        forward(to: Connection, map: (message: Message) => Message = message => message): void {
            reader.listen(input => {
                const output = map(input);
                to.writer.write(output);
            });
        },
        dispose: () => {
            childProcess.kill();
            reader.dispose();
            writer.dispose();
        }
    };
}
github anzwdev / al-code-outline / src / langserver / toolsLangServerClient.ts View on Github external
protected initialize() {
        try {
            //find binaries path
            let langServerPath : string = this._context.asAbsolutePath("bin/AZALDevToolsServer.exe");
            //start child process
            this._childProcess = cp.spawn(langServerPath, [this._alExtensionPath]);
            if (this._childProcess) {
                this._connection = rpc.createMessageConnection(
                    new rpc.StreamMessageReader(this._childProcess.stdout),
                    new rpc.StreamMessageWriter(this._childProcess.stdin));
                this._connection.listen();
            }
        }
        catch (e) {
        }
    }