@eclipse-glsp/server 1.1.0-next.3d7585d.42
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 +37 -0
- package/lib/common/command/command-stack.d.ts.map +1 -0
- package/lib/common/command/command-stack.js +48 -0
- package/lib/common/command/command-stack.js.map +1 -0
- package/lib/common/command/command.d.ts +37 -0
- package/lib/common/command/command.d.ts.map +1 -0
- package/lib/common/command/command.js +18 -0
- package/lib/common/command/command.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 +127 -0
- package/lib/common/di/diagram-module.d.ts.map +1 -0
- package/lib/common/di/diagram-module.js +283 -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 +88 -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/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 +28 -0
- package/lib/common/features/layout/layout-operation-handler.d.ts.map +1 -0
- package/lib/common/features/layout/layout-operation-handler.js +66 -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 +53 -0
- package/lib/common/features/model/model-state.d.ts.map +1 -0
- package/lib/common/features/model/model-state.js +75 -0
- package/lib/common/features/model/model-state.js.map +1 -0
- package/lib/common/features/model/model-submission-handler.d.ts +56 -0
- package/lib/common/features/model/model-submission-handler.d.ts.map +1 -0
- package/lib/common/features/model/model-submission-handler.js +97 -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 +9 -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 +55 -0
- package/lib/common/gmodel/apply-label-edit-operation-handler.js.map +1 -0
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.d.ts +2 -0
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.d.ts.map +1 -0
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.js +38 -0
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.js.map +1 -0
- package/lib/common/gmodel/change-bounds-operation-handler.d.ts +10 -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 +53 -0
- package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -0
- package/lib/common/gmodel/computed-bounds-action-handler.d.ts +29 -0
- package/lib/common/gmodel/computed-bounds-action-handler.d.ts.map +1 -0
- package/lib/common/gmodel/computed-bounds-action-handler.js +50 -0
- package/lib/common/gmodel/computed-bounds-action-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 +116 -0
- package/lib/common/gmodel/delete-operation-handler.js.map +1 -0
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts +31 -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 +65 -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 +31 -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 +58 -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 +86 -0
- package/lib/common/gmodel/gmodel-diagram-module.js.map +1 -0
- package/lib/common/gmodel/index.d.ts +26 -0
- package/lib/common/gmodel/index.d.ts.map +1 -0
- package/lib/common/gmodel/index.js +42 -0
- package/lib/common/gmodel/index.js.map +1 -0
- package/lib/common/gmodel/paste-operation-handler.d.ts +35 -0
- package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/paste-operation-handler.js +131 -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 +67 -0
- package/lib/common/gmodel/reconnect-edge-operation-handler.js.map +1 -0
- package/lib/common/index.d.ts +88 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +104 -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 +54 -0
- package/lib/common/operations/compound-operation-handler.js.map +1 -0
- package/lib/common/operations/create-operation-handler.d.ts +64 -0
- package/lib/common/operations/create-operation-handler.d.ts.map +1 -0
- package/lib/common/operations/create-operation-handler.js +90 -0
- package/lib/common/operations/create-operation-handler.js.map +1 -0
- package/lib/common/operations/cut-operation-handler.d.ts +25 -0
- package/lib/common/operations/cut-operation-handler.d.ts.map +1 -0
- package/lib/common/operations/cut-operation-handler.js +53 -0
- package/lib/common/operations/cut-operation-handler.js.map +1 -0
- package/lib/common/operations/operation-action-handler.d.ts +33 -0
- package/lib/common/operations/operation-action-handler.d.ts.map +1 -0
- package/lib/common/operations/operation-action-handler.js +94 -0
- package/lib/common/operations/operation-action-handler.js.map +1 -0
- package/lib/common/operations/operation-handler-registry.d.ts +29 -0
- package/lib/common/operations/operation-handler-registry.d.ts.map +1 -0
- package/lib/common/operations/operation-handler-registry.js +58 -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 +50 -0
- package/lib/common/operations/operation-handler.d.ts.map +1 -0
- package/lib/common/operations/operation-handler.js +7 -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 +110 -0
- package/lib/common/test/mock-util.d.ts.map +1 -0
- package/lib/common/test/mock-util.js +211 -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 +76 -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.ts +74 -0
- package/src/common/command/command.ts +39 -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 +397 -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 +90 -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/layout-engine.ts +31 -0
- package/src/common/features/layout/layout-operation-handler.ts +47 -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 +101 -0
- package/src/common/features/model/model-submission-handler.ts +106 -0
- package/src/common/features/model/request-model-action-handler.ts +67 -0
- package/src/common/features/model/save-model-action-handler.ts +38 -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.spec.ts +40 -0
- package/src/common/gmodel/apply-label-edit-operation-handler.ts +38 -0
- package/src/common/gmodel/change-bounds-operation-handler.ts +58 -0
- package/src/common/gmodel/change-routing-points-operation-handler.ts +39 -0
- package/src/common/gmodel/computed-bounds-action-handler.ts +51 -0
- package/src/common/gmodel/delete-operation-handler.ts +115 -0
- package/src/common/gmodel/gmodel-create-edge-operation-handler.ts +58 -0
- package/src/common/gmodel/gmodel-create-node-operation-handler.ts +47 -0
- package/src/common/gmodel/gmodel-diagram-module.ts +81 -0
- package/src/common/gmodel/index.ts +26 -0
- package/src/common/gmodel/paste-operation-handler.ts +119 -0
- package/src/common/gmodel/reconnect-edge-operation-handler.ts +55 -0
- package/src/common/index.ts +88 -0
- package/src/common/launch/glsp-server-launcher.ts +70 -0
- package/src/common/operations/compound-operation-handler.ts +38 -0
- package/src/common/operations/create-operation-handler.ts +106 -0
- package/src/common/operations/cut-operation-handler.ts +38 -0
- package/src/common/operations/operation-action-handler.ts +69 -0
- package/src/common/operations/operation-handler-registry.spec.ts +50 -0
- package/src/common/operations/operation-handler-registry.ts +51 -0
- package/src/common/operations/operation-handler.ts +57 -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 +256 -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,154 @@
|
|
|
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 { remove } from '@eclipse-glsp/protocol/lib/utils/array-util';
|
|
17
|
+
import { injectable } from 'inversify';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A registry manages a set of key-value pairs and provides query functionality. In GLSP this is typically used to
|
|
21
|
+
* provide a convenience API for working with multi-injected instances e.g. action handlers or
|
|
22
|
+
* operation handlers.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam K Key type
|
|
25
|
+
* @param V Value type
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
@injectable()
|
|
29
|
+
export class Registry<K, V> {
|
|
30
|
+
protected elements: Map<K, V> = new Map();
|
|
31
|
+
/**
|
|
32
|
+
* Registers a new key-value pair.
|
|
33
|
+
*
|
|
34
|
+
* @param key The key object.
|
|
35
|
+
* @param element The value object.
|
|
36
|
+
* @returns `true` if the pair was registered successfully, `false` if another pair with the same key is already
|
|
37
|
+
* registered.
|
|
38
|
+
*/
|
|
39
|
+
register(key: K, instance: V): boolean {
|
|
40
|
+
if (!this.hasKey(key)) {
|
|
41
|
+
this.elements.set(key, instance);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Removes the value with the given key from the registry.
|
|
49
|
+
*
|
|
50
|
+
* @param key The key of the value which should be removed.
|
|
51
|
+
* @returns `true` if the value was removed successfully, `false` if no value was registered for the given key.
|
|
52
|
+
*/
|
|
53
|
+
deregister(key: K): boolean {
|
|
54
|
+
return this.elements.delete(key);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Queries the registry to check whether a value for the given key is registered.
|
|
59
|
+
*
|
|
60
|
+
* @param key The key which should be checked.
|
|
61
|
+
* @returns `true` if a key-value pair is registered for the given key, `false` otherwise.
|
|
62
|
+
*/
|
|
63
|
+
hasKey(key: K): boolean {
|
|
64
|
+
return this.elements.has(key);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Retrieve the value for the given key.
|
|
69
|
+
*
|
|
70
|
+
* @param key The key whose value should be retrieved.
|
|
71
|
+
* @returns The registered value or `undefined`. Is `undefined` if no value was registered for the given key.
|
|
72
|
+
*/
|
|
73
|
+
get(key: K): V | undefined {
|
|
74
|
+
return this.elements.get(key);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve all registered values from the registry.
|
|
79
|
+
*
|
|
80
|
+
* @returns An array of all registered keys.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
getAll(): V[] {
|
|
84
|
+
return [...new Set(this.elements.values())];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Retrieve all registered keys from the registry.
|
|
89
|
+
*
|
|
90
|
+
* @returns An array of all registered keys.
|
|
91
|
+
*/
|
|
92
|
+
keys(): K[] {
|
|
93
|
+
return [...new Set(this.elements.keys())];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A multi registry is used to manage a set of key-value pairs. The main difference to {@link Registry} is that
|
|
99
|
+
* a multi registry doesn't enforce a 1-1 relation between key and value(s).
|
|
100
|
+
* One key can be associated with multiple values.
|
|
101
|
+
*
|
|
102
|
+
*
|
|
103
|
+
* @typeParam K Type of the key
|
|
104
|
+
* @param V Type of the values
|
|
105
|
+
*/
|
|
106
|
+
@injectable()
|
|
107
|
+
export class MultiRegistry<K, V> {
|
|
108
|
+
protected elements: Map<K, V[]> = new Map();
|
|
109
|
+
|
|
110
|
+
register(key: K, instance: V): void {
|
|
111
|
+
const instances = this.elements.get(key);
|
|
112
|
+
if (instances) {
|
|
113
|
+
instances.push(instance);
|
|
114
|
+
} else {
|
|
115
|
+
this.elements.set(key, [instance]);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
deregister(key: K, element: V): boolean {
|
|
120
|
+
const instances = this.elements.get(key);
|
|
121
|
+
if (instances) {
|
|
122
|
+
remove(instances, element);
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
deregisterAll(key: K): boolean {
|
|
129
|
+
return this.elements.delete(key);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
get(key: K): V[] {
|
|
133
|
+
const existingInstances = this.elements.get(key);
|
|
134
|
+
if (existingInstances) {
|
|
135
|
+
return [...new Set(existingInstances)];
|
|
136
|
+
} else {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
hasKey(key: K): boolean {
|
|
142
|
+
return this.elements.has(key);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
getAll(): V[] {
|
|
146
|
+
const values: V[] = [];
|
|
147
|
+
Array.from(this.elements.values()).forEach(instances => values.push(...instances));
|
|
148
|
+
return [...new Set(values)];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
keys(): K[] {
|
|
152
|
+
return [...new Set(this.elements.keys())];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
import { MaybePromise, RequestModelAction, SaveModelAction, TypeGuard } from '@eclipse-glsp/protocol';
|
|
17
|
+
import * as fs from 'fs-extra';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import { fileURLToPath } from 'url';
|
|
20
|
+
import { ModelState, SOURCE_URI_ARG } from '../common/features/model/model-state';
|
|
21
|
+
import { SourceModelStorage } from '../common/features/model/source-model-storage';
|
|
22
|
+
import { GLSPServerError } from '../common/utils/glsp-server-error';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* An abstract implementation of {@link SourceModelStorage} that provides utility methods for loading and saving JSON source models
|
|
26
|
+
* from/into a file.
|
|
27
|
+
*/
|
|
28
|
+
@injectable()
|
|
29
|
+
export abstract class AbstractJsonModelStorage implements SourceModelStorage {
|
|
30
|
+
@inject(ModelState)
|
|
31
|
+
protected modelState: ModelState;
|
|
32
|
+
|
|
33
|
+
abstract loadSourceModel(action: RequestModelAction): MaybePromise<void>;
|
|
34
|
+
|
|
35
|
+
abstract saveSourceModel(action: SaveModelAction): MaybePromise<void>;
|
|
36
|
+
|
|
37
|
+
protected getSourceUri(action: RequestModelAction): string {
|
|
38
|
+
const sourceUri = action.options?.[SOURCE_URI_ARG];
|
|
39
|
+
if (typeof sourceUri !== 'string') {
|
|
40
|
+
throw new GLSPServerError(`Invalid RequestModelAction! Missing argument with key '${SOURCE_URI_ARG}'`);
|
|
41
|
+
}
|
|
42
|
+
return sourceUri;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected loadFromFile(sourceUri: string): unknown;
|
|
46
|
+
protected loadFromFile<T>(sourceUri: string, guard: TypeGuard<T>): T;
|
|
47
|
+
protected loadFromFile<T>(sourceUri: string, guard?: TypeGuard<T>): T | unknown {
|
|
48
|
+
try {
|
|
49
|
+
const path = this.toPath(sourceUri);
|
|
50
|
+
let fileContent = this.readFile(path);
|
|
51
|
+
if (!fileContent) {
|
|
52
|
+
fileContent = this.createModelForEmptyFile(path);
|
|
53
|
+
if (!fileContent) {
|
|
54
|
+
throw new GLSPServerError(`Could not load the source model. The file '${path}' is empty!.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (guard && !guard(fileContent)) {
|
|
58
|
+
throw new Error('The loaded root object is not of the expected type!');
|
|
59
|
+
}
|
|
60
|
+
return fileContent;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw new GLSPServerError(`Could not load model from file: ${sourceUri}`, error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Can be overwritten to customize the behavior if the given file path points to an empty file.
|
|
68
|
+
* The default implementation returns undefined, concrete subclasses can customize this behavior and
|
|
69
|
+
* return new source model object instead.
|
|
70
|
+
* @param path The path of the empty file.
|
|
71
|
+
* @returns The new model or `undefined`
|
|
72
|
+
*/
|
|
73
|
+
protected createModelForEmptyFile(path: string): unknown | undefined {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected readFile(path: string): unknown | undefined {
|
|
78
|
+
try {
|
|
79
|
+
const data = fs.readFileSync(path, { encoding: 'utf8' });
|
|
80
|
+
if (!data || data.length === 0) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
return this.toJson(data);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
throw new GLSPServerError(`Could not read & parse file contents of '${path}' as json`, error);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
protected toJson(fileContent: string): unknown {
|
|
90
|
+
return JSON.parse(fileContent);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected toPath(sourceUri: string): string {
|
|
94
|
+
return sourceUri.startsWith('file://') ? fileURLToPath(sourceUri) : sourceUri;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
protected getFileUri(action: SaveModelAction): string {
|
|
98
|
+
const uri = action.fileUri ?? this.modelState.get(SOURCE_URI_ARG);
|
|
99
|
+
if (!uri) {
|
|
100
|
+
throw new GLSPServerError('Could not derive fileUri for saving the current source model');
|
|
101
|
+
}
|
|
102
|
+
return uri;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
protected writeFile(fileUri: string, model: unknown): void {
|
|
106
|
+
const path = this.toPath(fileUri);
|
|
107
|
+
const content = this.toString(model);
|
|
108
|
+
fs.writeFileSync(path, content);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
protected toString(model: unknown): string {
|
|
112
|
+
return JSON.stringify(model, undefined, 2);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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 { ContainerModule, interfaces } from 'inversify';
|
|
17
|
+
import * as winston from 'winston';
|
|
18
|
+
import { InjectionContainer, Logger, LoggerFactory, LogLevel, ModuleContext } from '../../common/index';
|
|
19
|
+
import { LaunchOptions } from '../launch/cli-parser';
|
|
20
|
+
import { WinstonLogger } from './winston-logger';
|
|
21
|
+
|
|
22
|
+
export function createAppModule(options: LaunchOptions): ContainerModule {
|
|
23
|
+
return new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
24
|
+
bind(InjectionContainer).toDynamicValue(dynamicContext => dynamicContext.container);
|
|
25
|
+
const context = { bind, unbind, isBound, rebind };
|
|
26
|
+
configureWinstonLogger(context, options);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Creates the global {@link winston.Logger} instance is used internally by all instances of {@link WinstonLogger}. Can be configured with
|
|
32
|
+
* the given {@link LaunchOptions}.
|
|
33
|
+
* @param options The {@link LaunchOptions}
|
|
34
|
+
* @returns the configured winston instance.
|
|
35
|
+
*/
|
|
36
|
+
export function createWinstonInstance<T extends LaunchOptions>(options: T): winston.Logger {
|
|
37
|
+
const level = LogLevel[options.logLevel];
|
|
38
|
+
const transports: winston.transport[] = [];
|
|
39
|
+
|
|
40
|
+
const printf = winston.format.printf(({ level, message, timestamp }) => `${timestamp} ${level} - ${message}`);
|
|
41
|
+
const timestamp = winston.format.timestamp({ format: () => new Date().toLocaleTimeString() });
|
|
42
|
+
|
|
43
|
+
const consoleLogFormat = winston.format.combine(winston.format.colorize(), timestamp, printf);
|
|
44
|
+
const fileLogFormat = winston.format.combine(timestamp, printf);
|
|
45
|
+
|
|
46
|
+
if (options.consoleLog) {
|
|
47
|
+
transports.push(new winston.transports.Console({ format: consoleLogFormat }));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (options.fileLog) {
|
|
51
|
+
const date = new Date();
|
|
52
|
+
const dateString = `${date.getDate()}-${
|
|
53
|
+
date.getMonth() + 1
|
|
54
|
+
}-${date.getFullYear()}_${date.getHours()}-${date.getMinutes()}-${date.getSeconds()}`;
|
|
55
|
+
|
|
56
|
+
const filename = `GLSP-Server_${dateString}.log`;
|
|
57
|
+
transports.push(new winston.transports.File({ dirname: options.logDir, filename, format: fileLogFormat }));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return winston.createLogger({ level, transports });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Configures the binding for {@link WinstonLogger} in the given {@link ModuleContext} with the given {@link LaunchOptions}.
|
|
65
|
+
* @param context The module context.
|
|
66
|
+
* @param options The launch options.
|
|
67
|
+
* @param rebind Flag to determine wether an existing {@link Logger} binding in the context should be rebound. Default is `true`.
|
|
68
|
+
* @param baseLoggerCreator The underling global {@link winston.Logger} instance.
|
|
69
|
+
*/
|
|
70
|
+
export function configureWinstonLogger<T extends LaunchOptions>(
|
|
71
|
+
context: ModuleContext,
|
|
72
|
+
options: T,
|
|
73
|
+
rebind = true,
|
|
74
|
+
baseLoggerCreator: (launchOptions: T) => winston.Logger = createWinstonInstance
|
|
75
|
+
): void {
|
|
76
|
+
const baseLogger = baseLoggerCreator(options);
|
|
77
|
+
if (rebind) {
|
|
78
|
+
if (context.isBound(Logger)) {
|
|
79
|
+
context.unbind(Logger);
|
|
80
|
+
}
|
|
81
|
+
if (context.isBound(LoggerFactory)) {
|
|
82
|
+
context.unbind(LoggerFactory);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
context.bind(Logger).toDynamicValue(dynamicContext => new WinstonLogger(baseLogger, getRequestParentName(dynamicContext)));
|
|
87
|
+
context.bind(LoggerFactory).toFactory(dynamicContext => (caller: string) => {
|
|
88
|
+
const logger = dynamicContext.container.get(Logger);
|
|
89
|
+
logger.caller = caller;
|
|
90
|
+
return logger;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getRequestParentName(context: interfaces.Context): string | undefined {
|
|
95
|
+
if (context.currentRequest.parentRequest) {
|
|
96
|
+
const bindings = context.currentRequest.parentRequest.bindings;
|
|
97
|
+
if (bindings.length > 0) {
|
|
98
|
+
return bindings[0].implementationType?.name;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 winston from 'winston';
|
|
17
|
+
import { asLogLevel, Logger, LogLevel } from '../../common/utils/logger';
|
|
18
|
+
|
|
19
|
+
export class WinstonLogger extends Logger {
|
|
20
|
+
constructor(protected baseLogger: winston.Logger, public caller?: string) {
|
|
21
|
+
super();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
info(message: string, ...params: any): void {
|
|
25
|
+
if (this.logLevel !== LogLevel.none) {
|
|
26
|
+
this.baseLogger.info(this.combinedMessage(message, ...params));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
warn(message: string, ...params: any[]): void {
|
|
31
|
+
if (this.logLevel !== LogLevel.none) {
|
|
32
|
+
this.baseLogger.warn(this.combinedMessage(message, ...params));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
error(message: string, ...params: any[]): void {
|
|
37
|
+
if (this.logLevel !== LogLevel.none) {
|
|
38
|
+
this.baseLogger.error(this.combinedMessage(message, ...params));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
debug(message: string, ...params: any[]): void {
|
|
43
|
+
if (this.logLevel !== LogLevel.none) {
|
|
44
|
+
this.baseLogger.debug(this.combinedMessage(message, ...params));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get logLevel(): LogLevel {
|
|
49
|
+
return asLogLevel(this.baseLogger.level) || LogLevel.none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
set logLevel(level: LogLevel) {
|
|
53
|
+
this.baseLogger.level = LogLevel[level];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
combinedMessage(message: string, ...params: any[]): string {
|
|
57
|
+
const caller = this.caller ? `[${this.caller}]` : '';
|
|
58
|
+
const additional = this.logAdditionals(...params);
|
|
59
|
+
return `${caller} ${message} ${additional}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
logAdditionals(...params: any[]): string {
|
|
63
|
+
if (!params || params.length === 0) {
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
return params.map(param => this.toString(param)).join(',\n');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
override toString(param: unknown): string {
|
|
70
|
+
if (param instanceof Error) {
|
|
71
|
+
return `${param.message}
|
|
72
|
+
${param.stack || ''}`;
|
|
73
|
+
}
|
|
74
|
+
return JSON.stringify(param, undefined, 4);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { GGraph, GModelElementSchema } from '@eclipse-glsp/graph';
|
|
17
|
+
import { MaybePromise, RequestModelAction, SaveModelAction } from '@eclipse-glsp/protocol';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import { GModelSerializer } from '../../common/features/model/gmodel-serializer';
|
|
20
|
+
import { ModelState } from '../../common/features/model/model-state';
|
|
21
|
+
import { Logger } from '../../common/utils/logger';
|
|
22
|
+
import { AbstractJsonModelStorage } from '../abstract-json-model-storage';
|
|
23
|
+
|
|
24
|
+
export const EMPTY_ROOT = GGraph.builder().id('empty').build();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A {@link SourceModelStorage} that reads and writes the graph model directly from / into
|
|
28
|
+
* a JSON file and uses it as source model.
|
|
29
|
+
*/
|
|
30
|
+
@injectable()
|
|
31
|
+
export class GModelStorage extends AbstractJsonModelStorage {
|
|
32
|
+
@inject(Logger)
|
|
33
|
+
protected logger: Logger;
|
|
34
|
+
|
|
35
|
+
@inject(GModelSerializer)
|
|
36
|
+
protected modelSerializer: GModelSerializer;
|
|
37
|
+
|
|
38
|
+
@inject(ModelState)
|
|
39
|
+
protected override modelState: ModelState;
|
|
40
|
+
|
|
41
|
+
loadSourceModel(action: RequestModelAction): MaybePromise<void> {
|
|
42
|
+
const sourceUri = this.getSourceUri(action);
|
|
43
|
+
const rootSchema = this.loadFromFile(sourceUri, GModelElementSchema.is);
|
|
44
|
+
const root = this.modelSerializer.createRoot(rootSchema);
|
|
45
|
+
this.modelState.updateRoot(root);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
saveSourceModel(action: SaveModelAction): MaybePromise<void> {
|
|
49
|
+
const fileUri = this.getFileUri(action);
|
|
50
|
+
const schema = this.modelSerializer.createSchema(this.modelState.root);
|
|
51
|
+
this.writeFile(fileUri, schema);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
export * from '../common/index';
|
|
17
|
+
export * from './abstract-json-model-storage';
|
|
18
|
+
export * from './di/app-module';
|
|
19
|
+
export * from './di/winston-logger';
|
|
20
|
+
export * from './gmodel/gmodel-storage';
|
|
21
|
+
export * from './launch/cli-parser';
|
|
22
|
+
export * from './launch/socket-cli-parser';
|
|
23
|
+
export * from './launch/socket-server-launcher';
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { expect } from 'chai';
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
import { LogLevel } from '../../common/utils/logger';
|
|
19
|
+
import { createCliParser, defaultLaunchOptions } from './cli-parser';
|
|
20
|
+
|
|
21
|
+
describe('test createCliParser', () => {
|
|
22
|
+
const parser = createCliParser();
|
|
23
|
+
|
|
24
|
+
parser.command.exitOverride();
|
|
25
|
+
const argv = ['/usr/bin/node', 'test'];
|
|
26
|
+
|
|
27
|
+
it('parse - no args', () => {
|
|
28
|
+
const options = parser.parse(argv);
|
|
29
|
+
expect(options).to.deep.equal(defaultLaunchOptions);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('parse - invalid log dir', () => {
|
|
33
|
+
expect(() => parser.parse([...argv, '--logDir', 'invalid.Path'])).to.throw();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('parse - valid log dir', () => {
|
|
37
|
+
const logDir = path.resolve('../customLog');
|
|
38
|
+
const result = parser.parse([...argv, '--logDir', '../customLog/']);
|
|
39
|
+
expect(result.logDir, logDir);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('parse - invalid logLevel', () => {
|
|
43
|
+
expect(() => parser.parse([...argv, '--logLevel', 'someRandomLevel'])).to.throw();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('parse - valid logLevel', () => {
|
|
47
|
+
const result = parser.parse([...argv, '--logLevel', 'error']);
|
|
48
|
+
expect(result.logLevel).to.be.equal(LogLevel.error);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('parse- no args with custom default options', () => {
|
|
52
|
+
const options = {
|
|
53
|
+
logDir: '.myLogDir',
|
|
54
|
+
logLevel: LogLevel.debug,
|
|
55
|
+
consoleLog: false,
|
|
56
|
+
fileLog: true
|
|
57
|
+
};
|
|
58
|
+
const result = createCliParser(options).parse(argv);
|
|
59
|
+
expect(result).to.deep.equal(options);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
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 cmd from 'commander';
|
|
17
|
+
import * as fs from 'fs-extra';
|
|
18
|
+
import * as path from 'path';
|
|
19
|
+
import { asLogLevel, LogLevel } from '../../common/utils/logger';
|
|
20
|
+
|
|
21
|
+
export interface LaunchOptions {
|
|
22
|
+
logLevel: LogLevel;
|
|
23
|
+
logDir?: string;
|
|
24
|
+
fileLog: boolean;
|
|
25
|
+
consoleLog: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface CliParser<O extends LaunchOptions = LaunchOptions> {
|
|
29
|
+
command: cmd.Command;
|
|
30
|
+
parse(argv?: string[]): O;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const defaultLaunchOptions: Required<LaunchOptions> = {
|
|
34
|
+
logLevel: LogLevel.info,
|
|
35
|
+
logDir: '.config',
|
|
36
|
+
consoleLog: true,
|
|
37
|
+
fileLog: false
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export function createCliParser<O extends LaunchOptions = LaunchOptions>(options: LaunchOptions = defaultLaunchOptions): CliParser<O> {
|
|
41
|
+
const command = new cmd.Command()
|
|
42
|
+
.version('1.0.0')
|
|
43
|
+
.description('GLSP server')
|
|
44
|
+
.showHelpAfterError(true)
|
|
45
|
+
.name('Launch a GLSP server')
|
|
46
|
+
.option('-l , --logLevel <logLevel>', `Set the log level. [default='${options.logLevel}']`, processLogLevel, options.logLevel)
|
|
47
|
+
.option(
|
|
48
|
+
'-d , --logDir <logDir>',
|
|
49
|
+
`Set the directory for log files (when file logging is enabled) [default=${options.logDir}]`,
|
|
50
|
+
processLogDir,
|
|
51
|
+
options.logDir
|
|
52
|
+
)
|
|
53
|
+
.addHelpText('afterAll', '\n Copyright (c) 2022-2023 Eclipse GLSP');
|
|
54
|
+
|
|
55
|
+
return { command, parse: argv => parse<O>(command, options as Partial<O>, argv) };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function parse<T extends cmd.OptionValues>(command: cmd.Command, defaultOptions: Partial<T>, argv?: string[]): T {
|
|
59
|
+
command.parse(argv);
|
|
60
|
+
return { ...defaultOptions, ...command.opts<T>() };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function processLogLevel(value: string): LogLevel {
|
|
64
|
+
const level = asLogLevel(value);
|
|
65
|
+
if (!level) {
|
|
66
|
+
throw new cmd.InvalidArgumentError("Argument has to be 'none'|'error'|'warn'|'info'|'debug'!");
|
|
67
|
+
}
|
|
68
|
+
return level;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function processLogDir(value: string): string {
|
|
72
|
+
const logDir = path.resolve(value);
|
|
73
|
+
if (path.extname(logDir).length !== 0 || !isDirectory(path.dirname(logDir))) {
|
|
74
|
+
throw new cmd.InvalidArgumentError('Argument is not a valid directory!');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return logDir;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function isDirectory(value: string): boolean {
|
|
81
|
+
try {
|
|
82
|
+
return fs.statSync(value).isDirectory();
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|