@eclipse-glsp/server 2.8.0-next.1 → 2.8.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/launch/worker-server-launcher.js +3 -5
- package/lib/browser/launch/worker-server-launcher.js.map +1 -1
- package/lib/common/actions/action-dispatcher.js +5 -8
- package/lib/common/actions/action-dispatcher.js.map +1 -1
- package/lib/common/actions/action-handler-registry.js +1 -1
- package/lib/common/actions/action-handler-registry.js.map +1 -1
- package/lib/common/actions/global-action-provider.js +1 -2
- package/lib/common/actions/global-action-provider.js.map +1 -1
- package/lib/common/command/command.js +1 -2
- package/lib/common/command/command.js.map +1 -1
- package/lib/common/command/recording-command.js +3 -6
- package/lib/common/command/recording-command.js.map +1 -1
- package/lib/common/di/diagram-module.js +5 -6
- package/lib/common/di/diagram-module.js.map +1 -1
- package/lib/common/di/glsp-module.js +1 -1
- package/lib/common/di/glsp-module.js.map +1 -1
- package/lib/common/di/server-module.js +1 -1
- package/lib/common/di/server-module.js.map +1 -1
- package/lib/common/features/directediting/context-edit-validator.js +3 -3
- package/lib/common/features/directediting/context-edit-validator.js.map +1 -1
- package/lib/common/features/directediting/label-edit-validator.js +1 -1
- package/lib/common/features/directediting/label-edit-validator.js.map +1 -1
- package/lib/common/features/layout/computed-bounds-action-handler.d.ts +16 -1
- package/lib/common/features/layout/computed-bounds-action-handler.d.ts.map +1 -1
- package/lib/common/features/layout/computed-bounds-action-handler.js +41 -4
- package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -1
- package/lib/common/features/layout/layout-operation-handler.js +1 -2
- package/lib/common/features/layout/layout-operation-handler.js.map +1 -1
- package/lib/common/features/model/gmodel-index.js +3 -5
- package/lib/common/features/model/gmodel-index.js.map +1 -1
- package/lib/common/features/model/gmodel-serializer.js +1 -2
- package/lib/common/features/model/gmodel-serializer.js.map +1 -1
- package/lib/common/features/model/model-submission-handler.d.ts +1 -2
- package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
- package/lib/common/features/model/model-submission-handler.js +3 -6
- package/lib/common/features/model/model-submission-handler.js.map +1 -1
- package/lib/common/features/model/request-model-action-handler.js +4 -6
- package/lib/common/features/model/request-model-action-handler.js.map +1 -1
- package/lib/common/features/navigation/navigation-target-resolution.js +1 -1
- package/lib/common/features/navigation/navigation-target-resolution.js.map +1 -1
- package/lib/common/features/progress/progress-service.d.ts.map +1 -1
- package/lib/common/features/progress/progress-service.js +1 -2
- package/lib/common/features/progress/progress-service.js.map +1 -1
- package/lib/common/features/validation/request-markers-handler.js +1 -2
- package/lib/common/features/validation/request-markers-handler.js.map +1 -1
- package/lib/common/gmodel/change-routing-points-operation-handler.js +1 -2
- package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js +3 -5
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.d.ts +1 -1
- package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.js +8 -11
- package/lib/common/gmodel/paste-operation-handler.js.map +1 -1
- package/lib/common/launch/glsp-server-launcher.d.ts +8 -1
- package/lib/common/launch/glsp-server-launcher.d.ts.map +1 -1
- package/lib/common/launch/glsp-server-launcher.js +11 -1
- package/lib/common/launch/glsp-server-launcher.js.map +1 -1
- package/lib/common/launch/jsonrpc-server-launcher.d.ts +51 -2
- package/lib/common/launch/jsonrpc-server-launcher.d.ts.map +1 -1
- package/lib/common/launch/jsonrpc-server-launcher.js +82 -3
- package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -1
- package/lib/common/operations/compound-operation-handler.js +1 -1
- package/lib/common/operations/compound-operation-handler.js.map +1 -1
- package/lib/common/operations/json-operation-handler.js +2 -3
- package/lib/common/operations/json-operation-handler.js.map +1 -1
- package/lib/common/protocol/glsp-server.js +6 -7
- package/lib/common/protocol/glsp-server.js.map +1 -1
- package/lib/common/session/client-session-manager.js +3 -5
- package/lib/common/session/client-session-manager.js.map +1 -1
- package/lib/common/utils/action-queue.js +2 -4
- package/lib/common/utils/action-queue.js.map +1 -1
- package/lib/common/utils/client-options-util.js +2 -2
- package/lib/common/utils/client-options-util.js.map +1 -1
- package/lib/common/utils/glsp-server-error.d.ts +2 -3
- package/lib/common/utils/glsp-server-error.d.ts.map +1 -1
- package/lib/common/utils/glsp-server-error.js +1 -1
- package/lib/common/utils/glsp-server-error.js.map +1 -1
- package/lib/common/utils/layout-util.d.ts +5 -5
- package/lib/common/utils/layout-util.d.ts.map +1 -1
- package/lib/common/utils/layout-util.js +17 -19
- package/lib/common/utils/layout-util.js.map +1 -1
- package/lib/common/utils/logger.js +1 -2
- package/lib/common/utils/logger.js.map +1 -1
- package/lib/node/abstract-json-model-storage.js +2 -4
- package/lib/node/abstract-json-model-storage.js.map +1 -1
- package/lib/node/launch/socket-server-launcher.d.ts +39 -2
- package/lib/node/launch/socket-server-launcher.d.ts.map +1 -1
- package/lib/node/launch/socket-server-launcher.js +50 -31
- package/lib/node/launch/socket-server-launcher.js.map +1 -1
- package/lib/node/launch/websocket-server-launcher.d.ts +36 -5
- package/lib/node/launch/websocket-server-launcher.d.ts.map +1 -1
- package/lib/node/launch/websocket-server-launcher.js +54 -13
- package/lib/node/launch/websocket-server-launcher.js.map +1 -1
- package/package.json +17 -21
- package/src/common/features/directediting/context-edit-validator.ts +2 -2
- package/src/common/features/layout/computed-bounds-action-handler.ts +52 -4
- package/src/common/features/model/model-submission-handler.ts +3 -2
- package/src/common/features/progress/progress-service.ts +2 -3
- package/src/common/gmodel/paste-operation-handler.ts +6 -6
- package/src/common/launch/glsp-server-launcher.ts +12 -1
- package/src/common/launch/jsonrpc-server-launcher.ts +89 -2
- package/src/common/utils/glsp-server-error.ts +3 -5
- package/src/common/utils/layout-util.ts +13 -12
- package/src/node/launch/socket-server-launcher.ts +54 -31
- package/src/node/launch/websocket-server-launcher.ts +72 -14
- package/src/browser/di/browser-action-dispatch-scope.spec.ts +0 -75
- package/src/common/actions/action-handler-registry.spec.ts +0 -52
- package/src/common/actions/global-action-provider.spec.ts +0 -68
- package/src/common/command/command-stack.spec.ts +0 -239
- package/src/common/command/command.spec.ts +0 -92
- package/src/common/command/recording-command.spec.ts +0 -86
- package/src/common/di/binding-target.spec.ts +0 -147
- package/src/common/di/multi-bindings.spec.ts +0 -133
- package/src/common/features/contextactions/context-actions-provider-registry.spec.ts +0 -69
- package/src/common/features/contextactions/request-context-actions-handler.spec.ts +0 -75
- package/src/common/features/contextactions/tool-palette-item-provider.spec.ts +0 -46
- package/src/common/features/directediting/context-edit-validator-registry.spec.ts +0 -54
- package/src/common/features/directediting/request-edit-validation-handler.spec.ts +0 -131
- package/src/common/features/model/gmodel-serializer.spec.ts +0 -141
- package/src/common/features/type-hints/request-type-hints-action-handler.spec.ts +0 -59
- package/src/common/operations/operation-handler-registry.spec.ts +0 -50
- package/src/common/protocol/glsp-server.spec.ts +0 -154
- package/src/common/session/client-session-factory.spec.ts +0 -60
- package/src/common/session/client-session-manager.spec.ts +0 -83
- package/src/common/test/mock-util.ts +0 -281
- package/src/common/utils/action-queue.spec.ts +0 -133
- package/src/common/utils/promise-queue.spec.ts +0 -142
- package/src/common/utils/registry.spec.ts +0 -225
- package/src/node/actions/action-dispatcher.spec.ts +0 -678
- package/src/node/launch/cli-parser.spec.ts +0 -61
- package/src/node/launch/socket-cli-parser.spec.ts +0 -73
- package/src/node/launch/socket-server-launcher.spec.ts +0 -74
|
@@ -1,12 +1,49 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022-2026 STMicroelectronics and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { Emitter } from '@eclipse-glsp/protocol';
|
|
1
17
|
import * as net from 'net';
|
|
2
18
|
import * as jsonrpc from 'vscode-jsonrpc/node';
|
|
3
19
|
import { JsonRpcGLSPServerLauncher } from '../../common/launch/jsonrpc-server-launcher';
|
|
4
20
|
import { Logger } from '../../common/utils/logger';
|
|
5
21
|
export declare class SocketServerLauncher extends JsonRpcGLSPServerLauncher<net.TcpSocketConnectOpts> {
|
|
6
22
|
protected logger: Logger;
|
|
7
|
-
protected netServer
|
|
8
|
-
|
|
23
|
+
protected netServer?: net.Server;
|
|
24
|
+
protected onConnectionEmitter: Emitter<net.Socket>;
|
|
25
|
+
/**
|
|
26
|
+
* Fires for every socket the server accepts, before the JSON-RPC connection is built on it.
|
|
27
|
+
*
|
|
28
|
+
* A listener must not consume the socket. Subscribe before {@link start} to observe the first connection; the
|
|
29
|
+
* subscription outlives an individual launch and is disposed by the caller.
|
|
30
|
+
*/
|
|
31
|
+
readonly onConnection: import("@eclipse-glsp/protocol").Event<net.Socket>;
|
|
32
|
+
protected getServerSocket(): net.Server | undefined;
|
|
33
|
+
protected registerDisposables(): void;
|
|
9
34
|
protected run(opts: net.TcpSocketConnectOpts): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Takes up a socket the server accepted. Observers are notified before the socket is read from.
|
|
37
|
+
*
|
|
38
|
+
* @param socket The accepted socket.
|
|
39
|
+
*/
|
|
40
|
+
protected acceptConnection(socket: net.Socket): void;
|
|
41
|
+
/**
|
|
42
|
+
* Reports the server as ready and resolves {@link listening}.
|
|
43
|
+
*
|
|
44
|
+
* @param server The server that reported itself as listening.
|
|
45
|
+
*/
|
|
46
|
+
protected handleListening(server: net.Server): void;
|
|
10
47
|
protected createConnection(socket: net.Socket): jsonrpc.MessageConnection;
|
|
11
48
|
}
|
|
12
49
|
//# sourceMappingURL=socket-server-launcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-server-launcher.d.ts","sourceRoot":"","sources":["../../../src/node/launch/socket-server-launcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"socket-server-launcher.d.ts","sourceRoot":"","sources":["../../../src/node/launch/socket-server-launcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAc,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,qBACa,oBAAqB,SAAQ,yBAAyB,CAAC,GAAG,CAAC,oBAAoB,CAAC;IACzF,UAAmC,MAAM,EAAE,MAAM,CAAC;IAElD,SAAS,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAEjC,SAAS,CAAC,mBAAmB,sBAA6B;IAE1D;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,qDAAkC;cAEpC,eAAe,IAAI,GAAG,CAAC,MAAM,GAAG,SAAS;cAIzC,mBAAmB,IAAI,IAAI;IAS9C,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAc5D;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI;IAKpD;;;;OAIG;IACH,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI;IAWnD,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,iBAAiB;CAG5E"}
|
|
@@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SocketServerLauncher = void 0;
|
|
13
13
|
/********************************************************************************
|
|
14
|
-
* Copyright (c) 2022-
|
|
14
|
+
* Copyright (c) 2022-2026 STMicroelectronics and others.
|
|
15
15
|
*
|
|
16
16
|
* This program and the accompanying materials are made available under the
|
|
17
17
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -33,41 +33,61 @@ const jsonrpc_server_launcher_1 = require("../../common/launch/jsonrpc-server-la
|
|
|
33
33
|
const logger_1 = require("../../common/utils/logger");
|
|
34
34
|
let SocketServerLauncher = class SocketServerLauncher extends jsonrpc_server_launcher_1.JsonRpcGLSPServerLauncher {
|
|
35
35
|
constructor() {
|
|
36
|
-
super();
|
|
36
|
+
super(...arguments);
|
|
37
|
+
this.onConnectionEmitter = new protocol_1.Emitter();
|
|
38
|
+
/**
|
|
39
|
+
* Fires for every socket the server accepts, before the JSON-RPC connection is built on it.
|
|
40
|
+
*
|
|
41
|
+
* A listener must not consume the socket. Subscribe before {@link start} to observe the first connection; the
|
|
42
|
+
* subscription outlives an individual launch and is disposed by the caller.
|
|
43
|
+
*/
|
|
44
|
+
this.onConnection = this.onConnectionEmitter.event;
|
|
45
|
+
}
|
|
46
|
+
getServerSocket() {
|
|
47
|
+
return this.netServer;
|
|
48
|
+
}
|
|
49
|
+
registerDisposables() {
|
|
50
|
+
super.registerDisposables();
|
|
37
51
|
this.toDispose.push(protocol_1.Disposable.create(() => {
|
|
38
|
-
this.netServer
|
|
52
|
+
this.netServer?.close();
|
|
39
53
|
}));
|
|
40
54
|
}
|
|
41
55
|
run(opts) {
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const addressInfo = this.netServer.address();
|
|
49
|
-
if (!addressInfo) {
|
|
50
|
-
this.logger.error('Could not resolve GLSP Server address info. Shutting down.');
|
|
51
|
-
this.shutdown();
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
else if (typeof addressInfo === 'string') {
|
|
55
|
-
this.logger.error(`GLSP Server is unexpectedly listening to pipe or domain socket "${addressInfo}". Shutting down.`);
|
|
56
|
-
this.shutdown();
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const currentPort = addressInfo.port;
|
|
60
|
-
this.logger.info(`The GLSP server is ready to accept new client requests on port: ${currentPort}`);
|
|
61
|
-
// Print a message to the output stream that indicates that the start is completed.
|
|
62
|
-
// This indicates to the client that the server process is ready (in an embedded scenario).
|
|
63
|
-
console.log(this.startupCompleteMessage.concat(currentPort.toString()));
|
|
64
|
-
});
|
|
65
|
-
this.netServer.on('error', () => this.shutdown());
|
|
56
|
+
this.resetListening();
|
|
57
|
+
const netServer = net.createServer(socket => this.acceptConnection(socket));
|
|
58
|
+
this.netServer = netServer;
|
|
59
|
+
netServer.listen(opts.port, opts.host);
|
|
60
|
+
netServer.on('listening', () => this.handleListening(netServer));
|
|
61
|
+
netServer.on('error', error => this.handleError(error));
|
|
66
62
|
return new Promise((resolve, reject) => {
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
netServer.on('close', () => resolve(undefined));
|
|
64
|
+
netServer.on('error', error => reject(error));
|
|
69
65
|
});
|
|
70
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Takes up a socket the server accepted. Observers are notified before the socket is read from.
|
|
69
|
+
*
|
|
70
|
+
* @param socket The accepted socket.
|
|
71
|
+
*/
|
|
72
|
+
acceptConnection(socket) {
|
|
73
|
+
this.onConnectionEmitter.fire(socket);
|
|
74
|
+
this.createServerInstance(this.createConnection(socket));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Reports the server as ready and resolves {@link listening}.
|
|
78
|
+
*
|
|
79
|
+
* @param server The server that reported itself as listening.
|
|
80
|
+
*/
|
|
81
|
+
handleListening(server) {
|
|
82
|
+
const addressInfo = this.settleListening(server);
|
|
83
|
+
if (!addressInfo) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.logger.info(`The GLSP server is ready to accept new client requests on port: ${addressInfo.port}`);
|
|
87
|
+
// Print a message to the output stream that indicates that the start is completed.
|
|
88
|
+
// This indicates to the client that the server process is ready (in an embedded scenario).
|
|
89
|
+
console.log(this.startupCompleteMessage.concat(addressInfo.port.toString()));
|
|
90
|
+
}
|
|
71
91
|
createConnection(socket) {
|
|
72
92
|
return jsonrpc.createMessageConnection(new jsonrpc.SocketMessageReader(socket), new jsonrpc.SocketMessageWriter(socket), console);
|
|
73
93
|
}
|
|
@@ -78,7 +98,6 @@ __decorate([
|
|
|
78
98
|
__metadata("design:type", logger_1.Logger)
|
|
79
99
|
], SocketServerLauncher.prototype, "logger", void 0);
|
|
80
100
|
exports.SocketServerLauncher = SocketServerLauncher = __decorate([
|
|
81
|
-
(0, inversify_1.injectable)()
|
|
82
|
-
__metadata("design:paramtypes", [])
|
|
101
|
+
(0, inversify_1.injectable)()
|
|
83
102
|
], SocketServerLauncher);
|
|
84
103
|
//# sourceMappingURL=socket-server-launcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-server-launcher.js","sourceRoot":"","sources":["../../../src/node/launch/socket-server-launcher.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,
|
|
1
|
+
{"version":3,"file":"socket-server-launcher.js","sourceRoot":"","sources":["../../../src/node/launch/socket-server-launcher.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qDAA6D;AAC7D,yCAA+C;AAC/C,2BAA2B;AAC3B,+CAA+C;AAC/C,yFA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AC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACO,gBAAgB,CAAC,MAAkB;QACzC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACO,eAAe,CAAC,MAAkB;QACxC,MAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,OAAO;QACX,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mEAAmE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QACxG,mFAAmF;QACnF,2FAA2F;QAC3F,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACjF,CAAC;IAES,gBAAgB,CAAC,MAAkB;QACzC,OAAO,OAAO,CAAC,uBAAuB,CAAC,IAAI,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,IAAI,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IACtI,CAAC;CACJ,CAAA;AAvEY,oDAAoB;AACM;IAAlC,IAAA,kBAAM,EAAC,eAAM,CAAC;8BAA4B,eAAM;oDAAC;+BADzC,oBAAoB;IADhC,IAAA,sBAAU,GAAE;GACA,oBAAoB,CAuEhC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
2
|
+
* Copyright (c) 2023-2026 EclipseSource and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { MaybePromise, WebSocketWrapper } from '@eclipse-glsp/protocol';
|
|
16
|
+
import { Emitter, MaybePromise, WebSocketWrapper } from '@eclipse-glsp/protocol';
|
|
17
17
|
import * as http from 'http';
|
|
18
|
+
import * as net from 'net';
|
|
18
19
|
import * as jsonrpc from 'vscode-jsonrpc';
|
|
19
|
-
import {
|
|
20
|
+
import { WebSocket, WebSocketServer } from 'ws';
|
|
20
21
|
import { JsonRpcGLSPServerLauncher } from '../../common/launch/jsonrpc-server-launcher';
|
|
21
22
|
import { Logger } from '../../common/utils/logger';
|
|
22
23
|
export interface WebSocketServerOptions {
|
|
@@ -34,11 +35,41 @@ export interface WebsocketConnectionData {
|
|
|
34
35
|
socket: WebSocket;
|
|
35
36
|
connection: jsonrpc.MessageConnection;
|
|
36
37
|
}
|
|
38
|
+
/** An accepted web socket together with the upgrade request it was negotiated with. */
|
|
39
|
+
export interface AcceptedWebSocket {
|
|
40
|
+
socket: WebSocket;
|
|
41
|
+
/** The handshake request, the only place where its headers and query are still available. */
|
|
42
|
+
request: http.IncomingMessage;
|
|
43
|
+
}
|
|
37
44
|
export declare class WebSocketServerLauncher extends JsonRpcGLSPServerLauncher<WebSocketServerOptions> {
|
|
38
45
|
protected logger: Logger;
|
|
39
|
-
protected server
|
|
40
|
-
|
|
46
|
+
protected server?: WebSocketServer;
|
|
47
|
+
/**
|
|
48
|
+
* The HTTP server the web socket server is mounted on.
|
|
49
|
+
*
|
|
50
|
+
* Held separately because `ws` only closes an HTTP server it created itself, so releasing the socket is up to us.
|
|
51
|
+
*/
|
|
52
|
+
protected httpServer?: http.Server;
|
|
53
|
+
protected onConnectionEmitter: Emitter<AcceptedWebSocket>;
|
|
54
|
+
/**
|
|
55
|
+
* Fires for every web socket the server accepts, before the JSON-RPC connection is built on it.
|
|
56
|
+
*
|
|
57
|
+
* A listener must not consume the socket. Subscribe before {@link start} to observe the first connection; the
|
|
58
|
+
* subscription outlives an individual launch and is disposed by the caller.
|
|
59
|
+
*/
|
|
60
|
+
readonly onConnection: import("@eclipse-glsp/protocol").Event<AcceptedWebSocket>;
|
|
61
|
+
protected getServerSocket(): net.Server | undefined;
|
|
62
|
+
protected registerDisposables(): void;
|
|
41
63
|
protected run(options: WebSocketServerOptions): Promise<void>;
|
|
64
|
+
/** Settles {@link listening} from the HTTP server, which may already be bound by the time we get here. */
|
|
65
|
+
protected observeListening(server: http.Server): void;
|
|
66
|
+
/**
|
|
67
|
+
* Takes up a web socket the server accepted. Observers are notified before the socket is read from.
|
|
68
|
+
*
|
|
69
|
+
* @param socket The accepted web socket.
|
|
70
|
+
* @param request The upgrade request the socket was negotiated with.
|
|
71
|
+
*/
|
|
72
|
+
protected acceptConnection(socket: WebSocket, request: http.IncomingMessage): void;
|
|
42
73
|
protected createConnection(socket: WebSocket): jsonrpc.MessageConnection;
|
|
43
74
|
protected resolveOptions(options: WebSocketServerOptions): Promise<ResolvedWebSocketServerOptions>;
|
|
44
75
|
protected createHttpServer(port: number, host?: string): http.Server;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket-server-launcher.d.ts","sourceRoot":"","sources":["../../../src/node/launch/websocket-server-launcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAyC,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"websocket-server-launcher.d.ts","sourceRoot":"","sources":["../../../src/node/launch/websocket-server-launcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAyC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,w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AY9B,GAAG,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBnE,0GAA0G;IAC1G,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI;IASrD;;;;;OAKG;IACH,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,eAAe,GAAG,IAAI;IAKlF,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,iBAAiB;cAIxD,cAAc,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC;IAQxG,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM;IAgB3D,KAAK,CAAC,OAAO,EAAE,sBAAsB,GAAG,YAAY,CAAC,IAAI,CAAC;CAGtE;AAeD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,gBAAgB,CAQjE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/********************************************************************************
|
|
3
|
-
* Copyright (c) 2023 EclipseSource and others.
|
|
3
|
+
* Copyright (c) 2023-2026 EclipseSource and others.
|
|
4
4
|
*
|
|
5
5
|
* This program and the accompanying materials are made available under the
|
|
6
6
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -36,26 +36,68 @@ const logger_1 = require("../../common/utils/logger");
|
|
|
36
36
|
const STATUS_UPGRADE_REQUIRED = 426;
|
|
37
37
|
let WebSocketServerLauncher = class WebSocketServerLauncher extends jsonrpc_server_launcher_1.JsonRpcGLSPServerLauncher {
|
|
38
38
|
constructor() {
|
|
39
|
-
super();
|
|
39
|
+
super(...arguments);
|
|
40
|
+
this.onConnectionEmitter = new protocol_1.Emitter();
|
|
41
|
+
/**
|
|
42
|
+
* Fires for every web socket the server accepts, before the JSON-RPC connection is built on it.
|
|
43
|
+
*
|
|
44
|
+
* A listener must not consume the socket. Subscribe before {@link start} to observe the first connection; the
|
|
45
|
+
* subscription outlives an individual launch and is disposed by the caller.
|
|
46
|
+
*/
|
|
47
|
+
this.onConnection = this.onConnectionEmitter.event;
|
|
48
|
+
}
|
|
49
|
+
getServerSocket() {
|
|
50
|
+
return this.httpServer;
|
|
51
|
+
}
|
|
52
|
+
registerDisposables() {
|
|
53
|
+
super.registerDisposables();
|
|
40
54
|
this.toDispose.push(protocol_1.Disposable.create(() => {
|
|
41
|
-
this.server
|
|
55
|
+
this.server?.close();
|
|
56
|
+
// `ws` leaves an HTTP server it did not create itself listening, so close ours explicitly.
|
|
57
|
+
this.httpServer?.close();
|
|
58
|
+
this.httpServer = undefined;
|
|
42
59
|
}));
|
|
43
60
|
}
|
|
44
61
|
async run(options) {
|
|
62
|
+
this.resetListening();
|
|
45
63
|
const resolvedOptions = await this.resolveOptions(options);
|
|
46
|
-
this.
|
|
64
|
+
if (!this.running) {
|
|
65
|
+
// Shut down while the options were being resolved, so release the socket they already bound.
|
|
66
|
+
resolvedOptions.server.close();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.httpServer = resolvedOptions.server;
|
|
70
|
+
this.server = new ws_1.WebSocketServer({ server: resolvedOptions.server, path: resolvedOptions.path });
|
|
47
71
|
const endpoint = `ws://${resolvedOptions.host}:${resolvedOptions.port}:${resolvedOptions.path}`;
|
|
48
72
|
this.logger.info(`The GLSP Websocket launcher is ready to accept new client requests on endpoint '${endpoint}'`);
|
|
49
73
|
console.log(this.startupCompleteMessage.concat(resolvedOptions.port.toString()));
|
|
50
|
-
this.server
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
74
|
+
this.observeListening(resolvedOptions.server);
|
|
75
|
+
this.server.on('connection', (ws, request) => this.acceptConnection(ws, request));
|
|
76
|
+
const server = this.server;
|
|
54
77
|
return new Promise((resolve, reject) => {
|
|
55
|
-
|
|
56
|
-
|
|
78
|
+
server.on('close', () => resolve(undefined));
|
|
79
|
+
server.on('error', error => reject(error));
|
|
57
80
|
});
|
|
58
81
|
}
|
|
82
|
+
/** Settles {@link listening} from the HTTP server, which may already be bound by the time we get here. */
|
|
83
|
+
observeListening(server) {
|
|
84
|
+
if (server.listening) {
|
|
85
|
+
this.settleListening(server);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
server.on('listening', () => this.settleListening(server));
|
|
89
|
+
server.on('error', error => this.handleError(error));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Takes up a web socket the server accepted. Observers are notified before the socket is read from.
|
|
93
|
+
*
|
|
94
|
+
* @param socket The accepted web socket.
|
|
95
|
+
* @param request The upgrade request the socket was negotiated with.
|
|
96
|
+
*/
|
|
97
|
+
acceptConnection(socket, request) {
|
|
98
|
+
this.onConnectionEmitter.fire({ socket, request });
|
|
99
|
+
this.createServerInstance(this.createConnection(socket));
|
|
100
|
+
}
|
|
59
101
|
createConnection(socket) {
|
|
60
102
|
return (0, protocol_1.createWebSocketConnection)(wrapWebSocket(socket));
|
|
61
103
|
}
|
|
@@ -69,7 +111,7 @@ let WebSocketServerLauncher = class WebSocketServerLauncher extends jsonrpc_serv
|
|
|
69
111
|
const server = http.createServer((req, res) => {
|
|
70
112
|
const body = http.STATUS_CODES[STATUS_UPGRADE_REQUIRED];
|
|
71
113
|
res.writeHead(426, {
|
|
72
|
-
'Content-Length': body
|
|
114
|
+
'Content-Length': body?.length,
|
|
73
115
|
'Content-Type': 'text/plain'
|
|
74
116
|
});
|
|
75
117
|
res.end(body);
|
|
@@ -89,8 +131,7 @@ __decorate([
|
|
|
89
131
|
__metadata("design:type", logger_1.Logger)
|
|
90
132
|
], WebSocketServerLauncher.prototype, "logger", void 0);
|
|
91
133
|
exports.WebSocketServerLauncher = WebSocketServerLauncher = __decorate([
|
|
92
|
-
(0, inversify_1.injectable)()
|
|
93
|
-
__metadata("design:paramtypes", [])
|
|
134
|
+
(0, inversify_1.injectable)()
|
|
94
135
|
], WebSocketServerLauncher);
|
|
95
136
|
async function getFreePort() {
|
|
96
137
|
return new Promise((resolve, reject) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket-server-launcher.js","sourceRoot":"","sources":["../../../src/node/launch/websocket-server-launcher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"websocket-server-launcher.js","sourceRoot":"","sources":["../../../src/node/launch/websocket-server-launcher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;AA6KlF,sCAQC;AAnLD,qDAAwH;AACxH,6BAA6B;AAC7B,yCAA+C;AAC/C,2BAA2B;AAE3B,2BAAgD;AAChD,yFAAwF;AACxF,sDAAmD;AA2BnD,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAG7B,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,mDAAiD;IAAvF;;QAaO,wBAAmB,GAAG,IAAI,kBAAO,EAAqB,CAAC;QAEjE;;;;;WAKG;QACM,iBAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;IA8F3D,CAAC;IA5FsB,eAAe;QAC9B,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAEkB,mBAAmB;QAClC,KAAK,CAAC,mBAAmB,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CACf,qBAAU,CAAC,MAAM,CAAC,GAAG,EAAE;YACnB,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;YACrB,2FAA2F;YAC3F,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAChC,CAAC,CAAC,CACL,CAAC;IACN,CAAC;IAES,KAAK,CAAC,GAAG,CAAC,OAA+B;QAC/C,IAAI,C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AE,CAAC;gBAC1C,MAAM,CAAC,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC,CAAC;gBAC9D,OAAO;YACX,CAAC;YACD,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AACD;;;GAGG;AACH,SAAgB,aAAa,CAAC,MAAiB;IAC3C,OAAO;QACH,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QACrC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC;QACzC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACrC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;KAChC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/server",
|
|
3
|
-
"version": "2.8.0-next.
|
|
3
|
+
"version": "2.8.0-next.10",
|
|
4
4
|
"description": "A js server framework for Eclipse GLSP",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eclipse",
|
|
@@ -45,38 +45,34 @@
|
|
|
45
45
|
"browser.d.ts",
|
|
46
46
|
"browser.js",
|
|
47
47
|
"common.d.ts",
|
|
48
|
-
"common.js"
|
|
48
|
+
"common.js",
|
|
49
|
+
"!**/*.spec.ts",
|
|
50
|
+
"!**/*.spec.tsx",
|
|
51
|
+
"!**/test/**"
|
|
49
52
|
],
|
|
50
|
-
"scripts": {
|
|
51
|
-
"build": "tsc -b",
|
|
52
|
-
"clean": "rimraf lib *.tsbuildinfo coverage .nyc_output",
|
|
53
|
-
"generate:index": "glsp generateIndex src/browser src/common src/node -s -f",
|
|
54
|
-
"lint": "eslint ./src",
|
|
55
|
-
"test": "mocha --config ../../.mocharc \"./src/**/*.spec.?(ts|tsx)\"",
|
|
56
|
-
"test:ci": "yarn test --reporter mocha-ctrf-json-reporter",
|
|
57
|
-
"test:coverage": "nyc yarn test:ci",
|
|
58
|
-
"watch": "tsc -w"
|
|
59
|
-
},
|
|
60
53
|
"dependencies": {
|
|
61
|
-
"@eclipse-glsp/graph": "2.8.0-next.1+ab013b0",
|
|
62
54
|
"@eclipse-glsp/protocol": "next",
|
|
63
|
-
"
|
|
64
|
-
"commander": "^8.3.0",
|
|
55
|
+
"commander": "^14.0.0",
|
|
65
56
|
"fast-json-patch": "^3.1.0",
|
|
66
|
-
"lodash": "4.17.21",
|
|
67
57
|
"vscode-jsonrpc": "8.2.0",
|
|
68
58
|
"winston": "^3.3.3",
|
|
69
|
-
"ws": "^8.12.1"
|
|
59
|
+
"ws": "^8.12.1",
|
|
60
|
+
"@eclipse-glsp/graph": "2.8.0-next.10"
|
|
70
61
|
},
|
|
71
62
|
"devDependencies": {
|
|
72
|
-
"@types/lodash": "4.14.191",
|
|
73
63
|
"@types/ws": "^8.5.4"
|
|
74
64
|
},
|
|
75
65
|
"peerDependencies": {
|
|
76
|
-
"inversify": "^6.1.3"
|
|
66
|
+
"inversify": "^6.1.3",
|
|
67
|
+
"reflect-metadata": "^0.2.2"
|
|
77
68
|
},
|
|
78
69
|
"publishConfig": {
|
|
79
70
|
"access": "public"
|
|
80
71
|
},
|
|
81
|
-
"
|
|
82
|
-
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "tsc -b",
|
|
74
|
+
"clean": "rimraf lib *.tsbuildinfo coverage",
|
|
75
|
+
"generate:index": "glsp generateIndex src/browser src/common src/node -s -f",
|
|
76
|
+
"lint": "eslint ./src"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2026 STMicroelectronics and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { GModelElement } from '@eclipse-glsp/graph
|
|
16
|
+
import { GModelElement } from '@eclipse-glsp/graph';
|
|
17
17
|
import { RequestEditValidationAction, ValidationStatus } from '@eclipse-glsp/protocol';
|
|
18
18
|
import { ModelState } from '../model/model-state';
|
|
19
19
|
import { LabelEditValidator } from './label-edit-validator';
|
|
@@ -14,10 +14,19 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { GModelRoot } from '@eclipse-glsp/graph';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
Action,
|
|
19
|
+
ComputedBoundsAction,
|
|
20
|
+
ElementAndAlignment,
|
|
21
|
+
ElementAndBounds,
|
|
22
|
+
ElementAndRoutingPoints,
|
|
23
|
+
LayoutOperation,
|
|
24
|
+
MaybePromise
|
|
25
|
+
} from '@eclipse-glsp/protocol';
|
|
18
26
|
import { inject, injectable } from 'inversify';
|
|
19
27
|
import { ActionHandler } from '../../actions/action-handler';
|
|
20
28
|
import { applyAlignment, applyElementAndBounds, applyRoute } from '../../utils/layout-util';
|
|
29
|
+
import { Logger } from '../../utils/logger';
|
|
21
30
|
import { ModelState } from '../model/model-state';
|
|
22
31
|
import { ModelSubmissionHandler } from '../model/model-submission-handler';
|
|
23
32
|
|
|
@@ -34,6 +43,9 @@ export class ComputedBoundsActionHandler implements ActionHandler {
|
|
|
34
43
|
@inject(ModelState)
|
|
35
44
|
protected modelState: ModelState;
|
|
36
45
|
|
|
46
|
+
@inject(Logger)
|
|
47
|
+
protected logger: Logger;
|
|
48
|
+
|
|
37
49
|
actionKinds = [ComputedBoundsAction.KIND];
|
|
38
50
|
execute(action: ComputedBoundsAction): MaybePromise<Action[]> {
|
|
39
51
|
const model = this.modelState.root;
|
|
@@ -48,11 +60,47 @@ export class ComputedBoundsActionHandler implements ActionHandler {
|
|
|
48
60
|
return [];
|
|
49
61
|
}
|
|
50
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Applies everything the client computed for the given model.
|
|
65
|
+
*
|
|
66
|
+
* An entry that cannot be applied is skipped and logged rather than treated as an error.
|
|
67
|
+
*/
|
|
51
68
|
protected applyBounds(root: GModelRoot, action: ComputedBoundsAction): void {
|
|
69
|
+
this.applyElementBounds(action.bounds);
|
|
70
|
+
this.applyAlignments(action.alignments ?? []);
|
|
71
|
+
this.applyRoutes(action.routes ?? []);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
protected applyElementBounds(allBounds: ElementAndBounds[]): void {
|
|
75
|
+
const index = this.modelState.index;
|
|
76
|
+
allBounds.forEach(bounds => {
|
|
77
|
+
if (!applyElementAndBounds(bounds, index)) {
|
|
78
|
+
this.logger.warn(`Skipped computed bounds of element '${bounds.elementId}'`);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
protected applyAlignments(alignments: ElementAndAlignment[]): void {
|
|
84
|
+
const index = this.modelState.index;
|
|
85
|
+
alignments.forEach(alignment => {
|
|
86
|
+
if (!applyAlignment(alignment, index)) {
|
|
87
|
+
this.logger.warn(`Skipped computed alignment of element '${alignment.elementId}'`);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Applies the computed routes.
|
|
94
|
+
*
|
|
95
|
+
* A skipped route is logged at debug level, an edge the client has not finished routing yet is expected.
|
|
96
|
+
*/
|
|
97
|
+
protected applyRoutes(routes: ElementAndRoutingPoints[]): void {
|
|
52
98
|
const index = this.modelState.index;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
99
|
+
routes.forEach(route => {
|
|
100
|
+
if (!applyRoute(route, index)) {
|
|
101
|
+
this.logger.debug(`Skipped computed route of element '${route.elementId}'`);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
56
104
|
}
|
|
57
105
|
|
|
58
106
|
priority?: number | undefined;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import {
|
|
17
17
|
Action,
|
|
18
|
+
DebouncedFunc,
|
|
18
19
|
DirtyStateChangeReason,
|
|
19
20
|
GModelRootSchema,
|
|
20
21
|
LayoutOperation,
|
|
@@ -26,9 +27,9 @@ import {
|
|
|
26
27
|
SetMarkersAction,
|
|
27
28
|
SetModelAction,
|
|
28
29
|
StatusAction,
|
|
29
|
-
UpdateModelAction
|
|
30
|
+
UpdateModelAction,
|
|
31
|
+
debounce
|
|
30
32
|
} from '@eclipse-glsp/protocol';
|
|
31
|
-
import { DebouncedFunc, debounce } from 'lodash';
|
|
32
33
|
|
|
33
34
|
import { inject, injectable, optional } from 'inversify';
|
|
34
35
|
import { ActionDispatcher } from '../../actions/action-dispatcher';
|
|
@@ -13,9 +13,8 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { EndProgressAction, StartProgressAction, UpdateProgressAction } from '@eclipse-glsp/protocol';
|
|
16
|
+
import { EndProgressAction, StartProgressAction, UpdateProgressAction, generateUuid } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { inject, injectable } from 'inversify';
|
|
18
|
-
import * as uuid from 'uuid';
|
|
19
18
|
import { ActionDispatcher } from '../../actions/action-dispatcher';
|
|
20
19
|
|
|
21
20
|
export const ProgressService = Symbol('ProgressService');
|
|
@@ -64,7 +63,7 @@ export class DefaultProgressService implements ProgressService {
|
|
|
64
63
|
protected actionDispatcher: ActionDispatcher;
|
|
65
64
|
|
|
66
65
|
start(title: string, options?: ProgressOptions): ProgressMonitor {
|
|
67
|
-
const progressId =
|
|
66
|
+
const progressId = generateUuid();
|
|
68
67
|
this.actionDispatcher.dispatch(StartProgressAction.create({ progressId, title, ...options }));
|
|
69
68
|
return {
|
|
70
69
|
update: updateOptions => this.actionDispatcher.dispatch(UpdateProgressAction.create(progressId, updateOptions)),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-
|
|
2
|
+
* Copyright (c) 2022-2026 STMicroelectronics and others.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made available under the
|
|
5
5
|
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { GBoundsAware, GEdge, GModelElement, isGBoundsAware } from '@eclipse-glsp/graph';
|
|
17
|
-
import { EditorContext, GModelElementSchema, MaybePromise, PasteOperation, Point } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { EditorContext, GModelElementSchema, MaybePromise, PasteOperation, Point, generateUuid } from '@eclipse-glsp/protocol';
|
|
18
18
|
import { inject, injectable } from 'inversify';
|
|
19
|
-
import * as uuid from 'uuid';
|
|
20
19
|
import { Command } from '../command/command';
|
|
21
20
|
import { GModelSerializer } from '../features/model/gmodel-serializer';
|
|
22
21
|
import { GModelOperationHandler } from './gmodel-operation-handler';
|
|
@@ -67,22 +66,23 @@ export class GModelPasteOperationHandler extends GModelOperationHandler {
|
|
|
67
66
|
|
|
68
67
|
protected getReferenceElementForPasteOffset(elements: GModelElement[]): GBoundsAware | undefined {
|
|
69
68
|
let minY = Number.MAX_VALUE;
|
|
69
|
+
let referenceElement: GBoundsAware | undefined;
|
|
70
70
|
for (const element of elements) {
|
|
71
71
|
if (isGBoundsAware(element)) {
|
|
72
72
|
const position = element.position ?? Point.ORIGIN;
|
|
73
73
|
if (minY > position.y) {
|
|
74
74
|
minY = position.y;
|
|
75
|
-
|
|
75
|
+
referenceElement = element;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
return
|
|
79
|
+
return referenceElement;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
protected reassignIds(elements: GModelElement[]): Map<string, string> {
|
|
83
83
|
const idMap = new Map<string, string>();
|
|
84
84
|
elements.forEach(element => {
|
|
85
|
-
const newId =
|
|
85
|
+
const newId = generateUuid();
|
|
86
86
|
idMap.set(element.id, newId);
|
|
87
87
|
element.id = newId;
|
|
88
88
|
const childMap = this.reassignIds(element.children);
|