Skip to content

Commit

Permalink
Update to vscode-jsonrpc 8.0.2 to be compliant with client
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-fleck-at committed Dec 19, 2022
1 parent e4d1fb1 commit 82b819f
Show file tree
Hide file tree
Showing 10 changed files with 316 additions and 601 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [1.1.0 - Upcoming]()

### Changes

- [protocol] Update to vscode-jsonrpc 8.0.2 to be compliant with client [#136](https://github.com/eclipse-glsp/glsp-theia-integration/pull/136)

### Breaking Changes

- [theia] Updated Theia dependencies to `1.27.0`. Due to API breaks, Theia versions `<1.27.0` are no longer supported. [#119](https://github.com/eclipse-glsp/glsp-theia-integration/pull/119) - Contributed on behalf of STMicroelectronics <br>
Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Pod
spec:
containers:
- name: node
image: eclipseglsp/ci:alpine-v3.1
image: eclipseglsp/ci:alpine-v4.0
tty: true
resources:
limits:
Expand Down Expand Up @@ -32,7 +32,7 @@ spec:
pipeline {
agent {
kubernetes {
label 'glsp-agent-pod'
label 'glsp-theia-agent-pod'
yaml kubernetes_config
}
}
Expand Down
7 changes: 4 additions & 3 deletions configs/local-linking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function linkClient(){
yarn $1
cd ../sprotty-protocol || exit
yarn $1

cd ../vscode-jsonrpc || exit
yarn $1
}

#### MAIN Script
Expand All @@ -46,12 +47,12 @@ if [[ "$2" != "--unlink" ]]; then
# Link client
linkClient link $baseDir
cd $baseDir/glsp-theia-integration || exit
yarn link sprotty sprotty-protocol @eclipse-glsp/client @eclipse-glsp/protocol @eclipse-glsp-examples/workflow-glsp
yarn link sprotty sprotty-protocol @eclipse-glsp/client @eclipse-glsp/protocol @eclipse-glsp-examples/workflow-glsp vscode-jsonrpc
yarn install --force
echo "--- LINKING SUCCESSFULL --- "
else
echo "--- Start unlinking all previously linked packages --- "
yarn unlink sprotty sprotty-protocol @eclipse-glsp/client @eclipse-glsp/protocol @eclipse-glsp-examples/workflow-glsp
yarn unlink sprotty sprotty-protocol @eclipse-glsp/client @eclipse-glsp/protocol @eclipse-glsp-examples/workflow-glsp vscode-jsonrpc
yarn install --force
linkClient unlink $baseDir
echo "--- UNLINKING SUCCESSFULL --- "
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"engines": {
"yarn": ">=1.7.0 <2",
"node": ">=14.18.0"
"node": ">=16.11.0"
},
"scripts": {
"all": "yarn install && yarn lint",
Expand All @@ -21,7 +21,7 @@
"watch": "lerna run --parallel watch"
},
"devDependencies": {
"@eclipse-glsp/config": "1.1.0-next.d03ad9f.112",
"@eclipse-glsp/config": "1.1.0-next.e31f2e5.119",
"@types/node": "14.x",
"lerna": "^6.1.0",
"rimraf": "^3.0.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/theia-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"@eclipse-glsp/client": "next",
"@theia/core": "^1.27.0",
"@theia/messages": "^1.27.0",
"sprotty-theia": "0.12.0"
"sprotty-theia": "0.12.0",
"vscode-jsonrpc": "8.0.2"
},
"scripts": {
"build": "tsc -b",
Expand Down
18 changes: 11 additions & 7 deletions packages/theia-integration/src/browser/channel-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Channel, Disposable, DisposableCollection, Emitter, MessageProvider } from '@theia/core';
import { createMessageConnection, Logger, Message, MessageConnection } from 'vscode-jsonrpc';
import { AbstractMessageReader, DataCallback, MessageReader } from 'vscode-jsonrpc/lib/messageReader';

import { AbstractMessageWriter, MessageWriter } from 'vscode-jsonrpc/lib/messageWriter';
import {
AbstractMessageReader, AbstractMessageWriter, createMessageConnection, DataCallback, Logger, Message,
MessageConnection, MessageReader, MessageWriter
} from 'vscode-jsonrpc';

// Temporary fix/workaround to enable comparability with Theia >=1.27 until https://github.com/eclipse-theia/theia/issues/11405 is resolved

Expand Down Expand Up @@ -46,8 +46,8 @@ export class ChannelMessageReader extends AbstractMessageReader implements Messa
this.toDispose.dispose();
}

listen(callback: DataCallback): void {
this.onMessageEmitter.event(callback);
listen(callback: DataCallback): Disposable {
return this.onMessageEmitter.event(callback);
}
}

Expand All @@ -62,12 +62,16 @@ export class ChannelMessageWriter extends AbstractMessageWriter implements Messa
this.toDispose = channel.onClose(() => this.fireClose());
}

write(msg: Message): void {
async write(msg: Message): Promise<void> {
const writeBuffer = this.channel.getWriteBuffer();
writeBuffer.writeBytes(Buffer.from(JSON.stringify(msg, undefined, 0)));
writeBuffer.commit();
}

end(): void {
this.dispose();
}

override dispose(): void {
super.dispose();
this.toDispose.dispose();
Expand Down
10 changes: 8 additions & 2 deletions packages/theia-integration/src/node/connection-forwarder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Channel, Disposable, DisposableCollection, MessageProvider } from '@theia/core';
import { Message } from 'vscode-jsonrpc';
import { IConnection } from 'vscode-ws-jsonrpc/lib/server';
import { Message, MessageReader, MessageWriter } from 'vscode-jsonrpc';

export interface IConnection extends Disposable {
readonly reader: MessageReader;
readonly writer: MessageWriter;
forward(to: IConnection, map?: (message: Message) => Message): void;
onClose(callback: () => void): Disposable;
}

// Temporary fix/workaround to enable comparability with Theia >=1.27 until https://github.com/eclipse-theia/theia/issues/11405 is resolved

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import { ProcessErrorEvent } from '@theia/process/lib/node/process';
import { ProcessManager } from '@theia/process/lib/node/process-manager';
import { RawProcess, RawProcessFactory } from '@theia/process/lib/node/raw-process';
import * as cp from 'child_process';
import { IConnection } from 'vscode-ws-jsonrpc/lib/server';
import { GLSPContribution } from '../common';
import { ConnectionForwarder } from './connection-forwarder';
import { ConnectionForwarder, IConnection } from './connection-forwarder';

export const GLSPServerContribution = Symbol.for('GLSPServerContribution');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { injectable, postConstruct } from '@theia/core/shared/inversify';
import { RawProcess } from '@theia/process/lib/node/raw-process';
import * as fs from 'fs';
import * as net from 'net';
import { createSocketConnection } from 'vscode-ws-jsonrpc/lib/server';
import { BaseGLSPServerContribution, GLSPServerContributionOptions } from './glsp-server-contribution';

/**
Expand Down Expand Up @@ -157,14 +156,16 @@ export abstract class GLSPSocketServerContribution extends BaseGLSPServerContrib
}
}

protected connectToSocketServer(clientChannel: Channel): void {
protected async connectToSocketServer(clientChannel: Channel): Promise<void> {
if (isNaN(this.options.socketConnectionOptions.port)) {
throw new Error(
// eslint-disable-next-line max-len
`Could not connect to to GLSP Server. The given server port is not a number: ${this.options.socketConnectionOptions.port}`
);
}
const socket = new net.Socket();
// eslint-disable-next-line import/no-unresolved
const { createSocketConnection } = await import('vscode-ws-jsonrpc/server');
const serverConnection = createSocketConnection(socket, socket, () => {
socket.destroy();
});
Expand Down
Loading

0 comments on commit 82b819f

Please sign in to comment.