Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
70 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import { StreamMessageReader, StreamMessageWriter } from 'vscode-jsonrpc'; | ||
import { start } from "./json-server"; | ||
|
||
const reader = new StreamMessageReader(process.stdin); | ||
const writer = new StreamMessageWriter(process.stdout); | ||
start(reader, writer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io). All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import * as path from 'path'; | ||
import { SocketMessageReader, SocketMessageWriter, Socket } from "vscode-ws-jsonrpc"; | ||
import { isRequestMessage } from "vscode-jsonrpc/lib/messages"; | ||
import { createServerProcess, forward, createConnection as createSocketConnection } from "vscode-ws-jsonrpc/lib/server"; | ||
import { InitializeRequest, InitializeParams } from "vscode-languageserver"; | ||
import { start } from "./json-server"; | ||
|
||
export function launch(socket: Socket) { | ||
const reader = new SocketMessageReader(socket); | ||
const writer = new SocketMessageWriter(socket); | ||
const asExternalProccess = process.argv.findIndex(value => value === '--external'); | ||
if (asExternalProccess) { | ||
const extJsonServerPath = path.resolve(__dirname, 'ext-json-server.js'); | ||
const socketConnection = createSocketConnection(reader, writer, () => socket.dispose()); | ||
const serverConnection = createServerProcess('JSON', 'node', [extJsonServerPath]); | ||
forward(socketConnection, serverConnection, message => { | ||
if (isRequestMessage(message)) { | ||
if (message.method === InitializeRequest.type.method) { | ||
const initializeParams = message.params as InitializeParams; | ||
initializeParams.processId = process.pid; | ||
} | ||
} | ||
return message; | ||
}); | ||
} else { | ||
start(reader, writer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters