@eclipse-glsp/server 1.1.0-next.5fd686c.61 → 1.1.0-next.abdebbd.65
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 +26 -2
- package/lib/browser/launch/worker-server-launcher.js.map +1 -1
- package/lib/common/actions/action-dispatcher.d.ts +2 -1
- package/lib/common/actions/action-dispatcher.d.ts.map +1 -1
- package/lib/common/actions/action-dispatcher.js +9 -6
- package/lib/common/actions/action-dispatcher.js.map +1 -1
- package/lib/common/actions/action-handler-registry.js +4 -2
- package/lib/common/actions/action-handler-registry.js.map +1 -1
- package/lib/common/actions/client-action-handler.d.ts +17 -8
- package/lib/common/actions/client-action-handler.d.ts.map +1 -1
- package/lib/common/actions/client-action-handler.js +32 -21
- package/lib/common/actions/client-action-handler.js.map +1 -1
- package/lib/common/actions/global-action-provider.d.ts +6 -21
- package/lib/common/actions/global-action-provider.d.ts.map +1 -1
- package/lib/common/actions/global-action-provider.js +17 -21
- package/lib/common/actions/global-action-provider.js.map +1 -1
- package/lib/common/command/command-stack.js +2 -1
- package/lib/common/command/command-stack.js.map +1 -1
- package/lib/common/command/recording-command.d.ts +1 -1
- package/lib/common/command/recording-command.d.ts.map +1 -1
- package/lib/common/command/recording-command.js +26 -3
- package/lib/common/command/recording-command.js.map +1 -1
- package/lib/common/command/undo-redo-action-handler.js +2 -1
- package/lib/common/command/undo-redo-action-handler.js.map +1 -1
- package/lib/common/di/client-session-module.d.ts +9 -1
- package/lib/common/di/client-session-module.d.ts.map +1 -1
- package/lib/common/di/client-session-module.js +9 -9
- package/lib/common/di/client-session-module.js.map +1 -1
- package/lib/common/di/diagram-module.d.ts +17 -1
- package/lib/common/di/diagram-module.d.ts.map +1 -1
- package/lib/common/di/diagram-module.js +4 -51
- package/lib/common/di/diagram-module.js.map +1 -1
- package/lib/common/di/glsp-module.js +2 -1
- package/lib/common/di/glsp-module.js.map +1 -1
- package/lib/common/di/server-module.d.ts +0 -1
- package/lib/common/di/server-module.d.ts.map +1 -1
- package/lib/common/di/server-module.js +0 -1
- package/lib/common/di/server-module.js.map +1 -1
- package/lib/common/diagram/request-type-hints-action-handler.js +2 -1
- package/lib/common/diagram/request-type-hints-action-handler.js.map +1 -1
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.js +2 -1
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.js.map +1 -1
- package/lib/common/features/contextactions/command-palette-action-provider.js +2 -1
- package/lib/common/features/contextactions/command-palette-action-provider.js.map +1 -1
- package/lib/common/features/contextactions/context-actions-provider-registry.js +2 -1
- package/lib/common/features/contextactions/context-actions-provider-registry.js.map +1 -1
- package/lib/common/features/contextactions/context-menu-item-provider.js +2 -1
- package/lib/common/features/contextactions/context-menu-item-provider.js.map +1 -1
- package/lib/common/features/contextactions/request-context-actions-handler.js +2 -1
- package/lib/common/features/contextactions/request-context-actions-handler.js.map +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.js +4 -2
- package/lib/common/features/contextactions/tool-palette-item-provider.js.map +1 -1
- package/lib/common/features/directediting/context-edit-validator-registry.js +2 -1
- package/lib/common/features/directediting/context-edit-validator-registry.js.map +1 -1
- package/lib/common/features/directediting/label-edit-validator.js +2 -1
- package/lib/common/features/directediting/label-edit-validator.js.map +1 -1
- package/lib/common/features/directediting/request-edit-validation-handler.js +2 -1
- package/lib/common/features/directediting/request-edit-validation-handler.js.map +1 -1
- package/lib/common/features/layout/computed-bounds-action-handler.js +2 -1
- package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -1
- package/lib/common/features/layout/layout-operation-handler.js +2 -1
- package/lib/common/features/layout/layout-operation-handler.js.map +1 -1
- package/lib/common/features/model/gmodel-factory.js +2 -1
- package/lib/common/features/model/gmodel-factory.js.map +1 -1
- package/lib/common/features/model/gmodel-index.js +2 -1
- package/lib/common/features/model/gmodel-index.js.map +1 -1
- package/lib/common/features/model/gmodel-serializer.js +2 -1
- package/lib/common/features/model/gmodel-serializer.js.map +1 -1
- package/lib/common/features/model/model-state.js +2 -1
- package/lib/common/features/model/model-state.js.map +1 -1
- package/lib/common/features/model/model-submission-handler.d.ts +28 -2
- package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
- package/lib/common/features/model/model-submission-handler.js +47 -7
- package/lib/common/features/model/model-submission-handler.js.map +1 -1
- package/lib/common/features/model/request-model-action-handler.d.ts.map +1 -1
- package/lib/common/features/model/request-model-action-handler.js +5 -4
- package/lib/common/features/model/request-model-action-handler.js.map +1 -1
- package/lib/common/features/model/save-model-action-handler.js +2 -1
- package/lib/common/features/model/save-model-action-handler.js.map +1 -1
- package/lib/common/features/navigation/navigation-target-provider-registry.js +2 -1
- package/lib/common/features/navigation/navigation-target-provider-registry.js.map +1 -1
- package/lib/common/features/navigation/navigation-target-resolver.js +2 -1
- package/lib/common/features/navigation/navigation-target-resolver.js.map +1 -1
- package/lib/common/features/navigation/request-navigation-targets-action-handler.js +2 -1
- package/lib/common/features/navigation/request-navigation-targets-action-handler.js.map +1 -1
- package/lib/common/features/navigation/resolve-navigation-targets-action-handler.js +2 -1
- package/lib/common/features/navigation/resolve-navigation-targets-action-handler.js.map +1 -1
- package/lib/common/features/popup/request-popup-model-action-handler.js +2 -1
- package/lib/common/features/popup/request-popup-model-action-handler.js.map +1 -1
- package/lib/common/features/progress/progress-service.js +26 -2
- package/lib/common/features/progress/progress-service.js.map +1 -1
- package/lib/common/features/validation/model-validator.js +2 -1
- package/lib/common/features/validation/model-validator.js.map +1 -1
- package/lib/common/features/validation/request-markers-handler.js +2 -1
- package/lib/common/features/validation/request-markers-handler.js.map +1 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.js +2 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.js.map +1 -1
- package/lib/common/gmodel/change-bounds-operation-handler.js +2 -1
- package/lib/common/gmodel/change-bounds-operation-handler.js.map +1 -1
- package/lib/common/gmodel/change-routing-points-operation-handler.js +2 -1
- package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -1
- package/lib/common/gmodel/cut-operation-handler.js +2 -1
- package/lib/common/gmodel/cut-operation-handler.js.map +1 -1
- package/lib/common/gmodel/delete-operation-handler.js +2 -1
- package/lib/common/gmodel/delete-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js +2 -1
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js +2 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-diagram-module.js +2 -1
- package/lib/common/gmodel/gmodel-diagram-module.js.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.js +26 -2
- package/lib/common/gmodel/paste-operation-handler.js.map +1 -1
- package/lib/common/gmodel/reconnect-edge-operation-handler.js +2 -1
- package/lib/common/gmodel/reconnect-edge-operation-handler.js.map +1 -1
- package/lib/common/launch/glsp-server-launcher.js +2 -1
- package/lib/common/launch/glsp-server-launcher.js.map +1 -1
- package/lib/common/launch/jsonrpc-server-launcher.js +2 -1
- package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -1
- package/lib/common/operations/compound-operation-handler.js +2 -1
- package/lib/common/operations/compound-operation-handler.js.map +1 -1
- package/lib/common/operations/operation-action-handler.d.ts.map +1 -1
- package/lib/common/operations/operation-action-handler.js +3 -2
- package/lib/common/operations/operation-action-handler.js.map +1 -1
- package/lib/common/operations/operation-handler-registry.js +4 -2
- package/lib/common/operations/operation-handler-registry.js.map +1 -1
- package/lib/common/operations/operation-handler.js +2 -1
- package/lib/common/operations/operation-handler.js.map +1 -1
- package/lib/common/protocol/client-action.d.ts +31 -0
- package/lib/common/protocol/client-action.d.ts.map +1 -0
- package/lib/common/protocol/client-action.js +35 -0
- package/lib/common/protocol/client-action.js.map +1 -0
- package/lib/common/protocol/glsp-server.d.ts +1 -1
- package/lib/common/protocol/glsp-server.d.ts.map +1 -1
- package/lib/common/protocol/glsp-server.js +9 -10
- package/lib/common/protocol/glsp-server.js.map +1 -1
- package/lib/common/session/client-session-factory.js +5 -4
- package/lib/common/session/client-session-factory.js.map +1 -1
- package/lib/common/session/client-session-manager.js +2 -1
- package/lib/common/session/client-session-manager.js.map +1 -1
- package/lib/common/utils/console-logger.js +2 -1
- package/lib/common/utils/console-logger.js.map +1 -1
- package/lib/common/utils/logger.js +2 -1
- package/lib/common/utils/logger.js.map +1 -1
- package/lib/common/utils/promise-queue.d.ts.map +1 -1
- package/lib/common/utils/promise-queue.js +3 -6
- package/lib/common/utils/promise-queue.js.map +1 -1
- package/lib/common/utils/registry.js +4 -2
- package/lib/common/utils/registry.js.map +1 -1
- package/lib/node/abstract-json-model-storage.d.ts.map +1 -1
- package/lib/node/abstract-json-model-storage.js +33 -3
- package/lib/node/abstract-json-model-storage.js.map +1 -1
- package/lib/node/di/app-module.js +24 -1
- package/lib/node/di/app-module.js.map +1 -1
- package/lib/node/gmodel/gmodel-storage.js +2 -1
- package/lib/node/gmodel/gmodel-storage.js.map +1 -1
- package/lib/node/launch/cli-parser.js +26 -3
- package/lib/node/launch/cli-parser.js.map +1 -1
- package/lib/node/launch/socket-cli-parser.js +24 -1
- package/lib/node/launch/socket-cli-parser.js.map +1 -1
- package/lib/node/launch/socket-server-launcher.js +27 -3
- package/lib/node/launch/socket-server-launcher.js.map +1 -1
- package/lib/node/launch/websocket-server-launcher.js +27 -3
- package/lib/node/launch/websocket-server-launcher.js.map +1 -1
- package/package.json +3 -4
- package/src/common/actions/action-dispatcher.spec.ts +3 -2
- package/src/common/actions/action-dispatcher.ts +8 -5
- package/src/common/actions/client-action-handler.ts +28 -18
- package/src/common/actions/global-action-provider.spec.ts +4 -15
- package/src/common/actions/global-action-provider.ts +21 -25
- package/src/common/command/recording-command.ts +2 -2
- package/src/common/di/client-session-module.ts +17 -10
- package/src/common/di/diagram-module.ts +6 -71
- package/src/common/di/server-module.ts +0 -1
- package/src/common/features/model/model-submission-handler.ts +50 -5
- package/src/common/features/model/request-model-action-handler.ts +4 -4
- package/src/common/operations/operation-action-handler.ts +2 -2
- package/src/common/protocol/client-action.ts +38 -0
- package/src/common/protocol/glsp-server.spec.ts +11 -10
- package/src/common/protocol/glsp-server.ts +11 -14
- package/src/common/session/client-session-factory.spec.ts +2 -2
- package/src/common/session/client-session-factory.ts +3 -3
- package/src/common/session/client-session-manager.spec.ts +4 -3
- package/src/common/utils/promise-queue.ts +4 -5
- package/src/node/abstract-json-model-storage.ts +8 -2
- package/src/node/launch/cli-parser.ts +1 -1
|
@@ -13,44 +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 {
|
|
17
|
-
CenterAction,
|
|
18
|
-
DeleteMarkersAction,
|
|
19
|
-
EndProgressAction,
|
|
20
|
-
ExportSvgAction,
|
|
21
|
-
FitToScreenAction,
|
|
22
|
-
NavigateToExternalTargetAction,
|
|
23
|
-
NavigateToTargetAction,
|
|
24
|
-
RequestBoundsAction,
|
|
25
|
-
SelectAction,
|
|
26
|
-
SelectAllAction,
|
|
27
|
-
ServerMessageAction,
|
|
28
|
-
ServerStatusAction,
|
|
29
|
-
SetBoundsAction,
|
|
30
|
-
SetClipboardDataAction,
|
|
31
|
-
SetContextActions,
|
|
32
|
-
SetDirtyStateAction,
|
|
33
|
-
SetEditModeAction,
|
|
34
|
-
SetEditValidationResultAction,
|
|
35
|
-
SetMarkersAction,
|
|
36
|
-
SetModelAction,
|
|
37
|
-
SetNavigationTargetsAction,
|
|
38
|
-
SetPopupModelAction,
|
|
39
|
-
SetResolvedNavigationTargetAction,
|
|
40
|
-
SetTypeHintsAction,
|
|
41
|
-
SetViewportAction,
|
|
42
|
-
SourceModelChangedAction,
|
|
43
|
-
StartProgressAction,
|
|
44
|
-
TriggerEdgeCreationAction,
|
|
45
|
-
TriggerNodeCreationAction,
|
|
46
|
-
UpdateModelAction,
|
|
47
|
-
UpdateProgressAction
|
|
48
|
-
} from '@eclipse-glsp/protocol';
|
|
49
16
|
import { interfaces } from 'inversify';
|
|
50
17
|
import { ActionDispatcher, DefaultActionDispatcher } from '../actions/action-dispatcher';
|
|
51
18
|
import { ActionHandlerConstructor, ActionHandlerFactory } from '../actions/action-handler';
|
|
52
19
|
import { ActionHandlerRegistry, ActionHandlerRegistryInitializer } from '../actions/action-handler-registry';
|
|
53
|
-
import {
|
|
20
|
+
import { ClientActionForwarder } from '../actions/client-action-handler';
|
|
54
21
|
import { CommandStack, DefaultCommandStack } from '../command/command-stack';
|
|
55
22
|
import { UndoRedoActionHandler } from '../command/undo-redo-action-handler';
|
|
56
23
|
import { DiagramConfiguration } from '../diagram/diagram-configuration';
|
|
@@ -101,7 +68,6 @@ import { BindingTarget, applyBindingTarget, applyOptionalBindingTarget } from '.
|
|
|
101
68
|
import { GLSPModule } from './glsp-module';
|
|
102
69
|
import { InstanceMultiBinding, MultiBinding } from './multi-binding';
|
|
103
70
|
import {
|
|
104
|
-
ClientActionKinds,
|
|
105
71
|
ClientId,
|
|
106
72
|
ContextActionsProviders,
|
|
107
73
|
ContextEditValidators,
|
|
@@ -167,6 +133,7 @@ export abstract class DiagramModule extends GLSPModule {
|
|
|
167
133
|
applyBindingTarget(context, DiagramType, this.bindDiagramType());
|
|
168
134
|
applyBindingTarget(context, ClientId, this.bindClientId());
|
|
169
135
|
applyBindingTarget(context, DiagramConfiguration, this.bindDiagramConfiguration()).inSingletonScope();
|
|
136
|
+
applyBindingTarget(context, ClientActionForwarder, this.bindClientActionForwarder()).inSingletonScope();
|
|
170
137
|
|
|
171
138
|
// Model-related bindings
|
|
172
139
|
applyBindingTarget(context, GModelSerializer, this.bindGModelSerializer()).inSingletonScope();
|
|
@@ -191,7 +158,6 @@ export abstract class DiagramModule extends GLSPModule {
|
|
|
191
158
|
|
|
192
159
|
// Action & operation related bindings
|
|
193
160
|
applyBindingTarget(context, ActionDispatcher, this.bindActionDispatcher()).inSingletonScope();
|
|
194
|
-
this.configureMultiBinding(new InstanceMultiBinding<string>(ClientActionKinds), binding => this.configureClientActions(binding));
|
|
195
161
|
this.configureMultiBinding(new InstanceMultiBinding<ActionHandlerConstructor>(ActionHandlerConstructor), binding =>
|
|
196
162
|
this.configureActionHandlers(binding)
|
|
197
163
|
);
|
|
@@ -233,7 +199,6 @@ export abstract class DiagramModule extends GLSPModule {
|
|
|
233
199
|
}
|
|
234
200
|
|
|
235
201
|
protected configureActionHandlers(binding: InstanceMultiBinding<ActionHandlerConstructor>): void {
|
|
236
|
-
binding.add(ClientActionHandler);
|
|
237
202
|
binding.add(RequestModelActionHandler);
|
|
238
203
|
binding.add(RequestContextActionsHandler);
|
|
239
204
|
binding.add(RequestTypeHintsActionHandler);
|
|
@@ -260,6 +225,10 @@ export abstract class DiagramModule extends GLSPModule {
|
|
|
260
225
|
return DefaultGModelSerializer;
|
|
261
226
|
}
|
|
262
227
|
|
|
228
|
+
protected bindClientActionForwarder(): BindingTarget<ClientActionForwarder> {
|
|
229
|
+
return ClientActionForwarder;
|
|
230
|
+
}
|
|
231
|
+
|
|
263
232
|
protected bindGModelIndex(): BindingTarget<GModelIndex> {
|
|
264
233
|
return GModelIndex;
|
|
265
234
|
}
|
|
@@ -330,40 +299,6 @@ export abstract class DiagramModule extends GLSPModule {
|
|
|
330
299
|
// empty as default
|
|
331
300
|
}
|
|
332
301
|
|
|
333
|
-
protected configureClientActions(binding: InstanceMultiBinding<string>): void {
|
|
334
|
-
binding.add(CenterAction.KIND);
|
|
335
|
-
binding.add(DeleteMarkersAction.KIND);
|
|
336
|
-
binding.add(EndProgressAction.KIND);
|
|
337
|
-
binding.add(ExportSvgAction.KIND);
|
|
338
|
-
binding.add(FitToScreenAction.KIND);
|
|
339
|
-
binding.add(NavigateToExternalTargetAction.KIND);
|
|
340
|
-
binding.add(NavigateToTargetAction.KIND);
|
|
341
|
-
binding.add(RequestBoundsAction.KIND);
|
|
342
|
-
binding.add(SelectAction.KIND);
|
|
343
|
-
binding.add(SelectAllAction.KIND);
|
|
344
|
-
binding.add(ServerMessageAction.KIND);
|
|
345
|
-
binding.add(ServerStatusAction.KIND);
|
|
346
|
-
binding.add(SetBoundsAction.KIND);
|
|
347
|
-
binding.add(SetClipboardDataAction.KIND);
|
|
348
|
-
binding.add(SetContextActions.KIND);
|
|
349
|
-
binding.add(SetDirtyStateAction.KIND);
|
|
350
|
-
binding.add(SetEditModeAction.KIND);
|
|
351
|
-
binding.add(SetEditValidationResultAction.KIND);
|
|
352
|
-
binding.add(SetMarkersAction.KIND);
|
|
353
|
-
binding.add(SetModelAction.KIND);
|
|
354
|
-
binding.add(SetNavigationTargetsAction.KIND);
|
|
355
|
-
binding.add(SetPopupModelAction.KIND);
|
|
356
|
-
binding.add(SetResolvedNavigationTargetAction.KIND);
|
|
357
|
-
binding.add(SetTypeHintsAction.KIND);
|
|
358
|
-
binding.add(SetViewportAction.KIND);
|
|
359
|
-
binding.add(SourceModelChangedAction.KIND);
|
|
360
|
-
binding.add(StartProgressAction.KIND);
|
|
361
|
-
binding.add(TriggerEdgeCreationAction.KIND);
|
|
362
|
-
binding.add(TriggerNodeCreationAction.KIND);
|
|
363
|
-
binding.add(UpdateModelAction.KIND);
|
|
364
|
-
binding.add(UpdateProgressAction.KIND);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
302
|
protected bindContextActionsProviderRegistry(): BindingTarget<ContextActionsProviderRegistry> {
|
|
368
303
|
return ContextActionsProviderRegistry;
|
|
369
304
|
}
|
|
@@ -41,7 +41,6 @@ import { DiagramModules, InjectionContainer } from './service-identifiers';
|
|
|
41
41
|
* * {@link ClientSessionFactory}
|
|
42
42
|
* * {@link ClientSessionManager}
|
|
43
43
|
* * {@link GlobalActionProvider}
|
|
44
|
-
* * {@link GLSPClientProxy}
|
|
45
44
|
*
|
|
46
45
|
*/
|
|
47
46
|
export class ServerModule extends GLSPModule {
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
MarkersReason,
|
|
21
21
|
MaybePromise,
|
|
22
22
|
RequestBoundsAction,
|
|
23
|
+
RequestModelAction,
|
|
23
24
|
SetDirtyStateAction,
|
|
24
25
|
SetMarkersAction,
|
|
25
26
|
SetModelAction,
|
|
@@ -35,6 +36,15 @@ import { GModelFactory } from './gmodel-factory';
|
|
|
35
36
|
import { GModelSerializer } from './gmodel-serializer';
|
|
36
37
|
import { ModelState } from './model-state';
|
|
37
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Helper class that provides utility methods to handle model updates i.e.
|
|
41
|
+
* submit a new model to the client. In addition, to the core model update action this class
|
|
42
|
+
* also takes care of related behavior like dirty state handling, validation and client/server side layouting.
|
|
43
|
+
* Note that the submissions handler is only responsible for deriving the set of actions that comprise a model update
|
|
44
|
+
* but does not actually dispatch them. The returned actions should be either manually dispatched
|
|
45
|
+
* to the `ActionDispatcher`, or simply returned as the result of an
|
|
46
|
+
* `ActionHandler.execute` method.
|
|
47
|
+
*/
|
|
38
48
|
@injectable()
|
|
39
49
|
export class ModelSubmissionHandler {
|
|
40
50
|
@inject(DiagramConfiguration)
|
|
@@ -60,8 +70,34 @@ export class ModelSubmissionHandler {
|
|
|
60
70
|
@optional()
|
|
61
71
|
protected validator?: ModelValidator;
|
|
62
72
|
|
|
73
|
+
protected requestModelAction?: RequestModelAction;
|
|
74
|
+
|
|
63
75
|
/**
|
|
64
|
-
* Returns a list of actions to
|
|
76
|
+
* Returns a list of actions to submit the initial revision of the client-side model, based on the injected
|
|
77
|
+
* {@link GModelState}. Typically this method is invoked by the {@link RequestModelActionHandler} when the diagram
|
|
78
|
+
* is (re)loaded.
|
|
79
|
+
* <p>
|
|
80
|
+
* These actions are not processed by this {@link ModelSubmissionHandler}, but should be either manually dispatched
|
|
81
|
+
* to the {@link ActionDispatcher}, or simply returned as the result of an
|
|
82
|
+
* {@link ActionHandler#execute(Action)} method.
|
|
83
|
+
* </p>
|
|
84
|
+
*
|
|
85
|
+
* @param requestAction The {@link RequestModelAction} that triggere the initial model update
|
|
86
|
+
* @return A list of actions to be processed in order to submit the intial model.
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
submitInitialModel(requestAction: RequestModelAction): MaybePromise<Action[]> {
|
|
90
|
+
/*
|
|
91
|
+
* In the default update action flow a `RequestModelAction` does not directly trigger a `SetModelAction` response
|
|
92
|
+
* (RequestModelAction (C) -> RequestBoundsAction (S) -> ComputedBoundsAction (C) -> SetModelACtion (S)
|
|
93
|
+
* Therefore we temporarily store the action later retrival
|
|
94
|
+
*/
|
|
95
|
+
this.requestModelAction = requestAction;
|
|
96
|
+
return this.submitModel();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Returns a list of actions to update the client-side model, based on the injected {@link ModelState}
|
|
65
101
|
*
|
|
66
102
|
* These actions are not processed by this {@link ModelSubmissionHandler}, but should be either manually dispatched
|
|
67
103
|
* to the `ActionDispatcher`, or simply returned as the result of an `ActionHandler.execute()` method.
|
|
@@ -71,13 +107,15 @@ export class ModelSubmissionHandler {
|
|
|
71
107
|
*/
|
|
72
108
|
submitModel(reason?: DirtyStateChangeReason): MaybePromise<Action[]> {
|
|
73
109
|
this.modelFactory.createModel();
|
|
74
|
-
|
|
110
|
+
|
|
111
|
+
const revision = this.requestModelAction ? 0 : this.modelState.root.revision! + 1;
|
|
112
|
+
this.modelState.root.revision = revision;
|
|
75
113
|
const root = this.serializeGModel();
|
|
76
114
|
|
|
77
115
|
if (this.diagramConfiguration.needsClientLayout) {
|
|
78
116
|
return [RequestBoundsAction.create(root), SetDirtyStateAction.create(this.commandStack.isDirty, { reason })];
|
|
79
117
|
}
|
|
80
|
-
return
|
|
118
|
+
return this.submitModelDirectly(reason);
|
|
81
119
|
}
|
|
82
120
|
|
|
83
121
|
/**
|
|
@@ -102,8 +140,8 @@ export class ModelSubmissionHandler {
|
|
|
102
140
|
}
|
|
103
141
|
const result: Action[] = [];
|
|
104
142
|
result.push(
|
|
105
|
-
|
|
106
|
-
?
|
|
143
|
+
this.requestModelAction
|
|
144
|
+
? this.createSetModeAction(root)
|
|
107
145
|
: UpdateModelAction.create(root, { animate: this.diagramConfiguration.animatedUpdate })
|
|
108
146
|
);
|
|
109
147
|
if (!this.diagramConfiguration.needsClientLayout) {
|
|
@@ -116,6 +154,13 @@ export class ModelSubmissionHandler {
|
|
|
116
154
|
return result;
|
|
117
155
|
}
|
|
118
156
|
|
|
157
|
+
protected createSetModeAction(newRoot: GModelRootSchema): SetModelAction {
|
|
158
|
+
const responseId = this.requestModelAction?.requestId ?? '';
|
|
159
|
+
const response = SetModelAction.create(newRoot, { responseId });
|
|
160
|
+
this.requestModelAction = undefined;
|
|
161
|
+
return response;
|
|
162
|
+
}
|
|
163
|
+
|
|
119
164
|
protected serializeGModel(): GModelRootSchema {
|
|
120
165
|
return this.serializer.createSchema(this.modelState.root);
|
|
121
166
|
}
|
|
@@ -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 { Action, RequestModelAction,
|
|
16
|
+
import { Action, RequestModelAction, StatusAction } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { inject, injectable } from 'inversify';
|
|
18
18
|
import { ActionDispatcher } from '../../actions/action-dispatcher';
|
|
19
19
|
import { ActionHandler } from '../../actions/action-handler';
|
|
@@ -61,7 +61,7 @@ export class RequestModelActionHandler implements ActionHandler {
|
|
|
61
61
|
}
|
|
62
62
|
this.reportModelLoadingFinished(progress);
|
|
63
63
|
|
|
64
|
-
return this.submissionHandler.
|
|
64
|
+
return this.submissionHandler.submitInitialModel(action);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
protected async handleReconnect(action: RequestModelAction): Promise<void> {
|
|
@@ -76,12 +76,12 @@ export class RequestModelActionHandler implements ActionHandler {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
protected reportModelLoading(message: string): ProgressMonitor {
|
|
79
|
-
this.actionDispatcher.dispatch(
|
|
79
|
+
this.actionDispatcher.dispatch(StatusAction.create(message, { severity: 'INFO' }));
|
|
80
80
|
return this.progressService.start(message);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
protected reportModelLoadingFinished(monitor: ProgressMonitor): void {
|
|
84
|
-
this.actionDispatcher.dispatch(
|
|
84
|
+
this.actionDispatcher.dispatch(StatusAction.create('', { severity: 'NONE' }));
|
|
85
85
|
monitor.end();
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -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 { Action, MaybePromise,
|
|
16
|
+
import { Action, MaybePromise, MessageAction, Operation } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { inject, injectable } from 'inversify';
|
|
18
18
|
import { ActionHandler } from '../actions/action-handler';
|
|
19
19
|
import { Command } from '../command/command';
|
|
@@ -47,7 +47,7 @@ export class OperationActionHandler implements ActionHandler {
|
|
|
47
47
|
}
|
|
48
48
|
if (this.modelState.isReadonly) {
|
|
49
49
|
return [
|
|
50
|
-
|
|
50
|
+
MessageAction.create(`Server is in readonly-mode! Could not execute operation: ${action.kind}`, {
|
|
51
51
|
severity: 'WARNING'
|
|
52
52
|
})
|
|
53
53
|
];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2023 EclipseSource 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
|
+
|
|
17
|
+
import { Action } from '@eclipse-glsp/protocol';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A helper interface that allows the server to mark actions that have been received from the client.
|
|
21
|
+
*/
|
|
22
|
+
export interface ClientAction extends Action {
|
|
23
|
+
__receivedFromClient: true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export namespace ClientAction {
|
|
27
|
+
export function is(object: unknown): object is ClientAction {
|
|
28
|
+
return Action.is(object) && '__receivedFromClient' in object && object.__receivedFromClient === true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Mark the given action as {@link ClientAction} by attaching the "__receivedFromClient" property
|
|
33
|
+
* @param action The action that should be marked as client action
|
|
34
|
+
*/
|
|
35
|
+
export function mark(action: Action): void {
|
|
36
|
+
(action as ClientAction).__receivedFromClient = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
InitializeClientSessionParameters,
|
|
21
21
|
InitializeParameters
|
|
22
22
|
} from '@eclipse-glsp/protocol';
|
|
23
|
+
import * as assert from 'assert';
|
|
23
24
|
import { expect } from 'chai';
|
|
24
25
|
import { Container, ContainerModule } from 'inversify';
|
|
25
26
|
import * as sinon from 'sinon';
|
|
@@ -28,7 +29,6 @@ import { ClientSessionManager } from '../session/client-session-manager';
|
|
|
28
29
|
import * as mock from '../test/mock-util';
|
|
29
30
|
import { Logger } from '../utils/logger';
|
|
30
31
|
import { DefaultGLSPServer } from './glsp-server';
|
|
31
|
-
import assert = require('assert');
|
|
32
32
|
|
|
33
33
|
describe('test DefaultGLSPServer', () => {
|
|
34
34
|
const container = new Container();
|
|
@@ -36,8 +36,8 @@ describe('test DefaultGLSPServer', () => {
|
|
|
36
36
|
const diagramType = 'myDiagram';
|
|
37
37
|
const applicationId = 'Test';
|
|
38
38
|
const protocolVersion = '1.0.0';
|
|
39
|
-
const
|
|
40
|
-
|
|
39
|
+
const actionKinds = new Map<string, string[]>();
|
|
40
|
+
actionKinds.set(diagramType, ['A1', 'A2']);
|
|
41
41
|
const sessionManager = new mock.StubClientSessionManager();
|
|
42
42
|
const spy_sessionManager_getOrCreate = sinon.spy(sessionManager, 'getOrCreateClientSession');
|
|
43
43
|
const spy_sessionManager_dispose = sinon.spy(sessionManager, 'disposeClientSession');
|
|
@@ -53,7 +53,7 @@ describe('test DefaultGLSPServer', () => {
|
|
|
53
53
|
bind(Logger).toConstantValue(new mock.StubLogger());
|
|
54
54
|
bind(GLSPClientProxy).toConstantValue(new mock.StubGLSPClientProxy());
|
|
55
55
|
bind(ClientSessionManager).toConstantValue(sessionManager);
|
|
56
|
-
bind(GlobalActionProvider).toConstantValue(
|
|
56
|
+
bind(GlobalActionProvider).toConstantValue(<GlobalActionProvider>{ actionKinds });
|
|
57
57
|
bind(GLSPServerListener).toConstantValue(listener1);
|
|
58
58
|
})
|
|
59
59
|
);
|
|
@@ -70,7 +70,7 @@ describe('test DefaultGLSPServer', () => {
|
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
it('Test calls before server initialization (should throw errors)', async () => {
|
|
73
|
-
assert.rejects(() => glspServer.initializeClientSession({ clientSessionId: 'id', diagramType: 'type' }));
|
|
73
|
+
assert.rejects(() => glspServer.initializeClientSession({ clientSessionId: 'id', diagramType: 'type', clientActionKinds: [] }));
|
|
74
74
|
assert.rejects(() => glspServer.disposeClientSession({ clientSessionId: 'id' }));
|
|
75
75
|
assert.throws(() => glspServer.process({ clientId: 'id', action: { kind: 'action' } }));
|
|
76
76
|
});
|
|
@@ -109,8 +109,8 @@ describe('test DefaultGLSPServer', () => {
|
|
|
109
109
|
const initializeParameters: InitializeParameters = { applicationId, protocolVersion };
|
|
110
110
|
const result = await glspServer.initialize(initializeParameters);
|
|
111
111
|
expect(result.protocolVersion).to.be.equal(protocolVersion);
|
|
112
|
-
expect(result.serverActions[diagramType]).to.be.equal(
|
|
113
|
-
expect(result.serverActions[diagramType]).to.be.equal(
|
|
112
|
+
expect(result.serverActions[diagramType]).to.be.equal(actionKinds.get(diagramType));
|
|
113
|
+
expect(result.serverActions[diagramType]).to.be.equal(actionKinds.get(diagramType));
|
|
114
114
|
expect(spy_listener1_initialize.calledWith(glspServer));
|
|
115
115
|
expect(spy_listener2_initialize.notCalled);
|
|
116
116
|
});
|
|
@@ -119,8 +119,8 @@ describe('test DefaultGLSPServer', () => {
|
|
|
119
119
|
const initializeParameters: InitializeParameters = { applicationId, protocolVersion };
|
|
120
120
|
const result = await glspServer.initialize(initializeParameters);
|
|
121
121
|
expect(result.protocolVersion).to.be.equal(protocolVersion);
|
|
122
|
-
expect(result.serverActions[diagramType]).to.be.equal(
|
|
123
|
-
expect(result.serverActions[diagramType]).to.be.equal(
|
|
122
|
+
expect(result.serverActions[diagramType]).to.be.equal(actionKinds.get(diagramType));
|
|
123
|
+
expect(result.serverActions[diagramType]).to.be.equal(actionKinds.get(diagramType));
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
it('initialize - subsequent call with other parameters', async () => {
|
|
@@ -131,7 +131,8 @@ describe('test DefaultGLSPServer', () => {
|
|
|
131
131
|
it('initialize client session', async () => {
|
|
132
132
|
const initializeClientSessionParameters: InitializeClientSessionParameters = {
|
|
133
133
|
clientSessionId,
|
|
134
|
-
diagramType
|
|
134
|
+
diagramType,
|
|
135
|
+
clientActionKinds: []
|
|
135
136
|
};
|
|
136
137
|
await glspServer.initializeClientSession(initializeClientSessionParameters);
|
|
137
138
|
expect(spy_sessionManager_getOrCreate.calledWith(initializeClientSessionParameters));
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
ActionMessage,
|
|
18
18
|
Args,
|
|
19
19
|
DisposeClientSessionParameters,
|
|
20
|
-
distinctAdd,
|
|
21
20
|
GLSPClientProxy,
|
|
22
21
|
GLSPServer,
|
|
23
22
|
GLSPServerListener,
|
|
@@ -25,9 +24,10 @@ import {
|
|
|
25
24
|
InitializeParameters,
|
|
26
25
|
InitializeResult,
|
|
27
26
|
MaybePromise,
|
|
28
|
-
|
|
27
|
+
MessageAction,
|
|
29
28
|
ServerActions,
|
|
30
|
-
|
|
29
|
+
distinctAdd,
|
|
30
|
+
remove
|
|
31
31
|
} from '@eclipse-glsp/protocol';
|
|
32
32
|
import { inject, injectable, multiInject, optional } from 'inversify';
|
|
33
33
|
import { GlobalActionProvider } from '../actions/global-action-provider';
|
|
@@ -35,6 +35,7 @@ import { ClientSession } from '../session/client-session';
|
|
|
35
35
|
import { ClientSessionManager } from '../session/client-session-manager';
|
|
36
36
|
import { GLSPServerError } from '../utils/glsp-server-error';
|
|
37
37
|
import { Logger } from '../utils/logger';
|
|
38
|
+
import { ClientAction } from './client-action';
|
|
38
39
|
|
|
39
40
|
@injectable()
|
|
40
41
|
export class DefaultGLSPServer implements GLSPServer {
|
|
@@ -50,8 +51,7 @@ export class DefaultGLSPServer implements GLSPServer {
|
|
|
50
51
|
protected actionProvider: GlobalActionProvider;
|
|
51
52
|
|
|
52
53
|
@inject(GLSPClientProxy)
|
|
53
|
-
|
|
54
|
-
protected glspClientProxy?: GLSPClientProxy;
|
|
54
|
+
protected glspClientProxy: GLSPClientProxy;
|
|
55
55
|
|
|
56
56
|
protected initializeResult?: InitializeResult;
|
|
57
57
|
|
|
@@ -97,7 +97,7 @@ export class DefaultGLSPServer implements GLSPServer {
|
|
|
97
97
|
this.applicationId = params.applicationId;
|
|
98
98
|
const serverActions: ServerActions = {};
|
|
99
99
|
|
|
100
|
-
this.actionProvider.
|
|
100
|
+
this.actionProvider.actionKinds.forEach((kinds, diagramType) => (serverActions[diagramType] = kinds));
|
|
101
101
|
|
|
102
102
|
let result = { protocolVersion: DefaultGLSPServer.PROTOCOL_VERSION, serverActions };
|
|
103
103
|
|
|
@@ -149,8 +149,9 @@ export class DefaultGLSPServer implements GLSPServer {
|
|
|
149
149
|
if (!clientSession) {
|
|
150
150
|
throw new Error(`No client session has been initialized for client id: ${clientSessionId}`);
|
|
151
151
|
}
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
const action = message.action;
|
|
153
|
+
ClientAction.mark(action);
|
|
154
|
+
clientSession.actionDispatcher.dispatch(action).catch(error => this.handleProcessError(message, error));
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
protected handleProcessError(message: ActionMessage, reason: any): void | PromiseLike<void> {
|
|
@@ -162,16 +163,12 @@ export class DefaultGLSPServer implements GLSPServer {
|
|
|
162
163
|
details = reason.cause?.toString?.();
|
|
163
164
|
errorMsg = reason.message;
|
|
164
165
|
}
|
|
165
|
-
const errorAction =
|
|
166
|
+
const errorAction = MessageAction.create(errorMsg, { severity: 'ERROR', details });
|
|
166
167
|
this.sendToClient({ clientId: message.clientId, action: errorAction });
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
protected sendToClient(message: ActionMessage): void {
|
|
170
|
-
|
|
171
|
-
this.glspClientProxy.process(message);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
throw new Error("Could not send message to client. No 'GLSPClientProxy' is connected");
|
|
171
|
+
this.glspClientProxy.process(message);
|
|
175
172
|
}
|
|
176
173
|
|
|
177
174
|
getClientSession(sessionId: string): ClientSession | undefined {
|
|
@@ -47,7 +47,7 @@ describe('test DefaultClientSessionFactory', () => {
|
|
|
47
47
|
const factory = container.resolve(DefaultClientSessionFactory);
|
|
48
48
|
|
|
49
49
|
it('create - new client session', () => {
|
|
50
|
-
const session = factory.create({ clientSessionId, diagramType });
|
|
50
|
+
const session = factory.create({ clientSessionId, diagramType, clientActionKinds: [] });
|
|
51
51
|
expect(session.id).to.be.equal(clientSessionId);
|
|
52
52
|
expect(session.diagramType).to.be.equal(diagramType);
|
|
53
53
|
expect(session.container.parent).to.be.equal(container);
|
|
@@ -55,6 +55,6 @@ describe('test DefaultClientSessionFactory', () => {
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
it('create - unknown diagram type', () => {
|
|
58
|
-
expect(() => factory.create({ clientSessionId, diagramType: 'unknown-type' })).to.throw(GLSPServerError);
|
|
58
|
+
expect(() => factory.create({ clientSessionId, diagramType: 'unknown-type', clientActionKinds: [] })).to.throw(GLSPServerError);
|
|
59
59
|
});
|
|
60
60
|
});
|
|
@@ -52,18 +52,18 @@ export class DefaultClientSessionFactory implements ClientSessionFactory {
|
|
|
52
52
|
protected glspClient: GLSPClientProxy;
|
|
53
53
|
|
|
54
54
|
create(params: InitializeClientSessionParameters): ClientSession {
|
|
55
|
-
const { clientSessionId:
|
|
55
|
+
const { clientSessionId: clientId, diagramType, clientActionKinds, args } = params;
|
|
56
56
|
const diagramModules = this.diagramModules.get(diagramType);
|
|
57
57
|
if (!diagramModules || diagramModules.length === 0) {
|
|
58
58
|
throw new GLSPServerError(`Could not retrieve diagram module configuration for diagram type: '${diagramType}''`);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const sessionModule = createClientSessionModule(
|
|
61
|
+
const sessionModule = createClientSessionModule({ clientId, glspClient: this.glspClient, clientActionKinds });
|
|
62
62
|
const sessionContainer = this.serverContainer.createChild();
|
|
63
63
|
sessionContainer.load(...diagramModules, sessionModule);
|
|
64
64
|
const initializers = sessionContainer.getAll<ClientSessionInitializer>(ClientSessionInitializer);
|
|
65
65
|
initializers.forEach(service => service.initialize(args));
|
|
66
66
|
const actionDispatcher = sessionContainer.get<ActionDispatcher>(ActionDispatcher);
|
|
67
|
-
return new DefaultClientSession(
|
|
67
|
+
return new DefaultClientSession(clientId, diagramType, actionDispatcher, sessionContainer);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
import { expect } from 'chai';
|
|
16
17
|
import { Container, ContainerModule } from 'inversify';
|
|
18
|
+
import * as sinon from 'sinon';
|
|
17
19
|
import * as mock from '../test/mock-util';
|
|
18
20
|
import { Logger } from '../utils/logger';
|
|
19
21
|
import { ClientSessionFactory } from './client-session-factory';
|
|
20
22
|
import { DefaultClientSessionManager } from './client-session-manager';
|
|
21
|
-
import { expect } from 'chai';
|
|
22
|
-
import * as sinon from 'sinon';
|
|
23
23
|
|
|
24
24
|
describe('test DefaultClientSessionManager', () => {
|
|
25
25
|
const testSession = mock.createClientSession('myId', 'myDiagram');
|
|
@@ -47,7 +47,8 @@ describe('test DefaultClientSessionManager', () => {
|
|
|
47
47
|
// Test execution
|
|
48
48
|
const createdSession = sessionManager.getOrCreateClientSession({
|
|
49
49
|
clientSessionId: testSession.id,
|
|
50
|
-
diagramType: testSession.diagramType
|
|
50
|
+
diagramType: testSession.diagramType,
|
|
51
|
+
clientActionKinds: []
|
|
51
52
|
});
|
|
52
53
|
expect(createdSession).to.not.be.undefined;
|
|
53
54
|
expect(createdSession.id).to.be.equal(testSession.id);
|
|
@@ -62,14 +62,13 @@ export class PromiseQueue<T = void> {
|
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.resolveQueuedPromise(element);
|
|
68
|
-
} catch (error) {
|
|
65
|
+
this.busy = true;
|
|
66
|
+
this.resolveQueuedPromise(element).catch(error => {
|
|
69
67
|
element.reject(error);
|
|
70
68
|
this.busy = false;
|
|
71
69
|
this.dequeue();
|
|
72
|
-
}
|
|
70
|
+
});
|
|
71
|
+
|
|
73
72
|
return true;
|
|
74
73
|
}
|
|
75
74
|
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { MaybePromise, RequestModelAction, SaveModelAction, TypeGuard } from '@eclipse-glsp/protocol';
|
|
17
|
-
import * as fs from 'fs
|
|
17
|
+
import * as fs from 'fs';
|
|
18
18
|
import { inject, injectable } from 'inversify';
|
|
19
|
+
import * as os from 'os';
|
|
19
20
|
import { fileURLToPath } from 'url';
|
|
20
21
|
import { ModelState, SOURCE_URI_ARG } from '../common/features/model/model-state';
|
|
21
22
|
import { SourceModelStorage } from '../common/features/model/source-model-storage';
|
|
@@ -91,7 +92,12 @@ export abstract class AbstractJsonModelStorage implements SourceModelStorage {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
protected toPath(sourceUri: string): string {
|
|
94
|
-
|
|
95
|
+
let path = sourceUri.startsWith('file://') ? fileURLToPath(sourceUri) : sourceUri;
|
|
96
|
+
if (os.platform() === 'win32') {
|
|
97
|
+
// Remove the leading slash if it exists (Windows paths don't have it)
|
|
98
|
+
path = path.replace(/^\//, '');
|
|
99
|
+
}
|
|
100
|
+
return path;
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
protected getFileUri(action: SaveModelAction): string {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import * as cmd from 'commander';
|
|
17
|
-
import * as fs from 'fs
|
|
17
|
+
import * as fs from 'fs';
|
|
18
18
|
import * as path from 'path';
|
|
19
19
|
import { LogLevel, LoggerConfigOptions, asLogLevel } from '../../common/utils/logger';
|
|
20
20
|
|