@eclipse-glsp/server 2.8.0-next.1 → 2.8.0-next.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/lib/browser/launch/worker-server-launcher.js +3 -5
  2. package/lib/browser/launch/worker-server-launcher.js.map +1 -1
  3. package/lib/common/actions/action-dispatcher.js +5 -8
  4. package/lib/common/actions/action-dispatcher.js.map +1 -1
  5. package/lib/common/actions/action-handler-registry.js +1 -1
  6. package/lib/common/actions/action-handler-registry.js.map +1 -1
  7. package/lib/common/actions/global-action-provider.js +1 -2
  8. package/lib/common/actions/global-action-provider.js.map +1 -1
  9. package/lib/common/command/command.js +1 -2
  10. package/lib/common/command/command.js.map +1 -1
  11. package/lib/common/command/recording-command.js +3 -6
  12. package/lib/common/command/recording-command.js.map +1 -1
  13. package/lib/common/di/diagram-module.js +5 -6
  14. package/lib/common/di/diagram-module.js.map +1 -1
  15. package/lib/common/di/glsp-module.js +1 -1
  16. package/lib/common/di/glsp-module.js.map +1 -1
  17. package/lib/common/di/server-module.js +1 -1
  18. package/lib/common/di/server-module.js.map +1 -1
  19. package/lib/common/features/directediting/context-edit-validator.js +3 -3
  20. package/lib/common/features/directediting/context-edit-validator.js.map +1 -1
  21. package/lib/common/features/directediting/label-edit-validator.js +1 -1
  22. package/lib/common/features/directediting/label-edit-validator.js.map +1 -1
  23. package/lib/common/features/layout/computed-bounds-action-handler.d.ts +16 -1
  24. package/lib/common/features/layout/computed-bounds-action-handler.d.ts.map +1 -1
  25. package/lib/common/features/layout/computed-bounds-action-handler.js +41 -4
  26. package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -1
  27. package/lib/common/features/layout/layout-operation-handler.js +1 -2
  28. package/lib/common/features/layout/layout-operation-handler.js.map +1 -1
  29. package/lib/common/features/model/gmodel-index.js +3 -5
  30. package/lib/common/features/model/gmodel-index.js.map +1 -1
  31. package/lib/common/features/model/gmodel-serializer.js +1 -2
  32. package/lib/common/features/model/gmodel-serializer.js.map +1 -1
  33. package/lib/common/features/model/model-submission-handler.d.ts +1 -2
  34. package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
  35. package/lib/common/features/model/model-submission-handler.js +3 -6
  36. package/lib/common/features/model/model-submission-handler.js.map +1 -1
  37. package/lib/common/features/model/request-model-action-handler.js +4 -6
  38. package/lib/common/features/model/request-model-action-handler.js.map +1 -1
  39. package/lib/common/features/navigation/navigation-target-resolution.js +1 -1
  40. package/lib/common/features/navigation/navigation-target-resolution.js.map +1 -1
  41. package/lib/common/features/progress/progress-service.d.ts.map +1 -1
  42. package/lib/common/features/progress/progress-service.js +1 -2
  43. package/lib/common/features/progress/progress-service.js.map +1 -1
  44. package/lib/common/features/validation/request-markers-handler.js +1 -2
  45. package/lib/common/features/validation/request-markers-handler.js.map +1 -1
  46. package/lib/common/gmodel/change-routing-points-operation-handler.js +1 -2
  47. package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -1
  48. package/lib/common/gmodel/gmodel-create-node-operation-handler.js +3 -5
  49. package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -1
  50. package/lib/common/gmodel/paste-operation-handler.d.ts +1 -1
  51. package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -1
  52. package/lib/common/gmodel/paste-operation-handler.js +8 -11
  53. package/lib/common/gmodel/paste-operation-handler.js.map +1 -1
  54. package/lib/common/launch/glsp-server-launcher.d.ts +8 -1
  55. package/lib/common/launch/glsp-server-launcher.d.ts.map +1 -1
  56. package/lib/common/launch/glsp-server-launcher.js +11 -1
  57. package/lib/common/launch/glsp-server-launcher.js.map +1 -1
  58. package/lib/common/launch/jsonrpc-server-launcher.d.ts +51 -2
  59. package/lib/common/launch/jsonrpc-server-launcher.d.ts.map +1 -1
  60. package/lib/common/launch/jsonrpc-server-launcher.js +82 -3
  61. package/lib/common/launch/jsonrpc-server-launcher.js.map +1 -1
  62. package/lib/common/operations/compound-operation-handler.js +1 -1
  63. package/lib/common/operations/compound-operation-handler.js.map +1 -1
  64. package/lib/common/operations/json-operation-handler.js +2 -3
  65. package/lib/common/operations/json-operation-handler.js.map +1 -1
  66. package/lib/common/protocol/glsp-server.js +6 -7
  67. package/lib/common/protocol/glsp-server.js.map +1 -1
  68. package/lib/common/session/client-session-manager.js +3 -5
  69. package/lib/common/session/client-session-manager.js.map +1 -1
  70. package/lib/common/utils/action-queue.js +2 -4
  71. package/lib/common/utils/action-queue.js.map +1 -1
  72. package/lib/common/utils/client-options-util.js +2 -2
  73. package/lib/common/utils/client-options-util.js.map +1 -1
  74. package/lib/common/utils/glsp-server-error.d.ts +2 -3
  75. package/lib/common/utils/glsp-server-error.d.ts.map +1 -1
  76. package/lib/common/utils/glsp-server-error.js +1 -1
  77. package/lib/common/utils/glsp-server-error.js.map +1 -1
  78. package/lib/common/utils/layout-util.d.ts +5 -5
  79. package/lib/common/utils/layout-util.d.ts.map +1 -1
  80. package/lib/common/utils/layout-util.js +17 -19
  81. package/lib/common/utils/layout-util.js.map +1 -1
  82. package/lib/common/utils/logger.js +1 -2
  83. package/lib/common/utils/logger.js.map +1 -1
  84. package/lib/node/abstract-json-model-storage.js +2 -4
  85. package/lib/node/abstract-json-model-storage.js.map +1 -1
  86. package/lib/node/launch/socket-server-launcher.d.ts +39 -2
  87. package/lib/node/launch/socket-server-launcher.d.ts.map +1 -1
  88. package/lib/node/launch/socket-server-launcher.js +50 -31
  89. package/lib/node/launch/socket-server-launcher.js.map +1 -1
  90. package/lib/node/launch/websocket-server-launcher.d.ts +36 -5
  91. package/lib/node/launch/websocket-server-launcher.d.ts.map +1 -1
  92. package/lib/node/launch/websocket-server-launcher.js +54 -13
  93. package/lib/node/launch/websocket-server-launcher.js.map +1 -1
  94. package/package.json +17 -21
  95. package/src/common/features/directediting/context-edit-validator.ts +2 -2
  96. package/src/common/features/layout/computed-bounds-action-handler.ts +52 -4
  97. package/src/common/features/model/model-submission-handler.ts +3 -2
  98. package/src/common/features/progress/progress-service.ts +2 -3
  99. package/src/common/gmodel/paste-operation-handler.ts +6 -6
  100. package/src/common/launch/glsp-server-launcher.ts +12 -1
  101. package/src/common/launch/jsonrpc-server-launcher.ts +89 -2
  102. package/src/common/utils/glsp-server-error.ts +3 -5
  103. package/src/common/utils/layout-util.ts +13 -12
  104. package/src/node/launch/socket-server-launcher.ts +54 -31
  105. package/src/node/launch/websocket-server-launcher.ts +72 -14
  106. package/src/browser/di/browser-action-dispatch-scope.spec.ts +0 -75
  107. package/src/common/actions/action-handler-registry.spec.ts +0 -52
  108. package/src/common/actions/global-action-provider.spec.ts +0 -68
  109. package/src/common/command/command-stack.spec.ts +0 -239
  110. package/src/common/command/command.spec.ts +0 -92
  111. package/src/common/command/recording-command.spec.ts +0 -86
  112. package/src/common/di/binding-target.spec.ts +0 -147
  113. package/src/common/di/multi-bindings.spec.ts +0 -133
  114. package/src/common/features/contextactions/context-actions-provider-registry.spec.ts +0 -69
  115. package/src/common/features/contextactions/request-context-actions-handler.spec.ts +0 -75
  116. package/src/common/features/contextactions/tool-palette-item-provider.spec.ts +0 -46
  117. package/src/common/features/directediting/context-edit-validator-registry.spec.ts +0 -54
  118. package/src/common/features/directediting/request-edit-validation-handler.spec.ts +0 -131
  119. package/src/common/features/model/gmodel-serializer.spec.ts +0 -141
  120. package/src/common/features/type-hints/request-type-hints-action-handler.spec.ts +0 -59
  121. package/src/common/operations/operation-handler-registry.spec.ts +0 -50
  122. package/src/common/protocol/glsp-server.spec.ts +0 -154
  123. package/src/common/session/client-session-factory.spec.ts +0 -60
  124. package/src/common/session/client-session-manager.spec.ts +0 -83
  125. package/src/common/test/mock-util.ts +0 -281
  126. package/src/common/utils/action-queue.spec.ts +0 -133
  127. package/src/common/utils/promise-queue.spec.ts +0 -142
  128. package/src/common/utils/registry.spec.ts +0 -225
  129. package/src/node/actions/action-dispatcher.spec.ts +0 -678
  130. package/src/node/launch/cli-parser.spec.ts +0 -61
  131. package/src/node/launch/socket-cli-parser.spec.ts +0 -73
  132. package/src/node/launch/socket-server-launcher.spec.ts +0 -74
@@ -1,133 +0,0 @@
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 { Container, ContainerModule, injectable } from 'inversify';
18
- import { InstanceMultiBinding, MultiBinding } from './multi-binding';
19
-
20
- @injectable()
21
- class TestClass {}
22
-
23
- @injectable()
24
- class TestClass1 extends TestClass {}
25
-
26
- @injectable()
27
- class TestClass2 extends TestClass {}
28
-
29
- @injectable()
30
- class TestClass3 extends TestClass {}
31
-
32
- describe('test implementations of MultiBinding', () => {
33
- describe('test basic functionaly (ClassMultiBinding) ', () => {
34
- const binding = new MultiBinding('TestClass');
35
- it('add - new binding', () => {
36
- binding.add(TestClass1);
37
- expect(binding.contains(TestClass1)).true;
38
-
39
- const result = binding.getAll();
40
- expect(result.length).to.be.equal(1);
41
- expect(result[0]).to.be.equal(TestClass1);
42
- });
43
-
44
- it('add - existing binding', () => {
45
- binding.add(TestClass1);
46
- expect(binding.getAll().length).to.be.equal(1);
47
- expect(binding.getAll()[0]).to.be.equal(TestClass1);
48
- });
49
-
50
- it('remove - existing binding', () => {
51
- expect(binding.contains(TestClass1)).true;
52
- binding.remove(TestClass1);
53
- expect(binding.contains(TestClass1)).false;
54
- expect(binding.getAll()).to.have.length(0);
55
- });
56
-
57
- it('remove - non-existing binding', () => {
58
- const previousSize = binding.getAll().length;
59
- binding.remove(TestClass2);
60
- expect(binding.getAll()).to.have.length(previousSize);
61
- });
62
-
63
- it('addAll - TestClass1 & TestClass2', () => {
64
- binding.addAll([TestClass1, TestClass2]);
65
-
66
- const result = binding.getAll();
67
- expect(result.length).to.be.equal(2);
68
- expect(result.includes(TestClass1)).true;
69
- expect(result.includes(TestClass2)).true;
70
- });
71
-
72
- it('rebind- TestClass2 to TestClass3', () => {
73
- binding.rebind(TestClass2, TestClass3);
74
- const result = binding.getAll();
75
- expect(result.length).to.be.equal(2);
76
- expect(result.includes(TestClass1)).true;
77
- expect(result.includes(TestClass3)).true;
78
- });
79
-
80
- it('rebind- TestClass2 to TestClass3- should fail', () => {
81
- binding.rebind(TestClass2, TestClass3);
82
- const result = binding.getAll();
83
- expect(result.length).to.be.equal(2);
84
- expect(result.includes(TestClass1)).true;
85
- expect(result.includes(TestClass3)).true;
86
- });
87
-
88
- it('removeAll- TestClass1 & TestClass3', () => {
89
- binding.removeAll([TestClass1, TestClass3]);
90
- const result = binding.getAll();
91
- expect(result).to.have.length(0);
92
- });
93
- });
94
-
95
- describe('test applyBinding', () => {
96
- it('apply binding of ClassMultiBinding', () => {
97
- const testContainer = new Container();
98
- const testModule = new ContainerModule((bind, unbind, isBound, rebind) => {
99
- const context = { bind, unbind, isBound, rebind };
100
- const binding = new MultiBinding('TestClass');
101
- binding.addAll([TestClass1, TestClass2, TestClass3]);
102
- binding.applyBindings(context);
103
- });
104
- testContainer.load(testModule);
105
- const result = testContainer.getAll('TestClass');
106
- expect(result).to.have.length(3);
107
- expect(result.find(instance => instance instanceof TestClass1)).to.not.be.undefined;
108
- expect(result.find(instance => instance instanceof TestClass2)).to.not.be.undefined;
109
- expect(result.find(instance => instance instanceof TestClass3)).to.not.be.undefined;
110
- });
111
-
112
- it('apply binding of InstanceMultiBinding', () => {
113
- const t1 = 't1';
114
- const t2 = 't2';
115
- const t3 = 't3';
116
- const identifier = 'myStrings';
117
-
118
- const testContainer = new Container();
119
- const testModule = new ContainerModule((bind, unbind, isBound, rebind) => {
120
- const context = { bind, unbind, isBound, rebind };
121
- const binding = new InstanceMultiBinding<string>(identifier);
122
- binding.addAll([t1, t2, t3]);
123
- binding.applyBindings(context);
124
- });
125
- testContainer.load(testModule);
126
- const result = testContainer.get<string[]>(identifier);
127
- expect(result).to.have.length(3);
128
- expect(result.includes(t1)).true;
129
- expect(result.includes(t2)).true;
130
- expect(result.includes(t3)).true;
131
- });
132
- });
133
- });
@@ -1,69 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2022-2026 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 { GModelElement } from '@eclipse-glsp/graph';
17
- import { Args, LabeledAction, Point } from '@eclipse-glsp/protocol';
18
- import { expect } from 'chai';
19
- import { CommandPaletteActionProvider } from './command-palette-action-provider';
20
- import { ContextActionsProvider } from './context-actions-provider';
21
- import { ContextActionsProviderRegistry } from './context-actions-provider-registry';
22
- import { DefaultToolPaletteItemProvider } from './tool-palette-item-provider';
23
-
24
- describe('Test DefaultContextActionsProviderRegistry', () => {
25
- it('check if default registry is empty', () => {
26
- const contextActionsProvider: ContextActionsProvider[] = [];
27
- const contextActionsProviderRegistry = new ContextActionsProviderRegistry(contextActionsProvider);
28
- expect(contextActionsProviderRegistry.keys()).to.have.length(0);
29
- });
30
-
31
- it('register DefaultToolPaletteItemProvider via ContextActionsProviders list', () => {
32
- const contextActionsProvider: ContextActionsProvider[] = [new DefaultToolPaletteItemProvider()];
33
- const contextActionsProviderRegistry = new ContextActionsProviderRegistry(contextActionsProvider);
34
- expect(contextActionsProviderRegistry.keys()).to.have.length(1);
35
- });
36
-
37
- it('register DefaultToolPaletteItemProvider via ToolPaletteItemProvider', () => {
38
- const contextActionsProvider: ContextActionsProvider[] = [];
39
- const contextActionsProviderRegistry = new ContextActionsProviderRegistry(
40
- contextActionsProvider,
41
- undefined,
42
- undefined,
43
- new DefaultToolPaletteItemProvider()
44
- );
45
- expect(contextActionsProviderRegistry.keys()).to.have.length(1);
46
- });
47
-
48
- it('register CustomCommandPaletteActionProvider via CommandPaletteActionProvider', () => {
49
- class CustomCommandPaletteActionProvider extends CommandPaletteActionProvider {
50
- getPaletteActions(
51
- _selectedElementIds: string[],
52
- _selectedElements: GModelElement[],
53
- _position: Point,
54
- _args?: Args
55
- ): LabeledAction[] {
56
- return [];
57
- }
58
- }
59
-
60
- const contextActionsProvider: ContextActionsProvider[] = [];
61
- const contextActionsProviderRegistry = new ContextActionsProviderRegistry(
62
- contextActionsProvider,
63
- undefined,
64
- new CustomCommandPaletteActionProvider(),
65
- undefined
66
- );
67
- expect(contextActionsProviderRegistry.keys()).to.have.length(1);
68
- });
69
- });
@@ -1,75 +0,0 @@
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 { PaletteItem, RequestContextActions, SetContextActions } from '@eclipse-glsp/protocol';
17
- import { expect } from 'chai';
18
- import { OperationHandlerRegistry } from '../../operations/operation-handler-registry';
19
- import * as mock from '../../test/mock-util';
20
- import { ContextActionsProvider } from './context-actions-provider';
21
- import { ContextActionsProviderRegistry } from './context-actions-provider-registry';
22
- import { RequestContextActionsHandler } from './request-context-actions-handler';
23
- import { DefaultToolPaletteItemProvider } from './tool-palette-item-provider';
24
-
25
- describe('Test RequestContextActionsHandler', () => {
26
- const operationHandlerRegistry = new OperationHandlerRegistry();
27
- const stubANode = new mock.StubCreateNodeOperationHandler('ANode');
28
- const stubBNode = new mock.StubCreateNodeOperationHandler('BNode');
29
- const stubAEdge = new mock.StubCreateEdgeOperationHandler('AEdge');
30
- const stubBEdge = new mock.StubCreateEdgeOperationHandler('BEdge');
31
- operationHandlerRegistry.registerHandler(stubBNode);
32
- operationHandlerRegistry.registerHandler(stubANode);
33
- operationHandlerRegistry.registerHandler(stubBEdge);
34
- operationHandlerRegistry.registerHandler(stubAEdge);
35
-
36
- const contextActionsProvider: ContextActionsProvider[] = [];
37
- const toolPaletteItemProvider = new DefaultToolPaletteItemProvider();
38
- toolPaletteItemProvider.operationHandlerRegistry = operationHandlerRegistry;
39
-
40
- const contextActionsProviderRegistry = new ContextActionsProviderRegistry(
41
- contextActionsProvider,
42
- undefined,
43
- undefined,
44
- toolPaletteItemProvider
45
- );
46
-
47
- const requestContextActionsHandler = new RequestContextActionsHandler();
48
- requestContextActionsHandler['contextActionsProviderRegistry'] = contextActionsProviderRegistry;
49
-
50
- it('request ToolPaletteContextActions', async () => {
51
- const actions = await requestContextActionsHandler.execute(
52
- RequestContextActions.create({ contextId: 'tool-palette', editorContext: { selectedElementIds: [] } })
53
- );
54
- expect(actions).to.have.length(1);
55
- const action = actions[0];
56
-
57
- expect(SetContextActions.is(action)).to.be.true;
58
- const setContextActions = action as SetContextActions;
59
- expect(setContextActions.actions).to.have.length(2);
60
-
61
- expect(PaletteItem.is(setContextActions.actions[0])).to.be.true;
62
- const firstPaletteItem = setContextActions.actions[0] as PaletteItem;
63
- expect(firstPaletteItem.label).to.be.equal('Nodes');
64
- expect(firstPaletteItem.children).to.have.length(2);
65
- expect(firstPaletteItem.children?.[0].label).to.be.equal('ANode');
66
- expect(firstPaletteItem.children?.[1].label).to.be.equal('BNode');
67
-
68
- expect(PaletteItem.is(setContextActions.actions[1])).to.be.true;
69
- const secondPaletteItem = setContextActions.actions[1] as PaletteItem;
70
- expect(secondPaletteItem.label).to.be.equal('Edges');
71
- expect(secondPaletteItem.children).to.have.length(2);
72
- expect(secondPaletteItem.children?.[0].label).to.be.equal('AEdge');
73
- expect(secondPaletteItem.children?.[1].label).to.be.equal('BEdge');
74
- });
75
- });
@@ -1,46 +0,0 @@
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 { OperationHandlerRegistry } from '../../operations/operation-handler-registry';
17
- import * as mock from '../../test/mock-util';
18
- import { DefaultToolPaletteItemProvider } from './tool-palette-item-provider';
19
- import { expect } from 'chai';
20
-
21
- describe('Test DefaultToolPaletteItemProvider', () => {
22
- const operationHandlerRegistry = new OperationHandlerRegistry();
23
- const stubANode = new mock.StubCreateNodeOperationHandler('ANode');
24
- const stubBNode = new mock.StubCreateNodeOperationHandler('BNode');
25
- const stubAEdge = new mock.StubCreateEdgeOperationHandler('AEdge');
26
- const stubBEdge = new mock.StubCreateEdgeOperationHandler('BEdge');
27
- operationHandlerRegistry.registerHandler(stubBNode);
28
- operationHandlerRegistry.registerHandler(stubANode);
29
- operationHandlerRegistry.registerHandler(stubBEdge);
30
- operationHandlerRegistry.registerHandler(stubAEdge);
31
-
32
- it('test getItems', () => {
33
- const toolPaletteItemProvider = new DefaultToolPaletteItemProvider();
34
- toolPaletteItemProvider.operationHandlerRegistry = operationHandlerRegistry;
35
- const items = toolPaletteItemProvider.getItems();
36
- expect(items).to.have.length(2);
37
- expect(items[0].label).to.be.equal('Nodes');
38
- expect(items[0].children).to.have.length(2);
39
- expect(items[0].children?.[0].label).to.be.equal('ANode');
40
- expect(items[0].children?.[1].label).to.be.equal('BNode');
41
- expect(items[1].label).to.be.equal('Edges');
42
- expect(items[1].children).to.have.length(2);
43
- expect(items[1].children?.[0].label).to.be.equal('AEdge');
44
- expect(items[1].children?.[1].label).to.be.equal('BEdge');
45
- });
46
- });
@@ -1,54 +0,0 @@
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 { TestContextEditValidator, TestLabelEditValidator } from '../../test/mock-util';
18
- import { DefaultModelState } from '../model/model-state';
19
- import { ContextEditValidator } from './context-edit-validator';
20
- import { DefaultContextEditValidatorRegistry } from './context-edit-validator-registry';
21
-
22
- describe('Test DefaultContextEditValidatorRegistry', () => {
23
- it('check if default registry is empty', () => {
24
- const contextEditValidators: ContextEditValidator[] = [];
25
- const contextEditValidatorRegistry = new DefaultContextEditValidatorRegistry(new DefaultModelState(), contextEditValidators);
26
- expect(contextEditValidatorRegistry.keys()).to.have.length(0);
27
- });
28
-
29
- it('register TestContextEditValidator via ContextEditValidators list', () => {
30
- const contextEditValidators: ContextEditValidator[] = [new TestContextEditValidator()];
31
- const contextEditValidatorsRegistry = new DefaultContextEditValidatorRegistry(new DefaultModelState(), contextEditValidators);
32
- expect(contextEditValidatorsRegistry.keys()).to.have.length(1);
33
- });
34
-
35
- it('register TestLabelEditValidator via LabelEditValidator', () => {
36
- const contextEditValidators: ContextEditValidator[] = [];
37
- const contextEditValidatorsRegistry = new DefaultContextEditValidatorRegistry(
38
- new DefaultModelState(),
39
- contextEditValidators,
40
- new TestLabelEditValidator()
41
- );
42
- expect(contextEditValidatorsRegistry.keys()).to.have.length(1);
43
- });
44
-
45
- it('register via ContextEditValidators list and LabelEditValidator', () => {
46
- const contextEditValidators: ContextEditValidator[] = [new TestContextEditValidator()];
47
- const contextEditValidatorsRegistry = new DefaultContextEditValidatorRegistry(
48
- new DefaultModelState(),
49
- contextEditValidators,
50
- new TestLabelEditValidator()
51
- );
52
- expect(contextEditValidatorsRegistry.keys()).to.have.length(2);
53
- });
54
- });
@@ -1,131 +0,0 @@
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 { GNode } from '@eclipse-glsp/graph';
17
- import { RequestEditValidationAction, SetEditValidationResultAction, ValidationStatus } from '@eclipse-glsp/protocol';
18
- import { expect } from 'chai';
19
- import * as sinon from 'sinon';
20
- import { TestContextEditValidator, TestLabelEditValidator } from '../../test/mock-util';
21
- import { GModelIndex } from '../model/gmodel-index';
22
- import { DefaultModelState } from '../model/model-state';
23
- import { ContextEditValidator } from './context-edit-validator';
24
- import { DefaultContextEditValidatorRegistry } from './context-edit-validator-registry';
25
- import { LabelEditValidator } from './label-edit-validator';
26
- import { RequestEditValidationHandler } from './request-edit-validation-handler';
27
-
28
- describe('Test RequestEditValidationHandler', () => {
29
- const contextEditValidators: ContextEditValidator[] = [new TestContextEditValidator()];
30
- const modelState = new DefaultModelState();
31
- Object.defineProperty(modelState, 'index', { value: new GModelIndex() });
32
- sinon.stub(modelState.index, 'get').callsFake(() => new GNode());
33
- const contextEditValidatorsRegistry = new DefaultContextEditValidatorRegistry(
34
- modelState,
35
- contextEditValidators,
36
- new TestLabelEditValidator()
37
- );
38
-
39
- const requestEditValidationHandler = new RequestEditValidationHandler();
40
- requestEditValidationHandler['contextEditValidatorRegistry'] = contextEditValidatorsRegistry;
41
-
42
- it('requestContextEditValidation with ok result', async () => {
43
- const actions = await requestEditValidationHandler.execute(
44
- RequestEditValidationAction.create({ contextId: 'test', modelElementId: '', text: 'ok' })
45
- );
46
- expect(actions).to.have.length(1);
47
- const action = actions[0];
48
-
49
- expect(SetEditValidationResultAction.is(action)).to.be.true;
50
- const setEditValidationResultAction = action as SetEditValidationResultAction;
51
- const status = setEditValidationResultAction.status;
52
-
53
- expect(status.severity).to.be.equal(ValidationStatus.Severity.OK);
54
- expect(status.message).to.be.equal('ok');
55
- });
56
-
57
- it('requestContextEditValidation with warning result', async () => {
58
- const actions = await requestEditValidationHandler.execute(
59
- RequestEditValidationAction.create({ contextId: 'test', modelElementId: '', text: 'warning' })
60
- );
61
- expect(actions).to.have.length(1);
62
- const action = actions[0];
63
-
64
- expect(SetEditValidationResultAction.is(action)).to.be.true;
65
- const setEditValidationResultAction = action as SetEditValidationResultAction;
66
- const status = setEditValidationResultAction.status;
67
-
68
- expect(status.severity).to.be.equal(ValidationStatus.Severity.WARNING);
69
- expect(status.message).to.be.equal('warning');
70
- });
71
-
72
- it('requestContextEditValidation with error result', async () => {
73
- const actions = await requestEditValidationHandler.execute(
74
- RequestEditValidationAction.create({ contextId: 'test', modelElementId: '', text: 'error' })
75
- );
76
- expect(actions).to.have.length(1);
77
- const action = actions[0];
78
-
79
- expect(SetEditValidationResultAction.is(action)).to.be.true;
80
- const setEditValidationResultAction = action as SetEditValidationResultAction;
81
- const status = setEditValidationResultAction.status;
82
-
83
- expect(status.severity).to.be.equal(ValidationStatus.Severity.ERROR);
84
- expect(status.message).to.be.equal('error');
85
- });
86
-
87
- it('requestLabelEditValidation with ok result', async () => {
88
- const actions = await requestEditValidationHandler.execute(
89
- RequestEditValidationAction.create({ contextId: LabelEditValidator.CONTEXT_ID, modelElementId: '', text: 'ok' })
90
- );
91
- expect(actions).to.have.length(1);
92
- const action = actions[0];
93
-
94
- expect(SetEditValidationResultAction.is(action)).to.be.true;
95
- const setEditValidationResultAction = action as SetEditValidationResultAction;
96
- const status = setEditValidationResultAction.status;
97
-
98
- expect(status.severity).to.be.equal(ValidationStatus.Severity.OK);
99
- expect(status.message).to.be.equal('ok');
100
- });
101
-
102
- it('requestLabelEditValidation with warning result', async () => {
103
- const actions = await requestEditValidationHandler.execute(
104
- RequestEditValidationAction.create({ contextId: LabelEditValidator.CONTEXT_ID, modelElementId: '', text: 'warning' })
105
- );
106
- expect(actions).to.have.length(1);
107
- const action = actions[0];
108
-
109
- expect(SetEditValidationResultAction.is(action)).to.be.true;
110
- const setEditValidationResultAction = action as SetEditValidationResultAction;
111
- const status = setEditValidationResultAction.status;
112
-
113
- expect(status.severity).to.be.equal(ValidationStatus.Severity.WARNING);
114
- expect(status.message).to.be.equal('warning');
115
- });
116
-
117
- it('requestLabelEditValidation with error result', async () => {
118
- const actions = await requestEditValidationHandler.execute(
119
- RequestEditValidationAction.create({ contextId: LabelEditValidator.CONTEXT_ID, modelElementId: '', text: 'error' })
120
- );
121
- expect(actions).to.have.length(1);
122
- const action = actions[0];
123
-
124
- expect(SetEditValidationResultAction.is(action)).to.be.true;
125
- const setEditValidationResultAction = action as SetEditValidationResultAction;
126
- const status = setEditValidationResultAction.status;
127
-
128
- expect(status.severity).to.be.equal(ValidationStatus.Severity.ERROR);
129
- expect(status.message).to.be.equal('error');
130
- });
131
- });
@@ -1,141 +0,0 @@
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 { GEdge, getDefaultMapping, GGraph, GNode } from '@eclipse-glsp/graph';
17
- import { expect } from 'chai';
18
- import { Container, ContainerModule } from 'inversify';
19
- import { DiagramConfiguration } from '../../diagram/diagram-configuration';
20
- import * as mock from '../../test/mock-util';
21
- import { GLSPServerError } from '../../utils/glsp-server-error';
22
- import { Logger } from '../../utils/logger';
23
- import { DefaultGModelSerializer } from './gmodel-serializer';
24
-
25
- class TestNode extends GNode {
26
- foo(): void {
27
- // should not be serialized to schema
28
- }
29
- }
30
-
31
- let testRootSchema: any;
32
-
33
- let testNodeSchema: any;
34
-
35
- let testNodeSchemaWithParent: any;
36
-
37
- describe('test DefaultGModelSerializer', () => {
38
- const container = new Container();
39
- const diagramConfiguration = new mock.StubDiagramConfiguration();
40
- diagramConfiguration['typeMapping'] = getDefaultMapping();
41
- diagramConfiguration.typeMapping.set('node', TestNode);
42
-
43
- container.load(
44
- new ContainerModule(bind => {
45
- bind(Logger).toConstantValue(new mock.StubLogger());
46
- bind(DiagramConfiguration).toConstantValue(diagramConfiguration);
47
- })
48
- );
49
-
50
- const serializer = container.resolve(DefaultGModelSerializer);
51
-
52
- beforeEach(() => {
53
- testRootSchema = {
54
- id: 'graph',
55
- type: 'graph',
56
- children: [
57
- { id: 'node1', type: 'node', position: { x: 5, y: 10 } },
58
- { id: 'node2', type: 'node', position: { x: 15, y: 5 } },
59
- { id: 'edge1', type: 'edge', sourceId: 'node1', targetId: 'node2' }
60
- ]
61
- };
62
- testNodeSchema = { id: 'node1', type: 'node', position: { x: 5, y: 10 }, children: [], cssClasses: [] };
63
- testNodeSchemaWithParent = {
64
- id: 'node1',
65
- type: 'node',
66
- position: { x: 5, y: 10 },
67
- children: [],
68
- cssClasses: [],
69
- parent: new GNode()
70
- };
71
- });
72
-
73
- it('createElement - unregistered type', () => {
74
- testNodeSchema['type'] = 'notRegistered';
75
- expect(() => serializer.createElement(testNodeSchema)).to.throw(GLSPServerError);
76
- });
77
-
78
- it('createElement - with root schema', () => {
79
- expect(() => serializer.createElement(testRootSchema)).to.throw(GLSPServerError);
80
- });
81
-
82
- it('createElement - with node schema', () => {
83
- const node = serializer.createElement(testNodeSchema);
84
- expect(node).to.be.an.instanceOf(TestNode);
85
- expect(node).to.be.deep.include(testNodeSchema);
86
- expect((node as TestNode).foo).to.not.be.undefined;
87
- });
88
-
89
- it('createElement- with sub type of registered schema', () => {
90
- testNodeSchema.type = 'node:rectangular';
91
- const node = serializer.createElement(testNodeSchema);
92
- expect(node).to.be.an.instanceOf(TestNode);
93
- expect(node).to.be.deep.include(testNodeSchema);
94
- expect((node as TestNode).foo).to.not.be.undefined;
95
- });
96
-
97
- it('createElement - with parent', () => {
98
- const parent = new GNode();
99
- const child = serializer.createElement(testNodeSchema, parent);
100
- expect(child).to.be.an.instanceOf(TestNode);
101
- expect(child).to.be.deep.include(testNodeSchemaWithParent);
102
- expect(child.parent).to.be.equal(parent);
103
- });
104
-
105
- it('createRoot - unregistered type', () => {
106
- testRootSchema['type'] = 'notRegistered';
107
- expect(() => serializer.createRoot(testNodeSchema)).to.throw(GLSPServerError);
108
- });
109
-
110
- it('createRoot - with child schema ', () => {
111
- expect(() => serializer.createRoot(testNodeSchema)).to.throw(GLSPServerError);
112
- });
113
-
114
- it('createRoot - with registered root schema', () => {
115
- const root = serializer.createRoot(testRootSchema);
116
- expect(root).to.be.an.instanceOf(GGraph);
117
- expect(root.children.length).to.be.equal(3);
118
- const node1 = root.children[0];
119
- expect(node1).to.be.an.instanceOf(TestNode);
120
- const node2 = root.children[1];
121
- expect(node2).to.be.an.instanceOf(TestNode);
122
- expect(root.children[2]).to.be.an.instanceOf(GEdge);
123
- const edge = root.children[2] as GEdge;
124
- expect(edge.sourceId).to.be.equal(node1.id);
125
- expect(edge.targetId).to.be.equal(node2.id);
126
- });
127
-
128
- it('createSchema- unregistered type', () => {
129
- expect(() => serializer.createRoot({ id: 'id', type: 'unregistered' })).to.throw(GLSPServerError);
130
- });
131
-
132
- it('createSchema- with node', () => {
133
- const testNode = new TestNode();
134
- testNode.position = { x: 5, y: 10 };
135
- testNode.size = { width: 10, height: 100 };
136
- testNode.layoutOptions = { ['my']: 'Options' };
137
- const schema = serializer.createSchema(testNode);
138
- delete (testNode as Partial<TestNode>).foo;
139
- expect(schema).to.be.deep.include(testNode);
140
- });
141
- });