@eclipse-glsp/server 1.1.0-next.3d7585d.42 → 1.1.0-next.42963d6.55

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 (365) hide show
  1. package/lib/browser/di/app-module.d.ts +2 -7
  2. package/lib/browser/di/app-module.d.ts.map +1 -1
  3. package/lib/browser/di/app-module.js +5 -30
  4. package/lib/browser/di/app-module.js.map +1 -1
  5. package/lib/browser/index.d.ts +0 -1
  6. package/lib/browser/index.d.ts.map +1 -1
  7. package/lib/browser/index.js +0 -1
  8. package/lib/browser/index.js.map +1 -1
  9. package/lib/browser/launch/worker-server-launcher.d.ts +11 -8
  10. package/lib/browser/launch/worker-server-launcher.d.ts.map +1 -1
  11. package/lib/browser/launch/worker-server-launcher.js +13 -21
  12. package/lib/browser/launch/worker-server-launcher.js.map +1 -1
  13. package/lib/common/actions/client-action-handler.d.ts +1 -2
  14. package/lib/common/actions/client-action-handler.d.ts.map +1 -1
  15. package/lib/common/actions/client-action-handler.js +17 -2
  16. package/lib/common/actions/client-action-handler.js.map +1 -1
  17. package/lib/common/command/command-stack.d.ts +60 -14
  18. package/lib/common/command/command-stack.d.ts.map +1 -1
  19. package/lib/common/command/command-stack.js +78 -24
  20. package/lib/common/command/command-stack.js.map +1 -1
  21. package/lib/common/command/command.d.ts +34 -7
  22. package/lib/common/command/command.d.ts.map +1 -1
  23. package/lib/common/command/command.js +73 -0
  24. package/lib/common/command/command.js.map +1 -1
  25. package/lib/common/command/recording-command.d.ts +75 -0
  26. package/lib/common/command/recording-command.d.ts.map +1 -0
  27. package/lib/common/command/recording-command.js +99 -0
  28. package/lib/common/command/recording-command.js.map +1 -0
  29. package/lib/common/command/undo-redo-action-handler.d.ts +28 -0
  30. package/lib/common/command/undo-redo-action-handler.d.ts.map +1 -0
  31. package/lib/common/command/undo-redo-action-handler.js +72 -0
  32. package/lib/common/command/undo-redo-action-handler.js.map +1 -0
  33. package/lib/common/di/client-session-module.d.ts +1 -1
  34. package/lib/common/di/client-session-module.d.ts.map +1 -1
  35. package/lib/common/di/client-session-module.js +2 -2
  36. package/lib/common/di/client-session-module.js.map +1 -1
  37. package/lib/common/di/diagram-module.d.ts +3 -0
  38. package/lib/common/di/diagram-module.d.ts.map +1 -1
  39. package/lib/common/di/diagram-module.js +12 -0
  40. package/lib/common/di/diagram-module.js.map +1 -1
  41. package/lib/common/di/glsp-module.d.ts +3 -1
  42. package/lib/common/di/glsp-module.d.ts.map +1 -1
  43. package/lib/common/di/glsp-module.js +0 -15
  44. package/lib/common/di/glsp-module.js.map +1 -1
  45. package/lib/common/di/multi-binding.d.ts +19 -4
  46. package/lib/common/di/multi-binding.d.ts.map +1 -1
  47. package/lib/common/di/multi-binding.js.map +1 -1
  48. package/lib/common/di/server-module.d.ts +1 -6
  49. package/lib/common/di/server-module.d.ts.map +1 -1
  50. package/lib/common/di/server-module.js +21 -17
  51. package/lib/common/di/server-module.js.map +1 -1
  52. package/lib/common/features/contextactions/tool-palette-item-provider.d.ts +1 -1
  53. package/lib/common/features/contextactions/tool-palette-item-provider.d.ts.map +1 -1
  54. package/lib/common/features/contextactions/tool-palette-item-provider.js +2 -4
  55. package/lib/common/features/contextactions/tool-palette-item-provider.js.map +1 -1
  56. package/lib/common/{gmodel → features/layout}/computed-bounds-action-handler.d.ts +8 -3
  57. package/lib/common/features/layout/computed-bounds-action-handler.d.ts.map +1 -0
  58. package/lib/common/{gmodel → features/layout}/computed-bounds-action-handler.js +9 -4
  59. package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -0
  60. package/lib/common/features/layout/layout-operation-handler.d.ts +12 -3
  61. package/lib/common/features/layout/layout-operation-handler.d.ts.map +1 -1
  62. package/lib/common/features/layout/layout-operation-handler.js +26 -10
  63. package/lib/common/features/layout/layout-operation-handler.js.map +1 -1
  64. package/lib/common/features/model/model-state.d.ts +0 -2
  65. package/lib/common/features/model/model-state.d.ts.map +1 -1
  66. package/lib/common/features/model/model-state.js +0 -1
  67. package/lib/common/features/model/model-state.js.map +1 -1
  68. package/lib/common/features/model/model-submission-handler.d.ts +2 -0
  69. package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
  70. package/lib/common/features/model/model-submission-handler.js +7 -2
  71. package/lib/common/features/model/model-submission-handler.js.map +1 -1
  72. package/lib/common/features/model/save-model-action-handler.d.ts +2 -2
  73. package/lib/common/features/model/save-model-action-handler.d.ts.map +1 -1
  74. package/lib/common/features/model/save-model-action-handler.js +5 -5
  75. package/lib/common/features/model/save-model-action-handler.js.map +1 -1
  76. package/lib/common/gmodel/apply-label-edit-operation-handler.d.ts +4 -5
  77. package/lib/common/gmodel/apply-label-edit-operation-handler.d.ts.map +1 -1
  78. package/lib/common/gmodel/apply-label-edit-operation-handler.js +12 -21
  79. package/lib/common/gmodel/apply-label-edit-operation-handler.js.map +1 -1
  80. package/lib/common/gmodel/change-bounds-operation-handler.d.ts +9 -6
  81. package/lib/common/gmodel/change-bounds-operation-handler.d.ts.map +1 -1
  82. package/lib/common/gmodel/change-bounds-operation-handler.js +14 -14
  83. package/lib/common/gmodel/change-bounds-operation-handler.js.map +1 -1
  84. package/lib/common/gmodel/change-routing-points-operation-handler.d.ts +5 -5
  85. package/lib/common/gmodel/change-routing-points-operation-handler.d.ts.map +1 -1
  86. package/lib/common/gmodel/change-routing-points-operation-handler.js +11 -14
  87. package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -1
  88. package/lib/common/{operations → gmodel}/cut-operation-handler.d.ts +5 -4
  89. package/lib/common/gmodel/cut-operation-handler.d.ts.map +1 -0
  90. package/lib/common/{operations → gmodel}/cut-operation-handler.js +13 -11
  91. package/lib/common/gmodel/cut-operation-handler.js.map +1 -0
  92. package/lib/common/gmodel/delete-operation-handler.d.ts +6 -6
  93. package/lib/common/gmodel/delete-operation-handler.d.ts.map +1 -1
  94. package/lib/common/gmodel/delete-operation-handler.js +13 -10
  95. package/lib/common/gmodel/delete-operation-handler.js.map +1 -1
  96. package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts +11 -7
  97. package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts.map +1 -1
  98. package/lib/common/gmodel/gmodel-create-edge-operation-handler.js +12 -13
  99. package/lib/common/gmodel/gmodel-create-edge-operation-handler.js.map +1 -1
  100. package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts +32 -5
  101. package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts.map +1 -1
  102. package/lib/common/gmodel/gmodel-create-node-operation-handler.js +45 -3
  103. package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -1
  104. package/lib/common/gmodel/gmodel-diagram-module.d.ts +8 -8
  105. package/lib/common/gmodel/gmodel-diagram-module.d.ts.map +1 -1
  106. package/lib/common/gmodel/gmodel-diagram-module.js +15 -21
  107. package/lib/common/gmodel/gmodel-diagram-module.js.map +1 -1
  108. package/lib/{node/launch/socket-server-launcher.spec.d.ts → common/gmodel/gmodel-operation-handler.d.ts} +9 -3
  109. package/lib/common/gmodel/gmodel-operation-handler.d.ts.map +1 -0
  110. package/lib/common/{protocol/glsp-client-proxy.js → gmodel/gmodel-operation-handler.js} +25 -35
  111. package/lib/common/gmodel/gmodel-operation-handler.js.map +1 -0
  112. package/lib/common/gmodel/index.d.ts +2 -1
  113. package/lib/common/gmodel/index.d.ts.map +1 -1
  114. package/lib/common/gmodel/index.js +2 -1
  115. package/lib/common/gmodel/index.js.map +1 -1
  116. package/lib/common/gmodel/paste-operation-handler.d.ts +7 -6
  117. package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -1
  118. package/lib/common/gmodel/paste-operation-handler.js +20 -15
  119. package/lib/common/gmodel/paste-operation-handler.js.map +1 -1
  120. package/lib/common/gmodel/reconnect-edge-operation-handler.d.ts +5 -5
  121. package/lib/common/gmodel/reconnect-edge-operation-handler.d.ts.map +1 -1
  122. package/lib/common/gmodel/reconnect-edge-operation-handler.js +11 -14
  123. package/lib/common/gmodel/reconnect-edge-operation-handler.js.map +1 -1
  124. package/lib/common/index.d.ts +5 -3
  125. package/lib/common/index.d.ts.map +1 -1
  126. package/lib/common/index.js +5 -3
  127. package/lib/common/index.js.map +1 -1
  128. package/lib/common/launch/glsp-server-launcher.d.ts +8 -7
  129. package/lib/common/launch/glsp-server-launcher.d.ts.map +1 -1
  130. package/lib/common/launch/glsp-server-launcher.js +27 -4
  131. package/lib/common/launch/glsp-server-launcher.js.map +1 -1
  132. package/lib/common/launch/jsonrpc-server-launcher.d.ts +38 -0
  133. package/lib/common/launch/jsonrpc-server-launcher.d.ts.map +1 -0
  134. package/lib/common/launch/jsonrpc-server-launcher.js +84 -0
  135. package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -0
  136. package/lib/common/operations/compound-operation-handler.d.ts +5 -5
  137. package/lib/common/operations/compound-operation-handler.d.ts.map +1 -1
  138. package/lib/common/operations/compound-operation-handler.js +37 -9
  139. package/lib/common/operations/compound-operation-handler.js.map +1 -1
  140. package/lib/common/operations/create-operation-handler.d.ts +8 -40
  141. package/lib/common/operations/create-operation-handler.d.ts.map +1 -1
  142. package/lib/common/operations/create-operation-handler.js +26 -85
  143. package/lib/common/operations/create-operation-handler.js.map +1 -1
  144. package/lib/common/operations/operation-action-handler.d.ts +10 -1
  145. package/lib/common/operations/operation-action-handler.d.ts.map +1 -1
  146. package/lib/common/operations/operation-action-handler.js +37 -22
  147. package/lib/common/operations/operation-action-handler.js.map +1 -1
  148. package/lib/common/operations/operation-handler-registry.d.ts +11 -2
  149. package/lib/common/operations/operation-handler-registry.d.ts.map +1 -1
  150. package/lib/common/operations/operation-handler-registry.js +31 -2
  151. package/lib/common/operations/operation-handler-registry.js.map +1 -1
  152. package/lib/common/operations/operation-handler.d.ts +28 -11
  153. package/lib/common/operations/operation-handler.d.ts.map +1 -1
  154. package/lib/common/operations/operation-handler.js +50 -1
  155. package/lib/common/operations/operation-handler.js.map +1 -1
  156. package/lib/common/protocol/glsp-server.d.ts +4 -104
  157. package/lib/common/protocol/glsp-server.d.ts.map +1 -1
  158. package/lib/common/protocol/glsp-server.js +13 -20
  159. package/lib/common/protocol/glsp-server.js.map +1 -1
  160. package/lib/common/session/client-session-factory.d.ts +1 -2
  161. package/lib/common/session/client-session-factory.d.ts.map +1 -1
  162. package/lib/common/session/client-session-factory.js +17 -2
  163. package/lib/common/session/client-session-factory.js.map +1 -1
  164. package/lib/common/session/client-session-manager.d.ts +1 -3
  165. package/lib/common/session/client-session-manager.d.ts.map +1 -1
  166. package/lib/common/session/client-session-manager.js.map +1 -1
  167. package/lib/{browser/di → common/utils}/console-logger.d.ts +7 -1
  168. package/lib/common/utils/console-logger.d.ts.map +1 -0
  169. package/lib/{browser/di → common/utils}/console-logger.js +26 -8
  170. package/lib/common/utils/console-logger.js.map +1 -0
  171. package/lib/common/utils/layout-util.d.ts +1 -1
  172. package/lib/common/utils/layout-util.d.ts.map +1 -1
  173. package/lib/common/utils/layout-util.js +3 -3
  174. package/lib/common/utils/layout-util.js.map +1 -1
  175. package/lib/common/utils/logger.d.ts +21 -0
  176. package/lib/common/utils/logger.d.ts.map +1 -1
  177. package/lib/common/utils/logger.js +12 -1
  178. package/lib/common/utils/logger.js.map +1 -1
  179. package/lib/node/di/app-module.d.ts +2 -2
  180. package/lib/node/di/app-module.d.ts.map +1 -1
  181. package/lib/node/di/app-module.js +10 -35
  182. package/lib/node/di/app-module.js.map +1 -1
  183. package/lib/node/index.d.ts +1 -0
  184. package/lib/node/index.d.ts.map +1 -1
  185. package/lib/node/index.js +1 -0
  186. package/lib/node/index.js.map +1 -1
  187. package/lib/node/launch/cli-parser.d.ts +2 -3
  188. package/lib/node/launch/cli-parser.d.ts.map +1 -1
  189. package/lib/node/launch/cli-parser.js.map +1 -1
  190. package/lib/node/launch/socket-cli-parser.js +1 -1
  191. package/lib/node/launch/socket-cli-parser.js.map +1 -1
  192. package/lib/node/launch/socket-server-launcher.d.ts +4 -24
  193. package/lib/node/launch/socket-server-launcher.d.ts.map +1 -1
  194. package/lib/node/launch/socket-server-launcher.js +15 -34
  195. package/lib/node/launch/socket-server-launcher.js.map +1 -1
  196. package/lib/node/launch/websocket-server-launcher.d.ts +53 -0
  197. package/lib/node/launch/websocket-server-launcher.d.ts.map +1 -0
  198. package/lib/node/launch/websocket-server-launcher.js +121 -0
  199. package/lib/node/launch/websocket-server-launcher.js.map +1 -0
  200. package/package.json +8 -5
  201. package/src/browser/di/app-module.ts +4 -32
  202. package/src/browser/index.ts +0 -1
  203. package/src/browser/launch/worker-server-launcher.ts +20 -22
  204. package/src/common/actions/client-action-handler.ts +1 -2
  205. package/src/common/command/command-stack.spec.ts +239 -0
  206. package/src/common/command/command-stack.ts +106 -20
  207. package/src/common/command/command.spec.ts +92 -0
  208. package/src/common/command/command.ts +96 -7
  209. package/src/common/command/recording-command.spec.ts +74 -0
  210. package/src/common/command/recording-command.ts +119 -0
  211. package/src/common/command/undo-redo-action-handler.ts +57 -0
  212. package/src/common/di/client-session-module.ts +1 -1
  213. package/src/common/di/diagram-module.ts +13 -0
  214. package/src/common/di/glsp-module.ts +3 -1
  215. package/src/common/di/multi-binding.ts +4 -5
  216. package/src/common/di/server-module.ts +6 -21
  217. package/src/common/features/contextactions/tool-palette-item-provider.ts +2 -4
  218. package/src/common/{gmodel → features/layout}/computed-bounds-action-handler.ts +10 -5
  219. package/src/common/features/layout/layout-operation-handler.ts +26 -11
  220. package/src/common/features/model/model-state.ts +0 -3
  221. package/src/common/features/model/model-submission-handler.ts +6 -2
  222. package/src/common/features/model/save-model-action-handler.ts +5 -6
  223. package/src/common/gmodel/apply-label-edit-operation-handler.ts +13 -15
  224. package/src/common/gmodel/change-bounds-operation-handler.ts +12 -8
  225. package/src/common/gmodel/change-routing-points-operation-handler.ts +8 -7
  226. package/src/common/{operations → gmodel}/cut-operation-handler.ts +9 -8
  227. package/src/common/gmodel/delete-operation-handler.ts +16 -10
  228. package/src/common/gmodel/gmodel-create-edge-operation-handler.ts +16 -10
  229. package/src/common/gmodel/gmodel-create-node-operation-handler.ts +54 -6
  230. package/src/common/gmodel/gmodel-diagram-module.ts +22 -27
  231. package/src/common/gmodel/gmodel-operation-handler.ts +31 -0
  232. package/src/common/gmodel/index.ts +2 -1
  233. package/src/common/gmodel/paste-operation-handler.ts +19 -11
  234. package/src/common/gmodel/reconnect-edge-operation-handler.ts +8 -7
  235. package/src/common/index.ts +5 -3
  236. package/src/common/launch/glsp-server-launcher.ts +15 -9
  237. package/src/common/launch/jsonrpc-server-launcher.ts +95 -0
  238. package/src/common/operations/compound-operation-handler.ts +14 -12
  239. package/src/common/operations/create-operation-handler.ts +17 -74
  240. package/src/common/operations/operation-action-handler.ts +51 -27
  241. package/src/common/operations/operation-handler-registry.ts +18 -3
  242. package/src/common/operations/operation-handler.ts +38 -13
  243. package/src/common/protocol/glsp-server.spec.ts +7 -4
  244. package/src/common/protocol/glsp-server.ts +17 -132
  245. package/src/common/session/client-session-factory.spec.ts +1 -1
  246. package/src/common/session/client-session-factory.ts +1 -2
  247. package/src/common/session/client-session-manager.ts +1 -3
  248. package/src/common/test/mock-util.ts +47 -41
  249. package/src/{browser/di → common/utils}/console-logger.ts +19 -1
  250. package/src/common/utils/layout-util.ts +1 -1
  251. package/src/common/utils/logger.ts +16 -1
  252. package/src/node/di/app-module.ts +4 -13
  253. package/src/node/index.ts +1 -0
  254. package/src/node/launch/cli-parser.ts +2 -3
  255. package/src/node/launch/socket-cli-parser.ts +1 -1
  256. package/src/node/launch/socket-server-launcher.spec.ts +6 -0
  257. package/src/node/launch/socket-server-launcher.ts +19 -35
  258. package/src/node/launch/websocket-server-launcher.ts +138 -0
  259. package/lib/browser/di/console-logger.d.ts.map +0 -1
  260. package/lib/browser/di/console-logger.js.map +0 -1
  261. package/lib/common/actions/action-dispatcher.spec.d.ts +0 -2
  262. package/lib/common/actions/action-dispatcher.spec.d.ts.map +0 -1
  263. package/lib/common/actions/action-dispatcher.spec.js +0 -264
  264. package/lib/common/actions/action-dispatcher.spec.js.map +0 -1
  265. package/lib/common/actions/action-handler-registry.spec.d.ts +0 -2
  266. package/lib/common/actions/action-handler-registry.spec.d.ts.map +0 -1
  267. package/lib/common/actions/action-handler-registry.spec.js +0 -50
  268. package/lib/common/actions/action-handler-registry.spec.js.map +0 -1
  269. package/lib/common/actions/global-action-provider.spec.d.ts +0 -2
  270. package/lib/common/actions/global-action-provider.spec.d.ts.map +0 -1
  271. package/lib/common/actions/global-action-provider.spec.js +0 -70
  272. package/lib/common/actions/global-action-provider.spec.js.map +0 -1
  273. package/lib/common/di/binding-target.spec.d.ts +0 -2
  274. package/lib/common/di/binding-target.spec.d.ts.map +0 -1
  275. package/lib/common/di/binding-target.spec.js +0 -121
  276. package/lib/common/di/binding-target.spec.js.map +0 -1
  277. package/lib/common/di/multi-bindings.spec.d.ts +0 -2
  278. package/lib/common/di/multi-bindings.spec.d.ts.map +0 -1
  279. package/lib/common/di/multi-bindings.spec.js +0 -137
  280. package/lib/common/di/multi-bindings.spec.js.map +0 -1
  281. package/lib/common/diagram/request-type-hints-action-handler.spec.d.ts +0 -2
  282. package/lib/common/diagram/request-type-hints-action-handler.spec.d.ts.map +0 -1
  283. package/lib/common/diagram/request-type-hints-action-handler.spec.js +0 -57
  284. package/lib/common/diagram/request-type-hints-action-handler.spec.js.map +0 -1
  285. package/lib/common/features/contextactions/context-actions-provider-registry.spec.d.ts +0 -2
  286. package/lib/common/features/contextactions/context-actions-provider-registry.spec.d.ts.map +0 -1
  287. package/lib/common/features/contextactions/context-actions-provider-registry.spec.js +0 -34
  288. package/lib/common/features/contextactions/context-actions-provider-registry.spec.js.map +0 -1
  289. package/lib/common/features/contextactions/request-context-actions-handler.spec.d.ts +0 -2
  290. package/lib/common/features/contextactions/request-context-actions-handler.spec.d.ts.map +0 -1
  291. package/lib/common/features/contextactions/request-context-actions-handler.spec.js +0 -63
  292. package/lib/common/features/contextactions/request-context-actions-handler.spec.js.map +0 -1
  293. package/lib/common/features/contextactions/tool-palette-item-provider.spec.d.ts +0 -2
  294. package/lib/common/features/contextactions/tool-palette-item-provider.spec.d.ts.map +0 -1
  295. package/lib/common/features/contextactions/tool-palette-item-provider.spec.js +0 -48
  296. package/lib/common/features/contextactions/tool-palette-item-provider.spec.js.map +0 -1
  297. package/lib/common/features/directediting/context-edit-validator-registry.spec.d.ts +0 -2
  298. package/lib/common/features/directediting/context-edit-validator-registry.spec.d.ts.map +0 -1
  299. package/lib/common/features/directediting/context-edit-validator-registry.spec.js +0 -44
  300. package/lib/common/features/directediting/context-edit-validator-registry.spec.js.map +0 -1
  301. package/lib/common/features/directediting/request-edit-validation-handler.spec.d.ts +0 -2
  302. package/lib/common/features/directediting/request-edit-validation-handler.spec.d.ts.map +0 -1
  303. package/lib/common/features/directediting/request-edit-validation-handler.spec.js +0 -97
  304. package/lib/common/features/directediting/request-edit-validation-handler.spec.js.map +0 -1
  305. package/lib/common/features/model/gmodel-serializer.spec.d.ts +0 -2
  306. package/lib/common/features/model/gmodel-serializer.spec.d.ts.map +0 -1
  307. package/lib/common/features/model/gmodel-serializer.spec.js +0 -124
  308. package/lib/common/features/model/gmodel-serializer.spec.js.map +0 -1
  309. package/lib/common/gmodel/apply-label-edit-operation-handler.spec.d.ts +0 -2
  310. package/lib/common/gmodel/apply-label-edit-operation-handler.spec.d.ts.map +0 -1
  311. package/lib/common/gmodel/apply-label-edit-operation-handler.spec.js +0 -38
  312. package/lib/common/gmodel/apply-label-edit-operation-handler.spec.js.map +0 -1
  313. package/lib/common/gmodel/computed-bounds-action-handler.d.ts.map +0 -1
  314. package/lib/common/gmodel/computed-bounds-action-handler.js.map +0 -1
  315. package/lib/common/operations/cut-operation-handler.d.ts.map +0 -1
  316. package/lib/common/operations/cut-operation-handler.js.map +0 -1
  317. package/lib/common/operations/operation-handler-registry.spec.d.ts +0 -2
  318. package/lib/common/operations/operation-handler-registry.spec.d.ts.map +0 -1
  319. package/lib/common/operations/operation-handler-registry.spec.js +0 -50
  320. package/lib/common/operations/operation-handler-registry.spec.js.map +0 -1
  321. package/lib/common/protocol/glsp-client-proxy.d.ts +0 -45
  322. package/lib/common/protocol/glsp-client-proxy.d.ts.map +0 -1
  323. package/lib/common/protocol/glsp-client-proxy.js.map +0 -1
  324. package/lib/common/protocol/glsp-server-listener.d.ts +0 -37
  325. package/lib/common/protocol/glsp-server-listener.d.ts.map +0 -1
  326. package/lib/common/protocol/glsp-server-listener.js +0 -5
  327. package/lib/common/protocol/glsp-server-listener.js.map +0 -1
  328. package/lib/common/protocol/glsp-server.spec.d.ts +0 -2
  329. package/lib/common/protocol/glsp-server.spec.d.ts.map +0 -1
  330. package/lib/common/protocol/glsp-server.spec.js +0 -119
  331. package/lib/common/protocol/glsp-server.spec.js.map +0 -1
  332. package/lib/common/session/client-session-factory.spec.d.ts +0 -2
  333. package/lib/common/session/client-session-factory.spec.d.ts.map +0 -1
  334. package/lib/common/session/client-session-factory.spec.js +0 -56
  335. package/lib/common/session/client-session-factory.spec.js.map +0 -1
  336. package/lib/common/session/client-session-manager.spec.d.ts +0 -2
  337. package/lib/common/session/client-session-manager.spec.d.ts.map +0 -1
  338. package/lib/common/session/client-session-manager.spec.js +0 -74
  339. package/lib/common/session/client-session-manager.spec.js.map +0 -1
  340. package/lib/common/test/mock-util.d.ts +0 -110
  341. package/lib/common/test/mock-util.d.ts.map +0 -1
  342. package/lib/common/test/mock-util.js +0 -211
  343. package/lib/common/test/mock-util.js.map +0 -1
  344. package/lib/common/utils/promise-queue.spec.d.ts +0 -2
  345. package/lib/common/utils/promise-queue.spec.d.ts.map +0 -1
  346. package/lib/common/utils/promise-queue.spec.js +0 -117
  347. package/lib/common/utils/promise-queue.spec.js.map +0 -1
  348. package/lib/common/utils/registry.spec.d.ts +0 -2
  349. package/lib/common/utils/registry.spec.d.ts.map +0 -1
  350. package/lib/common/utils/registry.spec.js +0 -199
  351. package/lib/common/utils/registry.spec.js.map +0 -1
  352. package/lib/node/launch/cli-parser.spec.d.ts +0 -2
  353. package/lib/node/launch/cli-parser.spec.d.ts.map +0 -1
  354. package/lib/node/launch/cli-parser.spec.js +0 -56
  355. package/lib/node/launch/cli-parser.spec.js.map +0 -1
  356. package/lib/node/launch/socket-cli-parser.spec.d.ts +0 -2
  357. package/lib/node/launch/socket-cli-parser.spec.d.ts.map +0 -1
  358. package/lib/node/launch/socket-cli-parser.spec.js +0 -66
  359. package/lib/node/launch/socket-cli-parser.spec.js.map +0 -1
  360. package/lib/node/launch/socket-server-launcher.spec.d.ts.map +0 -1
  361. package/lib/node/launch/socket-server-launcher.spec.js +0 -70
  362. package/lib/node/launch/socket-server-launcher.spec.js.map +0 -1
  363. package/src/common/gmodel/apply-label-edit-operation-handler.spec.ts +0 -40
  364. package/src/common/protocol/glsp-client-proxy.ts +0 -65
  365. package/src/common/protocol/glsp-server-listener.ts +0 -39
@@ -13,20 +13,19 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { MaybePromise } from '@eclipse-glsp/protocol';
16
+ import { Disposable, DisposableCollection, MaybePromise } from '@eclipse-glsp/protocol';
17
17
  import { Container, ContainerModule, inject, injectable, optional } from 'inversify';
18
18
  import { ServerModule } from '../di/server-module';
19
19
  import { InjectionContainer } from '../di/service-identifiers';
20
20
  import { Logger } from '../utils/logger';
21
21
 
22
- export const START_UP_COMPLETE_MSG = '[GLSP-Server]:Startup completed';
23
-
24
22
  @injectable()
25
- export abstract class GLSPServerLauncher<T = undefined> {
23
+ export abstract class GLSPServerLauncher<T> implements Disposable {
26
24
  @inject(Logger) protected logger: Logger;
27
25
 
28
26
  protected _modules: ContainerModule[] = [];
29
27
  protected running: boolean;
28
+ protected toDispose = new DisposableCollection();
30
29
 
31
30
  @inject(InjectionContainer) @optional() protected parentContainer?: Container;
32
31
 
@@ -34,13 +33,13 @@ export abstract class GLSPServerLauncher<T = undefined> {
34
33
  this._modules.push(serverModule, ...additionalModules);
35
34
  }
36
35
 
37
- createContainer(): Container {
36
+ createContainer(...additionalModules: ContainerModule[]): Container {
38
37
  const container = this.parentContainer ? this.parentContainer.createChild() : new Container();
39
- container.load(...this._modules);
38
+ container.load(...this._modules, ...additionalModules);
40
39
  return container;
41
40
  }
42
41
 
43
- start(startParams?: T): MaybePromise<void> {
42
+ start(startParams: T): MaybePromise<void> {
44
43
  if (!this.running) {
45
44
  this.running = true;
46
45
  return this.run(startParams);
@@ -48,10 +47,11 @@ export abstract class GLSPServerLauncher<T = undefined> {
48
47
  this.logger.warn('Could not start launcher. Launcher is already running!');
49
48
  }
50
49
 
51
- protected abstract run(startParams?: T): MaybePromise<void>;
50
+ protected abstract run(startParams: T): MaybePromise<void>;
52
51
 
53
52
  shutdown(): MaybePromise<void> {
54
53
  if (this.running) {
54
+ this.logger.info('Shutdown GLSPServerLauncher');
55
55
  const result = this.stop();
56
56
  this.running = false;
57
57
  return result;
@@ -59,7 +59,13 @@ export abstract class GLSPServerLauncher<T = undefined> {
59
59
  this.logger.warn('Could not stop launcher. Launcher is not running!');
60
60
  }
61
61
 
62
- protected abstract stop(): MaybePromise<void>;
62
+ protected stop(): MaybePromise<void> {
63
+ this.dispose();
64
+ }
65
+
66
+ dispose(): void {
67
+ this.toDispose.dispose();
68
+ }
63
69
 
64
70
  get modules(): ContainerModule[] {
65
71
  if (!this._modules) {
@@ -0,0 +1,95 @@
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 {
18
+ Disposable,
19
+ GLSPClientProxy,
20
+ GLSPServer,
21
+ JsonrpcClientProxy,
22
+ JsonrpcGLSPClient,
23
+ configureClientConnection
24
+ } from '@eclipse-glsp/protocol';
25
+ import { Container, ContainerModule, inject, injectable } from 'inversify';
26
+ import * as jsonrpc from 'vscode-jsonrpc';
27
+ import { Logger } from '../utils/logger';
28
+ import { GLSPServerLauncher } from './glsp-server-launcher';
29
+
30
+ export const START_UP_COMPLETE_MSG = '[GLSP-Server]:Startup completed. Accepting requests on port:';
31
+
32
+ export interface JsonRpcServerInstance {
33
+ server: GLSPServer;
34
+ clientConnection: jsonrpc.MessageConnection;
35
+ container: Container;
36
+ }
37
+
38
+ @injectable()
39
+ export abstract class JsonRpcGLSPServerLauncher<T> extends GLSPServerLauncher<T> {
40
+ @inject(Logger)
41
+ protected override logger: Logger;
42
+
43
+ protected serverInstances = new Map<jsonrpc.MessageConnection, JsonRpcServerInstance>();
44
+ protected startupCompleteMessage = START_UP_COMPLETE_MSG;
45
+
46
+ constructor() {
47
+ super();
48
+ this.toDispose.push(
49
+ Disposable.create(() => {
50
+ this.serverInstances.forEach(instance => this.disposeServerInstance(instance));
51
+ })
52
+ );
53
+ }
54
+
55
+ protected disposeServerInstance(instance: JsonRpcServerInstance): void {
56
+ this.serverInstances.delete(instance.clientConnection);
57
+ instance.server.shutdown();
58
+ instance.container.unbindAll();
59
+ instance.clientConnection.dispose();
60
+ }
61
+
62
+ protected createServerInstance(clientConnection: jsonrpc.MessageConnection): void {
63
+ const container = this.createContainer(this.createJsonRpcModule(clientConnection));
64
+ const server = container.get<GLSPServer>(GLSPServer);
65
+ const instance = { container, clientConnection, server };
66
+ this.serverInstances.set(clientConnection, instance);
67
+ this.configureClientConnection(instance);
68
+ }
69
+
70
+ protected createJsonRpcModule(clientConnection: jsonrpc.MessageConnection): ContainerModule {
71
+ return new ContainerModule(bind => {
72
+ bind(GLSPClientProxy).toDynamicValue(ctx => {
73
+ const proxy = ctx.container.resolve(JsonrpcClientProxy);
74
+ proxy.initialize(clientConnection);
75
+ return proxy;
76
+ });
77
+ });
78
+ }
79
+
80
+ protected configureClientConnection(serverInstance: JsonRpcServerInstance): void {
81
+ configureClientConnection(serverInstance.clientConnection, serverInstance.server);
82
+
83
+ serverInstance.clientConnection.onNotification(JsonrpcGLSPClient.ShutdownNotification, () =>
84
+ this.disposeServerInstance(serverInstance)
85
+ );
86
+
87
+ this.logger.info('Starting GLSP server connection');
88
+ }
89
+
90
+ protected createClientProxy(serverInstance: JsonRpcServerInstance): GLSPClientProxy {
91
+ const proxy = serverInstance.container.resolve(JsonrpcClientProxy);
92
+ proxy.initialize(serverInstance.clientConnection);
93
+ return proxy;
94
+ }
95
+ }
@@ -13,26 +13,28 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { CompoundOperation, MaybePromise, Operation } from '@eclipse-glsp/protocol';
16
+ import { CompoundOperation } from '@eclipse-glsp/protocol';
17
17
  import { inject, injectable } from 'inversify';
18
- import { OperationActionHandler } from './operation-action-handler';
18
+ import { Command, CompoundCommand } from '../command/command';
19
19
  import { OperationHandler } from './operation-handler';
20
20
  import { OperationHandlerRegistry } from './operation-handler-registry';
21
21
 
22
22
  @injectable()
23
- export class CompoundOperationHandler implements OperationHandler {
24
- operationType = CompoundOperation.KIND;
23
+ export class CompoundOperationHandler extends OperationHandler {
24
+ @inject(OperationHandlerRegistry)
25
+ protected operationHandlerRegistry: OperationHandlerRegistry;
25
26
 
26
- @inject(OperationHandlerRegistry) protected operationHandlerRegistry: OperationHandlerRegistry;
27
+ operationType = CompoundOperation.KIND;
27
28
 
28
- execute(operation: CompoundOperation): void {
29
- operation.operationList.forEach(nestedOperation => this.executeNestedOperation(nestedOperation));
30
- }
29
+ async createCommand(operation: CompoundOperation): Promise<Command | undefined> {
30
+ const maybeCommands = operation.operationList.map(op => this.operationHandlerRegistry.getExecutableCommand(op));
31
+ const commands: Command[] = [];
31
32
 
32
- executeNestedOperation(operation: Operation): MaybePromise<void> {
33
- const operationHandler = OperationActionHandler.getOperationHandler(operation, this.operationHandlerRegistry);
34
- if (operationHandler) {
35
- operationHandler.execute(operation);
33
+ for await (const command of maybeCommands) {
34
+ if (command) {
35
+ commands.push(command);
36
+ }
36
37
  }
38
+ return new CompoundCommand(commands);
37
39
  }
38
40
  }
@@ -13,94 +13,37 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { GModelElement } from '@eclipse-glsp/graph';
17
16
  import {
18
17
  CreateEdgeOperation,
19
18
  CreateNodeOperation,
20
- CreateOperation,
21
- MaybePromise,
22
- Operation,
23
- Point,
19
+ hasArrayProp,
20
+ hasFunctionProp,
21
+ hasStringProp,
24
22
  TriggerEdgeCreationAction,
25
23
  TriggerNodeCreationAction
26
24
  } from '@eclipse-glsp/protocol';
27
- import { inject, injectable } from 'inversify';
28
- import { ModelState } from '../features/model/model-state';
29
- import { getRelativeLocation } from '../utils/layout-util';
30
25
  import { OperationHandler } from './operation-handler';
31
26
 
32
27
  /**
33
28
  * A special {@link OperationHandler} that is responsible for the handling of {@link CreateOperation}s. Depending on its
34
29
  * operation type the triggered actions are {@link TriggerNodeCreationAction} or {@link TriggerEdgeCreationAction}s.
35
30
  */
36
- @injectable()
37
- export abstract class CreateOperationHandler implements OperationHandler {
38
- abstract operationType: string;
39
- abstract readonly label: string;
40
- abstract elementTypeIds: string[];
41
-
42
- abstract execute(operation: Operation): MaybePromise<void>;
43
-
44
- /**
45
- * Returns a list of {@link TriggerElementCreationAction}s for registered element types.
46
- *
47
- * @returns A list of {@link TriggerElementCreationAction}s.
48
- */
49
- getTriggerActions(): (TriggerEdgeCreationAction | TriggerNodeCreationAction)[] {
50
- if (this.operationType === CreateNodeOperation.KIND) {
51
- return this.elementTypeIds.map(typeId => TriggerNodeCreationAction.create(typeId));
52
- } else if (this.operationType === CreateEdgeOperation.KIND) {
53
- return this.elementTypeIds.map(typeId => TriggerEdgeCreationAction.create(typeId));
54
- }
55
- return [];
56
- }
57
-
58
- handles(operation: CreateOperation): boolean {
59
- return this.elementTypeIds.includes(operation.elementTypeId);
60
- }
31
+ export interface CreateOperationHandler extends OperationHandler {
32
+ readonly label: string;
33
+ elementTypeIds: string[];
34
+ operationType: CreateOperationKind;
35
+ getTriggerActions(): (TriggerEdgeCreationAction | TriggerNodeCreationAction)[];
61
36
  }
62
37
 
63
- /**
64
- * Abstract base implementation for {@link CreateOperationHandler} that
65
- * create an element that is represented with a {@link GNode} in the graphical model.
66
- */
67
- @injectable()
68
- export abstract class CreateNodeOperationHandler extends CreateOperationHandler {
69
- @inject(ModelState)
70
- protected modelState: ModelState;
71
-
72
- get operationType(): string {
73
- return CreateNodeOperation.KIND;
74
- }
75
-
76
- /**
77
- * Retrieve the graphical model element that should contain the newly created {@link GNode}.
78
- * If `undefined` is returned the {@link GNode} should be added directly to the diagram root.
79
- * @param operation The currently handled operation.
80
- * @returns The container {@link GModeElement} or `undefined`.
81
- */
82
- getContainer(operation: CreateNodeOperation): GModelElement | undefined {
83
- const index = this.modelState.index;
84
- return operation.containerId ? index.get(operation.containerId) : undefined;
85
- }
86
-
87
- getLocation(operation: CreateNodeOperation): Point | undefined {
88
- return operation.location;
89
- }
38
+ export type CreateOperationKind = typeof CreateNodeOperation.KIND | typeof CreateEdgeOperation.KIND;
90
39
 
91
- /**
92
- * Retrieves the diagram absolute location and the target container from the given {@link CreateNodeOperation}
93
- * and converts the absolute location to coordinates relative to the given container.
94
- * Relative coordinates can only be retrieved if the given container element is part of
95
- * a hierarchy of {@link GBoundsAware} elements. This means each (recursive) parent element need to
96
- * implement {@link GBoundsAware}. If that is not the case this method returns `undefined`.
97
- * @param absoluteLocation The diagram absolute position.
98
- * @param container The container element.
99
- * @returns The relative position or `undefined`.
100
- */
101
- getRelativeLocation(operation: CreateNodeOperation): Point | undefined {
102
- const container = this.getContainer(operation) ?? this.modelState.root;
103
- const absoluteLocation = this.getLocation(operation) ?? Point.ORIGIN;
104
- return getRelativeLocation(absoluteLocation, container);
40
+ export namespace CreateOperationHandler {
41
+ export function is(object: unknown): object is CreateOperationHandler {
42
+ return (
43
+ object instanceof OperationHandler &&
44
+ hasStringProp(object, 'label') &&
45
+ hasArrayProp(object, 'elementTypeIds') &&
46
+ hasFunctionProp(object, 'getTriggerActions')
47
+ );
105
48
  }
106
49
  }
@@ -13,57 +13,81 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { Action, CreateOperation, MaybePromise, Operation, ServerMessageAction } from '@eclipse-glsp/protocol';
16
+ import { Action, MaybePromise, Operation, ServerMessageAction } from '@eclipse-glsp/protocol';
17
17
  import { inject, injectable } from 'inversify';
18
18
  import { ActionHandler } from '../actions/action-handler';
19
+ import { Command } from '../command/command';
20
+ import { CommandStack } from '../command/command-stack';
19
21
  import { Operations } from '../di/service-identifiers';
20
22
  import { ModelState } from '../features/model/model-state';
21
23
  import { ModelSubmissionHandler } from '../features/model/model-submission-handler';
24
+ import { GLSPServerError } from '../utils/glsp-server-error';
22
25
  import { OperationHandler } from './operation-handler';
23
26
  import { OperationHandlerRegistry } from './operation-handler-registry';
24
27
 
25
28
  @injectable()
26
29
  export class OperationActionHandler implements ActionHandler {
27
- @inject(OperationHandlerRegistry) protected operationHandlerRegistry: OperationHandlerRegistry;
28
- @inject(ModelSubmissionHandler) protected modelSubmissionHandler: ModelSubmissionHandler;
29
- @inject(ModelState) protected modelState: ModelState;
30
+ @inject(OperationHandlerRegistry)
31
+ protected operationHandlerRegistry: OperationHandlerRegistry;
32
+
33
+ @inject(ModelSubmissionHandler)
34
+ protected modelSubmissionHandler: ModelSubmissionHandler;
35
+
36
+ @inject(ModelState)
37
+ protected modelState: ModelState;
38
+
39
+ @inject(CommandStack)
40
+ protected commandStack: CommandStack;
30
41
 
31
42
  constructor(@inject(Operations) readonly actionKinds: string[]) {}
32
43
 
33
44
  execute(action: Operation): MaybePromise<Action[]> {
34
- if (this.handles(action)) {
35
- if (this.modelState.isReadonly) {
36
- return [
37
- ServerMessageAction.create(`Server is in readonly-mode! Could not execute operation: ${action.kind}`, {
38
- severity: 'WARNING'
39
- })
40
- ];
41
- }
42
- const operationHandler = OperationActionHandler.getOperationHandler(action, this.operationHandlerRegistry);
43
- if (operationHandler) {
44
- return this.executeHandler(action, operationHandler);
45
- }
45
+ if (!this.handles(action)) {
46
+ throw new GLSPServerError(`Unhandled operation kind: ${action.kind}`);
47
+ }
48
+ if (this.modelState.isReadonly) {
49
+ return [
50
+ ServerMessageAction.create(`Server is in readonly-mode! Could not execute operation: ${action.kind}`, {
51
+ severity: 'WARNING'
52
+ })
53
+ ];
54
+ }
55
+ return this.executeOperation(action);
56
+ }
57
+
58
+ protected executeOperation(operation: Operation): MaybePromise<Action[]> {
59
+ const operationHandler = OperationActionHandler.getOperationHandler(operation, this.operationHandlerRegistry);
60
+ if (operationHandler) {
61
+ return this.executeHandler(operation, operationHandler);
46
62
  }
47
63
  return [];
48
64
  }
49
65
 
50
- async executeHandler(operation: Operation, handler: OperationHandler): Promise<Action[]> {
51
- // TODO: Create GModelRecordingCommand;
52
- await handler.execute(operation);
53
- this.modelState.index.indexRoot(this.modelState.root);
54
- this.modelState.isDirty = true;
55
- // TODO: this.modelState.execute(command)
66
+ protected async executeHandler(operation: Operation, handler: OperationHandler): Promise<Action[]> {
67
+ const command = await handler.execute(operation);
68
+ if (command) {
69
+ await this.executeCommand(command);
70
+ }
71
+ return this.modelSubmissionHandler.submitModel('operation');
72
+ }
73
+
74
+ protected async executeCommand(command: Command): Promise<void> {
75
+ return this.commandStack.execute(command);
76
+ }
77
+
78
+ protected submitModel(): MaybePromise<Action[]> {
56
79
  return this.modelSubmissionHandler.submitModel('operation');
57
80
  }
58
81
 
59
82
  handles(action: Action): boolean {
60
- if (this.actionKinds.includes(action.kind)) {
61
- return true;
62
- }
63
- return false;
83
+ return this.actionKinds.includes(action.kind);
64
84
  }
65
85
 
86
+ /**
87
+ * @Deprecated Use {@link OperationHandlerRegistry#getOperationHandler(Operation) instead}.
88
+ */
89
+
66
90
  static getOperationHandler(operation: Operation, registry: OperationHandlerRegistry): OperationHandler | undefined {
67
- return CreateOperation.is(operation) ? registry.get(`${operation.kind}_${operation.elementTypeId}`) : registry.get(operation.kind);
91
+ return registry.getOperationHandler(operation);
68
92
  }
69
93
  }
@@ -13,8 +13,9 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import { Args } from '@eclipse-glsp/protocol';
16
+ import { Args, CreateOperation, MaybePromise, Operation } from '@eclipse-glsp/protocol';
17
17
  import { inject, injectable, optional } from 'inversify';
18
+ import { Command } from '../command/command';
18
19
  import { ClientSessionInitializer } from '../session/client-session-initializer';
19
20
  import { Registry } from '../utils/registry';
20
21
  import { CreateOperationHandler } from './create-operation-handler';
@@ -23,13 +24,27 @@ import { OperationHandler, OperationHandlerConstructor, OperationHandlerFactory
23
24
  @injectable()
24
25
  export class OperationHandlerRegistry extends Registry<string, OperationHandler> {
25
26
  registerHandler(handler: OperationHandler): boolean {
26
- if (handler instanceof CreateOperationHandler) {
27
+ if (CreateOperationHandler.is(handler)) {
27
28
  handler.elementTypeIds.forEach(typeId => this.register(`${handler.operationType}_${typeId}`, handler));
28
29
  return true;
29
30
  } else {
30
31
  return this.register(handler.operationType, handler);
31
32
  }
32
33
  }
34
+
35
+ getOperationHandler(operation: Operation): OperationHandler | undefined {
36
+ return CreateOperation.is(operation) ? this.get(`${operation.kind}_${operation.elementTypeId}`) : this.get(operation.kind);
37
+ }
38
+
39
+ /**
40
+ * Returns the matching command for the given operation.
41
+ *
42
+ * @param operation operation
43
+ * @return the matching command for the given operation
44
+ */
45
+ getExecutableCommand(operation: Operation): MaybePromise<Command | undefined> {
46
+ return this.getOperationHandler(operation)?.createCommand(operation);
47
+ }
33
48
  }
34
49
 
35
50
  @injectable()
@@ -44,7 +59,7 @@ export class OperationHandlerRegistryInitializer implements ClientSessionInitial
44
59
  @inject(OperationHandlerRegistry)
45
60
  protected registry: OperationHandlerRegistry;
46
61
 
47
- initialize(args?: Args): void {
62
+ initialize(_args?: Args): void {
48
63
  const handlers = this.handlerConstructors.map(constructor => this.factory(constructor));
49
64
  handlers.forEach(handler => this.registry.registerHandler(handler));
50
65
  }
@@ -14,38 +14,63 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
  import { MaybePromise, Operation } from '@eclipse-glsp/protocol';
17
- import { interfaces } from 'inversify';
18
-
19
- export const OperationHandler = Symbol('OperationHandler');
17
+ import { inject, injectable, interfaces } from 'inversify';
18
+ import { Command } from '../command/command';
19
+ import { ModelState } from '../features/model/model-state';
20
20
 
21
21
  /**
22
22
  * An operation handler can execute {@link Operation}s of a certain type (subclass).
23
23
  * The operation handler processes the operation in the {@link OperationHandler.execute()} method. The result
24
- * of the execution is an update of the `ModelState` state.
25
- * This update is reversible (undo) and can be reapplied (redo). For basic diagram languages these updates are typically
26
- * applied directly on the `ModelState` using EMF `Command`s and the
27
- * `ModelState.execute()` method. For more complex diagram languages the
28
- * GModel state might be updated indirectly and the operation handler manipulates a custom model representation.
24
+ * of the execution is a {@link Command} that captures the corresponding source model changes.
25
+ * This command can be applied on the `CommandStack` and is reversible (undo) and can be reapplied (redo).
29
26
  *
30
27
  * The `OperationActionHandler` is responsible for retrieving all available (valid) operation handlers for an
31
28
  * operation that is dispatched via `ActionDispatcher`.
32
29
  */
33
- export interface OperationHandler {
30
+ @injectable()
31
+ export abstract class OperationHandler {
32
+ @inject(ModelState)
33
+ protected modelState: ModelState;
34
+
34
35
  /**
35
36
  * Returns the operation type that can be handled by this operation handler.
36
37
  *
37
38
  * @returns the operation type that can be handled.
38
39
  */
39
- readonly operationType: string;
40
+ abstract operationType: string;
40
41
 
41
42
  readonly label?: string;
42
43
 
43
44
  /**
44
- * Executes the operation handler for the given {@link Operation}.
45
+ * Creates a command that performs the operation in the source model(s). If `undefined` is returned, no update
46
+ * is performed on the model(s).
47
+ *
48
+ * @param operation The operation to process.
49
+ * @return The created command to be executed on the command stack or `undefined` nothing should be done.
50
+ */
51
+ abstract createCommand(operation: Operation): MaybePromise<Command | undefined>;
52
+
53
+ /**
54
+ * Executes the operation handler for the given {@link Operation} and returns the corresponding {@link Command}.
55
+ * If the given operation cannot be handled by this handler or the handler execution did not result in any changes
56
+ * `undefined` is returned.
57
+ *
58
+ * @param operation The operation that should be executed or empty if nothing should be done.
59
+ * @returns The command capturing the execution changes or `undefined`
60
+ */
61
+ execute(operation: Operation): MaybePromise<Command | undefined> {
62
+ return this.handles(operation) ? this.createCommand(operation) : undefined;
63
+ }
64
+
65
+ /**
66
+ * Validates whether the given {@link Operation} can be handled by this operation handler.
45
67
  *
46
- * @param operation The operation that should be executed.
68
+ * @param operation The operation that should be validated.
69
+ * @returns `true` if the given operation can be handled, `false` otherwise.
47
70
  */
48
- execute(operation: Operation): MaybePromise<void>;
71
+ handles(operation: Operation): boolean {
72
+ return this.modelState.root && operation.kind === this.operationType;
73
+ }
49
74
  }
50
75
 
51
76
  export const OperationHandlerConstructor = Symbol('OperationHandlerConstructor');
@@ -13,7 +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 { DisposeClientSessionParameters, InitializeClientSessionParameters, InitializeParameters } from '@eclipse-glsp/protocol';
16
+ import {
17
+ DisposeClientSessionParameters,
18
+ GLSPClientProxy,
19
+ GLSPServerListener,
20
+ InitializeClientSessionParameters,
21
+ InitializeParameters
22
+ } from '@eclipse-glsp/protocol';
17
23
  import { expect } from 'chai';
18
24
  import { Container, ContainerModule } from 'inversify';
19
25
  import * as sinon from 'sinon';
@@ -21,9 +27,7 @@ import { GlobalActionProvider } from '../actions/global-action-provider';
21
27
  import { ClientSessionManager } from '../session/client-session-manager';
22
28
  import * as mock from '../test/mock-util';
23
29
  import { Logger } from '../utils/logger';
24
- import { GLSPClientProxy, JsonRpcGLSPClientProxy } from './glsp-client-proxy';
25
30
  import { DefaultGLSPServer } from './glsp-server';
26
- import { GLSPServerListener } from './glsp-server-listener';
27
31
  import assert = require('assert');
28
32
 
29
33
  describe('test DefaultGLSPServer', () => {
@@ -48,7 +52,6 @@ describe('test DefaultGLSPServer', () => {
48
52
  new ContainerModule(bind => {
49
53
  bind(Logger).toConstantValue(new mock.StubLogger());
50
54
  bind(GLSPClientProxy).toConstantValue(new mock.StubGLSPClientProxy());
51
- bind(JsonRpcGLSPClientProxy).toConstantValue(new mock.StubGLSPClientProxy());
52
55
  bind(ClientSessionManager).toConstantValue(sessionManager);
53
56
  bind(GlobalActionProvider).toConstantValue({ clientActionKinds: new Map<string, string[]>(), serverActionKinds });
54
57
  bind(GLSPServerListener).toConstantValue(listener1);