@eclipse-glsp/server 1.1.0-next.f0fc2cf.63 → 2.0.0

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.
Files changed (244) hide show
  1. package/lib/browser/launch/worker-server-launcher.js +2 -1
  2. package/lib/browser/launch/worker-server-launcher.js.map +1 -1
  3. package/lib/common/actions/action-dispatcher.d.ts +2 -1
  4. package/lib/common/actions/action-dispatcher.d.ts.map +1 -1
  5. package/lib/common/actions/action-dispatcher.js +9 -6
  6. package/lib/common/actions/action-dispatcher.js.map +1 -1
  7. package/lib/common/actions/action-handler-registry.js +4 -2
  8. package/lib/common/actions/action-handler-registry.js.map +1 -1
  9. package/lib/common/actions/client-action-handler.d.ts +17 -8
  10. package/lib/common/actions/client-action-handler.d.ts.map +1 -1
  11. package/lib/common/actions/client-action-handler.js +32 -21
  12. package/lib/common/actions/client-action-handler.js.map +1 -1
  13. package/lib/common/actions/global-action-provider.d.ts +6 -21
  14. package/lib/common/actions/global-action-provider.d.ts.map +1 -1
  15. package/lib/common/actions/global-action-provider.js +17 -21
  16. package/lib/common/actions/global-action-provider.js.map +1 -1
  17. package/lib/common/command/command-stack.js +2 -1
  18. package/lib/common/command/command-stack.js.map +1 -1
  19. package/lib/common/command/recording-command.d.ts +9 -15
  20. package/lib/common/command/recording-command.d.ts.map +1 -1
  21. package/lib/common/command/recording-command.js +12 -26
  22. package/lib/common/command/recording-command.js.map +1 -1
  23. package/lib/common/command/undo-redo-action-handler.js +2 -1
  24. package/lib/common/command/undo-redo-action-handler.js.map +1 -1
  25. package/lib/common/di/client-session-module.d.ts +9 -1
  26. package/lib/common/di/client-session-module.d.ts.map +1 -1
  27. package/lib/common/di/client-session-module.js +9 -9
  28. package/lib/common/di/client-session-module.js.map +1 -1
  29. package/lib/common/di/diagram-module.d.ts +20 -1
  30. package/lib/common/di/diagram-module.d.ts.map +1 -1
  31. package/lib/common/di/diagram-module.js +17 -56
  32. package/lib/common/di/diagram-module.js.map +1 -1
  33. package/lib/common/di/glsp-module.js +2 -1
  34. package/lib/common/di/glsp-module.js.map +1 -1
  35. package/lib/common/di/server-module.d.ts +0 -1
  36. package/lib/common/di/server-module.d.ts.map +1 -1
  37. package/lib/common/di/server-module.js +0 -1
  38. package/lib/common/di/server-module.js.map +1 -1
  39. package/lib/common/features/clipboard/request-clipboard-data-action-handler.d.ts.map +1 -1
  40. package/lib/common/features/clipboard/request-clipboard-data-action-handler.js +2 -1
  41. package/lib/common/features/clipboard/request-clipboard-data-action-handler.js.map +1 -1
  42. package/lib/common/features/contextactions/command-palette-action-provider.js +2 -1
  43. package/lib/common/features/contextactions/command-palette-action-provider.js.map +1 -1
  44. package/lib/common/features/contextactions/context-actions-provider-registry.js +2 -1
  45. package/lib/common/features/contextactions/context-actions-provider-registry.js.map +1 -1
  46. package/lib/common/features/contextactions/context-menu-item-provider.js +2 -1
  47. package/lib/common/features/contextactions/context-menu-item-provider.js.map +1 -1
  48. package/lib/common/features/contextactions/request-context-actions-handler.js +2 -1
  49. package/lib/common/features/contextactions/request-context-actions-handler.js.map +1 -1
  50. package/lib/common/features/contextactions/tool-palette-item-provider.js +4 -2
  51. package/lib/common/features/contextactions/tool-palette-item-provider.js.map +1 -1
  52. package/lib/common/features/directediting/context-edit-validator-registry.js +2 -1
  53. package/lib/common/features/directediting/context-edit-validator-registry.js.map +1 -1
  54. package/lib/common/features/directediting/label-edit-validator.js +2 -1
  55. package/lib/common/features/directediting/label-edit-validator.js.map +1 -1
  56. package/lib/common/features/directediting/request-edit-validation-handler.js +2 -1
  57. package/lib/common/features/directediting/request-edit-validation-handler.js.map +1 -1
  58. package/lib/common/features/layout/computed-bounds-action-handler.js +2 -1
  59. package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -1
  60. package/lib/common/features/layout/layout-operation-handler.js +2 -1
  61. package/lib/common/features/layout/layout-operation-handler.js.map +1 -1
  62. package/lib/common/features/model/gmodel-factory.js +2 -1
  63. package/lib/common/features/model/gmodel-factory.js.map +1 -1
  64. package/lib/common/features/model/gmodel-index.js +2 -1
  65. package/lib/common/features/model/gmodel-index.js.map +1 -1
  66. package/lib/common/features/model/gmodel-serializer.d.ts +10 -10
  67. package/lib/common/features/model/gmodel-serializer.d.ts.map +1 -1
  68. package/lib/common/features/model/gmodel-serializer.js +2 -1
  69. package/lib/common/features/model/gmodel-serializer.js.map +1 -1
  70. package/lib/common/features/model/model-state.d.ts.map +1 -1
  71. package/lib/common/features/model/model-state.js +5 -1
  72. package/lib/common/features/model/model-state.js.map +1 -1
  73. package/lib/common/features/model/model-submission-handler.d.ts +28 -3
  74. package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
  75. package/lib/common/features/model/model-submission-handler.js +63 -8
  76. package/lib/common/features/model/model-submission-handler.js.map +1 -1
  77. package/lib/common/features/model/request-model-action-handler.d.ts.map +1 -1
  78. package/lib/common/features/model/request-model-action-handler.js +5 -4
  79. package/lib/common/features/model/request-model-action-handler.js.map +1 -1
  80. package/lib/common/features/model/save-model-action-handler.js +2 -1
  81. package/lib/common/features/model/save-model-action-handler.js.map +1 -1
  82. package/lib/common/features/navigation/navigation-target-provider-registry.js +2 -1
  83. package/lib/common/features/navigation/navigation-target-provider-registry.js.map +1 -1
  84. package/lib/common/features/navigation/navigation-target-resolver.js +2 -1
  85. package/lib/common/features/navigation/navigation-target-resolver.js.map +1 -1
  86. package/lib/common/features/navigation/request-navigation-targets-action-handler.js +2 -1
  87. package/lib/common/features/navigation/request-navigation-targets-action-handler.js.map +1 -1
  88. package/lib/common/features/navigation/resolve-navigation-targets-action-handler.js +2 -1
  89. package/lib/common/features/navigation/resolve-navigation-targets-action-handler.js.map +1 -1
  90. package/lib/common/features/popup/request-popup-model-action-handler.js +2 -1
  91. package/lib/common/features/popup/request-popup-model-action-handler.js.map +1 -1
  92. package/lib/common/features/progress/progress-service.js +2 -1
  93. package/lib/common/features/progress/progress-service.js.map +1 -1
  94. package/lib/common/features/type-hints/edge-creation-checker.d.ts +42 -0
  95. package/lib/common/features/type-hints/edge-creation-checker.d.ts.map +1 -0
  96. package/lib/common/features/type-hints/edge-creation-checker.js +20 -0
  97. package/lib/common/features/type-hints/edge-creation-checker.js.map +1 -0
  98. package/lib/common/features/type-hints/request-check-edge-action-handler.d.ts +29 -0
  99. package/lib/common/features/type-hints/request-check-edge-action-handler.d.ts.map +1 -0
  100. package/lib/common/features/type-hints/request-check-edge-action-handler.js +72 -0
  101. package/lib/common/features/type-hints/request-check-edge-action-handler.js.map +1 -0
  102. package/lib/common/{diagram → features/type-hints}/request-type-hints-action-handler.d.ts +2 -3
  103. package/lib/common/features/type-hints/request-type-hints-action-handler.d.ts.map +1 -0
  104. package/lib/common/{diagram → features/type-hints}/request-type-hints-action-handler.js +3 -3
  105. package/lib/common/features/type-hints/request-type-hints-action-handler.js.map +1 -0
  106. package/lib/common/features/validation/model-validator.js +2 -1
  107. package/lib/common/features/validation/model-validator.js.map +1 -1
  108. package/lib/common/features/validation/request-markers-handler.js +2 -1
  109. package/lib/common/features/validation/request-markers-handler.js.map +1 -1
  110. package/lib/common/gmodel/apply-label-edit-operation-handler.js +2 -1
  111. package/lib/common/gmodel/apply-label-edit-operation-handler.js.map +1 -1
  112. package/lib/common/gmodel/change-bounds-operation-handler.js +2 -1
  113. package/lib/common/gmodel/change-bounds-operation-handler.js.map +1 -1
  114. package/lib/common/gmodel/change-routing-points-operation-handler.js +2 -1
  115. package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -1
  116. package/lib/common/gmodel/cut-operation-handler.d.ts.map +1 -1
  117. package/lib/common/gmodel/cut-operation-handler.js +7 -4
  118. package/lib/common/gmodel/cut-operation-handler.js.map +1 -1
  119. package/lib/common/gmodel/delete-operation-handler.d.ts +1 -1
  120. package/lib/common/gmodel/delete-operation-handler.d.ts.map +1 -1
  121. package/lib/common/gmodel/delete-operation-handler.js +7 -6
  122. package/lib/common/gmodel/delete-operation-handler.js.map +1 -1
  123. package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts +3 -3
  124. package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts.map +1 -1
  125. package/lib/common/gmodel/gmodel-create-edge-operation-handler.js +2 -1
  126. package/lib/common/gmodel/gmodel-create-edge-operation-handler.js.map +1 -1
  127. package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts +3 -3
  128. package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts.map +1 -1
  129. package/lib/common/gmodel/gmodel-create-node-operation-handler.js +2 -1
  130. package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -1
  131. package/lib/common/gmodel/gmodel-diagram-module.js +2 -1
  132. package/lib/common/gmodel/gmodel-diagram-module.js.map +1 -1
  133. package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -1
  134. package/lib/common/gmodel/paste-operation-handler.js +2 -1
  135. package/lib/common/gmodel/paste-operation-handler.js.map +1 -1
  136. package/lib/common/gmodel/reconnect-edge-operation-handler.js +2 -1
  137. package/lib/common/gmodel/reconnect-edge-operation-handler.js.map +1 -1
  138. package/lib/common/index.d.ts +3 -1
  139. package/lib/common/index.d.ts.map +1 -1
  140. package/lib/common/index.js +3 -1
  141. package/lib/common/index.js.map +1 -1
  142. package/lib/common/launch/glsp-server-launcher.js +2 -1
  143. package/lib/common/launch/glsp-server-launcher.js.map +1 -1
  144. package/lib/common/launch/jsonrpc-server-launcher.js +2 -1
  145. package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -1
  146. package/lib/common/operations/compound-operation-handler.d.ts +5 -0
  147. package/lib/common/operations/compound-operation-handler.d.ts.map +1 -1
  148. package/lib/common/operations/compound-operation-handler.js +8 -2
  149. package/lib/common/operations/compound-operation-handler.js.map +1 -1
  150. package/lib/common/operations/create-operation-handler.d.ts +19 -5
  151. package/lib/common/operations/create-operation-handler.d.ts.map +1 -1
  152. package/lib/common/operations/create-operation-handler.js +2 -1
  153. package/lib/common/operations/create-operation-handler.js.map +1 -1
  154. package/lib/common/operations/json-operation-handler.d.ts +94 -0
  155. package/lib/common/operations/json-operation-handler.d.ts.map +1 -0
  156. package/lib/common/operations/json-operation-handler.js +120 -0
  157. package/lib/common/operations/json-operation-handler.js.map +1 -0
  158. package/lib/common/operations/operation-action-handler.d.ts.map +1 -1
  159. package/lib/common/operations/operation-action-handler.js +3 -2
  160. package/lib/common/operations/operation-action-handler.js.map +1 -1
  161. package/lib/common/operations/operation-handler-registry.d.ts +1 -9
  162. package/lib/common/operations/operation-handler-registry.d.ts.map +1 -1
  163. package/lib/common/operations/operation-handler-registry.js +4 -12
  164. package/lib/common/operations/operation-handler-registry.js.map +1 -1
  165. package/lib/common/operations/operation-handler.d.ts +2 -2
  166. package/lib/common/operations/operation-handler.d.ts.map +1 -1
  167. package/lib/common/operations/operation-handler.js +2 -1
  168. package/lib/common/operations/operation-handler.js.map +1 -1
  169. package/lib/common/protocol/client-action.d.ts +31 -0
  170. package/lib/common/protocol/client-action.d.ts.map +1 -0
  171. package/lib/common/protocol/client-action.js +35 -0
  172. package/lib/common/protocol/client-action.js.map +1 -0
  173. package/lib/common/protocol/glsp-server.d.ts +1 -1
  174. package/lib/common/protocol/glsp-server.d.ts.map +1 -1
  175. package/lib/common/protocol/glsp-server.js +9 -10
  176. package/lib/common/protocol/glsp-server.js.map +1 -1
  177. package/lib/common/session/client-session-factory.js +5 -4
  178. package/lib/common/session/client-session-factory.js.map +1 -1
  179. package/lib/common/session/client-session-manager.js +2 -1
  180. package/lib/common/session/client-session-manager.js.map +1 -1
  181. package/lib/common/utils/console-logger.js +2 -1
  182. package/lib/common/utils/console-logger.js.map +1 -1
  183. package/lib/common/utils/logger.js +2 -1
  184. package/lib/common/utils/logger.js.map +1 -1
  185. package/lib/common/utils/promise-queue.d.ts.map +1 -1
  186. package/lib/common/utils/promise-queue.js +3 -6
  187. package/lib/common/utils/promise-queue.js.map +1 -1
  188. package/lib/common/utils/registry.d.ts +3 -1
  189. package/lib/common/utils/registry.d.ts.map +1 -1
  190. package/lib/common/utils/registry.js +15 -4
  191. package/lib/common/utils/registry.js.map +1 -1
  192. package/lib/node/abstract-json-model-storage.js +2 -1
  193. package/lib/node/abstract-json-model-storage.js.map +1 -1
  194. package/lib/node/gmodel/gmodel-storage.d.ts.map +1 -1
  195. package/lib/node/gmodel/gmodel-storage.js +4 -2
  196. package/lib/node/gmodel/gmodel-storage.js.map +1 -1
  197. package/lib/node/launch/socket-server-launcher.js +2 -1
  198. package/lib/node/launch/socket-server-launcher.js.map +1 -1
  199. package/lib/node/launch/websocket-server-launcher.js +2 -1
  200. package/lib/node/launch/websocket-server-launcher.js.map +1 -1
  201. package/package.json +4 -4
  202. package/src/common/actions/action-dispatcher.spec.ts +3 -2
  203. package/src/common/actions/action-dispatcher.ts +8 -5
  204. package/src/common/actions/client-action-handler.ts +28 -18
  205. package/src/common/actions/global-action-provider.spec.ts +4 -15
  206. package/src/common/actions/global-action-provider.ts +21 -25
  207. package/src/common/command/recording-command.spec.ts +15 -5
  208. package/src/common/command/recording-command.ts +16 -27
  209. package/src/common/di/client-session-module.ts +17 -10
  210. package/src/common/di/diagram-module.ts +23 -75
  211. package/src/common/di/server-module.ts +0 -1
  212. package/src/common/features/clipboard/request-clipboard-data-action-handler.ts +3 -3
  213. package/src/common/features/model/gmodel-serializer.ts +11 -11
  214. package/src/common/features/model/model-state.ts +3 -0
  215. package/src/common/features/model/model-submission-handler.ts +52 -7
  216. package/src/common/features/model/request-model-action-handler.ts +4 -4
  217. package/src/common/features/type-hints/edge-creation-checker.ts +44 -0
  218. package/src/common/features/type-hints/request-check-edge-action-handler.ts +62 -0
  219. package/src/common/{diagram → features/type-hints}/request-type-hints-action-handler.spec.ts +2 -2
  220. package/src/common/{diagram → features/type-hints}/request-type-hints-action-handler.ts +2 -3
  221. package/src/common/gmodel/cut-operation-handler.ts +5 -3
  222. package/src/common/gmodel/delete-operation-handler.ts +6 -5
  223. package/src/common/gmodel/gmodel-create-edge-operation-handler.ts +3 -3
  224. package/src/common/gmodel/gmodel-create-node-operation-handler.ts +3 -3
  225. package/src/common/gmodel/paste-operation-handler.ts +2 -2
  226. package/src/common/index.ts +3 -1
  227. package/src/common/operations/compound-operation-handler.ts +6 -1
  228. package/src/common/operations/create-operation-handler.ts +22 -5
  229. package/src/common/operations/json-operation-handler.ts +147 -0
  230. package/src/common/operations/operation-action-handler.ts +2 -2
  231. package/src/common/operations/operation-handler-registry.ts +1 -12
  232. package/src/common/operations/operation-handler.ts +2 -2
  233. package/src/common/protocol/client-action.ts +38 -0
  234. package/src/common/protocol/glsp-server.spec.ts +11 -10
  235. package/src/common/protocol/glsp-server.ts +11 -14
  236. package/src/common/session/client-session-factory.spec.ts +2 -2
  237. package/src/common/session/client-session-factory.ts +3 -3
  238. package/src/common/session/client-session-manager.spec.ts +4 -3
  239. package/src/common/utils/promise-queue.ts +4 -5
  240. package/src/common/utils/registry.spec.ts +3 -1
  241. package/src/common/utils/registry.ts +8 -3
  242. package/src/node/gmodel/gmodel-storage.ts +3 -3
  243. package/lib/common/diagram/request-type-hints-action-handler.d.ts.map +0 -1
  244. package/lib/common/diagram/request-type-hints-action-handler.js.map +0 -1
@@ -13,21 +13,20 @@
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';
17
- import { ClientActionKinds, DiagramModules, InjectionContainer } from '../di/service-identifiers';
18
+ import * as sinon from 'sinon';
19
+ import { DiagramModules, InjectionContainer } from '../di/service-identifiers';
18
20
  import { ClientSessionInitializer } from '../session/client-session-initializer';
19
21
  import * as mock from '../test/mock-util';
20
22
  import { Logger } from '../utils/logger';
21
23
  import { ActionHandler } from './action-handler';
22
24
  import { ActionHandlerRegistry } from './action-handler-registry';
23
25
  import { DefaultGlobalActionProvider } from './global-action-provider';
24
- import * as sinon from 'sinon';
25
- import { expect } from 'chai';
26
26
 
27
27
  describe('test DefaultGlobalActionProvider', () => {
28
28
  const container = new Container();
29
29
  const serverActions = ['A1', 'A2', 'A3'];
30
- const clientActions = ['C1', 'C2'];
31
30
  const diagramType = 'myDiagramType';
32
31
 
33
32
  const handler1Actions = ['A1', 'A2'];
@@ -44,8 +43,6 @@ describe('test DefaultGlobalActionProvider', () => {
44
43
  bind(ActionHandler).toConstantValue(new mock.StubActionHandler(handler1Actions));
45
44
  bind(ActionHandler).toConstantValue(new mock.StubActionHandler(handler2Actions));
46
45
  bind(ActionHandlerRegistry).toConstantValue(handlerRegistry);
47
- bind(ClientActionKinds).toConstantValue(clientActions[0]);
48
- bind(ClientActionKinds).toConstantValue(clientActions[1]);
49
46
  });
50
47
 
51
48
  const diagramModules = new Map<string, ContainerModule[]>();
@@ -62,18 +59,10 @@ describe('test DefaultGlobalActionProvider', () => {
62
59
  const actionProvider = container.resolve(DefaultGlobalActionProvider);
63
60
 
64
61
  it('serverActionsKinds', () => {
65
- const result = actionProvider.serverActionKinds;
62
+ const result = actionProvider.actionKinds;
66
63
  expect(result.size).to.be.equal(1);
67
64
  const resultServerActions = result.get(diagramType);
68
65
  expect(resultServerActions).to.not.be.undefined;
69
66
  expect(serverActions.every(action => resultServerActions!.includes(action))).true;
70
67
  });
71
-
72
- it('clientActionKinds', () => {
73
- const result = actionProvider.clientActionKinds;
74
- expect(result.size).to.be.equal(1);
75
- const resultClientActions = result.get(diagramType);
76
- expect(resultClientActions).to.not.be.undefined;
77
- expect(clientActions.every(action => resultClientActions!.includes(action))).true;
78
- });
79
68
  });
@@ -13,60 +13,56 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
+ import { distinctAdd } from '@eclipse-glsp/protocol';
16
17
  import { Container, ContainerModule, inject, injectable } from 'inversify';
17
- import { ClientActionKinds, DiagramModules, InjectionContainer } from '../di/service-identifiers';
18
+ import { createClientSessionModule } from '../di/client-session-module';
19
+ import { DiagramModules, InjectionContainer } from '../di/service-identifiers';
18
20
  import { ClientSessionInitializer } from '../session/client-session-initializer';
19
21
  import { ActionHandlerRegistry } from './action-handler-registry';
20
- import { ClientActionHandler } from './client-action-handler';
21
22
 
22
23
  export const GlobalActionProvider = Symbol('GlobalActionProvider');
23
24
 
25
+ /**
26
+ * Provides a map of handled action kinds grouped by `diagramType`
27
+ */
24
28
  export interface GlobalActionProvider {
25
- readonly serverActionKinds: Map<string, string[]>;
26
- readonly clientActionKinds: Map<string, string[]>;
29
+ readonly actionKinds: Map<string, string[]>;
27
30
  }
28
31
 
29
32
  @injectable()
30
33
  export class DefaultGlobalActionProvider implements GlobalActionProvider {
31
- public readonly serverActionKinds: Map<string, string[]>;
32
- public readonly clientActionKinds: Map<string, string[]>;
34
+ public readonly actionKinds: Map<string, string[]>;
33
35
 
34
36
  constructor(
35
37
  @inject(InjectionContainer) serverContainer: Container,
36
38
  @inject(DiagramModules) diagramModules: Map<string, ContainerModule[]>
37
39
  ) {
38
- this.serverActionKinds = new Map();
39
- this.clientActionKinds = new Map();
40
+ this.actionKinds = new Map();
40
41
  diagramModules.forEach((modules, diagramType) => {
41
42
  const container = this.createDiagramContainer(serverContainer, modules);
42
43
  const initializers = container.getAll<ClientSessionInitializer>(ClientSessionInitializer);
43
44
  initializers.forEach(service => service.initialize());
44
- this.loadServerActionKinds(diagramType, container);
45
- this.loadClientActionKinds(diagramType, container);
45
+ this.loadActionKinds(diagramType, container);
46
46
  container.unbindAll();
47
47
  });
48
48
  }
49
49
 
50
50
  createDiagramContainer(serverContainer: Container, modules: ContainerModule[]): Container {
51
51
  const container = serverContainer.createChild();
52
- container.load(...modules);
52
+ const clientSessionModule = createClientSessionModule({
53
+ clientId: 'tempId',
54
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
55
+ glspClient: { process: () => {} },
56
+ clientActionKinds: []
57
+ });
58
+ container.load(...modules, clientSessionModule);
53
59
  return container;
54
60
  }
55
61
 
56
- loadServerActionKinds(diagramType: string, diagramContainer: Container): void {
62
+ loadActionKinds(diagramType: string, diagramContainer: Container): void {
57
63
  const handlerRegistry = diagramContainer.get<ActionHandlerRegistry>(ActionHandlerRegistry);
58
- const diagramServerActions = this.serverActionKinds.get(diagramType) ?? [];
59
- handlerRegistry
60
- .getAll()
61
- .filter(handler => !(handler instanceof ClientActionHandler))
62
- .forEach(handler => diagramServerActions.push(...handler.actionKinds));
63
- this.serverActionKinds.set(diagramType, [...new Set(diagramServerActions)]);
64
- }
65
-
66
- loadClientActionKinds(diagramType: string, diagramContainer: Container): void {
67
- const clientActionKinds = diagramContainer.getAll<string>(ClientActionKinds);
68
- const diagramClientActions = this.clientActionKinds.get(diagramType) ?? [];
69
- diagramClientActions.push(...clientActionKinds);
70
- this.clientActionKinds.set(diagramType, diagramClientActions);
64
+ const diagramServerActions = this.actionKinds.get(diagramType) ?? [];
65
+ handlerRegistry.getAll().forEach(handler => distinctAdd(diagramServerActions, ...handler.actionKinds));
66
+ this.actionKinds.set(diagramType, diagramServerActions);
71
67
  }
72
68
  }
@@ -14,9 +14,9 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { AnyObject } from '@eclipse-glsp/protocol';
17
+ import { AnyObject, MaybePromise } from '@eclipse-glsp/protocol';
18
18
  import { expect } from 'chai';
19
- import { RecordingCommand } from './recording-command';
19
+ import { AbstractRecordingCommand } from './recording-command';
20
20
 
21
21
  interface TestModel {
22
22
  string: string;
@@ -27,6 +27,16 @@ interface TestModel {
27
27
 
28
28
  let jsonObject: TestModel;
29
29
 
30
+ class TestRecordingCommand<JsonObject extends AnyObject = AnyObject> extends AbstractRecordingCommand<JsonObject> {
31
+ constructor(protected jsonObject: JsonObject, protected doExecute: () => MaybePromise<void>) {
32
+ super();
33
+ }
34
+
35
+ protected getJsonObject(): MaybePromise<JsonObject> {
36
+ return this.jsonObject;
37
+ }
38
+ }
39
+
30
40
  describe('RecordingCommand', () => {
31
41
  let beforeState: TestModel;
32
42
 
@@ -41,14 +51,14 @@ describe('RecordingCommand', () => {
41
51
 
42
52
  it('should be undoable after execution', async () => {
43
53
  // eslint-disable-next-line @typescript-eslint/no-empty-function
44
- const command = new RecordingCommand(jsonObject, () => {});
54
+ const command = new TestRecordingCommand(jsonObject, () => {});
45
55
  expect(command.canUndo()).to.be.false;
46
56
  await command.execute();
47
57
  expect(command.canUndo()).to.be.true;
48
58
  });
49
59
 
50
60
  it('should restore the pre execution state when undo is called', async () => {
51
- const command = new RecordingCommand(jsonObject, () => {
61
+ const command = new TestRecordingCommand(jsonObject, () => {
52
62
  jsonObject.string = 'bar';
53
63
  jsonObject.flag = false;
54
64
  jsonObject.maybe = { hello: 'world' };
@@ -60,7 +70,7 @@ describe('RecordingCommand', () => {
60
70
  });
61
71
 
62
72
  it('should restore the post execution state when redo is called', async () => {
63
- const command = new RecordingCommand(jsonObject, () => {
73
+ const command = new TestRecordingCommand(jsonObject, () => {
64
74
  jsonObject.string = 'bar';
65
75
  jsonObject.flag = false;
66
76
  jsonObject.maybe = { hello: 'world' };
@@ -14,8 +14,7 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { GModelRootSchema } from '@eclipse-glsp/graph';
18
- import { AnyObject, MaybePromise } from '@eclipse-glsp/protocol';
17
+ import { AnyObject, GModelElementSchema, GModelRootSchema, MaybePromise } from '@eclipse-glsp/protocol';
19
18
  import * as jsonPatch from 'fast-json-patch';
20
19
  import { GModelSerializer } from '../features/model/gmodel-serializer';
21
20
  import { ModelState } from '../features/model/model-state';
@@ -34,6 +33,7 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
34
33
  const afterState = await this.getJsonObject();
35
34
  this.undoPatch = jsonPatch.compare(afterState, beforeState);
36
35
  this.redoPatch = jsonPatch.compare(beforeState, afterState);
36
+ this.postChange?.(afterState);
37
37
  }
38
38
 
39
39
  /**
@@ -48,8 +48,8 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
48
48
  */
49
49
  protected abstract doExecute(): MaybePromise<void>;
50
50
 
51
- protected applyPatch(object: JsonObject, patch: jsonPatch.Operation[]): MaybePromise<void> {
52
- jsonPatch.applyPatch(object, patch, false, true);
51
+ protected applyPatch(object: JsonObject, patch: jsonPatch.Operation[]): jsonPatch.PatchResult<JsonObject> {
52
+ return jsonPatch.applyPatch(object, patch, false, true);
53
53
  }
54
54
 
55
55
  /**
@@ -64,33 +64,28 @@ export abstract class AbstractRecordingCommand<JsonObject extends AnyObject> imp
64
64
 
65
65
  async undo(): Promise<void> {
66
66
  if (this.undoPatch) {
67
- return this.applyPatch(await this.getJsonObject(), this.undoPatch);
67
+ const result = this.applyPatch(await this.getJsonObject(), this.undoPatch);
68
+ this.postChange?.(result.newDocument);
68
69
  }
69
70
  }
70
71
 
71
72
  async redo(): Promise<void> {
72
73
  if (this.redoPatch) {
73
- return this.applyPatch(await this.getJsonObject(), this.redoPatch);
74
+ const result = this.applyPatch(await this.getJsonObject(), this.redoPatch);
75
+ this.postChange?.(result.newDocument);
74
76
  }
75
77
  }
76
78
 
77
79
  canUndo(): boolean {
78
80
  return !!this.undoPatch && !!this.redoPatch;
79
81
  }
80
- }
81
-
82
- /**
83
- * Simple base implementation of {@link AbstractRecordingCommand} that records the changes made to the given JSON object during
84
- * the the given `doExecute` function.
85
- */
86
- export class RecordingCommand<JsonObject extends AnyObject = AnyObject> extends AbstractRecordingCommand<JsonObject> {
87
- constructor(protected jsonObject: JsonObject, protected doExecute: () => MaybePromise<void>) {
88
- super();
89
- }
90
82
 
91
- protected getJsonObject(): MaybePromise<JsonObject> {
92
- return this.jsonObject;
93
- }
83
+ /**
84
+ * Optional hook that (if implemented) will be
85
+ * executed after every command-driven action that changed
86
+ * the underlying model i.e. command execute, undo and redo.
87
+ */
88
+ protected postChange?(newModel: JsonObject): MaybePromise<void>;
94
89
  }
95
90
 
96
91
  /**
@@ -102,18 +97,12 @@ export class GModelRecordingCommand extends AbstractRecordingCommand<GModelRootS
102
97
  super();
103
98
  }
104
99
 
105
- override async execute(): Promise<void> {
106
- await super.execute();
107
- this.modelState.index.indexRoot(this.modelState.root);
108
- }
109
-
110
100
  protected getJsonObject(): MaybePromise<GModelRootSchema> {
111
101
  return this.serializer.createSchema(this.modelState.root);
112
102
  }
113
103
 
114
- protected override applyPatch(rootSchema: GModelRootSchema, patch: jsonPatch.Operation[]): MaybePromise<void> {
115
- super.applyPatch(rootSchema, patch);
116
- const newRoot = this.serializer.createRoot(rootSchema);
104
+ protected override postChange(newModel: GModelElementSchema): MaybePromise<void> {
105
+ const newRoot = this.serializer.createRoot(newModel);
117
106
  this.modelState.updateRoot(newRoot);
118
107
  }
119
108
  }
@@ -13,17 +13,24 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { GLSPClientProxy } from '@eclipse-glsp/protocol';
16
+ import { GLSPClientProxy, bindOrRebind } from '@eclipse-glsp/protocol';
17
17
  import { ContainerModule } from 'inversify';
18
- import { ClientId } from './service-identifiers';
18
+ import { ClientActionKinds, ClientId } from './service-identifiers';
19
19
 
20
- export function createClientSessionModule(clientId: string, glspClient: GLSPClientProxy): ContainerModule {
21
- return new ContainerModule((bind, _unbind, isBound, rebind) => {
22
- if (isBound(ClientId)) {
23
- rebind(ClientId).toConstantValue(clientId);
24
- } else {
25
- bind(ClientId).toConstantValue(clientId);
26
- }
27
- bind(GLSPClientProxy).toConstantValue(glspClient);
20
+ export interface ClientSessionModuleOptions {
21
+ clientId: string;
22
+ glspClient: GLSPClientProxy;
23
+ clientActionKinds: string[];
24
+ }
25
+
26
+ /**
27
+ * Creates the DI module that binds client session specific configuration
28
+ */
29
+ export function createClientSessionModule(options: ClientSessionModuleOptions): ContainerModule {
30
+ return new ContainerModule((bind, unbind, isBound, rebind) => {
31
+ const context = { bind, unbind, isBound, rebind };
32
+ bindOrRebind(context, ClientId).toConstantValue(options.clientId);
33
+ bind(GLSPClientProxy).toConstantValue(options.glspClient);
34
+ bind(ClientActionKinds).toConstantValue(new Set(options.clientActionKinds));
28
35
  });
29
36
  }
@@ -13,48 +13,14 @@
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 { ClientActionHandler } from '../actions/client-action-handler';
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';
57
- import { RequestTypeHintsActionHandler } from '../diagram/request-type-hints-action-handler';
58
24
  import { CommandPaletteActionProvider } from '../features/contextactions/command-palette-action-provider';
59
25
  import { ContextActionsProvider } from '../features/contextactions/context-actions-provider';
60
26
  import { ContextActionsProviderRegistry } from '../features/contextactions/context-actions-provider-registry';
@@ -90,6 +56,9 @@ import { ResolveNavigationTargetsActionHandler } from '../features/navigation/re
90
56
  import { PopupModelFactory } from '../features/popup/popup-model-factory';
91
57
  import { RequestPopupModelActionHandler } from '../features/popup/request-popup-model-action-handler';
92
58
  import { DefaultProgressService, ProgressService } from '../features/progress/progress-service';
59
+ import { EdgeCreationChecker } from '../features/type-hints/edge-creation-checker';
60
+ import { RequestCheckEdgeActionHandler } from '../features/type-hints/request-check-edge-action-handler';
61
+ import { RequestTypeHintsActionHandler } from '../features/type-hints/request-type-hints-action-handler';
93
62
  import { ModelValidator } from '../features/validation/model-validator';
94
63
  import { RequestMarkersHandler } from '../features/validation/request-markers-handler';
95
64
  import { CompoundOperationHandler } from '../operations/compound-operation-handler';
@@ -101,7 +70,6 @@ import { BindingTarget, applyBindingTarget, applyOptionalBindingTarget } from '.
101
70
  import { GLSPModule } from './glsp-module';
102
71
  import { InstanceMultiBinding, MultiBinding } from './multi-binding';
103
72
  import {
104
- ClientActionKinds,
105
73
  ClientId,
106
74
  ContextActionsProviders,
107
75
  ContextEditValidators,
@@ -155,6 +123,7 @@ import {
155
123
  * - {@link ClientSessionInitializer} as {@link ClassMultiBinding<ClientSessionInitializer>}
156
124
  * - {@link PopupModelFactory} as optional binding
157
125
  * - {@link LayoutEngine} as optional binding
126
+ * - {@link EdgeCreationChecker} as optional binding
158
127
  */
159
128
 
160
129
  export abstract class DiagramModule extends GLSPModule {
@@ -167,6 +136,7 @@ export abstract class DiagramModule extends GLSPModule {
167
136
  applyBindingTarget(context, DiagramType, this.bindDiagramType());
168
137
  applyBindingTarget(context, ClientId, this.bindClientId());
169
138
  applyBindingTarget(context, DiagramConfiguration, this.bindDiagramConfiguration()).inSingletonScope();
139
+ applyBindingTarget(context, ClientActionForwarder, this.bindClientActionForwarder()).inSingletonScope();
170
140
 
171
141
  // Model-related bindings
172
142
  applyBindingTarget(context, GModelSerializer, this.bindGModelSerializer()).inSingletonScope();
@@ -191,7 +161,6 @@ export abstract class DiagramModule extends GLSPModule {
191
161
 
192
162
  // Action & operation related bindings
193
163
  applyBindingTarget(context, ActionDispatcher, this.bindActionDispatcher()).inSingletonScope();
194
- this.configureMultiBinding(new InstanceMultiBinding<string>(ClientActionKinds), binding => this.configureClientActions(binding));
195
164
  this.configureMultiBinding(new InstanceMultiBinding<ActionHandlerConstructor>(ActionHandlerConstructor), binding =>
196
165
  this.configureActionHandlers(binding)
197
166
  );
@@ -206,7 +175,7 @@ export abstract class DiagramModule extends GLSPModule {
206
175
  applyBindingTarget(context, CommandStack, this.bindCommandStack()).inSingletonScope();
207
176
 
208
177
  // Navigation
209
- applyOptionalBindingTarget(context, NavigationTargetResolver, this.bindNavigationTargetResolver());
178
+ applyOptionalBindingTarget(context, NavigationTargetResolver, this.bindNavigationTargetResolver())?.inSingletonScope();
210
179
  this.configureMultiBinding(new MultiBinding<NavigationTargetProvider>(NavigationTargetProviders), binding =>
211
180
  this.configureNavigationTargetProviders(binding)
212
181
  );
@@ -223,8 +192,9 @@ export abstract class DiagramModule extends GLSPModule {
223
192
  this.configureClientSessionInitializers(binding)
224
193
  );
225
194
  applyBindingTarget(context, ProgressService, this.bindProgressService()).inSingletonScope();
226
- applyOptionalBindingTarget(context, PopupModelFactory, this.bindPopupModelFactory());
227
- applyOptionalBindingTarget(context, LayoutEngine, this.bindLayoutEngine?.());
195
+ applyOptionalBindingTarget(context, PopupModelFactory, this.bindPopupModelFactory())?.inSingletonScope();
196
+ applyOptionalBindingTarget(context, LayoutEngine, this.bindLayoutEngine())?.inSingletonScope();
197
+ applyOptionalBindingTarget(context, EdgeCreationChecker, this.bindEdgeCreationChecker())?.inSingletonScope();
228
198
  }
229
199
 
230
200
  configureClientSessionInitializers(binding: MultiBinding<ClientSessionInitializer>): void {
@@ -233,11 +203,11 @@ export abstract class DiagramModule extends GLSPModule {
233
203
  }
234
204
 
235
205
  protected configureActionHandlers(binding: InstanceMultiBinding<ActionHandlerConstructor>): void {
236
- binding.add(ClientActionHandler);
237
206
  binding.add(RequestModelActionHandler);
238
207
  binding.add(RequestContextActionsHandler);
239
208
  binding.add(RequestTypeHintsActionHandler);
240
209
  binding.add(OperationActionHandler);
210
+ binding.add(RequestCheckEdgeActionHandler);
241
211
  binding.add(RequestMarkersHandler);
242
212
  binding.add(RequestPopupModelActionHandler);
243
213
  binding.add(RequestEditValidationHandler);
@@ -260,6 +230,10 @@ export abstract class DiagramModule extends GLSPModule {
260
230
  return DefaultGModelSerializer;
261
231
  }
262
232
 
233
+ protected bindClientActionForwarder(): BindingTarget<ClientActionForwarder> {
234
+ return ClientActionForwarder;
235
+ }
236
+
263
237
  protected bindGModelIndex(): BindingTarget<GModelIndex> {
264
238
  return GModelIndex;
265
239
  }
@@ -330,40 +304,6 @@ export abstract class DiagramModule extends GLSPModule {
330
304
  // empty as default
331
305
  }
332
306
 
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
307
  protected bindContextActionsProviderRegistry(): BindingTarget<ContextActionsProviderRegistry> {
368
308
  return ContextActionsProviderRegistry;
369
309
  }
@@ -396,6 +336,7 @@ export abstract class DiagramModule extends GLSPModule {
396
336
  protected bindModelValidator(): BindingTarget<ModelValidator> | undefined {
397
337
  return undefined;
398
338
  }
339
+
399
340
  protected bindLabelEditValidator(): BindingTarget<LabelEditValidator> | undefined {
400
341
  return undefined;
401
342
  }
@@ -403,9 +344,11 @@ export abstract class DiagramModule extends GLSPModule {
403
344
  protected bindToolPaletteItemProvider(): BindingTarget<ToolPaletteItemProvider> | undefined {
404
345
  return DefaultToolPaletteItemProvider;
405
346
  }
347
+
406
348
  protected bindCommandPaletteActionProvider(): BindingTarget<CommandPaletteActionProvider> | undefined {
407
349
  return undefined;
408
350
  }
351
+
409
352
  protected bindContextMenuItemProvider(): BindingTarget<ContextMenuItemProvider> | undefined {
410
353
  return undefined;
411
354
  }
@@ -417,7 +360,12 @@ export abstract class DiagramModule extends GLSPModule {
417
360
  protected bindPopupModelFactory(): BindingTarget<PopupModelFactory> | undefined {
418
361
  return undefined;
419
362
  }
363
+
420
364
  protected bindLayoutEngine(): BindingTarget<LayoutEngine> | undefined {
421
365
  return undefined;
422
366
  }
367
+
368
+ protected bindEdgeCreationChecker(): BindingTarget<EdgeCreationChecker> | undefined {
369
+ return undefined;
370
+ }
423
371
  }
@@ -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 {
@@ -16,10 +16,10 @@
16
16
  import {
17
17
  Action,
18
18
  ClipboardData,
19
+ GModelElementSchema,
19
20
  MaybePromise,
20
21
  RequestClipboardDataAction,
21
- SetClipboardDataAction,
22
- SModelElementSchema
22
+ SetClipboardDataAction
23
23
  } from '@eclipse-glsp/protocol';
24
24
  import { inject, injectable } from 'inversify';
25
25
  import { ActionHandler } from '../../actions/action-handler';
@@ -37,7 +37,7 @@ export class RequestClipboardDataActionHandler implements ActionHandler {
37
37
  protected modelSerializer: GModelSerializer;
38
38
 
39
39
  execute(action: RequestClipboardDataAction): MaybePromise<Action[]> {
40
- const schemas: SModelElementSchema[] = [];
40
+ const schemas: GModelElementSchema[] = [];
41
41
  const index = this.modelState.index;
42
42
  const selectedElements = index.getAll(action.editorContext.selectedElementIds);
43
43
  const clipboardData: ClipboardData = { format: 'application/json' };
@@ -14,8 +14,8 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
  /* Derived from sprotty (https://github.com/eclipse/sprotty/blob/master/packages/sprotty/src/base/model/smodel-factory.ts) */
17
- import { GModelElement, GModelElementConstructor, GModelElementSchema, GModelRoot, GModelRootSchema } from '@eclipse-glsp/graph';
18
- import { SModelElementSchema, SModelRootSchema } from '@eclipse-glsp/protocol';
17
+ import { GModelElement, GModelElementConstructor, GModelRoot } from '@eclipse-glsp/graph';
18
+ import { GModelElementSchema, GModelRootSchema } from '@eclipse-glsp/protocol';
19
19
  import { inject, injectable } from 'inversify';
20
20
  import { DiagramConfiguration } from '../../diagram/diagram-configuration';
21
21
  import { GLSPServerError } from '../../utils/glsp-server-error';
@@ -65,7 +65,7 @@ export class DefaultGModelSerializer implements GModelSerializer {
65
65
  @inject(DiagramConfiguration) protected diagramConfiguration: DiagramConfiguration;
66
66
 
67
67
  reservedKeys = ['children', 'parent', 'index', 'source', 'target'];
68
- createRoot(schema: SModelElementSchema): GModelRoot {
68
+ createRoot(schema: GModelElementSchema): GModelRoot {
69
69
  const constructor = this.getConfiguredConstructor(schema);
70
70
  if (constructor) {
71
71
  const element = new constructor();
@@ -77,7 +77,7 @@ export class DefaultGModelSerializer implements GModelSerializer {
77
77
  throw new GLSPServerError(`No constructor is configured in DiagramConfiguration for type ${schema.type}`);
78
78
  }
79
79
 
80
- getConfiguredConstructor(schema: SModelElementSchema): GModelElementConstructor | undefined {
80
+ getConfiguredConstructor(schema: GModelElementSchema): GModelElementConstructor | undefined {
81
81
  let key = schema.type;
82
82
  while (!this.diagramConfiguration.typeMapping.has(key)) {
83
83
  const i = key.lastIndexOf(':');
@@ -95,7 +95,7 @@ export class DefaultGModelSerializer implements GModelSerializer {
95
95
  return constructor;
96
96
  }
97
97
 
98
- createElement(schema: SModelElementSchema, parent?: GModelElement): GModelElement {
98
+ createElement(schema: GModelElementSchema, parent?: GModelElement): GModelElement {
99
99
  const constructor = this.getConfiguredConstructor(schema);
100
100
  if (constructor) {
101
101
  const element = new constructor();
@@ -109,7 +109,7 @@ export class DefaultGModelSerializer implements GModelSerializer {
109
109
  throw new GLSPServerError(`No constructor is configured in DiagramConfiguration for type ${schema.type}`);
110
110
  }
111
111
 
112
- createSchema(element: GModelElement): SModelElementSchema {
112
+ createSchema(element: GModelElement): GModelElementSchema {
113
113
  const schema = {};
114
114
  for (const key in element) {
115
115
  if (!this.isReserved(element, key)) {
@@ -121,15 +121,15 @@ export class DefaultGModelSerializer implements GModelSerializer {
121
121
  }
122
122
  (schema as any)['children'] = (element.children ?? []).map(child => this.createSchema(child));
123
123
 
124
- return schema as SModelElementSchema;
124
+ return schema as GModelElementSchema;
125
125
  }
126
126
 
127
- protected initializeRoot(root: GModelRoot, schema: SModelRootSchema): GModelRoot {
127
+ protected initializeRoot(root: GModelRoot, schema: GModelRootSchema): GModelRoot {
128
128
  this.initializeParent(root, schema);
129
129
  return root;
130
130
  }
131
131
 
132
- protected initializeElement(element: GModelElement, schema: SModelElementSchema): GModelElement {
132
+ protected initializeElement(element: GModelElement, schema: GModelRootSchema): GModelElement {
133
133
  for (const key in schema) {
134
134
  if (!this.isReserved(element, key)) {
135
135
  const value = (schema as any)[key];
@@ -141,7 +141,7 @@ export class DefaultGModelSerializer implements GModelSerializer {
141
141
  return element;
142
142
  }
143
143
 
144
- protected initializeChild(child: GModelElement, schema: SModelElementSchema, parent?: GModelElement): GModelElement {
144
+ protected initializeChild(child: GModelElement, schema: GModelElementSchema, parent?: GModelElement): GModelElement {
145
145
  this.initializeParent(child, schema);
146
146
  if (parent) {
147
147
  child.parent = parent;
@@ -149,7 +149,7 @@ export class DefaultGModelSerializer implements GModelSerializer {
149
149
  return child;
150
150
  }
151
151
 
152
- protected initializeParent(parent: GModelElement, schema: SModelElementSchema): GModelElement {
152
+ protected initializeParent(parent: GModelElement, schema: GModelElementSchema): GModelElement {
153
153
  this.initializeElement(parent, schema);
154
154
  if (schema.children) {
155
155
  parent.children = schema.children.map(childSchema => this.createElement(childSchema, parent));
@@ -92,6 +92,9 @@ export class DefaultModelState implements ModelState {
92
92
  }
93
93
 
94
94
  updateRoot(newRoot: GModelRoot): void {
95
+ if (!newRoot.revision && this.root) {
96
+ newRoot.revision = this.root.revision;
97
+ }
95
98
  this.root = newRoot;
96
99
  this.index.indexRoot(newRoot);
97
100
  }