Skip to content

Commit

Permalink
#105 #104 #96 #94 #39 Cleanup and refactor client-server communication
Browse files Browse the repository at this point in the history
- Remove deprecated glsp client protcol and reuse the new API provided by @eclipse-glsp/client (#94 #96)
- Update dependencies to align with sprotty 0.9.0 and Theia 1.3.0. (104)
- Refactor glsp contributions to avoid dependencies on the (now deprecated) @theia/language module (#105)
- Provide a dedicated TheiaGLSPClient that uses the MessageService to propagate connection errors. (#39)
- Use unique application id in widgetId.

Requires: eclipse-glsp/glsp-client/pull/79

Part of:
- eclipse-glsp/glsp/issues/104
- eclipse-glsp/glsp/issues/94
- eclipse-glsp/glsp/issues/96
- eclipse-glsp/glsp/issues/105
- eclipse-glsp/glsp/issues/39
  • Loading branch information
tortmayr committed Aug 24, 2020
1 parent e9315cd commit 6fa15d9
Show file tree
Hide file tree
Showing 20 changed files with 861 additions and 1,012 deletions.
19 changes: 6 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,15 @@
"css"
],
"dependencies": {
"@theia/core": "1.0.0",
"@theia/editor": "1.0.0",
"@theia/filesystem": "1.0.0",
"@theia/messages": "1.0.0",
"@theia/languages": "1.0.0",
"@theia/monaco": "1.0.0",
"@theia/process": "1.0.0",
"@theia/workspace": "1.0.0",
"@theia/markers": "1.0.0",
"sprotty-theia": "next",
"@eclipse-glsp/client": "next"
"sprotty-theia": "0.9.0",
"@eclipse-glsp/client": "next",
"ts-md5": "1.2.7"
},
"devDependencies": {
"@types/node": "10.14.18",
"rimraf": "^2.6.1",
"tslint": "^5.5.0",
"typescript": "3.6.4"
"typescript": "^3.9.2"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
Expand All @@ -57,7 +49,8 @@
},
"theiaExtensions": [
{
"frontend": "lib/browser/frontend-module"
"frontend": "lib/browser/glsp-frontend-module",
"backend": "lib/node/glsp-backend-module"
}
],
"main": "lib/index",
Expand Down
10 changes: 4 additions & 6 deletions src/browser/diagram/glsp-diagram-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { GLSPClient } from "@eclipse-glsp/client";
import { CommandRegistry } from "@theia/core";
import { ApplicationShell } from "@theia/core/lib/browser";
import { EditorManager } from "@theia/editor/lib/browser";
import { inject, injectable } from "inversify";
import { ActionMessage } from "sprotty";
import { ActionMessageReceiver } from "sprotty-theia/lib/theia/languageserver/diagram-language-client";

import { ActionMessageNotification } from "../../common";
import { GLSPClientContribution } from "../language/glsp-client-contribution";
import { GLSPClient } from "../language/glsp-client-services";
import { GLSPClientContribution } from "../glsp-client-contribution";

@injectable()
export class GLSPDiagramClient {
Expand All @@ -35,14 +34,13 @@ export class GLSPDiagramClient {
constructor(readonly glspClientContribution: GLSPClientContribution,
readonly editorManager: EditorManager) {
this.glspClientContribution.glspClient
.then(gc => gc.onNotification(ActionMessageNotification.type, this.onMessageReceived.bind(this)))
.then(gc => gc.onActionMessage(this.onMessageReceived.bind(this)))
.catch(err => console.error(err));
}

sendThroughLsp(message: ActionMessage) {
this.glspClientContribution.glspClient
.then(gc => gc.onReady()
.then(() => gc.sendNotification(ActionMessageNotification.type, message)));
.then(client => client.sendActionMessage(message));
}

onMessageReceived(message: ActionMessage) {
Expand Down
4 changes: 2 additions & 2 deletions src/browser/diagram/glsp-diagram-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { EditMode, GLSPActionDispatcher } from "@eclipse-glsp/client";
import { ApplicationIdProvider, EditMode, GLSPActionDispatcher } from "@eclipse-glsp/client";
import {
FrontendApplicationContribution,
NavigatableWidgetOptions,
Expand Down Expand Up @@ -72,7 +72,7 @@ export abstract class GLSPDiagramManager extends DiagramManager {
async createWidget(options?: any): Promise<DiagramWidget> {
if (DiagramWidgetOptions.is(options)) {
const clientId = this.createClientId();
const widgetId = this.id + ':' + options.uri;
const widgetId = `${ApplicationIdProvider.get()}-${this.diagramType}:${options.uri}`;
const config = this.diagramConfigurationRegistry.get(options.diagramType);
const diContainer = config.createContainer(clientId);
return new GLSPDiagramWidget(options, widgetId, diContainer, this.editorPreferences, this.diagramConnector);
Expand Down
2 changes: 2 additions & 0 deletions src/browser/diagram/glsp-diagram-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
********************************************************************************/
import {
DiagramServer,
DisposeClientAction,
EditorContextService,
EnableToolPaletteAction,
GLSP_TYPES,
Expand Down Expand Up @@ -50,6 +51,7 @@ export class GLSPDiagramWidget extends DiagramWidget implements SaveableSource {
const prefUpdater = editorPreferences.onPreferenceChanged(() => this.updateSaveable());
this.toDispose.push(prefUpdater);
this.toDispose.push(this.saveable);
this.toDispose.push(Disposable.create(() => this.actionDispatcher.dispatch(new DisposeClientAction())));
}

protected updateSaveable() {
Expand Down
2 changes: 1 addition & 1 deletion src/browser/diagram/glsp-theia-sprotty-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import {
ActionMessage,
ExportSvgAction,
GLSPClient,
isGLSPServerStatusAction,
remove,
ServerMessageAction,
Expand All @@ -27,7 +28,6 @@ import { Message, MessageType } from "@theia/core/lib/common";
import { EditorManager } from "@theia/editor/lib/browser";
import { DiagramManager, DiagramWidget, TheiaDiagramServer, TheiaFileSaver, TheiaSprottyConnector } from "sprotty-theia";

import { GLSPClient } from "../language/glsp-client-services";
import { GLSPDiagramClient } from "./glsp-diagram-client";
import { GLSPMessageOptions, GLSPNotificationManager } from "./glsp-notification-manager";

Expand Down
25 changes: 25 additions & 0 deletions src/browser/diagram/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* 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
********************************************************************************/
export * from './glsp-command-handler';
export * from './glsp-diagram-client';
export * from './glsp-diagram-layout-commands';
export * from './glsp-diagram-manager';
export * from './glsp-diagram-widget';
export * from './glsp-theia-diagram-server';
export * from './glsp-theia-sprotty-connector';
export * from './glsp-notification-manager';
export * from './glsp-theia-context-menu-service';
export * from './glsp-diagram-context-key-service';
Loading

0 comments on commit 6fa15d9

Please sign in to comment.