@eclipse-glsp/server 1.1.0-RC05
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/LICENSE +642 -0
- package/README.md +8 -0
- package/browser.d.ts +16 -0
- package/browser.js +18 -0
- package/lib/browser/di/app-module.d.ts +24 -0
- package/lib/browser/di/app-module.d.ts.map +1 -0
- package/lib/browser/di/app-module.js +55 -0
- package/lib/browser/di/app-module.js.map +1 -0
- package/lib/browser/di/console-logger.d.ts +29 -0
- package/lib/browser/di/console-logger.d.ts.map +1 -0
- package/lib/browser/di/console-logger.js +81 -0
- package/lib/browser/di/console-logger.js.map +1 -0
- package/lib/browser/index.d.ts +20 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +36 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/launch/worker-server-launcher.d.ts +26 -0
- package/lib/browser/launch/worker-server-launcher.d.ts.map +1 -0
- package/lib/browser/launch/worker-server-launcher.js +65 -0
- package/lib/browser/launch/worker-server-launcher.js.map +1 -0
- package/lib/common/actions/action-dispatcher.d.ts +74 -0
- package/lib/common/actions/action-dispatcher.d.ts.map +1 -0
- package/lib/common/actions/action-dispatcher.js +128 -0
- package/lib/common/actions/action-dispatcher.js.map +1 -0
- package/lib/common/actions/action-dispatcher.spec.d.ts +2 -0
- package/lib/common/actions/action-dispatcher.spec.d.ts.map +1 -0
- package/lib/common/actions/action-dispatcher.spec.js +264 -0
- package/lib/common/actions/action-dispatcher.spec.js.map +1 -0
- package/lib/common/actions/action-handler-registry.d.ts +40 -0
- package/lib/common/actions/action-handler-registry.d.ts.map +1 -0
- package/lib/common/actions/action-handler-registry.js +65 -0
- package/lib/common/actions/action-handler-registry.js.map +1 -0
- package/lib/common/actions/action-handler-registry.spec.d.ts +2 -0
- package/lib/common/actions/action-handler-registry.spec.d.ts.map +1 -0
- package/lib/common/actions/action-handler-registry.spec.js +50 -0
- package/lib/common/actions/action-handler-registry.spec.js.map +1 -0
- package/lib/common/actions/action-handler.d.ts +55 -0
- package/lib/common/actions/action-handler.d.ts.map +1 -0
- package/lib/common/actions/action-handler.js +7 -0
- package/lib/common/actions/action-handler.js.map +1 -0
- package/lib/common/actions/client-action-handler.d.ts +30 -0
- package/lib/common/actions/client-action-handler.d.ts.map +1 -0
- package/lib/common/actions/client-action-handler.js +56 -0
- package/lib/common/actions/client-action-handler.js.map +1 -0
- package/lib/common/actions/global-action-provider.d.ts +30 -0
- package/lib/common/actions/global-action-provider.d.ts.map +1 -0
- package/lib/common/actions/global-action-provider.js +81 -0
- package/lib/common/actions/global-action-provider.js.map +1 -0
- package/lib/common/actions/global-action-provider.spec.d.ts +2 -0
- package/lib/common/actions/global-action-provider.spec.d.ts.map +1 -0
- package/lib/common/actions/global-action-provider.spec.js +70 -0
- package/lib/common/actions/global-action-provider.spec.js.map +1 -0
- package/lib/common/command/command-stack.d.ts +67 -0
- package/lib/common/command/command-stack.d.ts.map +1 -0
- package/lib/common/command/command-stack.js +117 -0
- package/lib/common/command/command-stack.js.map +1 -0
- package/lib/common/command/command-stack.spec.d.ts +2 -0
- package/lib/common/command/command-stack.spec.d.ts.map +1 -0
- package/lib/common/command/command-stack.spec.js +207 -0
- package/lib/common/command/command-stack.spec.js.map +1 -0
- package/lib/common/command/command.d.ts +63 -0
- package/lib/common/command/command.d.ts.map +1 -0
- package/lib/common/command/command.js +87 -0
- package/lib/common/command/command.js.map +1 -0
- package/lib/common/command/command.spec.d.ts +2 -0
- package/lib/common/command/command.spec.d.ts.map +1 -0
- package/lib/common/command/command.spec.js +86 -0
- package/lib/common/command/command.spec.js.map +1 -0
- 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/recording-command.spec.d.ts +17 -0
- package/lib/common/command/recording-command.spec.d.ts.map +1 -0
- package/lib/common/command/recording-command.spec.js +62 -0
- package/lib/common/command/recording-command.spec.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/binding-target.d.ts +73 -0
- package/lib/common/di/binding-target.d.ts.map +1 -0
- package/lib/common/di/binding-target.js +143 -0
- package/lib/common/di/binding-target.js.map +1 -0
- package/lib/common/di/binding-target.spec.d.ts +2 -0
- package/lib/common/di/binding-target.spec.d.ts.map +1 -0
- package/lib/common/di/binding-target.spec.js +121 -0
- package/lib/common/di/binding-target.spec.js.map +1 -0
- package/lib/common/di/client-session-module.d.ts +19 -0
- package/lib/common/di/client-session-module.d.ts.map +1 -0
- package/lib/common/di/client-session-module.js +34 -0
- package/lib/common/di/client-session-module.js.map +1 -0
- package/lib/common/di/diagram-module.d.ts +130 -0
- package/lib/common/di/diagram-module.d.ts.map +1 -0
- package/lib/common/di/diagram-module.js +295 -0
- package/lib/common/di/diagram-module.js.map +1 -0
- package/lib/common/di/glsp-module.d.ts +47 -0
- package/lib/common/di/glsp-module.d.ts.map +1 -0
- package/lib/common/di/glsp-module.js +59 -0
- package/lib/common/di/glsp-module.js.map +1 -0
- package/lib/common/di/multi-binding.d.ts +41 -0
- package/lib/common/di/multi-binding.d.ts.map +1 -0
- package/lib/common/di/multi-binding.js +82 -0
- package/lib/common/di/multi-binding.js.map +1 -0
- package/lib/common/di/multi-bindings.spec.d.ts +2 -0
- package/lib/common/di/multi-bindings.spec.d.ts.map +1 -0
- package/lib/common/di/multi-bindings.spec.js +137 -0
- package/lib/common/di/multi-bindings.spec.js.map +1 -0
- package/lib/common/di/server-module.d.ts +73 -0
- package/lib/common/di/server-module.d.ts.map +1 -0
- package/lib/common/di/server-module.js +103 -0
- package/lib/common/di/server-module.js.map +1 -0
- package/lib/common/di/service-identifiers.d.ts +29 -0
- package/lib/common/di/service-identifiers.d.ts.map +1 -0
- package/lib/common/di/service-identifiers.js +14 -0
- package/lib/common/di/service-identifiers.js.map +1 -0
- package/lib/common/diagram/diagram-configuration.d.ts +89 -0
- package/lib/common/diagram/diagram-configuration.d.ts.map +1 -0
- package/lib/common/diagram/diagram-configuration.js +30 -0
- package/lib/common/diagram/diagram-configuration.js.map +1 -0
- package/lib/common/diagram/request-type-hints-action-handler.d.ts +25 -0
- package/lib/common/diagram/request-type-hints-action-handler.d.ts.map +1 -0
- package/lib/common/diagram/request-type-hints-action-handler.js +53 -0
- package/lib/common/diagram/request-type-hints-action-handler.js.map +1 -0
- package/lib/common/diagram/request-type-hints-action-handler.spec.d.ts +2 -0
- package/lib/common/diagram/request-type-hints-action-handler.spec.d.ts.map +1 -0
- package/lib/common/diagram/request-type-hints-action-handler.spec.js +57 -0
- package/lib/common/diagram/request-type-hints-action-handler.spec.js.map +1 -0
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.d.ts +26 -0
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.d.ts.map +1 -0
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.js +61 -0
- package/lib/common/features/clipboard/request-clipboard-data-action-handler.js.map +1 -0
- package/lib/common/features/contextactions/command-palette-action-provider.d.ts +63 -0
- package/lib/common/features/contextactions/command-palette-action-provider.d.ts.map +1 -0
- package/lib/common/features/contextactions/command-palette-action-provider.js +72 -0
- package/lib/common/features/contextactions/command-palette-action-provider.js.map +1 -0
- package/lib/common/features/contextactions/context-actions-provider-registry.d.ts +12 -0
- package/lib/common/features/contextactions/context-actions-provider-registry.d.ts.map +1 -0
- package/lib/common/features/contextactions/context-actions-provider-registry.js +70 -0
- package/lib/common/features/contextactions/context-actions-provider-registry.js.map +1 -0
- package/lib/common/features/contextactions/context-actions-provider-registry.spec.d.ts +2 -0
- package/lib/common/features/contextactions/context-actions-provider-registry.spec.d.ts.map +1 -0
- package/lib/common/features/contextactions/context-actions-provider-registry.spec.js +34 -0
- package/lib/common/features/contextactions/context-actions-provider-registry.spec.js.map +1 -0
- package/lib/common/features/contextactions/context-actions-provider.d.ts +34 -0
- package/lib/common/features/contextactions/context-actions-provider.d.ts.map +1 -0
- package/lib/common/features/contextactions/context-actions-provider.js +5 -0
- package/lib/common/features/contextactions/context-actions-provider.js.map +1 -0
- package/lib/common/features/contextactions/context-menu-item-provider.d.ts +43 -0
- package/lib/common/features/contextactions/context-menu-item-provider.d.ts.map +1 -0
- package/lib/common/features/contextactions/context-menu-item-provider.js +36 -0
- package/lib/common/features/contextactions/context-menu-item-provider.js.map +1 -0
- package/lib/common/features/contextactions/request-context-actions-handler.d.ts +24 -0
- package/lib/common/features/contextactions/request-context-actions-handler.d.ts.map +1 -0
- package/lib/common/features/contextactions/request-context-actions-handler.js +53 -0
- package/lib/common/features/contextactions/request-context-actions-handler.js.map +1 -0
- package/lib/common/features/contextactions/request-context-actions-handler.spec.d.ts +2 -0
- package/lib/common/features/contextactions/request-context-actions-handler.spec.d.ts.map +1 -0
- package/lib/common/features/contextactions/request-context-actions-handler.spec.js +63 -0
- package/lib/common/features/contextactions/request-context-actions-handler.spec.js.map +1 -0
- package/lib/common/features/contextactions/tool-palette-item-provider.d.ts +50 -0
- package/lib/common/features/contextactions/tool-palette-item-provider.d.ts.map +1 -0
- package/lib/common/features/contextactions/tool-palette-item-provider.js +86 -0
- package/lib/common/features/contextactions/tool-palette-item-provider.js.map +1 -0
- package/lib/common/features/contextactions/tool-palette-item-provider.spec.d.ts +2 -0
- package/lib/common/features/contextactions/tool-palette-item-provider.spec.d.ts.map +1 -0
- package/lib/common/features/contextactions/tool-palette-item-provider.spec.js +48 -0
- package/lib/common/features/contextactions/tool-palette-item-provider.spec.js.map +1 -0
- package/lib/common/features/directediting/context-edit-validator-registry.d.ts +14 -0
- package/lib/common/features/directediting/context-edit-validator-registry.d.ts.map +1 -0
- package/lib/common/features/directediting/context-edit-validator-registry.js +57 -0
- package/lib/common/features/directediting/context-edit-validator-registry.js.map +1 -0
- package/lib/common/features/directediting/context-edit-validator-registry.spec.d.ts +2 -0
- package/lib/common/features/directediting/context-edit-validator-registry.spec.d.ts.map +1 -0
- package/lib/common/features/directediting/context-edit-validator-registry.spec.js +44 -0
- package/lib/common/features/directediting/context-edit-validator-registry.spec.js.map +1 -0
- package/lib/common/features/directediting/context-edit-validator.d.ts +25 -0
- package/lib/common/features/directediting/context-edit-validator.d.ts.map +1 -0
- package/lib/common/features/directediting/context-edit-validator.js +40 -0
- package/lib/common/features/directediting/context-edit-validator.js.map +1 -0
- package/lib/common/features/directediting/label-edit-validator.d.ts +32 -0
- package/lib/common/features/directediting/label-edit-validator.d.ts.map +1 -0
- package/lib/common/features/directediting/label-edit-validator.js +21 -0
- package/lib/common/features/directediting/label-edit-validator.js.map +1 -0
- package/lib/common/features/directediting/request-edit-validation-handler.d.ts +26 -0
- package/lib/common/features/directediting/request-edit-validation-handler.d.ts.map +1 -0
- package/lib/common/features/directediting/request-edit-validation-handler.js +61 -0
- package/lib/common/features/directediting/request-edit-validation-handler.js.map +1 -0
- package/lib/common/features/directediting/request-edit-validation-handler.spec.d.ts +2 -0
- package/lib/common/features/directediting/request-edit-validation-handler.spec.d.ts.map +1 -0
- package/lib/common/features/directediting/request-edit-validation-handler.spec.js +97 -0
- package/lib/common/features/directediting/request-edit-validation-handler.spec.js.map +1 -0
- package/lib/common/features/layout/computed-bounds-action-handler.d.ts +34 -0
- package/lib/common/features/layout/computed-bounds-action-handler.d.ts.map +1 -0
- package/lib/common/features/layout/computed-bounds-action-handler.js +55 -0
- package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -0
- package/lib/common/features/layout/layout-engine.d.ts +29 -0
- package/lib/common/features/layout/layout-engine.d.ts.map +1 -0
- package/lib/common/features/layout/layout-engine.js +20 -0
- package/lib/common/features/layout/layout-engine.js.map +1 -0
- package/lib/common/features/layout/layout-operation-handler.d.ts +37 -0
- package/lib/common/features/layout/layout-operation-handler.d.ts.map +1 -0
- package/lib/common/features/layout/layout-operation-handler.js +82 -0
- package/lib/common/features/layout/layout-operation-handler.js.map +1 -0
- package/lib/common/features/model/gmodel-factory.d.ts +39 -0
- package/lib/common/features/model/gmodel-factory.d.ts.map +1 -0
- package/lib/common/features/model/gmodel-factory.js +39 -0
- package/lib/common/features/model/gmodel-factory.js.map +1 -0
- package/lib/common/features/model/gmodel-index.d.ts +107 -0
- package/lib/common/features/model/gmodel-index.d.ts.map +1 -0
- package/lib/common/features/model/gmodel-index.js +193 -0
- package/lib/common/features/model/gmodel-index.js.map +1 -0
- package/lib/common/features/model/gmodel-serializer.d.ts +67 -0
- package/lib/common/features/model/gmodel-serializer.d.ts.map +1 -0
- package/lib/common/features/model/gmodel-serializer.js +143 -0
- package/lib/common/features/model/gmodel-serializer.js.map +1 -0
- package/lib/common/features/model/gmodel-serializer.spec.d.ts +2 -0
- package/lib/common/features/model/gmodel-serializer.spec.d.ts.map +1 -0
- package/lib/common/features/model/gmodel-serializer.spec.js +124 -0
- package/lib/common/features/model/gmodel-serializer.spec.js.map +1 -0
- package/lib/common/features/model/model-state.d.ts +51 -0
- package/lib/common/features/model/model-state.d.ts.map +1 -0
- package/lib/common/features/model/model-state.js +74 -0
- package/lib/common/features/model/model-state.js.map +1 -0
- package/lib/common/features/model/model-submission-handler.d.ts +58 -0
- package/lib/common/features/model/model-submission-handler.d.ts.map +1 -0
- package/lib/common/features/model/model-submission-handler.js +102 -0
- package/lib/common/features/model/model-submission-handler.js.map +1 -0
- package/lib/common/features/model/request-model-action-handler.d.ts +37 -0
- package/lib/common/features/model/request-model-action-handler.d.ts.map +1 -0
- package/lib/common/features/model/request-model-action-handler.js +83 -0
- package/lib/common/features/model/request-model-action-handler.js.map +1 -0
- package/lib/common/features/model/save-model-action-handler.d.ts +26 -0
- package/lib/common/features/model/save-model-action-handler.d.ts.map +1 -0
- package/lib/common/features/model/save-model-action-handler.js +54 -0
- package/lib/common/features/model/save-model-action-handler.js.map +1 -0
- package/lib/common/features/model/source-model-storage.d.ts +47 -0
- package/lib/common/features/model/source-model-storage.d.ts.map +1 -0
- package/lib/common/features/model/source-model-storage.js +5 -0
- package/lib/common/features/model/source-model-storage.js.map +1 -0
- package/lib/common/features/navigation/json-opener-options.d.ts +36 -0
- package/lib/common/features/navigation/json-opener-options.d.ts.map +1 -0
- package/lib/common/features/navigation/json-opener-options.js +60 -0
- package/lib/common/features/navigation/json-opener-options.js.map +1 -0
- package/lib/common/features/navigation/navigation-target-provider-registry.d.ts +12 -0
- package/lib/common/features/navigation/navigation-target-provider-registry.d.ts.map +1 -0
- package/lib/common/features/navigation/navigation-target-provider-registry.js +47 -0
- package/lib/common/features/navigation/navigation-target-provider-registry.js.map +1 -0
- package/lib/common/features/navigation/navigation-target-provider.d.ts +48 -0
- package/lib/common/features/navigation/navigation-target-provider.d.ts.map +1 -0
- package/lib/common/features/navigation/navigation-target-provider.js +5 -0
- package/lib/common/features/navigation/navigation-target-provider.js.map +1 -0
- package/lib/common/features/navigation/navigation-target-resolution.d.ts +23 -0
- package/lib/common/features/navigation/navigation-target-resolution.d.ts.map +1 -0
- package/lib/common/features/navigation/navigation-target-resolution.js +12 -0
- package/lib/common/features/navigation/navigation-target-resolution.js.map +1 -0
- package/lib/common/features/navigation/navigation-target-resolver.d.ts +31 -0
- package/lib/common/features/navigation/navigation-target-resolver.d.ts.map +1 -0
- package/lib/common/features/navigation/navigation-target-resolver.js +49 -0
- package/lib/common/features/navigation/navigation-target-resolver.js.map +1 -0
- package/lib/common/features/navigation/request-navigation-targets-action-handler.d.ts +24 -0
- package/lib/common/features/navigation/request-navigation-targets-action-handler.d.ts.map +1 -0
- package/lib/common/features/navigation/request-navigation-targets-action-handler.js +55 -0
- package/lib/common/features/navigation/request-navigation-targets-action-handler.js.map +1 -0
- package/lib/common/features/navigation/resolve-navigation-targets-action-handler.d.ts +26 -0
- package/lib/common/features/navigation/resolve-navigation-targets-action-handler.d.ts.map +1 -0
- package/lib/common/features/navigation/resolve-navigation-targets-action-handler.js +59 -0
- package/lib/common/features/navigation/resolve-navigation-targets-action-handler.js.map +1 -0
- package/lib/common/features/popup/popup-model-factory.d.ts +36 -0
- package/lib/common/features/popup/popup-model-factory.d.ts.map +1 -0
- package/lib/common/features/popup/popup-model-factory.js +20 -0
- package/lib/common/features/popup/popup-model-factory.js.map +1 -0
- package/lib/common/features/popup/request-popup-model-action-handler.d.ts +31 -0
- package/lib/common/features/popup/request-popup-model-action-handler.d.ts.map +1 -0
- package/lib/common/features/popup/request-popup-model-action-handler.js +77 -0
- package/lib/common/features/popup/request-popup-model-action-handler.js.map +1 -0
- package/lib/common/features/validation/model-validator.d.ts +33 -0
- package/lib/common/features/validation/model-validator.d.ts.map +1 -0
- package/lib/common/features/validation/model-validator.js +5 -0
- package/lib/common/features/validation/model-validator.js.map +1 -0
- package/lib/common/features/validation/request-markers-handler.d.ts +11 -0
- package/lib/common/features/validation/request-markers-handler.d.ts.map +1 -0
- package/lib/common/features/validation/request-markers-handler.js +70 -0
- package/lib/common/features/validation/request-markers-handler.js.map +1 -0
- package/lib/common/gmodel/apply-label-edit-operation-handler.d.ts +8 -0
- package/lib/common/gmodel/apply-label-edit-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/apply-label-edit-operation-handler.js +46 -0
- package/lib/common/gmodel/apply-label-edit-operation-handler.js.map +1 -0
- package/lib/common/gmodel/change-bounds-operation-handler.d.ts +13 -0
- package/lib/common/gmodel/change-bounds-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/change-bounds-operation-handler.js +71 -0
- package/lib/common/gmodel/change-bounds-operation-handler.js.map +1 -0
- package/lib/common/gmodel/change-routing-points-operation-handler.d.ts +24 -0
- package/lib/common/gmodel/change-routing-points-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/change-routing-points-operation-handler.js +50 -0
- package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -0
- package/lib/common/gmodel/cut-operation-handler.d.ts +26 -0
- package/lib/common/gmodel/cut-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/cut-operation-handler.js +55 -0
- package/lib/common/gmodel/cut-operation-handler.js.map +1 -0
- package/lib/common/gmodel/delete-operation-handler.d.ts +32 -0
- package/lib/common/gmodel/delete-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/delete-operation-handler.js +119 -0
- package/lib/common/gmodel/delete-operation-handler.js.map +1 -0
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts +35 -0
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js +64 -0
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js.map +1 -0
- package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts +58 -0
- package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js +100 -0
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -0
- package/lib/common/gmodel/gmodel-diagram-module.d.ts +31 -0
- package/lib/common/gmodel/gmodel-diagram-module.d.ts.map +1 -0
- package/lib/common/gmodel/gmodel-diagram-module.js +80 -0
- package/lib/common/gmodel/gmodel-diagram-module.js.map +1 -0
- package/lib/common/gmodel/gmodel-operation-handler.d.ts +23 -0
- package/lib/common/gmodel/gmodel-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/gmodel-operation-handler.js +43 -0
- package/lib/common/gmodel/gmodel-operation-handler.js.map +1 -0
- package/lib/common/gmodel/index.d.ts +27 -0
- package/lib/common/gmodel/index.d.ts.map +1 -0
- package/lib/common/gmodel/index.js +43 -0
- package/lib/common/gmodel/index.js.map +1 -0
- package/lib/common/gmodel/paste-operation-handler.d.ts +36 -0
- package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/paste-operation-handler.js +136 -0
- package/lib/common/gmodel/paste-operation-handler.js.map +1 -0
- package/lib/common/gmodel/reconnect-edge-operation-handler.d.ts +9 -0
- package/lib/common/gmodel/reconnect-edge-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/reconnect-edge-operation-handler.js +64 -0
- package/lib/common/gmodel/reconnect-edge-operation-handler.js.map +1 -0
- package/lib/common/index.d.ts +89 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +105 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/launch/glsp-server-launcher.d.ts +34 -0
- package/lib/common/launch/glsp-server-launcher.d.ts.map +1 -0
- package/lib/common/launch/glsp-server-launcher.js +64 -0
- package/lib/common/launch/glsp-server-launcher.js.map +1 -0
- package/lib/common/operations/compound-operation-handler.d.ts +25 -0
- package/lib/common/operations/compound-operation-handler.d.ts.map +1 -0
- package/lib/common/operations/compound-operation-handler.js +82 -0
- package/lib/common/operations/compound-operation-handler.js.map +1 -0
- package/lib/common/operations/create-operation-handler.d.ts +32 -0
- package/lib/common/operations/create-operation-handler.d.ts.map +1 -0
- package/lib/common/operations/create-operation-handler.js +31 -0
- package/lib/common/operations/create-operation-handler.js.map +1 -0
- package/lib/common/operations/operation-action-handler.d.ts +42 -0
- package/lib/common/operations/operation-action-handler.d.ts.map +1 -0
- package/lib/common/operations/operation-action-handler.js +109 -0
- package/lib/common/operations/operation-action-handler.js.map +1 -0
- package/lib/common/operations/operation-handler-registry.d.ts +38 -0
- package/lib/common/operations/operation-handler-registry.d.ts.map +1 -0
- package/lib/common/operations/operation-handler-registry.js +87 -0
- package/lib/common/operations/operation-handler-registry.js.map +1 -0
- package/lib/common/operations/operation-handler-registry.spec.d.ts +2 -0
- package/lib/common/operations/operation-handler-registry.spec.d.ts.map +1 -0
- package/lib/common/operations/operation-handler-registry.spec.js +50 -0
- package/lib/common/operations/operation-handler-registry.spec.js.map +1 -0
- package/lib/common/operations/operation-handler.d.ts +67 -0
- package/lib/common/operations/operation-handler.d.ts.map +1 -0
- package/lib/common/operations/operation-handler.js +56 -0
- package/lib/common/operations/operation-handler.js.map +1 -0
- package/lib/common/protocol/glsp-client-proxy.d.ts +45 -0
- package/lib/common/protocol/glsp-client-proxy.d.ts.map +1 -0
- package/lib/common/protocol/glsp-client-proxy.js +53 -0
- package/lib/common/protocol/glsp-client-proxy.js.map +1 -0
- package/lib/common/protocol/glsp-server-listener.d.ts +37 -0
- package/lib/common/protocol/glsp-server-listener.d.ts.map +1 -0
- package/lib/common/protocol/glsp-server-listener.js +5 -0
- package/lib/common/protocol/glsp-server-listener.js.map +1 -0
- package/lib/common/protocol/glsp-server.d.ts +150 -0
- package/lib/common/protocol/glsp-server.d.ts.map +1 -0
- package/lib/common/protocol/glsp-server.js +188 -0
- package/lib/common/protocol/glsp-server.js.map +1 -0
- package/lib/common/protocol/glsp-server.spec.d.ts +2 -0
- package/lib/common/protocol/glsp-server.spec.d.ts.map +1 -0
- package/lib/common/protocol/glsp-server.spec.js +119 -0
- package/lib/common/protocol/glsp-server.spec.js.map +1 -0
- package/lib/common/session/client-session-factory.d.ts +42 -0
- package/lib/common/session/client-session-factory.d.ts.map +1 -0
- package/lib/common/session/client-session-factory.js +54 -0
- package/lib/common/session/client-session-factory.js.map +1 -0
- package/lib/common/session/client-session-factory.spec.d.ts +2 -0
- package/lib/common/session/client-session-factory.spec.d.ts.map +1 -0
- package/lib/common/session/client-session-factory.spec.js +56 -0
- package/lib/common/session/client-session-factory.spec.js.map +1 -0
- package/lib/common/session/client-session-initializer.d.ts +26 -0
- package/lib/common/session/client-session-initializer.d.ts.map +1 -0
- package/lib/common/session/client-session-initializer.js +5 -0
- package/lib/common/session/client-session-initializer.js.map +1 -0
- package/lib/common/session/client-session-listener.d.ts +40 -0
- package/lib/common/session/client-session-listener.d.ts.map +1 -0
- package/lib/common/session/client-session-listener.js +3 -0
- package/lib/common/session/client-session-listener.js.map +1 -0
- package/lib/common/session/client-session-manager.d.ts +102 -0
- package/lib/common/session/client-session-manager.d.ts.map +1 -0
- package/lib/common/session/client-session-manager.js +116 -0
- package/lib/common/session/client-session-manager.js.map +1 -0
- package/lib/common/session/client-session-manager.spec.d.ts +2 -0
- package/lib/common/session/client-session-manager.spec.d.ts.map +1 -0
- package/lib/common/session/client-session-manager.spec.js +74 -0
- package/lib/common/session/client-session-manager.spec.js.map +1 -0
- package/lib/common/session/client-session.d.ts +52 -0
- package/lib/common/session/client-session.d.ts.map +1 -0
- package/lib/common/session/client-session.js +34 -0
- package/lib/common/session/client-session.js.map +1 -0
- package/lib/common/test/mock-util.d.ts +117 -0
- package/lib/common/test/mock-util.d.ts.map +1 -0
- package/lib/common/test/mock-util.js +194 -0
- package/lib/common/test/mock-util.js.map +1 -0
- package/lib/common/utils/args-util.d.ts +38 -0
- package/lib/common/utils/args-util.d.ts.map +1 -0
- package/lib/common/utils/args-util.js +81 -0
- package/lib/common/utils/args-util.js.map +1 -0
- package/lib/common/utils/client-options-util.d.ts +20 -0
- package/lib/common/utils/client-options-util.d.ts.map +1 -0
- package/lib/common/utils/client-options-util.js +26 -0
- package/lib/common/utils/client-options-util.js.map +1 -0
- package/lib/common/utils/glsp-server-error.d.ts +21 -0
- package/lib/common/utils/glsp-server-error.d.ts.map +1 -0
- package/lib/common/utils/glsp-server-error.js +33 -0
- package/lib/common/utils/glsp-server-error.js.map +1 -0
- package/lib/common/utils/layout-util.d.ts +74 -0
- package/lib/common/utils/layout-util.d.ts.map +1 -0
- package/lib/common/utils/layout-util.js +166 -0
- package/lib/common/utils/layout-util.js.map +1 -0
- package/lib/common/utils/logger.d.ts +27 -0
- package/lib/common/utils/logger.d.ts.map +1 -0
- package/lib/common/utils/logger.js +67 -0
- package/lib/common/utils/logger.js.map +1 -0
- package/lib/common/utils/promise-queue.d.ts +48 -0
- package/lib/common/utils/promise-queue.d.ts.map +1 -0
- package/lib/common/utils/promise-queue.js +93 -0
- package/lib/common/utils/promise-queue.js.map +1 -0
- package/lib/common/utils/promise-queue.spec.d.ts +2 -0
- package/lib/common/utils/promise-queue.spec.d.ts.map +1 -0
- package/lib/common/utils/promise-queue.spec.js +117 -0
- package/lib/common/utils/promise-queue.spec.js.map +1 -0
- package/lib/common/utils/registry.d.ts +73 -0
- package/lib/common/utils/registry.d.ts.map +1 -0
- package/lib/common/utils/registry.js +160 -0
- package/lib/common/utils/registry.js.map +1 -0
- package/lib/common/utils/registry.spec.d.ts +2 -0
- package/lib/common/utils/registry.spec.d.ts.map +1 -0
- package/lib/common/utils/registry.spec.js +199 -0
- package/lib/common/utils/registry.spec.js.map +1 -0
- package/lib/node/abstract-json-model-storage.d.ts +45 -0
- package/lib/node/abstract-json-model-storage.d.ts.map +1 -0
- package/lib/node/abstract-json-model-storage.js +103 -0
- package/lib/node/abstract-json-model-storage.js.map +1 -0
- package/lib/node/di/app-module.d.ts +36 -0
- package/lib/node/di/app-module.d.ts.map +1 -0
- package/lib/node/di/app-module.js +91 -0
- package/lib/node/di/app-module.js.map +1 -0
- package/lib/node/di/winston-logger.d.ts +32 -0
- package/lib/node/di/winston-logger.d.ts.map +1 -0
- package/lib/node/di/winston-logger.js +57 -0
- package/lib/node/di/winston-logger.js.map +1 -0
- package/lib/node/gmodel/gmodel-storage.d.ts +34 -0
- package/lib/node/gmodel/gmodel-storage.d.ts.map +1 -0
- package/lib/node/gmodel/gmodel-storage.js +68 -0
- package/lib/node/gmodel/gmodel-storage.js.map +1 -0
- package/lib/node/index.d.ts +24 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +40 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/launch/cli-parser.d.ts +34 -0
- package/lib/node/launch/cli-parser.d.ts.map +1 -0
- package/lib/node/launch/cli-parser.js +71 -0
- package/lib/node/launch/cli-parser.js.map +1 -0
- package/lib/node/launch/cli-parser.spec.d.ts +2 -0
- package/lib/node/launch/cli-parser.spec.d.ts.map +1 -0
- package/lib/node/launch/cli-parser.spec.js +56 -0
- package/lib/node/launch/cli-parser.spec.js.map +1 -0
- package/lib/node/launch/socket-cli-parser.d.ts +9 -0
- package/lib/node/launch/socket-cli-parser.d.ts.map +1 -0
- package/lib/node/launch/socket-cli-parser.js +43 -0
- package/lib/node/launch/socket-cli-parser.js.map +1 -0
- package/lib/node/launch/socket-cli-parser.spec.d.ts +2 -0
- package/lib/node/launch/socket-cli-parser.spec.d.ts.map +1 -0
- package/lib/node/launch/socket-cli-parser.spec.js +66 -0
- package/lib/node/launch/socket-cli-parser.spec.js.map +1 -0
- package/lib/node/launch/socket-server-launcher.d.ts +34 -0
- package/lib/node/launch/socket-server-launcher.d.ts.map +1 -0
- package/lib/node/launch/socket-server-launcher.js +104 -0
- package/lib/node/launch/socket-server-launcher.js.map +1 -0
- package/lib/node/launch/socket-server-launcher.spec.d.ts +17 -0
- package/lib/node/launch/socket-server-launcher.spec.d.ts.map +1 -0
- package/lib/node/launch/socket-server-launcher.spec.js +70 -0
- package/lib/node/launch/socket-server-launcher.spec.js.map +1 -0
- package/node.d.ts +16 -0
- package/node.js +18 -0
- package/package.json +77 -0
- package/src/browser/di/app-module.ts +55 -0
- package/src/browser/di/console-logger.ts +71 -0
- package/src/browser/index.ts +19 -0
- package/src/browser/launch/worker-server-launcher.ts +58 -0
- package/src/common/actions/action-dispatcher.spec.ts +290 -0
- package/src/common/actions/action-dispatcher.ts +152 -0
- package/src/common/actions/action-handler-registry.spec.ts +52 -0
- package/src/common/actions/action-handler-registry.ts +60 -0
- package/src/common/actions/action-handler.ts +62 -0
- package/src/common/actions/client-action-handler.ts +50 -0
- package/src/common/actions/global-action-provider.spec.ts +79 -0
- package/src/common/actions/global-action-provider.ts +72 -0
- package/src/common/command/command-stack.spec.ts +239 -0
- package/src/common/command/command-stack.ts +159 -0
- package/src/common/command/command.spec.ts +93 -0
- package/src/common/command/command.ts +124 -0
- 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/binding-target.spec.ts +147 -0
- package/src/common/di/binding-target.ts +188 -0
- package/src/common/di/client-session-module.ts +29 -0
- package/src/common/di/diagram-module.ts +410 -0
- package/src/common/di/glsp-module.ts +66 -0
- package/src/common/di/multi-binding.ts +89 -0
- package/src/common/di/multi-bindings.spec.ts +133 -0
- package/src/common/di/server-module.ts +131 -0
- package/src/common/di/service-identifiers.ts +39 -0
- package/src/common/diagram/diagram-configuration.ts +97 -0
- package/src/common/diagram/request-type-hints-action-handler.spec.ts +59 -0
- package/src/common/diagram/request-type-hints-action-handler.ts +36 -0
- package/src/common/features/clipboard/request-clipboard-data-action-handler.ts +51 -0
- package/src/common/features/contextactions/command-palette-action-provider.ts +94 -0
- package/src/common/features/contextactions/context-actions-provider-registry.spec.ts +69 -0
- package/src/common/features/contextactions/context-actions-provider-registry.ts +47 -0
- package/src/common/features/contextactions/context-actions-provider.ts +36 -0
- package/src/common/features/contextactions/context-menu-item-provider.ts +52 -0
- package/src/common/features/contextactions/request-context-actions-handler.spec.ts +75 -0
- package/src/common/features/contextactions/request-context-actions-handler.ts +37 -0
- package/src/common/features/contextactions/tool-palette-item-provider.spec.ts +46 -0
- package/src/common/features/contextactions/tool-palette-item-provider.ts +88 -0
- package/src/common/features/directediting/context-edit-validator-registry.spec.ts +54 -0
- package/src/common/features/directediting/context-edit-validator-registry.ts +43 -0
- package/src/common/features/directediting/context-edit-validator.ts +55 -0
- package/src/common/features/directediting/label-edit-validator.ts +35 -0
- package/src/common/features/directediting/request-edit-validation-handler.spec.ts +131 -0
- package/src/common/features/directediting/request-edit-validation-handler.ts +43 -0
- package/src/common/features/layout/computed-bounds-action-handler.ts +56 -0
- package/src/common/features/layout/layout-engine.ts +31 -0
- package/src/common/features/layout/layout-operation-handler.ts +62 -0
- package/src/common/features/model/gmodel-factory.ts +60 -0
- package/src/common/features/model/gmodel-index.ts +195 -0
- package/src/common/features/model/gmodel-serializer.spec.ts +141 -0
- package/src/common/features/model/gmodel-serializer.ts +175 -0
- package/src/common/features/model/model-state.ts +98 -0
- package/src/common/features/model/model-submission-handler.ts +110 -0
- package/src/common/features/model/request-model-action-handler.ts +67 -0
- package/src/common/features/model/save-model-action-handler.ts +37 -0
- package/src/common/features/model/source-model-storage.ts +49 -0
- package/src/common/features/navigation/json-opener-options.ts +69 -0
- package/src/common/features/navigation/navigation-target-provider-registry.ts +36 -0
- package/src/common/features/navigation/navigation-target-provider.ts +50 -0
- package/src/common/features/navigation/navigation-target-resolution.ts +22 -0
- package/src/common/features/navigation/navigation-target-resolver.ts +61 -0
- package/src/common/features/navigation/request-navigation-targets-action-handler.ts +39 -0
- package/src/common/features/navigation/resolve-navigation-targets-action-handler.ts +42 -0
- package/src/common/features/popup/popup-model-factory.ts +38 -0
- package/src/common/features/popup/request-popup-model-action-handler.ts +60 -0
- package/src/common/features/validation/model-validator.ts +34 -0
- package/src/common/features/validation/request-markers-handler.ts +51 -0
- package/src/common/gmodel/README.md +7 -0
- package/src/common/gmodel/apply-label-edit-operation-handler.ts +36 -0
- package/src/common/gmodel/change-bounds-operation-handler.ts +62 -0
- package/src/common/gmodel/change-routing-points-operation-handler.ts +40 -0
- package/src/common/gmodel/cut-operation-handler.ts +39 -0
- package/src/common/gmodel/delete-operation-handler.ts +121 -0
- package/src/common/gmodel/gmodel-create-edge-operation-handler.ts +64 -0
- package/src/common/gmodel/gmodel-create-node-operation-handler.ts +95 -0
- package/src/common/gmodel/gmodel-diagram-module.ts +76 -0
- package/src/common/gmodel/gmodel-operation-handler.ts +31 -0
- package/src/common/gmodel/index.ts +27 -0
- package/src/common/gmodel/paste-operation-handler.ts +127 -0
- package/src/common/gmodel/reconnect-edge-operation-handler.ts +56 -0
- package/src/common/index.ts +89 -0
- package/src/common/launch/glsp-server-launcher.ts +70 -0
- package/src/common/operations/compound-operation-handler.ts +40 -0
- package/src/common/operations/create-operation-handler.ts +49 -0
- package/src/common/operations/operation-action-handler.ts +93 -0
- package/src/common/operations/operation-handler-registry.spec.ts +50 -0
- package/src/common/operations/operation-handler-registry.ts +66 -0
- package/src/common/operations/operation-handler.ts +82 -0
- package/src/common/protocol/glsp-client-proxy.ts +65 -0
- package/src/common/protocol/glsp-server-listener.ts +39 -0
- package/src/common/protocol/glsp-server.spec.ts +150 -0
- package/src/common/protocol/glsp-server.ts +320 -0
- package/src/common/session/client-session-factory.spec.ts +60 -0
- package/src/common/session/client-session-factory.ts +70 -0
- package/src/common/session/client-session-initializer.ts +27 -0
- package/src/common/session/client-session-listener.ts +41 -0
- package/src/common/session/client-session-manager.spec.ts +82 -0
- package/src/common/session/client-session-manager.ts +182 -0
- package/src/common/session/client-session.ts +62 -0
- package/src/common/test/mock-util.ts +241 -0
- package/src/common/utils/args-util.ts +98 -0
- package/src/common/utils/client-options-util.ts +22 -0
- package/src/common/utils/glsp-server-error.ts +27 -0
- package/src/common/utils/layout-util.ts +164 -0
- package/src/common/utils/logger.ts +72 -0
- package/src/common/utils/promise-queue.spec.ts +138 -0
- package/src/common/utils/promise-queue.ts +103 -0
- package/src/common/utils/registry.spec.ts +223 -0
- package/src/common/utils/registry.ts +154 -0
- package/src/node/abstract-json-model-storage.ts +114 -0
- package/src/node/di/app-module.ts +102 -0
- package/src/node/di/winston-logger.ts +76 -0
- package/src/node/gmodel/gmodel-storage.ts +53 -0
- package/src/node/index.ts +23 -0
- package/src/node/launch/cli-parser.spec.ts +61 -0
- package/src/node/launch/cli-parser.ts +86 -0
- package/src/node/launch/socket-cli-parser.spec.ts +73 -0
- package/src/node/launch/socket-cli-parser.ts +52 -0
- package/src/node/launch/socket-server-launcher.spec.ts +68 -0
- package/src/node/launch/socket-server-launcher.ts +90 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022-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 { Container, injectable } from 'inversify';
|
|
18
|
+
import * as jsonrpc from 'vscode-jsonrpc/browser';
|
|
19
|
+
import { GLSPServer, GLSPServerLauncher, JsonRpcGLSPServer, MaybePromise, START_UP_COMPLETE_MSG } from '../../common/index';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class WorkerServerLauncher extends GLSPServerLauncher {
|
|
23
|
+
private connection?: jsonrpc.MessageConnection;
|
|
24
|
+
|
|
25
|
+
protected run(): MaybePromise<void> {
|
|
26
|
+
if (this.connection) {
|
|
27
|
+
throw new Error('Error during launch. Server already has an active client connection');
|
|
28
|
+
}
|
|
29
|
+
const container = this.createContainer();
|
|
30
|
+
this.connection = this.createConnection();
|
|
31
|
+
const glspServer = container.get<JsonRpcGLSPServer>(JsonRpcGLSPServer);
|
|
32
|
+
glspServer.connect(this.connection);
|
|
33
|
+
this.connection.onDispose(() => this.disposeClientConnection(container, glspServer));
|
|
34
|
+
|
|
35
|
+
this.logger.info('GLSP server worker connection established');
|
|
36
|
+
this.connection.listen();
|
|
37
|
+
postMessage(START_UP_COMPLETE_MSG);
|
|
38
|
+
return new Promise((resolve, rejects) => {
|
|
39
|
+
this.connection?.onClose(() => resolve(undefined));
|
|
40
|
+
this.connection?.onError(error => rejects(error));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected disposeClientConnection(container: Container, glspServer: GLSPServer): void {
|
|
45
|
+
glspServer.shutdown();
|
|
46
|
+
container.unbindAll();
|
|
47
|
+
this.connection = undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
protected stop(): MaybePromise<void> {
|
|
51
|
+
this.logger.info('Shutdown WorkerServerLauncher');
|
|
52
|
+
this.connection?.dispose();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected createConnection(): jsonrpc.MessageConnection {
|
|
56
|
+
return jsonrpc.createMessageConnection(new jsonrpc.BrowserMessageReader(self), new jsonrpc.BrowserMessageWriter(self));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022-2023 STMicroelectronics and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { Action, UpdateModelAction } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { expect } from 'chai';
|
|
18
|
+
import { Container, ContainerModule } from 'inversify';
|
|
19
|
+
import * as sinon from 'sinon';
|
|
20
|
+
import { ClientActionKinds, ClientId } from '../di/service-identifiers';
|
|
21
|
+
import { ClientSessionManager } from '../session/client-session-manager';
|
|
22
|
+
import * as mock from '../test/mock-util';
|
|
23
|
+
import { Logger } from '../utils/logger';
|
|
24
|
+
import { DefaultActionDispatcher } from './action-dispatcher';
|
|
25
|
+
import { ActionHandler } from './action-handler';
|
|
26
|
+
import { ActionHandlerRegistry } from './action-handler-registry';
|
|
27
|
+
import assert = require('assert');
|
|
28
|
+
|
|
29
|
+
function waitSync(timeInMillis: number): void {
|
|
30
|
+
const start = Date.now();
|
|
31
|
+
let now = start;
|
|
32
|
+
while (now - start < timeInMillis) {
|
|
33
|
+
now = Date.now();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe('test DefaultActionDispatcher', () => {
|
|
38
|
+
const container = new Container();
|
|
39
|
+
const clientId = 'myClientId';
|
|
40
|
+
const actionHandlerRegistry = new ActionHandlerRegistry();
|
|
41
|
+
let registry_get_stub: sinon.SinonStub<[string], ActionHandler[]>;
|
|
42
|
+
const sandbox = sinon.createSandbox();
|
|
43
|
+
|
|
44
|
+
container.load(
|
|
45
|
+
new ContainerModule(bind => {
|
|
46
|
+
bind(Logger).toConstantValue(new mock.StubLogger());
|
|
47
|
+
bind(ClientSessionManager).toConstantValue(new mock.StubClientSessionManager());
|
|
48
|
+
bind(ClientId).toConstantValue(clientId);
|
|
49
|
+
bind(ActionHandlerRegistry).toConstantValue(actionHandlerRegistry);
|
|
50
|
+
bind(ClientActionKinds).toConstantValue(['response', 'response1', 'response2']);
|
|
51
|
+
})
|
|
52
|
+
);
|
|
53
|
+
const actionDispatcher = container.resolve(DefaultActionDispatcher);
|
|
54
|
+
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
registry_get_stub = sandbox.stub(actionHandlerRegistry, 'get');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
sandbox.restore();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('test with one-way actions (no response actions)', () => {
|
|
64
|
+
it('dispatch- unhandled action', async () => {
|
|
65
|
+
assert.rejects(actionDispatcher.dispatch({ kind: 'unhandled' }));
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('dispatch - one action', async () => {
|
|
69
|
+
// Mock setup
|
|
70
|
+
const action = 'action';
|
|
71
|
+
const handler = new mock.StubActionHandler([action]);
|
|
72
|
+
const getHandler = (kind: string): ActionHandler[] => (kind === action ? [handler] : []);
|
|
73
|
+
registry_get_stub.callsFake(getHandler);
|
|
74
|
+
const spy_handler_execute = sinon.spy(handler, 'execute');
|
|
75
|
+
// Test execution
|
|
76
|
+
await actionDispatcher.dispatch({ kind: action });
|
|
77
|
+
expect(spy_handler_execute.calledOnce).true;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('test multi dispatch with single-handled actions', () => {
|
|
81
|
+
// Mock Setup
|
|
82
|
+
const action1 = 'a1';
|
|
83
|
+
const action2 = 'a2';
|
|
84
|
+
const action3 = 'a3';
|
|
85
|
+
|
|
86
|
+
const handler1 = new mock.StubActionHandler([action1]);
|
|
87
|
+
const handler2 = new mock.StubActionHandler([action2]);
|
|
88
|
+
const handler3 = new mock.StubActionHandler([action3]);
|
|
89
|
+
|
|
90
|
+
const spy_handler1_execute = sinon.stub(handler1, 'execute').returns([]);
|
|
91
|
+
const spy_handler2_execute = sinon.stub(handler2, 'execute').returns([]);
|
|
92
|
+
const spy_handler3_execute = sinon.stub(handler3, 'execute').returns([]);
|
|
93
|
+
const handlerMockImpl = (kind: string): ActionHandler[] => {
|
|
94
|
+
switch (kind) {
|
|
95
|
+
case action1:
|
|
96
|
+
return [handler1];
|
|
97
|
+
case action2:
|
|
98
|
+
return [handler2];
|
|
99
|
+
case action3:
|
|
100
|
+
return [handler3];
|
|
101
|
+
default:
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
it('dispatch - multiple actions', async () => {
|
|
107
|
+
// Mock setup
|
|
108
|
+
registry_get_stub.callsFake(handlerMockImpl);
|
|
109
|
+
// Test execution
|
|
110
|
+
actionDispatcher.dispatch({ kind: action1 });
|
|
111
|
+
actionDispatcher.dispatch({ kind: action2 });
|
|
112
|
+
await actionDispatcher.dispatch({ kind: action3 });
|
|
113
|
+
// Check if all handlers have been called
|
|
114
|
+
expect(spy_handler1_execute.called).true;
|
|
115
|
+
expect(spy_handler2_execute.called).true;
|
|
116
|
+
expect(spy_handler3_execute.called).true;
|
|
117
|
+
// Check if all handlers have been called in the right order
|
|
118
|
+
sinon.assert.callOrder(spy_handler1_execute, spy_handler2_execute, spy_handler3_execute);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('dispatchAll- multiple actions', async () => {
|
|
122
|
+
// Mock setup
|
|
123
|
+
registry_get_stub.callsFake(handlerMockImpl);
|
|
124
|
+
// Test execution
|
|
125
|
+
await actionDispatcher.dispatchAll([{ kind: action1 }, { kind: action2 }, { kind: action3 }]);
|
|
126
|
+
// Check if all handlers have been called
|
|
127
|
+
expect(spy_handler1_execute.calledOnce);
|
|
128
|
+
expect(spy_handler2_execute.calledOnce);
|
|
129
|
+
expect(spy_handler3_execute.calledOnce);
|
|
130
|
+
// Check if all handlers have been called in the right order
|
|
131
|
+
sinon.assert.callOrder(spy_handler1_execute, spy_handler2_execute, spy_handler3_execute);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('dispatch - multiple actions (racing execution times)', async () => {
|
|
135
|
+
// Mock setup
|
|
136
|
+
registry_get_stub.callsFake(handlerMockImpl);
|
|
137
|
+
spy_handler1_execute.callsFake((_action: Action) => {
|
|
138
|
+
waitSync(500);
|
|
139
|
+
return [];
|
|
140
|
+
});
|
|
141
|
+
spy_handler2_execute.callsFake((_action: Action) => {
|
|
142
|
+
waitSync(200);
|
|
143
|
+
return [];
|
|
144
|
+
});
|
|
145
|
+
spy_handler3_execute.callsFake((_action: Action) => {
|
|
146
|
+
waitSync(100);
|
|
147
|
+
return [];
|
|
148
|
+
});
|
|
149
|
+
// Test execution
|
|
150
|
+
actionDispatcher.dispatch({ kind: action1 });
|
|
151
|
+
actionDispatcher.dispatch({ kind: action2 });
|
|
152
|
+
await actionDispatcher.dispatch({ kind: action3 });
|
|
153
|
+
// Check if all handlers have been called
|
|
154
|
+
expect(spy_handler1_execute.calledOnce);
|
|
155
|
+
expect(spy_handler2_execute.calledOnce);
|
|
156
|
+
expect(spy_handler3_execute.calledOnce);
|
|
157
|
+
// Check if all handlers have been called in the right order
|
|
158
|
+
sinon.assert.callOrder(spy_handler1_execute, spy_handler2_execute, spy_handler3_execute);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('dispatch- one action & multiple handlers', async () => {
|
|
163
|
+
// Mock setup
|
|
164
|
+
const action1 = 'a1';
|
|
165
|
+
|
|
166
|
+
const handler1 = new mock.StubActionHandler([action1]);
|
|
167
|
+
const handler2 = new mock.StubActionHandler([action1]);
|
|
168
|
+
|
|
169
|
+
registry_get_stub.callsFake((kind: string) => (kind === action1 ? [handler1, handler2] : []));
|
|
170
|
+
const spy_handler1_execute = sinon.spy(handler1, 'execute');
|
|
171
|
+
const spy_handler2_execute = sinon.spy(handler2, 'execute');
|
|
172
|
+
// Test execution
|
|
173
|
+
await actionDispatcher.dispatch({ kind: action1 });
|
|
174
|
+
expect(spy_handler1_execute.calledOnce);
|
|
175
|
+
expect(spy_handler2_execute.calledOnce);
|
|
176
|
+
sinon.assert.callOrder(spy_handler1_execute, spy_handler2_execute);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
describe('test with handler response actions ', () => {
|
|
181
|
+
it('dispatch - one action & one handler response action', async () => {
|
|
182
|
+
// Mock setup
|
|
183
|
+
const request = 'request';
|
|
184
|
+
const response = 'response';
|
|
185
|
+
|
|
186
|
+
const requestHandler = new mock.StubActionHandler([request]);
|
|
187
|
+
const responseHandler = new mock.StubActionHandler([response]);
|
|
188
|
+
|
|
189
|
+
const spy_requestHandler_execute = sinon.stub(requestHandler, 'execute').returns([{ kind: response }]);
|
|
190
|
+
const spy_responseHandler_execute = sinon.spy(responseHandler, 'execute');
|
|
191
|
+
registry_get_stub.callsFake((kind: string) => {
|
|
192
|
+
switch (kind) {
|
|
193
|
+
case request:
|
|
194
|
+
return [requestHandler];
|
|
195
|
+
case response:
|
|
196
|
+
return [responseHandler];
|
|
197
|
+
default:
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
// Test execution
|
|
202
|
+
await actionDispatcher.dispatch({ kind: request });
|
|
203
|
+
// Add a delay so that the action dispatcher has time to dispatch the handler response
|
|
204
|
+
await mock.delay(200);
|
|
205
|
+
// Check if all handlers have been called
|
|
206
|
+
expect(spy_requestHandler_execute.calledOnce);
|
|
207
|
+
expect(spy_responseHandler_execute.calledOnce);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('dispatch - multiple actions & multiple response', async () => {
|
|
211
|
+
// Mock setup
|
|
212
|
+
const request1 = 'request1';
|
|
213
|
+
const request2 = 'request2';
|
|
214
|
+
const response1 = 'response1';
|
|
215
|
+
const response2 = 'response2';
|
|
216
|
+
|
|
217
|
+
const responseHandler1 = new mock.StubActionHandler([response1]);
|
|
218
|
+
const responseHandler2 = new mock.StubActionHandler([response2]);
|
|
219
|
+
const requestHandler1 = new mock.StubActionHandler([request1]);
|
|
220
|
+
const requestHandler2 = new mock.StubActionHandler([request2]);
|
|
221
|
+
|
|
222
|
+
const spy_requestHandler1_execute = sinon.stub(requestHandler1, 'execute').returns([{ kind: response1 }, { kind: response2 }]);
|
|
223
|
+
const spy_requestHandler2_execute = sinon.stub(requestHandler2, 'execute').returns([{ kind: response2 }]);
|
|
224
|
+
const spy_responseHandler1_execute = sinon.spy(responseHandler1, 'execute');
|
|
225
|
+
const spy_responseHandler2_execute = sinon.spy(responseHandler2, 'execute');
|
|
226
|
+
registry_get_stub.callsFake((kind: string) => {
|
|
227
|
+
switch (kind) {
|
|
228
|
+
case request1:
|
|
229
|
+
return [requestHandler1];
|
|
230
|
+
case request2:
|
|
231
|
+
return [requestHandler2];
|
|
232
|
+
case response1:
|
|
233
|
+
return [responseHandler1, responseHandler2];
|
|
234
|
+
case response2:
|
|
235
|
+
return [responseHandler2];
|
|
236
|
+
default:
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
// Test execution
|
|
241
|
+
actionDispatcher.dispatch({ kind: request1 });
|
|
242
|
+
await actionDispatcher.dispatch({ kind: request2 });
|
|
243
|
+
|
|
244
|
+
// Add a delay so that the action dispatcher has time to dispatch the handler response
|
|
245
|
+
await mock.delay(100);
|
|
246
|
+
// Check if all handlers have been called correctly
|
|
247
|
+
expect(spy_requestHandler1_execute.calledOnce);
|
|
248
|
+
expect(spy_requestHandler2_execute.calledOnce);
|
|
249
|
+
expect(spy_responseHandler1_execute.calledOnce);
|
|
250
|
+
expect(spy_responseHandler2_execute.calledThrice);
|
|
251
|
+
// Check if all handlers have been called in the right order
|
|
252
|
+
sinon.assert.callOrder(spy_requestHandler1_execute, spy_requestHandler2_execute);
|
|
253
|
+
sinon.assert.callOrder(spy_responseHandler1_execute, spy_responseHandler2_execute);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
describe('test dispatch after next update', () => {
|
|
258
|
+
it('dispatchAfterNextUpdate', async () => {
|
|
259
|
+
// Mock setup
|
|
260
|
+
const updateModelAction = UpdateModelAction.create({ id: 'newRoot', type: 'myType' });
|
|
261
|
+
const intermediateAction = 'intermediate';
|
|
262
|
+
const postUpdateAction = 'postUpdate';
|
|
263
|
+
const handler = new mock.StubActionHandler([updateModelAction.kind, intermediateAction]);
|
|
264
|
+
const postUpdateHandler = new mock.StubActionHandler([postUpdateAction]);
|
|
265
|
+
|
|
266
|
+
const getHandler = (kind: string): ActionHandler[] => {
|
|
267
|
+
if (kind === updateModelAction.kind || kind === intermediateAction) {
|
|
268
|
+
return [handler];
|
|
269
|
+
} else if (kind === postUpdateAction) {
|
|
270
|
+
return [postUpdateHandler];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return [];
|
|
274
|
+
};
|
|
275
|
+
registry_get_stub.callsFake(getHandler);
|
|
276
|
+
const spy_postUpdateHandler_execute = sinon.spy(postUpdateHandler, 'execute');
|
|
277
|
+
|
|
278
|
+
// Test execution
|
|
279
|
+
actionDispatcher.dispatchAfterNextUpdate({ kind: postUpdateAction });
|
|
280
|
+
expect(spy_postUpdateHandler_execute.called).to.be.false;
|
|
281
|
+
await actionDispatcher.dispatch({ kind: intermediateAction });
|
|
282
|
+
expect(spy_postUpdateHandler_execute.called).to.be.false;
|
|
283
|
+
await actionDispatcher.dispatch(updateModelAction);
|
|
284
|
+
expect(spy_postUpdateHandler_execute.calledOnce);
|
|
285
|
+
// Check that action does not get dispatched again
|
|
286
|
+
await actionDispatcher.dispatch(updateModelAction);
|
|
287
|
+
expect(spy_postUpdateHandler_execute.calledOnce);
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022-2023 STMicroelectronics and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { Action, Disposable, flatPush, MaybeArray, RequestAction, ResponseAction, UpdateModelAction } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { inject, injectable } from 'inversify';
|
|
18
|
+
import { ClientActionKinds, ClientId } from '../di/service-identifiers';
|
|
19
|
+
import { GLSPServerError } from '../utils/glsp-server-error';
|
|
20
|
+
import { Logger } from '../utils/logger';
|
|
21
|
+
import { PromiseQueue } from '../utils/promise-queue';
|
|
22
|
+
import { ActionHandler } from './action-handler';
|
|
23
|
+
import { ActionHandlerRegistry } from './action-handler-registry';
|
|
24
|
+
|
|
25
|
+
export const ActionDispatcher = Symbol('ActionDispatcher');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The central component that process all {@link Action}s by dispatching them to their designated
|
|
29
|
+
* handlers.
|
|
30
|
+
*/
|
|
31
|
+
export interface ActionDispatcher {
|
|
32
|
+
/**
|
|
33
|
+
* Processes the given action by dispatching it to all registered handlers.
|
|
34
|
+
*
|
|
35
|
+
* @param action The action that should be dispatched.
|
|
36
|
+
* @returns A promise indicating when the action processing is complete.
|
|
37
|
+
*/
|
|
38
|
+
dispatch(action: Action): Promise<void>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Processes all given actions by dispatching to the corresponding handlers.
|
|
42
|
+
*
|
|
43
|
+
* @param actions Actions to dispatch
|
|
44
|
+
* @returns A promise indicating that all actions have been processed.
|
|
45
|
+
*/
|
|
46
|
+
dispatchAll(actions: Action[]): Promise<void>;
|
|
47
|
+
dispatchAll(...actions: Action[]): Promise<void>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Processes all given actions, by dispatching them to the corresponding handlers, after the next model update.
|
|
51
|
+
* The given actions are queued until the next model update cycle has been completed i.e. an
|
|
52
|
+
* `UpdateModelAction` has been dispatched and processed by this action dispatcher.
|
|
53
|
+
*
|
|
54
|
+
* @param actions The actions that should be dispatched after the next model update
|
|
55
|
+
*/
|
|
56
|
+
dispatchAfterNextUpdate(actions: Action[]): void;
|
|
57
|
+
dispatchAfterNextUpdate(...actions: Action[]): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@injectable()
|
|
61
|
+
export class DefaultActionDispatcher implements ActionDispatcher, Disposable {
|
|
62
|
+
@inject(ActionHandlerRegistry)
|
|
63
|
+
protected actionHandlerRegistry: ActionHandlerRegistry;
|
|
64
|
+
|
|
65
|
+
@inject(ClientActionKinds)
|
|
66
|
+
protected clientActionKinds: string[];
|
|
67
|
+
|
|
68
|
+
@inject(Logger)
|
|
69
|
+
private logger: Logger;
|
|
70
|
+
|
|
71
|
+
@inject(ClientId)
|
|
72
|
+
protected clientId: string;
|
|
73
|
+
|
|
74
|
+
protected actionQueue = new PromiseQueue();
|
|
75
|
+
protected postUpdateQueue: Action[] = [];
|
|
76
|
+
|
|
77
|
+
dispatch(action: Action): Promise<void> {
|
|
78
|
+
// Dont queue actions that are just delegated to the client
|
|
79
|
+
if (this.clientActionKinds.includes(action.kind)) {
|
|
80
|
+
return this.doDispatch(action);
|
|
81
|
+
}
|
|
82
|
+
return this.actionQueue.enqueue(() => this.doDispatch(action));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected async doDispatch(action: Action): Promise<void> {
|
|
86
|
+
this.logger.debug('Dispatch action:', action.kind);
|
|
87
|
+
const actionHandlers = this.actionHandlerRegistry.get(action.kind);
|
|
88
|
+
if (actionHandlers.length === 0) {
|
|
89
|
+
throw new GLSPServerError(`No handler registered for action kind: ${action.kind}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const responses: Action[] = [];
|
|
93
|
+
for (const handler of actionHandlers) {
|
|
94
|
+
const response = await this.executeHandler(handler, action);
|
|
95
|
+
responses.push(...response);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (UpdateModelAction.is(action) && this.postUpdateQueue.length > 0) {
|
|
99
|
+
responses.push(...this.postUpdateQueue);
|
|
100
|
+
this.postUpdateQueue = [];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
await this.dispatchResponses(responses);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
protected async executeHandler(handler: ActionHandler, request: Action): Promise<Action[]> {
|
|
107
|
+
const responseActions = await handler.execute(request);
|
|
108
|
+
return responseActions.map(action => respond(request, action));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
protected dispatchResponses(actions: Action[]): Promise<void> {
|
|
112
|
+
if (actions.length === 0) {
|
|
113
|
+
return Promise.resolve();
|
|
114
|
+
}
|
|
115
|
+
const responseQueue = new PromiseQueue();
|
|
116
|
+
const responses = actions.map(action => responseQueue.enqueue(() => this.doDispatch(action)));
|
|
117
|
+
return Promise.all(responses).then(() => Promise.resolve());
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
dispatchAll(...actions: MaybeArray<Action>[]): Promise<void> {
|
|
121
|
+
if (actions.length === 0) {
|
|
122
|
+
return Promise.resolve();
|
|
123
|
+
}
|
|
124
|
+
const flat: Action[] = [];
|
|
125
|
+
flatPush(flat, actions);
|
|
126
|
+
return Promise.all(flat.map(action => this.dispatch(action))).then(() => Promise.resolve());
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
dispatchAfterNextUpdate(...actions: MaybeArray<Action>[]): void {
|
|
130
|
+
if (actions.length !== 0) {
|
|
131
|
+
flatPush(this.postUpdateQueue, actions);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
dispose(): void {
|
|
136
|
+
this.actionQueue.clear();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Transfers the {@link RequestAction.requestId id} from request to response if applicable.
|
|
142
|
+
*
|
|
143
|
+
* @param request potential {@link RequestAction}
|
|
144
|
+
* @param response potential {@link ResponseAction}
|
|
145
|
+
* @returns given response action with id set if applicable
|
|
146
|
+
*/
|
|
147
|
+
export function respond(request: Action, response: Action): Action {
|
|
148
|
+
if (RequestAction.is(request) && ResponseAction.is(response)) {
|
|
149
|
+
(response as any).responseId = request.requestId;
|
|
150
|
+
}
|
|
151
|
+
return response;
|
|
152
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022-2023 STMicroelectronics and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import * as mock from '../test/mock-util';
|
|
17
|
+
import { ActionHandlerRegistry } from './action-handler-registry';
|
|
18
|
+
import { expect } from 'chai';
|
|
19
|
+
|
|
20
|
+
describe('Test ActionHandlerRegistry (only functionality that is not covered by "registry.spec.ts"', () => {
|
|
21
|
+
const singleAction = 'singleHandledAction';
|
|
22
|
+
const multiAction = 'multiHandledAction';
|
|
23
|
+
|
|
24
|
+
const h1 = new mock.StubActionHandler([singleAction]);
|
|
25
|
+
const h2 = new mock.StubActionHandler([multiAction]);
|
|
26
|
+
const h3 = new mock.StubActionHandler([multiAction]);
|
|
27
|
+
const h4 = new mock.StubActionHandler([multiAction]);
|
|
28
|
+
const registry: ActionHandlerRegistry = new ActionHandlerRegistry();
|
|
29
|
+
|
|
30
|
+
it('registerHandler - should register given handlers', () => {
|
|
31
|
+
// setup
|
|
32
|
+
registry.registerHandler(h1);
|
|
33
|
+
registry.registerHandler(h2);
|
|
34
|
+
registry.registerHandler(h3);
|
|
35
|
+
registry.registerHandler(h4);
|
|
36
|
+
|
|
37
|
+
const result = registry.getAll();
|
|
38
|
+
expect(result).to.have.length(4);
|
|
39
|
+
expect(result.includes(h1)).true;
|
|
40
|
+
expect(result.includes(h2)).true;
|
|
41
|
+
expect(result.includes(h3)).true;
|
|
42
|
+
expect(result.includes(h4)).true;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('get - should return three handlers sorted by priority', () => {
|
|
46
|
+
const result = registry.get(multiAction);
|
|
47
|
+
expect(result.length).to.be.equal(3);
|
|
48
|
+
expect(result[0]).to.be.deep.equal(h4);
|
|
49
|
+
expect(result[1]).to.be.deep.equal(h2);
|
|
50
|
+
expect(result[2]).to.be.deep.equal(h3);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022-2023 STMicroelectronics and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { Args } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { inject, injectable, optional } from 'inversify';
|
|
18
|
+
import { ClientSessionInitializer } from '../session/client-session-initializer';
|
|
19
|
+
import { MultiRegistry } from '../utils/registry';
|
|
20
|
+
import { ActionHandler, ActionHandlerConstructor, ActionHandlerFactory } from './action-handler';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* An action handler registry keeps track of registered action handlers for a certain action.
|
|
24
|
+
*/
|
|
25
|
+
@injectable()
|
|
26
|
+
export class ActionHandlerRegistry extends MultiRegistry<string, ActionHandler> {
|
|
27
|
+
registerHandler(handler: ActionHandler): void {
|
|
28
|
+
return handler.actionKinds.forEach(kind => this.register(kind, handler));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Retrieve all registered {@link ActionHandler}s that can handle the given action.
|
|
33
|
+
* The resulting list is ordered descending using {@link ActionHandler.getPriority}.
|
|
34
|
+
*
|
|
35
|
+
* @param action The action
|
|
36
|
+
* @returns A list of all registered handlers that can handle the given action.
|
|
37
|
+
*/
|
|
38
|
+
override get(key: string): ActionHandler[] {
|
|
39
|
+
const result = super.get(key);
|
|
40
|
+
return result.sort((a, b) => a.priority ?? 0 - (b.priority ?? 0));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@injectable()
|
|
45
|
+
export class ActionHandlerRegistryInitializer implements ClientSessionInitializer {
|
|
46
|
+
@inject(ActionHandlerFactory)
|
|
47
|
+
protected factory: ActionHandlerFactory;
|
|
48
|
+
|
|
49
|
+
@inject(ActionHandlerConstructor)
|
|
50
|
+
@optional()
|
|
51
|
+
protected handlerConstructors: ActionHandlerConstructor[] = [];
|
|
52
|
+
|
|
53
|
+
@inject(ActionHandlerRegistry)
|
|
54
|
+
protected registry: ActionHandlerRegistry;
|
|
55
|
+
|
|
56
|
+
initialize(_args?: Args): void {
|
|
57
|
+
const handlers = this.handlerConstructors.map(constructor => this.factory(constructor));
|
|
58
|
+
handlers.forEach(handler => this.registry.registerHandler(handler));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2022-2023 STMicroelectronics and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { Action, MaybePromise } from '@eclipse-glsp/protocol';
|
|
17
|
+
import { interfaces } from 'inversify';
|
|
18
|
+
|
|
19
|
+
export const ActionHandler = Symbol('ActionHandler');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* An action handler can execute certain {@link Action} types that are dispatched by the
|
|
23
|
+
* {@link ActionDispatcher}. The action handler processes the action in the {@link ActionHandler.execute()}
|
|
24
|
+
* method and returns a list of response actions to be dispatched as a result of processing the original action.
|
|
25
|
+
* One action handler can handle multiple different action types, see {@link ActionHandler.actionKinds}.
|
|
26
|
+
*/
|
|
27
|
+
export interface ActionHandler {
|
|
28
|
+
/**
|
|
29
|
+
* Returns the list of action kinds that can be handled by this action handler.
|
|
30
|
+
*
|
|
31
|
+
* @returns A list of action kind strings.
|
|
32
|
+
*/
|
|
33
|
+
actionKinds: string[];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Executes the action handler for the given {@link Action} and returns a list of response actions that should be
|
|
37
|
+
* dispatched as a result of processing the original action. This list can be empty, if no more actions need to be
|
|
38
|
+
* executed.
|
|
39
|
+
*
|
|
40
|
+
* @param action The action that should be processed.
|
|
41
|
+
* @returns A list of response actions that should be dispatched.
|
|
42
|
+
*/
|
|
43
|
+
execute(action: Action, ...args: unknown[]): MaybePromise<Action[]>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns the priority of this action handler. The priority is used to derive the execution order if multiple
|
|
47
|
+
* action handlers should execute the same {@link Action}. The default priority is `0` and the priority is sorted
|
|
48
|
+
* descending. This means handlers with a priority > 0 are executed before handlers with a default priority and
|
|
49
|
+
* handlers with a priority < 0 are executed afterwards.
|
|
50
|
+
*
|
|
51
|
+
* @returns the priority as integer.
|
|
52
|
+
*/
|
|
53
|
+
priority?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const ActionHandlerConstructor = Symbol('ActionHandlerConstructor');
|
|
57
|
+
|
|
58
|
+
export type ActionHandlerConstructor = interfaces.Newable<ActionHandler>;
|
|
59
|
+
|
|
60
|
+
export const ActionHandlerFactory = Symbol('ActionHandlerFactory');
|
|
61
|
+
|
|
62
|
+
export type ActionHandlerFactory = (constructor: ActionHandlerConstructor) => ActionHandler;
|