@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.
- package/lib/browser/di/app-module.d.ts +2 -7
- package/lib/browser/di/app-module.d.ts.map +1 -1
- package/lib/browser/di/app-module.js +5 -30
- package/lib/browser/di/app-module.js.map +1 -1
- package/lib/browser/index.d.ts +0 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/launch/worker-server-launcher.d.ts +11 -8
- package/lib/browser/launch/worker-server-launcher.d.ts.map +1 -1
- package/lib/browser/launch/worker-server-launcher.js +13 -21
- package/lib/browser/launch/worker-server-launcher.js.map +1 -1
- package/lib/common/actions/client-action-handler.d.ts +1 -2
- package/lib/common/actions/client-action-handler.d.ts.map +1 -1
- package/lib/common/actions/client-action-handler.js +17 -2
- package/lib/common/actions/client-action-handler.js.map +1 -1
- package/lib/common/command/command-stack.d.ts +60 -14
- package/lib/common/command/command-stack.d.ts.map +1 -1
- package/lib/common/command/command-stack.js +78 -24
- package/lib/common/command/command-stack.js.map +1 -1
- package/lib/common/command/command.d.ts +34 -7
- package/lib/common/command/command.d.ts.map +1 -1
- package/lib/common/command/command.js +73 -0
- package/lib/common/command/command.js.map +1 -1
- package/lib/common/command/recording-command.d.ts +75 -0
- package/lib/common/command/recording-command.d.ts.map +1 -0
- package/lib/common/command/recording-command.js +99 -0
- package/lib/common/command/recording-command.js.map +1 -0
- package/lib/common/command/undo-redo-action-handler.d.ts +28 -0
- package/lib/common/command/undo-redo-action-handler.d.ts.map +1 -0
- package/lib/common/command/undo-redo-action-handler.js +72 -0
- package/lib/common/command/undo-redo-action-handler.js.map +1 -0
- package/lib/common/di/client-session-module.d.ts +1 -1
- package/lib/common/di/client-session-module.d.ts.map +1 -1
- package/lib/common/di/client-session-module.js +2 -2
- package/lib/common/di/client-session-module.js.map +1 -1
- package/lib/common/di/diagram-module.d.ts +3 -0
- package/lib/common/di/diagram-module.d.ts.map +1 -1
- package/lib/common/di/diagram-module.js +12 -0
- package/lib/common/di/diagram-module.js.map +1 -1
- package/lib/common/di/glsp-module.d.ts +3 -1
- package/lib/common/di/glsp-module.d.ts.map +1 -1
- package/lib/common/di/glsp-module.js +0 -15
- package/lib/common/di/glsp-module.js.map +1 -1
- package/lib/common/di/multi-binding.d.ts +19 -4
- package/lib/common/di/multi-binding.d.ts.map +1 -1
- package/lib/common/di/multi-binding.js.map +1 -1
- package/lib/common/di/server-module.d.ts +1 -6
- package/lib/common/di/server-module.d.ts.map +1 -1
- package/lib/common/di/server-module.js +21 -17
- package/lib/common/di/server-module.js.map +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.d.ts +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.d.ts.map +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.js +2 -4
- package/lib/common/features/contextactions/tool-palette-item-provider.js.map +1 -1
- package/lib/common/{gmodel → features/layout}/computed-bounds-action-handler.d.ts +8 -3
- package/lib/common/features/layout/computed-bounds-action-handler.d.ts.map +1 -0
- package/lib/common/{gmodel → features/layout}/computed-bounds-action-handler.js +9 -4
- package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -0
- package/lib/common/features/layout/layout-operation-handler.d.ts +12 -3
- package/lib/common/features/layout/layout-operation-handler.d.ts.map +1 -1
- package/lib/common/features/layout/layout-operation-handler.js +26 -10
- package/lib/common/features/layout/layout-operation-handler.js.map +1 -1
- package/lib/common/features/model/model-state.d.ts +0 -2
- package/lib/common/features/model/model-state.d.ts.map +1 -1
- package/lib/common/features/model/model-state.js +0 -1
- package/lib/common/features/model/model-state.js.map +1 -1
- package/lib/common/features/model/model-submission-handler.d.ts +2 -0
- package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
- package/lib/common/features/model/model-submission-handler.js +7 -2
- package/lib/common/features/model/model-submission-handler.js.map +1 -1
- package/lib/common/features/model/save-model-action-handler.d.ts +2 -2
- package/lib/common/features/model/save-model-action-handler.d.ts.map +1 -1
- package/lib/common/features/model/save-model-action-handler.js +5 -5
- package/lib/common/features/model/save-model-action-handler.js.map +1 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.d.ts +4 -5
- package/lib/common/gmodel/apply-label-edit-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.js +12 -21
- package/lib/common/gmodel/apply-label-edit-operation-handler.js.map +1 -1
- package/lib/common/gmodel/change-bounds-operation-handler.d.ts +9 -6
- package/lib/common/gmodel/change-bounds-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/change-bounds-operation-handler.js +14 -14
- package/lib/common/gmodel/change-bounds-operation-handler.js.map +1 -1
- package/lib/common/gmodel/change-routing-points-operation-handler.d.ts +5 -5
- package/lib/common/gmodel/change-routing-points-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/change-routing-points-operation-handler.js +11 -14
- package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -1
- package/lib/common/{operations → gmodel}/cut-operation-handler.d.ts +5 -4
- package/lib/common/gmodel/cut-operation-handler.d.ts.map +1 -0
- package/lib/common/{operations → gmodel}/cut-operation-handler.js +13 -11
- package/lib/common/gmodel/cut-operation-handler.js.map +1 -0
- package/lib/common/gmodel/delete-operation-handler.d.ts +6 -6
- package/lib/common/gmodel/delete-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/delete-operation-handler.js +13 -10
- package/lib/common/gmodel/delete-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts +11 -7
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js +12 -13
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts +32 -5
- package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js +45 -3
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-diagram-module.d.ts +8 -8
- package/lib/common/gmodel/gmodel-diagram-module.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-diagram-module.js +15 -21
- package/lib/common/gmodel/gmodel-diagram-module.js.map +1 -1
- package/lib/{node/launch/socket-server-launcher.spec.d.ts → common/gmodel/gmodel-operation-handler.d.ts} +9 -3
- package/lib/common/gmodel/gmodel-operation-handler.d.ts.map +1 -0
- package/lib/common/{protocol/glsp-client-proxy.js → gmodel/gmodel-operation-handler.js} +25 -35
- package/lib/common/gmodel/gmodel-operation-handler.js.map +1 -0
- package/lib/common/gmodel/index.d.ts +2 -1
- package/lib/common/gmodel/index.d.ts.map +1 -1
- package/lib/common/gmodel/index.js +2 -1
- package/lib/common/gmodel/index.js.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.d.ts +7 -6
- package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.js +20 -15
- package/lib/common/gmodel/paste-operation-handler.js.map +1 -1
- package/lib/common/gmodel/reconnect-edge-operation-handler.d.ts +5 -5
- package/lib/common/gmodel/reconnect-edge-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/reconnect-edge-operation-handler.js +11 -14
- package/lib/common/gmodel/reconnect-edge-operation-handler.js.map +1 -1
- package/lib/common/index.d.ts +5 -3
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +5 -3
- package/lib/common/index.js.map +1 -1
- package/lib/common/launch/glsp-server-launcher.d.ts +8 -7
- package/lib/common/launch/glsp-server-launcher.d.ts.map +1 -1
- package/lib/common/launch/glsp-server-launcher.js +27 -4
- package/lib/common/launch/glsp-server-launcher.js.map +1 -1
- package/lib/common/launch/jsonrpc-server-launcher.d.ts +38 -0
- package/lib/common/launch/jsonrpc-server-launcher.d.ts.map +1 -0
- package/lib/common/launch/jsonrpc-server-launcher.js +84 -0
- package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -0
- package/lib/common/operations/compound-operation-handler.d.ts +5 -5
- package/lib/common/operations/compound-operation-handler.d.ts.map +1 -1
- package/lib/common/operations/compound-operation-handler.js +37 -9
- package/lib/common/operations/compound-operation-handler.js.map +1 -1
- package/lib/common/operations/create-operation-handler.d.ts +8 -40
- package/lib/common/operations/create-operation-handler.d.ts.map +1 -1
- package/lib/common/operations/create-operation-handler.js +26 -85
- package/lib/common/operations/create-operation-handler.js.map +1 -1
- package/lib/common/operations/operation-action-handler.d.ts +10 -1
- package/lib/common/operations/operation-action-handler.d.ts.map +1 -1
- package/lib/common/operations/operation-action-handler.js +37 -22
- package/lib/common/operations/operation-action-handler.js.map +1 -1
- package/lib/common/operations/operation-handler-registry.d.ts +11 -2
- package/lib/common/operations/operation-handler-registry.d.ts.map +1 -1
- package/lib/common/operations/operation-handler-registry.js +31 -2
- package/lib/common/operations/operation-handler-registry.js.map +1 -1
- package/lib/common/operations/operation-handler.d.ts +28 -11
- package/lib/common/operations/operation-handler.d.ts.map +1 -1
- package/lib/common/operations/operation-handler.js +50 -1
- package/lib/common/operations/operation-handler.js.map +1 -1
- package/lib/common/protocol/glsp-server.d.ts +4 -104
- package/lib/common/protocol/glsp-server.d.ts.map +1 -1
- package/lib/common/protocol/glsp-server.js +13 -20
- package/lib/common/protocol/glsp-server.js.map +1 -1
- package/lib/common/session/client-session-factory.d.ts +1 -2
- package/lib/common/session/client-session-factory.d.ts.map +1 -1
- package/lib/common/session/client-session-factory.js +17 -2
- package/lib/common/session/client-session-factory.js.map +1 -1
- package/lib/common/session/client-session-manager.d.ts +1 -3
- package/lib/common/session/client-session-manager.d.ts.map +1 -1
- package/lib/common/session/client-session-manager.js.map +1 -1
- package/lib/{browser/di → common/utils}/console-logger.d.ts +7 -1
- package/lib/common/utils/console-logger.d.ts.map +1 -0
- package/lib/{browser/di → common/utils}/console-logger.js +26 -8
- package/lib/common/utils/console-logger.js.map +1 -0
- package/lib/common/utils/layout-util.d.ts +1 -1
- package/lib/common/utils/layout-util.d.ts.map +1 -1
- package/lib/common/utils/layout-util.js +3 -3
- package/lib/common/utils/layout-util.js.map +1 -1
- package/lib/common/utils/logger.d.ts +21 -0
- package/lib/common/utils/logger.d.ts.map +1 -1
- package/lib/common/utils/logger.js +12 -1
- package/lib/common/utils/logger.js.map +1 -1
- package/lib/node/di/app-module.d.ts +2 -2
- package/lib/node/di/app-module.d.ts.map +1 -1
- package/lib/node/di/app-module.js +10 -35
- package/lib/node/di/app-module.js.map +1 -1
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/launch/cli-parser.d.ts +2 -3
- package/lib/node/launch/cli-parser.d.ts.map +1 -1
- package/lib/node/launch/cli-parser.js.map +1 -1
- package/lib/node/launch/socket-cli-parser.js +1 -1
- package/lib/node/launch/socket-cli-parser.js.map +1 -1
- package/lib/node/launch/socket-server-launcher.d.ts +4 -24
- package/lib/node/launch/socket-server-launcher.d.ts.map +1 -1
- package/lib/node/launch/socket-server-launcher.js +15 -34
- package/lib/node/launch/socket-server-launcher.js.map +1 -1
- package/lib/node/launch/websocket-server-launcher.d.ts +53 -0
- package/lib/node/launch/websocket-server-launcher.d.ts.map +1 -0
- package/lib/node/launch/websocket-server-launcher.js +121 -0
- package/lib/node/launch/websocket-server-launcher.js.map +1 -0
- package/package.json +8 -5
- package/src/browser/di/app-module.ts +4 -32
- package/src/browser/index.ts +0 -1
- package/src/browser/launch/worker-server-launcher.ts +20 -22
- package/src/common/actions/client-action-handler.ts +1 -2
- package/src/common/command/command-stack.spec.ts +239 -0
- package/src/common/command/command-stack.ts +106 -20
- package/src/common/command/command.spec.ts +92 -0
- package/src/common/command/command.ts +96 -7
- package/src/common/command/recording-command.spec.ts +74 -0
- package/src/common/command/recording-command.ts +119 -0
- package/src/common/command/undo-redo-action-handler.ts +57 -0
- package/src/common/di/client-session-module.ts +1 -1
- package/src/common/di/diagram-module.ts +13 -0
- package/src/common/di/glsp-module.ts +3 -1
- package/src/common/di/multi-binding.ts +4 -5
- package/src/common/di/server-module.ts +6 -21
- package/src/common/features/contextactions/tool-palette-item-provider.ts +2 -4
- package/src/common/{gmodel → features/layout}/computed-bounds-action-handler.ts +10 -5
- package/src/common/features/layout/layout-operation-handler.ts +26 -11
- package/src/common/features/model/model-state.ts +0 -3
- package/src/common/features/model/model-submission-handler.ts +6 -2
- package/src/common/features/model/save-model-action-handler.ts +5 -6
- package/src/common/gmodel/apply-label-edit-operation-handler.ts +13 -15
- package/src/common/gmodel/change-bounds-operation-handler.ts +12 -8
- package/src/common/gmodel/change-routing-points-operation-handler.ts +8 -7
- package/src/common/{operations → gmodel}/cut-operation-handler.ts +9 -8
- package/src/common/gmodel/delete-operation-handler.ts +16 -10
- package/src/common/gmodel/gmodel-create-edge-operation-handler.ts +16 -10
- package/src/common/gmodel/gmodel-create-node-operation-handler.ts +54 -6
- package/src/common/gmodel/gmodel-diagram-module.ts +22 -27
- package/src/common/gmodel/gmodel-operation-handler.ts +31 -0
- package/src/common/gmodel/index.ts +2 -1
- package/src/common/gmodel/paste-operation-handler.ts +19 -11
- package/src/common/gmodel/reconnect-edge-operation-handler.ts +8 -7
- package/src/common/index.ts +5 -3
- package/src/common/launch/glsp-server-launcher.ts +15 -9
- package/src/common/launch/jsonrpc-server-launcher.ts +95 -0
- package/src/common/operations/compound-operation-handler.ts +14 -12
- package/src/common/operations/create-operation-handler.ts +17 -74
- package/src/common/operations/operation-action-handler.ts +51 -27
- package/src/common/operations/operation-handler-registry.ts +18 -3
- package/src/common/operations/operation-handler.ts +38 -13
- package/src/common/protocol/glsp-server.spec.ts +7 -4
- package/src/common/protocol/glsp-server.ts +17 -132
- package/src/common/session/client-session-factory.spec.ts +1 -1
- package/src/common/session/client-session-factory.ts +1 -2
- package/src/common/session/client-session-manager.ts +1 -3
- package/src/common/test/mock-util.ts +47 -41
- package/src/{browser/di → common/utils}/console-logger.ts +19 -1
- package/src/common/utils/layout-util.ts +1 -1
- package/src/common/utils/logger.ts +16 -1
- package/src/node/di/app-module.ts +4 -13
- package/src/node/index.ts +1 -0
- package/src/node/launch/cli-parser.ts +2 -3
- package/src/node/launch/socket-cli-parser.ts +1 -1
- package/src/node/launch/socket-server-launcher.spec.ts +6 -0
- package/src/node/launch/socket-server-launcher.ts +19 -35
- package/src/node/launch/websocket-server-launcher.ts +138 -0
- package/lib/browser/di/console-logger.d.ts.map +0 -1
- package/lib/browser/di/console-logger.js.map +0 -1
- package/lib/common/actions/action-dispatcher.spec.d.ts +0 -2
- package/lib/common/actions/action-dispatcher.spec.d.ts.map +0 -1
- package/lib/common/actions/action-dispatcher.spec.js +0 -264
- package/lib/common/actions/action-dispatcher.spec.js.map +0 -1
- package/lib/common/actions/action-handler-registry.spec.d.ts +0 -2
- package/lib/common/actions/action-handler-registry.spec.d.ts.map +0 -1
- package/lib/common/actions/action-handler-registry.spec.js +0 -50
- package/lib/common/actions/action-handler-registry.spec.js.map +0 -1
- package/lib/common/actions/global-action-provider.spec.d.ts +0 -2
- package/lib/common/actions/global-action-provider.spec.d.ts.map +0 -1
- package/lib/common/actions/global-action-provider.spec.js +0 -70
- package/lib/common/actions/global-action-provider.spec.js.map +0 -1
- package/lib/common/di/binding-target.spec.d.ts +0 -2
- package/lib/common/di/binding-target.spec.d.ts.map +0 -1
- package/lib/common/di/binding-target.spec.js +0 -121
- package/lib/common/di/binding-target.spec.js.map +0 -1
- package/lib/common/di/multi-bindings.spec.d.ts +0 -2
- package/lib/common/di/multi-bindings.spec.d.ts.map +0 -1
- package/lib/common/di/multi-bindings.spec.js +0 -137
- package/lib/common/di/multi-bindings.spec.js.map +0 -1
- package/lib/common/diagram/request-type-hints-action-handler.spec.d.ts +0 -2
- package/lib/common/diagram/request-type-hints-action-handler.spec.d.ts.map +0 -1
- package/lib/common/diagram/request-type-hints-action-handler.spec.js +0 -57
- package/lib/common/diagram/request-type-hints-action-handler.spec.js.map +0 -1
- package/lib/common/features/contextactions/context-actions-provider-registry.spec.d.ts +0 -2
- package/lib/common/features/contextactions/context-actions-provider-registry.spec.d.ts.map +0 -1
- package/lib/common/features/contextactions/context-actions-provider-registry.spec.js +0 -34
- package/lib/common/features/contextactions/context-actions-provider-registry.spec.js.map +0 -1
- package/lib/common/features/contextactions/request-context-actions-handler.spec.d.ts +0 -2
- package/lib/common/features/contextactions/request-context-actions-handler.spec.d.ts.map +0 -1
- package/lib/common/features/contextactions/request-context-actions-handler.spec.js +0 -63
- package/lib/common/features/contextactions/request-context-actions-handler.spec.js.map +0 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.spec.d.ts +0 -2
- package/lib/common/features/contextactions/tool-palette-item-provider.spec.d.ts.map +0 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.spec.js +0 -48
- package/lib/common/features/contextactions/tool-palette-item-provider.spec.js.map +0 -1
- package/lib/common/features/directediting/context-edit-validator-registry.spec.d.ts +0 -2
- package/lib/common/features/directediting/context-edit-validator-registry.spec.d.ts.map +0 -1
- package/lib/common/features/directediting/context-edit-validator-registry.spec.js +0 -44
- package/lib/common/features/directediting/context-edit-validator-registry.spec.js.map +0 -1
- package/lib/common/features/directediting/request-edit-validation-handler.spec.d.ts +0 -2
- package/lib/common/features/directediting/request-edit-validation-handler.spec.d.ts.map +0 -1
- package/lib/common/features/directediting/request-edit-validation-handler.spec.js +0 -97
- package/lib/common/features/directediting/request-edit-validation-handler.spec.js.map +0 -1
- package/lib/common/features/model/gmodel-serializer.spec.d.ts +0 -2
- package/lib/common/features/model/gmodel-serializer.spec.d.ts.map +0 -1
- package/lib/common/features/model/gmodel-serializer.spec.js +0 -124
- package/lib/common/features/model/gmodel-serializer.spec.js.map +0 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.d.ts +0 -2
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.d.ts.map +0 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.js +0 -38
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.js.map +0 -1
- package/lib/common/gmodel/computed-bounds-action-handler.d.ts.map +0 -1
- package/lib/common/gmodel/computed-bounds-action-handler.js.map +0 -1
- package/lib/common/operations/cut-operation-handler.d.ts.map +0 -1
- package/lib/common/operations/cut-operation-handler.js.map +0 -1
- package/lib/common/operations/operation-handler-registry.spec.d.ts +0 -2
- package/lib/common/operations/operation-handler-registry.spec.d.ts.map +0 -1
- package/lib/common/operations/operation-handler-registry.spec.js +0 -50
- package/lib/common/operations/operation-handler-registry.spec.js.map +0 -1
- package/lib/common/protocol/glsp-client-proxy.d.ts +0 -45
- package/lib/common/protocol/glsp-client-proxy.d.ts.map +0 -1
- package/lib/common/protocol/glsp-client-proxy.js.map +0 -1
- package/lib/common/protocol/glsp-server-listener.d.ts +0 -37
- package/lib/common/protocol/glsp-server-listener.d.ts.map +0 -1
- package/lib/common/protocol/glsp-server-listener.js +0 -5
- package/lib/common/protocol/glsp-server-listener.js.map +0 -1
- package/lib/common/protocol/glsp-server.spec.d.ts +0 -2
- package/lib/common/protocol/glsp-server.spec.d.ts.map +0 -1
- package/lib/common/protocol/glsp-server.spec.js +0 -119
- package/lib/common/protocol/glsp-server.spec.js.map +0 -1
- package/lib/common/session/client-session-factory.spec.d.ts +0 -2
- package/lib/common/session/client-session-factory.spec.d.ts.map +0 -1
- package/lib/common/session/client-session-factory.spec.js +0 -56
- package/lib/common/session/client-session-factory.spec.js.map +0 -1
- package/lib/common/session/client-session-manager.spec.d.ts +0 -2
- package/lib/common/session/client-session-manager.spec.d.ts.map +0 -1
- package/lib/common/session/client-session-manager.spec.js +0 -74
- package/lib/common/session/client-session-manager.spec.js.map +0 -1
- package/lib/common/test/mock-util.d.ts +0 -110
- package/lib/common/test/mock-util.d.ts.map +0 -1
- package/lib/common/test/mock-util.js +0 -211
- package/lib/common/test/mock-util.js.map +0 -1
- package/lib/common/utils/promise-queue.spec.d.ts +0 -2
- package/lib/common/utils/promise-queue.spec.d.ts.map +0 -1
- package/lib/common/utils/promise-queue.spec.js +0 -117
- package/lib/common/utils/promise-queue.spec.js.map +0 -1
- package/lib/common/utils/registry.spec.d.ts +0 -2
- package/lib/common/utils/registry.spec.d.ts.map +0 -1
- package/lib/common/utils/registry.spec.js +0 -199
- package/lib/common/utils/registry.spec.js.map +0 -1
- package/lib/node/launch/cli-parser.spec.d.ts +0 -2
- package/lib/node/launch/cli-parser.spec.d.ts.map +0 -1
- package/lib/node/launch/cli-parser.spec.js +0 -56
- package/lib/node/launch/cli-parser.spec.js.map +0 -1
- package/lib/node/launch/socket-cli-parser.spec.d.ts +0 -2
- package/lib/node/launch/socket-cli-parser.spec.d.ts.map +0 -1
- package/lib/node/launch/socket-cli-parser.spec.js +0 -66
- package/lib/node/launch/socket-cli-parser.spec.js.map +0 -1
- package/lib/node/launch/socket-server-launcher.spec.d.ts.map +0 -1
- package/lib/node/launch/socket-server-launcher.spec.js +0 -70
- package/lib/node/launch/socket-server-launcher.spec.js.map +0 -1
- package/src/common/gmodel/apply-label-edit-operation-handler.spec.ts +0 -40
- package/src/common/protocol/glsp-client-proxy.ts +0 -65
- package/src/common/protocol/glsp-server-listener.ts +0 -39
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
import { expect } from 'chai';
|
|
17
|
+
import { Container, ContainerModule } from 'inversify';
|
|
18
|
+
import * as sinon from 'sinon';
|
|
19
|
+
import { expectToThrowAsync, StubCommand, StubLogger } from '../test/mock-util';
|
|
20
|
+
import { Logger } from '../utils/logger';
|
|
21
|
+
import { DefaultCommandStack } from './command-stack';
|
|
22
|
+
|
|
23
|
+
describe('test DefaultCommandStack', () => {
|
|
24
|
+
const sandbox = sinon.createSandbox();
|
|
25
|
+
const container = new Container();
|
|
26
|
+
|
|
27
|
+
const command1 = sandbox.stub(new StubCommand());
|
|
28
|
+
const command2 = sandbox.stub(new StubCommand());
|
|
29
|
+
let commandStack: DefaultCommandStack;
|
|
30
|
+
|
|
31
|
+
container.load(
|
|
32
|
+
new ContainerModule(bind => {
|
|
33
|
+
bind(Logger).toConstantValue(new StubLogger());
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
commandStack = container.resolve(DefaultCommandStack);
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
sandbox.reset();
|
|
40
|
+
commandStack = container.resolve(DefaultCommandStack);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('execute', () => {
|
|
44
|
+
it('should execute the given command and become dirty', async () => {
|
|
45
|
+
expect(commandStack.isDirty).to.be.false;
|
|
46
|
+
await commandStack.execute(command1);
|
|
47
|
+
expect(command1.execute.calledOnce).to.be.true;
|
|
48
|
+
expect(commandStack.isDirty).to.be.true;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should execute the given commands in order and become dirty', async () => {
|
|
52
|
+
expect(commandStack.isDirty).to.be.false;
|
|
53
|
+
await commandStack.execute(command1);
|
|
54
|
+
await commandStack.execute(command2);
|
|
55
|
+
|
|
56
|
+
expect(command1.execute.calledOnce).to.be.true;
|
|
57
|
+
expect(command2.execute.calledOnce).to.be.true;
|
|
58
|
+
expect(command2.execute.calledAfter(command1.execute)).to.be.true;
|
|
59
|
+
expect(commandStack.isDirty).to.be.true;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should be able to undo after execute', async () => {
|
|
63
|
+
expect(commandStack.canUndo()).to.be.false;
|
|
64
|
+
await commandStack.execute(command1);
|
|
65
|
+
expect(commandStack.canUndo()).to.be.true;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should clear the redo stack after execution', async () => {
|
|
69
|
+
commandStack['commands'].push(command2);
|
|
70
|
+
commandStack['top'] = -1;
|
|
71
|
+
expect(commandStack.canRedo()).to.be.true;
|
|
72
|
+
|
|
73
|
+
await commandStack.execute(command1);
|
|
74
|
+
expect(commandStack.canRedo()).to.be.false;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should flush the stack in case of an execution error', async () => {
|
|
78
|
+
command2.execute.throwsException();
|
|
79
|
+
const flushSpy = sandbox.spy(commandStack, 'flush');
|
|
80
|
+
|
|
81
|
+
await expectToThrowAsync(() => commandStack.execute(command2));
|
|
82
|
+
expect(command2.execute.calledOnce).to.be.true;
|
|
83
|
+
expect(flushSpy.calledOnce).to.be.true;
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('undo', () => {
|
|
88
|
+
it('should do nothing if the command stack is empty', async () => {
|
|
89
|
+
expect(commandStack.isDirty).to.be.false;
|
|
90
|
+
|
|
91
|
+
await commandStack.undo();
|
|
92
|
+
expect(commandStack.canUndo()).to.be.false;
|
|
93
|
+
expect(commandStack.canRedo()).to.be.false;
|
|
94
|
+
expect(commandStack.isDirty).to.be.false;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should undo the command and become non-dirty again', async () => {
|
|
98
|
+
commandStack['commands'].push(command1);
|
|
99
|
+
commandStack['top'] = 0;
|
|
100
|
+
expect(commandStack.isDirty).to.be.true;
|
|
101
|
+
expect(commandStack.canUndo()).to.be.true;
|
|
102
|
+
expect(commandStack.canRedo()).to.be.false;
|
|
103
|
+
|
|
104
|
+
await commandStack.undo();
|
|
105
|
+
expect(command1.undo.calledOnce).to.be.true;
|
|
106
|
+
expect(commandStack.isDirty).to.be.false;
|
|
107
|
+
expect(commandStack.canRedo()).to.be.true;
|
|
108
|
+
expect(commandStack.canUndo()).to.be.false;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should undo multiple command and become non-dirty again', async () => {
|
|
112
|
+
commandStack['commands'].push(command1, command2);
|
|
113
|
+
commandStack['top'] = 1;
|
|
114
|
+
expect(commandStack.isDirty).to.be.true;
|
|
115
|
+
expect(commandStack.canUndo()).to.be.true;
|
|
116
|
+
expect(commandStack.canRedo()).to.be.false;
|
|
117
|
+
|
|
118
|
+
await commandStack.undo();
|
|
119
|
+
expect(command2.undo.calledOnce).to.be.true;
|
|
120
|
+
expect(commandStack.canRedo()).to.be.true;
|
|
121
|
+
expect(commandStack.canUndo()).to.be.true;
|
|
122
|
+
expect(commandStack.isDirty).to.be.true;
|
|
123
|
+
|
|
124
|
+
await commandStack.undo();
|
|
125
|
+
expect(command1.undo.calledOnce).to.be.true;
|
|
126
|
+
expect(command1.undo.calledAfter(command2.undo)).to.be.true;
|
|
127
|
+
expect(commandStack.isDirty).to.be.false;
|
|
128
|
+
expect(commandStack.canRedo()).to.be.true;
|
|
129
|
+
expect(commandStack.canUndo()).to.be.false;
|
|
130
|
+
});
|
|
131
|
+
it('should flush the stack in case of an execution error', async () => {
|
|
132
|
+
command2.undo.throwsException();
|
|
133
|
+
const flushSpy = sandbox.spy(commandStack, 'flush');
|
|
134
|
+
commandStack['commands'].push(command2);
|
|
135
|
+
commandStack['top'] = 0;
|
|
136
|
+
|
|
137
|
+
await expectToThrowAsync(() => commandStack.undo());
|
|
138
|
+
expect(command2.undo.calledOnce).to.be.true;
|
|
139
|
+
expect(flushSpy.calledOnce).to.be.true;
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('redo', () => {
|
|
144
|
+
it('should do nothing if the command stack is empty', async () => {
|
|
145
|
+
expect(commandStack.isDirty).to.be.false;
|
|
146
|
+
|
|
147
|
+
await commandStack.redo();
|
|
148
|
+
expect(commandStack.canUndo()).to.be.false;
|
|
149
|
+
expect(commandStack.canRedo()).to.be.false;
|
|
150
|
+
expect(commandStack.isDirty).to.be.false;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should redo the command and become dirty again', async () => {
|
|
154
|
+
commandStack['commands'].push(command1);
|
|
155
|
+
commandStack['top'] = -1;
|
|
156
|
+
expect(commandStack.isDirty).to.be.false;
|
|
157
|
+
expect(commandStack.canUndo()).to.be.false;
|
|
158
|
+
expect(commandStack.canRedo()).to.be.true;
|
|
159
|
+
|
|
160
|
+
await commandStack.redo();
|
|
161
|
+
expect(command1.redo.calledOnce).to.be.true;
|
|
162
|
+
expect(commandStack.isDirty).to.be.true;
|
|
163
|
+
expect(commandStack.canRedo()).to.be.false;
|
|
164
|
+
expect(commandStack.canUndo()).to.be.true;
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('should undo multiple command and become non-dirty again', async () => {
|
|
168
|
+
commandStack['commands'].push(command2, command1);
|
|
169
|
+
commandStack['top'] = -1;
|
|
170
|
+
commandStack['saveIndex'] = -1;
|
|
171
|
+
expect(commandStack.isDirty).to.be.false;
|
|
172
|
+
expect(commandStack.canUndo()).to.be.false;
|
|
173
|
+
expect(commandStack.canRedo()).to.be.true;
|
|
174
|
+
|
|
175
|
+
await commandStack.redo();
|
|
176
|
+
expect(command2.redo.calledOnce).to.be.true;
|
|
177
|
+
expect(commandStack.canRedo()).to.be.true;
|
|
178
|
+
expect(commandStack.canUndo()).to.be.true;
|
|
179
|
+
expect(commandStack.isDirty).to.be.true;
|
|
180
|
+
|
|
181
|
+
await commandStack.redo();
|
|
182
|
+
expect(command1.redo.calledOnce).to.be.true;
|
|
183
|
+
expect(command1.redo.calledAfter(command2.redo)).to.be.true;
|
|
184
|
+
expect(commandStack.isDirty).to.be.true;
|
|
185
|
+
expect(commandStack.canRedo()).to.be.false;
|
|
186
|
+
expect(commandStack.canUndo()).to.be.true;
|
|
187
|
+
});
|
|
188
|
+
it('should flush the stack in case of an execution error', async () => {
|
|
189
|
+
command2.redo.throwsException();
|
|
190
|
+
const flushSpy = sandbox.spy(commandStack, 'flush');
|
|
191
|
+
commandStack['commands'].push(command2);
|
|
192
|
+
commandStack['top'] = -1;
|
|
193
|
+
|
|
194
|
+
await expectToThrowAsync(() => commandStack.redo());
|
|
195
|
+
expect(command2.redo.calledOnce).to.be.true;
|
|
196
|
+
expect(flushSpy.calledOnce).to.be.true;
|
|
197
|
+
});
|
|
198
|
+
it('should be able to undo after redo', async () => {
|
|
199
|
+
commandStack['commands'].push(command1);
|
|
200
|
+
commandStack['top'] = -1;
|
|
201
|
+
expect(commandStack.canUndo()).to.be.false;
|
|
202
|
+
await commandStack.redo();
|
|
203
|
+
expect(commandStack.canUndo()).to.be.true;
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
describe('flush', () => {
|
|
208
|
+
it('should reset the internal state of the command stack', () => {
|
|
209
|
+
commandStack['commands'].push(command1, command1);
|
|
210
|
+
commandStack['top'] = 0;
|
|
211
|
+
|
|
212
|
+
commandStack.flush();
|
|
213
|
+
expect(commandStack.isDirty).to.be.false;
|
|
214
|
+
expect(commandStack.canUndo()).to.be.false;
|
|
215
|
+
expect(commandStack.canRedo()).to.be.false;
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe('isSaveDone', () => {
|
|
220
|
+
it('should become non-dirty after execution', () => {
|
|
221
|
+
commandStack['commands'].push(command1);
|
|
222
|
+
commandStack['top'] = 0;
|
|
223
|
+
expect(commandStack.isDirty).to.be.true;
|
|
224
|
+
|
|
225
|
+
commandStack.saveIsDone();
|
|
226
|
+
expect(commandStack.isDirty).to.be.false;
|
|
227
|
+
});
|
|
228
|
+
it('should maintain undo/redo history after execution', () => {
|
|
229
|
+
commandStack['commands'].push(command1, command2);
|
|
230
|
+
commandStack['top'] = 0;
|
|
231
|
+
expect(commandStack.canUndo()).to.be.true;
|
|
232
|
+
expect(commandStack.canRedo()).to.be.true;
|
|
233
|
+
|
|
234
|
+
commandStack.saveIsDone();
|
|
235
|
+
expect(commandStack.canUndo()).to.be.true;
|
|
236
|
+
expect(commandStack.canRedo()).to.be.true;
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
});
|
|
@@ -13,62 +13,148 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import {
|
|
16
|
+
import { MaybePromise } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
import { Logger } from '../utils/logger';
|
|
17
19
|
import { Command } from './command';
|
|
18
20
|
|
|
19
21
|
export const CommandStack = Symbol('CommandStack');
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
|
-
* A
|
|
23
|
-
*
|
|
24
|
+
* A command stack keeps track of {@link Command commands} that have been executed.
|
|
25
|
+
* Executed commands can be undone in the reverse order of their original execution.
|
|
26
|
+
* Unless a new command has been executed after an undo operation, commands can be
|
|
27
|
+
* redone in the original order of their execution.
|
|
28
|
+
*
|
|
24
29
|
*/
|
|
25
30
|
export interface CommandStack {
|
|
26
31
|
/**
|
|
27
|
-
* Clears any redoable commands not yet redone, adds the command
|
|
32
|
+
* Clears any redoable commands not yet redone, adds the command to the stack and then invokes {@link Command.execute}.
|
|
28
33
|
* @param command the command to execute.
|
|
29
34
|
*/
|
|
30
|
-
execute(command: Command): void
|
|
35
|
+
execute(command: Command): MaybePromise<void>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Removes the topmost (i.e. last executed) command from the stack and invokes {@link Command.undo}.
|
|
39
|
+
*/
|
|
40
|
+
undo(): MaybePromise<void>;
|
|
31
41
|
|
|
32
42
|
/**
|
|
33
|
-
*
|
|
43
|
+
* Returns `true` if the top command on the stack can be undone.
|
|
34
44
|
*/
|
|
35
|
-
|
|
45
|
+
canUndo(): boolean;
|
|
36
46
|
|
|
37
47
|
/**
|
|
38
|
-
*
|
|
48
|
+
* Re-adds the last undo command on top of the stack and invokes {@link Command.redo}
|
|
39
49
|
*/
|
|
40
|
-
redo(): void
|
|
50
|
+
redo(): MaybePromise<void>;
|
|
41
51
|
|
|
42
52
|
/**
|
|
43
|
-
*
|
|
53
|
+
* Returns `true` if there are redoable commands in the stack.
|
|
44
54
|
*/
|
|
45
|
-
|
|
55
|
+
canRedo(): boolean;
|
|
46
56
|
|
|
47
57
|
/**
|
|
48
58
|
* Called after a save has been successfully performed.
|
|
49
59
|
*/
|
|
50
60
|
saveIsDone(): void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Indicates wether the command stack has unsaved changes.
|
|
64
|
+
*/
|
|
65
|
+
readonly isDirty: boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Disposes all the commands in the stack.
|
|
69
|
+
*/
|
|
70
|
+
flush(): void;
|
|
51
71
|
}
|
|
52
72
|
|
|
53
73
|
@injectable()
|
|
54
74
|
export class DefaultCommandStack implements CommandStack {
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
@inject(Logger)
|
|
76
|
+
protected logger: Logger;
|
|
77
|
+
|
|
78
|
+
protected commands: Command[] = [];
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The current position within the command list from which the next execute, undo, or redo, will be performed.
|
|
82
|
+
*/
|
|
83
|
+
protected top = -1;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The current position within the command list when {@link DefaultCommandStack.saveIsDone} is called.
|
|
87
|
+
*/
|
|
88
|
+
protected saveIndex = -1;
|
|
89
|
+
|
|
90
|
+
async execute(command: Command): Promise<void> {
|
|
91
|
+
try {
|
|
92
|
+
await command.execute();
|
|
93
|
+
} catch (error) {
|
|
94
|
+
this.handleError(error);
|
|
95
|
+
}
|
|
96
|
+
// Clear the command list past the top (i.e. the old redo list)
|
|
97
|
+
this.commands = this.commands.slice(0, this.top + 1);
|
|
98
|
+
this.commands.push(command);
|
|
99
|
+
++this.top;
|
|
100
|
+
|
|
101
|
+
// if the saveIndex points to the old redo list we can never reach a state again
|
|
102
|
+
// where save is not necessary. => ensure that `isDirty` always returns true
|
|
103
|
+
if (this.saveIndex >= this.top) {
|
|
104
|
+
this.saveIndex = -2;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async undo(): Promise<void> {
|
|
109
|
+
if (this.canUndo()) {
|
|
110
|
+
const command = this.commands[this.top--];
|
|
111
|
+
try {
|
|
112
|
+
await command.undo();
|
|
113
|
+
} catch (error) {
|
|
114
|
+
this.handleError(error);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
57
117
|
}
|
|
58
118
|
|
|
59
|
-
|
|
60
|
-
|
|
119
|
+
canUndo(): boolean {
|
|
120
|
+
return this.top !== -1 //
|
|
121
|
+
? Command.canUndo(this.commands[this.top])
|
|
122
|
+
: false;
|
|
61
123
|
}
|
|
62
124
|
|
|
63
|
-
redo(): void {
|
|
64
|
-
|
|
125
|
+
async redo(): Promise<void> {
|
|
126
|
+
if (this.canRedo()) {
|
|
127
|
+
const command = this.commands[++this.top];
|
|
128
|
+
try {
|
|
129
|
+
await command.redo();
|
|
130
|
+
} catch (error) {
|
|
131
|
+
this.handleError(error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
65
134
|
}
|
|
66
135
|
|
|
67
|
-
|
|
68
|
-
return
|
|
136
|
+
canRedo(): boolean {
|
|
137
|
+
return this.top < this.commands.length - 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
get isDirty(): boolean {
|
|
141
|
+
return this.saveIndex !== this.top;
|
|
69
142
|
}
|
|
70
143
|
|
|
71
144
|
saveIsDone(): void {
|
|
72
|
-
|
|
145
|
+
this.saveIndex = this.top;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
flush(): void {
|
|
149
|
+
this.commands = [];
|
|
150
|
+
this.top = -1;
|
|
151
|
+
this.saveIndex = -1;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
protected handleError(error: any): never {
|
|
155
|
+
// if an error occurred during the command execution the stack might be in an erroneous state => we have to flush the command stack
|
|
156
|
+
this.flush();
|
|
157
|
+
this.logger.error('An error occurred during command execution. CommandStack will be flushed!', error);
|
|
158
|
+
throw error;
|
|
73
159
|
}
|
|
74
160
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
import { expect } from 'chai';
|
|
17
|
+
import * as sinon from 'sinon';
|
|
18
|
+
import { expectToThrowAsync, StubCommand } from '../test/mock-util';
|
|
19
|
+
import { CompoundCommand } from './command';
|
|
20
|
+
|
|
21
|
+
describe('CompoundCommand', () => {
|
|
22
|
+
const sandbox = sinon.createSandbox();
|
|
23
|
+
|
|
24
|
+
const command1 = sandbox.stub(new StubCommand());
|
|
25
|
+
const command2 = sandbox.stub(new StubCommand());
|
|
26
|
+
const command3 = sandbox.stub(new StubCommand());
|
|
27
|
+
|
|
28
|
+
const compoundCommand = new CompoundCommand(command1, command2, command3);
|
|
29
|
+
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
sandbox.reset();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('execute', () => {
|
|
35
|
+
it('Should execute the subcommands in order', async () => {
|
|
36
|
+
await compoundCommand.execute();
|
|
37
|
+
expect(command1.execute.calledOnce).to.be.true;
|
|
38
|
+
expect(command2.execute.calledOnce).to.be.true;
|
|
39
|
+
expect(command3.execute.calledOnce).to.be.true;
|
|
40
|
+
expect(command1.execute.calledBefore(command2.execute)).to.be.true;
|
|
41
|
+
expect(command2.execute.calledBefore(command3.execute)).to.be.true;
|
|
42
|
+
});
|
|
43
|
+
it('Should undo partially executed subcommands in case of an error', async () => {
|
|
44
|
+
command3.execute.throwsException();
|
|
45
|
+
|
|
46
|
+
await expectToThrowAsync(() => compoundCommand.execute());
|
|
47
|
+
|
|
48
|
+
expect(command1.execute.calledOnce).to.be.true;
|
|
49
|
+
expect(command2.execute.calledOnce).to.be.true;
|
|
50
|
+
expect(command3.execute.calledOnce).to.be.true;
|
|
51
|
+
expect(command1.undo.calledOnce).to.be.true;
|
|
52
|
+
expect(command2.undo.calledOnce).to.be.true;
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('undo', () => {
|
|
57
|
+
it('Should undo the subcommands in reverse order', async () => {
|
|
58
|
+
await compoundCommand.undo();
|
|
59
|
+
expect(command1.undo.calledOnce).to.be.true;
|
|
60
|
+
expect(command2.undo.calledOnce).to.be.true;
|
|
61
|
+
expect(command3.undo.calledOnce).to.be.true;
|
|
62
|
+
expect(command1.undo.calledAfter(command2.undo)).to.be.true;
|
|
63
|
+
expect(command2.undo.calledAfter(command3.undo)).to.be.true;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('Should redo partially undone subcommands in case of an error', async () => {
|
|
67
|
+
command1.undo.throwsException();
|
|
68
|
+
await expectToThrowAsync(() => compoundCommand.undo());
|
|
69
|
+
|
|
70
|
+
expect(command1.undo.calledOnce).to.be.true;
|
|
71
|
+
expect(command2.undo.calledOnce).to.be.true;
|
|
72
|
+
expect(command3.undo.calledOnce).to.be.true;
|
|
73
|
+
expect(command3.redo.calledOnce).to.be.true;
|
|
74
|
+
expect(command2.redo.calledOnce).to.be.true;
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('canUndo', () => {
|
|
79
|
+
it('should return true if all subcommands can be undone', () => {
|
|
80
|
+
command1.canUndo?.returns(true);
|
|
81
|
+
command2.canUndo?.returns(true);
|
|
82
|
+
command3.canUndo?.returns(true);
|
|
83
|
+
expect(compoundCommand.canUndo()).to.be.true;
|
|
84
|
+
});
|
|
85
|
+
it('should return true if anyof the subcommands cannot be undone', () => {
|
|
86
|
+
command1.canUndo?.returns(true);
|
|
87
|
+
command2.canUndo?.returns(false);
|
|
88
|
+
command3.canUndo?.returns(true);
|
|
89
|
+
expect(compoundCommand.canUndo()).to.be.true;
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -14,26 +14,115 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
+
import { flatPush, MaybeArray, MaybePromise } from '@eclipse-glsp/protocol';
|
|
18
|
+
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
+
* A command implements a specific modification of the source model, which can be applied by invoking `execute()`.
|
|
21
|
+
* Commands may also provide implementations to `undo()` and `redo()` the effect they had.
|
|
22
|
+
* To maintain an order in which commands can be undone and redone, they are managed in the context of a {@link CommandStack}.
|
|
23
|
+
*
|
|
24
|
+
* Each command is self contained and stores all the information it needs to execute, undo or redo itself.
|
|
25
|
+
*
|
|
26
|
+
* In theory commands can be used to execute arbitrary activities and not only modify the source model.
|
|
27
|
+
* However, it is mostly used to record and manage changes made to the source model via GLSP operations.
|
|
20
28
|
*/
|
|
21
29
|
export interface Command {
|
|
22
30
|
/**
|
|
23
|
-
* Performs the command activity required for the effect.
|
|
31
|
+
* Performs the command activity required for the effect (e.g. source model change).
|
|
24
32
|
*/
|
|
25
|
-
execute(): void
|
|
33
|
+
execute(): MaybePromise<void>;
|
|
26
34
|
|
|
27
35
|
/**
|
|
28
36
|
* Performs the command activity required to `undo` the effects of a preceding `execute` (or `redo`).
|
|
29
37
|
* The effect, if any, of calling `undo` before `execute` or `redo` have been called, is undefined.
|
|
30
38
|
*/
|
|
31
|
-
undo(): void
|
|
39
|
+
undo(): MaybePromise<void>;
|
|
32
40
|
|
|
33
41
|
/**
|
|
34
42
|
* Performs the command activity required to `redo` the effect after undoing the effect.
|
|
35
43
|
* The effect, if any, of calling `redo` before `undo` is called is undefined.
|
|
36
|
-
* Note that if you implement `redo` to call `execute` then any derived class will be restricted by that decision also.
|
|
37
44
|
*/
|
|
38
|
-
redo(): void
|
|
45
|
+
redo(): MaybePromise<void>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns whether the command can be undone.
|
|
49
|
+
* This function is optional. If not implemented, it is assumed that the command can be undone.
|
|
50
|
+
* @returns whether the command can be undone
|
|
51
|
+
*/
|
|
52
|
+
canUndo?(): boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export namespace Command {
|
|
56
|
+
export function canUndo(command: Command): boolean {
|
|
57
|
+
return command.canUndo?.() ?? true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A command that comprises a sequence of subcommands.
|
|
63
|
+
*/
|
|
64
|
+
export class CompoundCommand implements Command {
|
|
65
|
+
protected readonly commands: Command[];
|
|
66
|
+
|
|
67
|
+
constructor(commands: Command[]);
|
|
68
|
+
constructor(...commands: Command[]);
|
|
69
|
+
constructor(...commands: MaybeArray<Command>[]) {
|
|
70
|
+
this.commands = [];
|
|
71
|
+
flatPush(this.commands, commands);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async execute(): Promise<void> {
|
|
75
|
+
const alreadyExecuted: Command[] = [];
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
for (const command of this.commands) {
|
|
79
|
+
await command.execute();
|
|
80
|
+
alreadyExecuted.unshift(command);
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
for (const command of alreadyExecuted) {
|
|
84
|
+
if (Command.canUndo(command)) {
|
|
85
|
+
await command.undo();
|
|
86
|
+
} else {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async undo(): Promise<void> {
|
|
95
|
+
const alreadyUndone: Command[] = [];
|
|
96
|
+
try {
|
|
97
|
+
for (const command of [...this.commands].reverse()) {
|
|
98
|
+
await command.undo();
|
|
99
|
+
alreadyUndone.unshift(command);
|
|
100
|
+
}
|
|
101
|
+
} catch (err) {
|
|
102
|
+
for (const command of alreadyUndone) {
|
|
103
|
+
await command.redo();
|
|
104
|
+
}
|
|
105
|
+
throw err;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async redo(): Promise<void> {
|
|
110
|
+
const alreadyRedone: Command[] = [];
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
for (const command of this.commands) {
|
|
114
|
+
await command.redo();
|
|
115
|
+
alreadyRedone.unshift(command);
|
|
116
|
+
}
|
|
117
|
+
} catch (err) {
|
|
118
|
+
for (const command of alreadyRedone) {
|
|
119
|
+
await command.undo();
|
|
120
|
+
}
|
|
121
|
+
throw err;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
canUndo(): boolean {
|
|
126
|
+
return this.commands.every(Command.canUndo);
|
|
127
|
+
}
|
|
39
128
|
}
|