@eclipse-glsp/server 1.1.0-next.3d7585d.42 → 1.1.0-next.44aae0c.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/command/command-stack.d.ts +45 -14
- package/lib/common/command/command-stack.d.ts.map +1 -1
- package/lib/common/command/command-stack.js +78 -9
- package/lib/common/command/command-stack.js.map +1 -1
- package/lib/common/command/command-stack.spec.d.ts +2 -0
- package/lib/common/command/command-stack.spec.d.ts.map +1 -0
- package/lib/common/command/command-stack.spec.js +207 -0
- package/lib/common/command/command-stack.spec.js.map +1 -0
- package/lib/common/command/command.d.ts +34 -7
- package/lib/common/command/command.d.ts.map +1 -1
- package/lib/common/command/command.js +73 -0
- package/lib/common/command/command.js.map +1 -1
- package/lib/common/command/command.spec.d.ts +2 -0
- package/lib/common/command/command.spec.d.ts.map +1 -0
- package/lib/common/command/command.spec.js +86 -0
- package/lib/common/command/command.spec.js.map +1 -0
- package/lib/common/command/recording-command.d.ts +75 -0
- package/lib/common/command/recording-command.d.ts.map +1 -0
- package/lib/common/command/recording-command.js +99 -0
- package/lib/common/command/recording-command.js.map +1 -0
- package/lib/common/command/recording-command.spec.d.ts +17 -0
- package/lib/common/command/recording-command.spec.d.ts.map +1 -0
- package/lib/common/command/recording-command.spec.js +62 -0
- package/lib/common/command/recording-command.spec.js.map +1 -0
- package/lib/common/command/undo-redo-action-handler.d.ts +28 -0
- package/lib/common/command/undo-redo-action-handler.d.ts.map +1 -0
- package/lib/common/command/undo-redo-action-handler.js +72 -0
- package/lib/common/command/undo-redo-action-handler.js.map +1 -0
- package/lib/common/di/diagram-module.d.ts +3 -0
- package/lib/common/di/diagram-module.d.ts.map +1 -1
- package/lib/common/di/diagram-module.js +12 -0
- package/lib/common/di/diagram-module.js.map +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.d.ts +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.d.ts.map +1 -1
- package/lib/common/features/contextactions/tool-palette-item-provider.js +2 -4
- package/lib/common/features/contextactions/tool-palette-item-provider.js.map +1 -1
- package/lib/common/{gmodel → features/layout}/computed-bounds-action-handler.d.ts +8 -3
- package/lib/common/features/layout/computed-bounds-action-handler.d.ts.map +1 -0
- package/lib/common/{gmodel → features/layout}/computed-bounds-action-handler.js +8 -3
- package/lib/common/features/layout/computed-bounds-action-handler.js.map +1 -0
- package/lib/common/features/layout/layout-operation-handler.d.ts +12 -3
- package/lib/common/features/layout/layout-operation-handler.d.ts.map +1 -1
- package/lib/common/features/layout/layout-operation-handler.js +26 -10
- package/lib/common/features/layout/layout-operation-handler.js.map +1 -1
- package/lib/common/features/model/model-state.d.ts +0 -2
- package/lib/common/features/model/model-state.d.ts.map +1 -1
- package/lib/common/features/model/model-state.js +0 -1
- package/lib/common/features/model/model-state.js.map +1 -1
- package/lib/common/features/model/model-submission-handler.d.ts +2 -0
- package/lib/common/features/model/model-submission-handler.d.ts.map +1 -1
- package/lib/common/features/model/model-submission-handler.js +7 -2
- package/lib/common/features/model/model-submission-handler.js.map +1 -1
- package/lib/common/features/model/save-model-action-handler.d.ts +2 -2
- package/lib/common/features/model/save-model-action-handler.d.ts.map +1 -1
- package/lib/common/features/model/save-model-action-handler.js +5 -5
- package/lib/common/features/model/save-model-action-handler.js.map +1 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.d.ts +4 -5
- package/lib/common/gmodel/apply-label-edit-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.js +12 -21
- package/lib/common/gmodel/apply-label-edit-operation-handler.js.map +1 -1
- package/lib/common/gmodel/change-bounds-operation-handler.d.ts +9 -6
- package/lib/common/gmodel/change-bounds-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/change-bounds-operation-handler.js +14 -14
- package/lib/common/gmodel/change-bounds-operation-handler.js.map +1 -1
- package/lib/common/gmodel/change-routing-points-operation-handler.d.ts +5 -5
- package/lib/common/gmodel/change-routing-points-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/change-routing-points-operation-handler.js +11 -14
- package/lib/common/gmodel/change-routing-points-operation-handler.js.map +1 -1
- package/lib/common/{operations → gmodel}/cut-operation-handler.d.ts +5 -4
- package/lib/common/gmodel/cut-operation-handler.d.ts.map +1 -0
- package/lib/common/{operations → gmodel}/cut-operation-handler.js +13 -11
- package/lib/common/gmodel/cut-operation-handler.js.map +1 -0
- package/lib/common/gmodel/delete-operation-handler.d.ts +6 -6
- package/lib/common/gmodel/delete-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/delete-operation-handler.js +13 -10
- package/lib/common/gmodel/delete-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts +11 -7
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js +12 -13
- package/lib/common/gmodel/gmodel-create-edge-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts +32 -5
- package/lib/common/gmodel/gmodel-create-node-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js +45 -3
- package/lib/common/gmodel/gmodel-create-node-operation-handler.js.map +1 -1
- package/lib/common/gmodel/gmodel-diagram-module.d.ts +8 -8
- package/lib/common/gmodel/gmodel-diagram-module.d.ts.map +1 -1
- package/lib/common/gmodel/gmodel-diagram-module.js +15 -21
- package/lib/common/gmodel/gmodel-diagram-module.js.map +1 -1
- package/lib/common/gmodel/gmodel-operation-handler.d.ts +23 -0
- package/lib/common/gmodel/gmodel-operation-handler.d.ts.map +1 -0
- package/lib/common/gmodel/gmodel-operation-handler.js +43 -0
- package/lib/common/gmodel/gmodel-operation-handler.js.map +1 -0
- package/lib/common/gmodel/index.d.ts +2 -1
- package/lib/common/gmodel/index.d.ts.map +1 -1
- package/lib/common/gmodel/index.js +2 -1
- package/lib/common/gmodel/index.js.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.d.ts +7 -6
- package/lib/common/gmodel/paste-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/paste-operation-handler.js +20 -15
- package/lib/common/gmodel/paste-operation-handler.js.map +1 -1
- package/lib/common/gmodel/reconnect-edge-operation-handler.d.ts +5 -5
- package/lib/common/gmodel/reconnect-edge-operation-handler.d.ts.map +1 -1
- package/lib/common/gmodel/reconnect-edge-operation-handler.js +11 -14
- package/lib/common/gmodel/reconnect-edge-operation-handler.js.map +1 -1
- package/lib/common/index.d.ts +2 -1
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +2 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/operations/compound-operation-handler.d.ts +5 -5
- package/lib/common/operations/compound-operation-handler.d.ts.map +1 -1
- package/lib/common/operations/compound-operation-handler.js +37 -9
- package/lib/common/operations/compound-operation-handler.js.map +1 -1
- package/lib/common/operations/create-operation-handler.d.ts +8 -40
- package/lib/common/operations/create-operation-handler.d.ts.map +1 -1
- package/lib/common/operations/create-operation-handler.js +26 -85
- package/lib/common/operations/create-operation-handler.js.map +1 -1
- package/lib/common/operations/operation-action-handler.d.ts +10 -1
- package/lib/common/operations/operation-action-handler.d.ts.map +1 -1
- package/lib/common/operations/operation-action-handler.js +37 -22
- package/lib/common/operations/operation-action-handler.js.map +1 -1
- package/lib/common/operations/operation-handler-registry.d.ts +11 -2
- package/lib/common/operations/operation-handler-registry.d.ts.map +1 -1
- package/lib/common/operations/operation-handler-registry.js +31 -2
- package/lib/common/operations/operation-handler-registry.js.map +1 -1
- package/lib/common/operations/operation-handler.d.ts +28 -11
- package/lib/common/operations/operation-handler.d.ts.map +1 -1
- package/lib/common/operations/operation-handler.js +50 -1
- package/lib/common/operations/operation-handler.js.map +1 -1
- package/lib/common/test/mock-util.d.ts +14 -1
- package/lib/common/test/mock-util.d.ts.map +1 -1
- package/lib/common/test/mock-util.js +42 -37
- package/lib/common/test/mock-util.js.map +1 -1
- package/package.json +4 -3
- package/src/common/command/command-stack.spec.ts +239 -0
- package/src/common/command/command-stack.ts +106 -20
- package/src/common/command/command.spec.ts +92 -0
- package/src/common/command/command.ts +96 -7
- package/src/common/command/recording-command.spec.ts +74 -0
- package/src/common/command/recording-command.ts +119 -0
- package/src/common/command/undo-redo-action-handler.ts +57 -0
- package/src/common/di/diagram-module.ts +13 -0
- package/src/common/features/contextactions/tool-palette-item-provider.ts +2 -4
- package/src/common/{gmodel → features/layout}/computed-bounds-action-handler.ts +9 -4
- package/src/common/features/layout/layout-operation-handler.ts +26 -11
- package/src/common/features/model/model-state.ts +0 -3
- package/src/common/features/model/model-submission-handler.ts +6 -2
- package/src/common/features/model/save-model-action-handler.ts +5 -6
- package/src/common/gmodel/apply-label-edit-operation-handler.ts +13 -15
- package/src/common/gmodel/change-bounds-operation-handler.ts +12 -8
- package/src/common/gmodel/change-routing-points-operation-handler.ts +8 -7
- package/src/common/{operations → gmodel}/cut-operation-handler.ts +9 -8
- package/src/common/gmodel/delete-operation-handler.ts +16 -10
- package/src/common/gmodel/gmodel-create-edge-operation-handler.ts +16 -10
- package/src/common/gmodel/gmodel-create-node-operation-handler.ts +54 -6
- package/src/common/gmodel/gmodel-diagram-module.ts +22 -27
- package/src/common/gmodel/gmodel-operation-handler.ts +31 -0
- package/src/common/gmodel/index.ts +2 -1
- package/src/common/gmodel/paste-operation-handler.ts +19 -11
- package/src/common/gmodel/reconnect-edge-operation-handler.ts +8 -7
- package/src/common/index.ts +2 -1
- package/src/common/operations/compound-operation-handler.ts +14 -12
- package/src/common/operations/create-operation-handler.ts +17 -74
- package/src/common/operations/operation-action-handler.ts +51 -27
- package/src/common/operations/operation-handler-registry.ts +18 -3
- package/src/common/operations/operation-handler.ts +38 -13
- package/src/common/test/mock-util.ts +42 -36
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.d.ts +0 -2
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.d.ts.map +0 -1
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.js +0 -38
- package/lib/common/gmodel/apply-label-edit-operation-handler.spec.js.map +0 -1
- package/lib/common/gmodel/computed-bounds-action-handler.d.ts.map +0 -1
- package/lib/common/gmodel/computed-bounds-action-handler.js.map +0 -1
- package/lib/common/operations/cut-operation-handler.d.ts.map +0 -1
- package/lib/common/operations/cut-operation-handler.js.map +0 -1
- package/src/common/gmodel/apply-label-edit-operation-handler.spec.ts +0 -40
|
@@ -13,94 +13,37 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { GModelElement } from '@eclipse-glsp/graph';
|
|
17
16
|
import {
|
|
18
17
|
CreateEdgeOperation,
|
|
19
18
|
CreateNodeOperation,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Point,
|
|
19
|
+
hasArrayProp,
|
|
20
|
+
hasFunctionProp,
|
|
21
|
+
hasStringProp,
|
|
24
22
|
TriggerEdgeCreationAction,
|
|
25
23
|
TriggerNodeCreationAction
|
|
26
24
|
} from '@eclipse-glsp/protocol';
|
|
27
|
-
import { inject, injectable } from 'inversify';
|
|
28
|
-
import { ModelState } from '../features/model/model-state';
|
|
29
|
-
import { getRelativeLocation } from '../utils/layout-util';
|
|
30
25
|
import { OperationHandler } from './operation-handler';
|
|
31
26
|
|
|
32
27
|
/**
|
|
33
28
|
* A special {@link OperationHandler} that is responsible for the handling of {@link CreateOperation}s. Depending on its
|
|
34
29
|
* operation type the triggered actions are {@link TriggerNodeCreationAction} or {@link TriggerEdgeCreationAction}s.
|
|
35
30
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
abstract execute(operation: Operation): MaybePromise<void>;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Returns a list of {@link TriggerElementCreationAction}s for registered element types.
|
|
46
|
-
*
|
|
47
|
-
* @returns A list of {@link TriggerElementCreationAction}s.
|
|
48
|
-
*/
|
|
49
|
-
getTriggerActions(): (TriggerEdgeCreationAction | TriggerNodeCreationAction)[] {
|
|
50
|
-
if (this.operationType === CreateNodeOperation.KIND) {
|
|
51
|
-
return this.elementTypeIds.map(typeId => TriggerNodeCreationAction.create(typeId));
|
|
52
|
-
} else if (this.operationType === CreateEdgeOperation.KIND) {
|
|
53
|
-
return this.elementTypeIds.map(typeId => TriggerEdgeCreationAction.create(typeId));
|
|
54
|
-
}
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
handles(operation: CreateOperation): boolean {
|
|
59
|
-
return this.elementTypeIds.includes(operation.elementTypeId);
|
|
60
|
-
}
|
|
31
|
+
export interface CreateOperationHandler extends OperationHandler {
|
|
32
|
+
readonly label: string;
|
|
33
|
+
elementTypeIds: string[];
|
|
34
|
+
operationType: CreateOperationKind;
|
|
35
|
+
getTriggerActions(): (TriggerEdgeCreationAction | TriggerNodeCreationAction)[];
|
|
61
36
|
}
|
|
62
37
|
|
|
63
|
-
|
|
64
|
-
* Abstract base implementation for {@link CreateOperationHandler} that
|
|
65
|
-
* create an element that is represented with a {@link GNode} in the graphical model.
|
|
66
|
-
*/
|
|
67
|
-
@injectable()
|
|
68
|
-
export abstract class CreateNodeOperationHandler extends CreateOperationHandler {
|
|
69
|
-
@inject(ModelState)
|
|
70
|
-
protected modelState: ModelState;
|
|
71
|
-
|
|
72
|
-
get operationType(): string {
|
|
73
|
-
return CreateNodeOperation.KIND;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Retrieve the graphical model element that should contain the newly created {@link GNode}.
|
|
78
|
-
* If `undefined` is returned the {@link GNode} should be added directly to the diagram root.
|
|
79
|
-
* @param operation The currently handled operation.
|
|
80
|
-
* @returns The container {@link GModeElement} or `undefined`.
|
|
81
|
-
*/
|
|
82
|
-
getContainer(operation: CreateNodeOperation): GModelElement | undefined {
|
|
83
|
-
const index = this.modelState.index;
|
|
84
|
-
return operation.containerId ? index.get(operation.containerId) : undefined;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
getLocation(operation: CreateNodeOperation): Point | undefined {
|
|
88
|
-
return operation.location;
|
|
89
|
-
}
|
|
38
|
+
export type CreateOperationKind = typeof CreateNodeOperation.KIND | typeof CreateEdgeOperation.KIND;
|
|
90
39
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
* @returns The relative position or `undefined`.
|
|
100
|
-
*/
|
|
101
|
-
getRelativeLocation(operation: CreateNodeOperation): Point | undefined {
|
|
102
|
-
const container = this.getContainer(operation) ?? this.modelState.root;
|
|
103
|
-
const absoluteLocation = this.getLocation(operation) ?? Point.ORIGIN;
|
|
104
|
-
return getRelativeLocation(absoluteLocation, container);
|
|
40
|
+
export namespace CreateOperationHandler {
|
|
41
|
+
export function is(object: unknown): object is CreateOperationHandler {
|
|
42
|
+
return (
|
|
43
|
+
object instanceof OperationHandler &&
|
|
44
|
+
hasStringProp(object, 'label') &&
|
|
45
|
+
hasArrayProp(object, 'elementTypeIds') &&
|
|
46
|
+
hasFunctionProp(object, 'getTriggerActions')
|
|
47
|
+
);
|
|
105
48
|
}
|
|
106
49
|
}
|
|
@@ -13,57 +13,81 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Action,
|
|
16
|
+
import { Action, MaybePromise, Operation, ServerMessageAction } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { inject, injectable } from 'inversify';
|
|
18
18
|
import { ActionHandler } from '../actions/action-handler';
|
|
19
|
+
import { Command } from '../command/command';
|
|
20
|
+
import { CommandStack } from '../command/command-stack';
|
|
19
21
|
import { Operations } from '../di/service-identifiers';
|
|
20
22
|
import { ModelState } from '../features/model/model-state';
|
|
21
23
|
import { ModelSubmissionHandler } from '../features/model/model-submission-handler';
|
|
24
|
+
import { GLSPServerError } from '../utils/glsp-server-error';
|
|
22
25
|
import { OperationHandler } from './operation-handler';
|
|
23
26
|
import { OperationHandlerRegistry } from './operation-handler-registry';
|
|
24
27
|
|
|
25
28
|
@injectable()
|
|
26
29
|
export class OperationActionHandler implements ActionHandler {
|
|
27
|
-
@inject(OperationHandlerRegistry)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
@inject(OperationHandlerRegistry)
|
|
31
|
+
protected operationHandlerRegistry: OperationHandlerRegistry;
|
|
32
|
+
|
|
33
|
+
@inject(ModelSubmissionHandler)
|
|
34
|
+
protected modelSubmissionHandler: ModelSubmissionHandler;
|
|
35
|
+
|
|
36
|
+
@inject(ModelState)
|
|
37
|
+
protected modelState: ModelState;
|
|
38
|
+
|
|
39
|
+
@inject(CommandStack)
|
|
40
|
+
protected commandStack: CommandStack;
|
|
30
41
|
|
|
31
42
|
constructor(@inject(Operations) readonly actionKinds: string[]) {}
|
|
32
43
|
|
|
33
44
|
execute(action: Operation): MaybePromise<Action[]> {
|
|
34
|
-
if (this.handles(action)) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
if (!this.handles(action)) {
|
|
46
|
+
throw new GLSPServerError(`Unhandled operation kind: ${action.kind}`);
|
|
47
|
+
}
|
|
48
|
+
if (this.modelState.isReadonly) {
|
|
49
|
+
return [
|
|
50
|
+
ServerMessageAction.create(`Server is in readonly-mode! Could not execute operation: ${action.kind}`, {
|
|
51
|
+
severity: 'WARNING'
|
|
52
|
+
})
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
return this.executeOperation(action);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protected executeOperation(operation: Operation): MaybePromise<Action[]> {
|
|
59
|
+
const operationHandler = OperationActionHandler.getOperationHandler(operation, this.operationHandlerRegistry);
|
|
60
|
+
if (operationHandler) {
|
|
61
|
+
return this.executeHandler(operation, operationHandler);
|
|
46
62
|
}
|
|
47
63
|
return [];
|
|
48
64
|
}
|
|
49
65
|
|
|
50
|
-
async executeHandler(operation: Operation, handler: OperationHandler): Promise<Action[]> {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
protected async executeHandler(operation: Operation, handler: OperationHandler): Promise<Action[]> {
|
|
67
|
+
const command = await handler.execute(operation);
|
|
68
|
+
if (command) {
|
|
69
|
+
await this.executeCommand(command);
|
|
70
|
+
}
|
|
71
|
+
return this.modelSubmissionHandler.submitModel('operation');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
protected async executeCommand(command: Command): Promise<void> {
|
|
75
|
+
return this.commandStack.execute(command);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected submitModel(): MaybePromise<Action[]> {
|
|
56
79
|
return this.modelSubmissionHandler.submitModel('operation');
|
|
57
80
|
}
|
|
58
81
|
|
|
59
82
|
handles(action: Action): boolean {
|
|
60
|
-
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
83
|
+
return this.actionKinds.includes(action.kind);
|
|
64
84
|
}
|
|
65
85
|
|
|
86
|
+
/**
|
|
87
|
+
* @Deprecated Use {@link OperationHandlerRegistry#getOperationHandler(Operation) instead}.
|
|
88
|
+
*/
|
|
89
|
+
|
|
66
90
|
static getOperationHandler(operation: Operation, registry: OperationHandlerRegistry): OperationHandler | undefined {
|
|
67
|
-
return
|
|
91
|
+
return registry.getOperationHandler(operation);
|
|
68
92
|
}
|
|
69
93
|
}
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
import { Args } from '@eclipse-glsp/protocol';
|
|
16
|
+
import { Args, CreateOperation, MaybePromise, Operation } from '@eclipse-glsp/protocol';
|
|
17
17
|
import { inject, injectable, optional } from 'inversify';
|
|
18
|
+
import { Command } from '../command/command';
|
|
18
19
|
import { ClientSessionInitializer } from '../session/client-session-initializer';
|
|
19
20
|
import { Registry } from '../utils/registry';
|
|
20
21
|
import { CreateOperationHandler } from './create-operation-handler';
|
|
@@ -23,13 +24,27 @@ import { OperationHandler, OperationHandlerConstructor, OperationHandlerFactory
|
|
|
23
24
|
@injectable()
|
|
24
25
|
export class OperationHandlerRegistry extends Registry<string, OperationHandler> {
|
|
25
26
|
registerHandler(handler: OperationHandler): boolean {
|
|
26
|
-
if (handler
|
|
27
|
+
if (CreateOperationHandler.is(handler)) {
|
|
27
28
|
handler.elementTypeIds.forEach(typeId => this.register(`${handler.operationType}_${typeId}`, handler));
|
|
28
29
|
return true;
|
|
29
30
|
} else {
|
|
30
31
|
return this.register(handler.operationType, handler);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
34
|
+
|
|
35
|
+
getOperationHandler(operation: Operation): OperationHandler | undefined {
|
|
36
|
+
return CreateOperation.is(operation) ? this.get(`${operation.kind}_${operation.elementTypeId}`) : this.get(operation.kind);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Returns the matching command for the given operation.
|
|
41
|
+
*
|
|
42
|
+
* @param operation operation
|
|
43
|
+
* @return the matching command for the given operation
|
|
44
|
+
*/
|
|
45
|
+
getExecutableCommand(operation: Operation): MaybePromise<Command | undefined> {
|
|
46
|
+
return this.getOperationHandler(operation)?.createCommand(operation);
|
|
47
|
+
}
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
@injectable()
|
|
@@ -44,7 +59,7 @@ export class OperationHandlerRegistryInitializer implements ClientSessionInitial
|
|
|
44
59
|
@inject(OperationHandlerRegistry)
|
|
45
60
|
protected registry: OperationHandlerRegistry;
|
|
46
61
|
|
|
47
|
-
initialize(
|
|
62
|
+
initialize(_args?: Args): void {
|
|
48
63
|
const handlers = this.handlerConstructors.map(constructor => this.factory(constructor));
|
|
49
64
|
handlers.forEach(handler => this.registry.registerHandler(handler));
|
|
50
65
|
}
|
|
@@ -14,38 +14,63 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
import { MaybePromise, Operation } from '@eclipse-glsp/protocol';
|
|
17
|
-
import { interfaces } from 'inversify';
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
import { inject, injectable, interfaces } from 'inversify';
|
|
18
|
+
import { Command } from '../command/command';
|
|
19
|
+
import { ModelState } from '../features/model/model-state';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* An operation handler can execute {@link Operation}s of a certain type (subclass).
|
|
23
23
|
* The operation handler processes the operation in the {@link OperationHandler.execute()} method. The result
|
|
24
|
-
* of the execution is
|
|
25
|
-
* This
|
|
26
|
-
* applied directly on the `ModelState` using EMF `Command`s and the
|
|
27
|
-
* `ModelState.execute()` method. For more complex diagram languages the
|
|
28
|
-
* GModel state might be updated indirectly and the operation handler manipulates a custom model representation.
|
|
24
|
+
* of the execution is a {@link Command} that captures the corresponding source model changes.
|
|
25
|
+
* This command can be applied on the `CommandStack` and is reversible (undo) and can be reapplied (redo).
|
|
29
26
|
*
|
|
30
27
|
* The `OperationActionHandler` is responsible for retrieving all available (valid) operation handlers for an
|
|
31
28
|
* operation that is dispatched via `ActionDispatcher`.
|
|
32
29
|
*/
|
|
33
|
-
|
|
30
|
+
@injectable()
|
|
31
|
+
export abstract class OperationHandler {
|
|
32
|
+
@inject(ModelState)
|
|
33
|
+
protected modelState: ModelState;
|
|
34
|
+
|
|
34
35
|
/**
|
|
35
36
|
* Returns the operation type that can be handled by this operation handler.
|
|
36
37
|
*
|
|
37
38
|
* @returns the operation type that can be handled.
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
abstract operationType: string;
|
|
40
41
|
|
|
41
42
|
readonly label?: string;
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
|
-
*
|
|
45
|
+
* Creates a command that performs the operation in the source model(s). If `undefined` is returned, no update
|
|
46
|
+
* is performed on the model(s).
|
|
47
|
+
*
|
|
48
|
+
* @param operation The operation to process.
|
|
49
|
+
* @return The created command to be executed on the command stack or `undefined` nothing should be done.
|
|
50
|
+
*/
|
|
51
|
+
abstract createCommand(operation: Operation): MaybePromise<Command | undefined>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Executes the operation handler for the given {@link Operation} and returns the corresponding {@link Command}.
|
|
55
|
+
* If the given operation cannot be handled by this handler or the handler execution did not result in any changes
|
|
56
|
+
* `undefined` is returned.
|
|
57
|
+
*
|
|
58
|
+
* @param operation The operation that should be executed or empty if nothing should be done.
|
|
59
|
+
* @returns The command capturing the execution changes or `undefined`
|
|
60
|
+
*/
|
|
61
|
+
execute(operation: Operation): MaybePromise<Command | undefined> {
|
|
62
|
+
return this.handles(operation) ? this.createCommand(operation) : undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Validates whether the given {@link Operation} can be handled by this operation handler.
|
|
45
67
|
*
|
|
46
|
-
* @param operation The operation that should be
|
|
68
|
+
* @param operation The operation that should be validated.
|
|
69
|
+
* @returns `true` if the given operation can be handled, `false` otherwise.
|
|
47
70
|
*/
|
|
48
|
-
|
|
71
|
+
handles(operation: Operation): boolean {
|
|
72
|
+
return this.modelState.root && operation.kind === this.operationType;
|
|
73
|
+
}
|
|
49
74
|
}
|
|
50
75
|
|
|
51
76
|
export const OperationHandlerConstructor = Symbol('OperationHandlerConstructor');
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
16
17
|
// Stub-implementation classes used for unit testing
|
|
17
18
|
|
|
18
19
|
import { GEdge, GModelElement, GModelElementConstructor, GNode } from '@eclipse-glsp/graph';
|
|
@@ -24,15 +25,18 @@ import {
|
|
|
24
25
|
EdgeTypeHint,
|
|
25
26
|
InitializeClientSessionParameters,
|
|
26
27
|
MaybeArray,
|
|
28
|
+
MaybePromise,
|
|
27
29
|
Point,
|
|
28
30
|
RequestEditValidationAction,
|
|
29
31
|
ShapeTypeHint,
|
|
30
32
|
ValidationStatus
|
|
31
33
|
} from '@eclipse-glsp/protocol';
|
|
34
|
+
import { expect } from 'chai';
|
|
32
35
|
import { Container } from 'inversify';
|
|
33
36
|
import { MessageConnection } from 'vscode-jsonrpc';
|
|
34
37
|
import { ActionDispatcher } from '../actions/action-dispatcher';
|
|
35
38
|
import { ActionHandler, ActionHandlerFactory } from '../actions/action-handler';
|
|
39
|
+
import { Command } from '../command/command';
|
|
36
40
|
import { DiagramConfiguration, ServerLayoutKind } from '../diagram/diagram-configuration';
|
|
37
41
|
import { ContextEditValidator } from '../features/directediting/context-edit-validator';
|
|
38
42
|
import { LabelEditValidator } from '../features/directediting/label-edit-validator';
|
|
@@ -51,6 +55,25 @@ export async function delay(ms: number): Promise<void> {
|
|
|
51
55
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
52
56
|
}
|
|
53
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Consumes a maybe async function and checks for error
|
|
60
|
+
* @param method - The function to check
|
|
61
|
+
* @param message - Optional message to match with error message
|
|
62
|
+
*/
|
|
63
|
+
export async function expectToThrowAsync(toEvaluate: () => MaybePromise<void>, message?: string): Promise<void> {
|
|
64
|
+
let err: Error | undefined = undefined;
|
|
65
|
+
try {
|
|
66
|
+
await toEvaluate();
|
|
67
|
+
} catch (error: any) {
|
|
68
|
+
err = error;
|
|
69
|
+
}
|
|
70
|
+
if (message) {
|
|
71
|
+
expect(err?.message).to.be.equal(message);
|
|
72
|
+
} else {
|
|
73
|
+
expect(err).to.be.an('Error');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
54
77
|
export function createClientSession(
|
|
55
78
|
id: string,
|
|
56
79
|
diagramType: string,
|
|
@@ -103,9 +126,7 @@ export class StubCreateEdgeOperationHandler extends GModelCreateEdgeOperationHan
|
|
|
103
126
|
}
|
|
104
127
|
|
|
105
128
|
export class StubActionDispatcher implements ActionDispatcher {
|
|
106
|
-
dispatchAfterNextUpdate(...actions: MaybeArray<Action[]>): void {
|
|
107
|
-
// NO-OP
|
|
108
|
-
}
|
|
129
|
+
dispatchAfterNextUpdate(...actions: MaybeArray<Action[]>): void {}
|
|
109
130
|
|
|
110
131
|
dispatch(action: Action): Promise<void> {
|
|
111
132
|
return Promise.resolve();
|
|
@@ -158,51 +179,31 @@ export class StubLogger extends Logger {
|
|
|
158
179
|
logLevel = LogLevel.none;
|
|
159
180
|
caller = undefined;
|
|
160
181
|
|
|
161
|
-
info(message: string, ...params: any[]): void {
|
|
162
|
-
// no-op
|
|
163
|
-
}
|
|
182
|
+
info(message: string, ...params: any[]): void {}
|
|
164
183
|
|
|
165
|
-
warn(message: string, ...params: any[]): void {
|
|
166
|
-
// no-op
|
|
167
|
-
}
|
|
184
|
+
warn(message: string, ...params: any[]): void {}
|
|
168
185
|
|
|
169
|
-
error(message: string, ...params: any[]): void {
|
|
170
|
-
// no-op
|
|
171
|
-
}
|
|
186
|
+
error(message: string, ...params: any[]): void {}
|
|
172
187
|
|
|
173
|
-
debug(message: string, ...params: any[]): void {
|
|
174
|
-
// no-op
|
|
175
|
-
}
|
|
188
|
+
debug(message: string, ...params: any[]): void {}
|
|
176
189
|
}
|
|
177
190
|
|
|
178
191
|
export class StubClientSessionListener implements ClientSessionListener {
|
|
179
|
-
sessionCreated(clientSession: ClientSession): void {
|
|
180
|
-
// no-op
|
|
181
|
-
}
|
|
192
|
+
sessionCreated(clientSession: ClientSession): void {}
|
|
182
193
|
|
|
183
|
-
sessionDisposed(clientSession: ClientSession): void {
|
|
184
|
-
// no-op
|
|
185
|
-
}
|
|
194
|
+
sessionDisposed(clientSession: ClientSession): void {}
|
|
186
195
|
}
|
|
187
196
|
|
|
188
197
|
export class StubGLSPClientProxy implements JsonRpcGLSPClientProxy {
|
|
189
|
-
connect(connection: MessageConnection): void {
|
|
190
|
-
// no-op
|
|
191
|
-
}
|
|
198
|
+
connect(connection: MessageConnection): void {}
|
|
192
199
|
|
|
193
|
-
process(message: ActionMessage<Action>): void {
|
|
194
|
-
// no-op
|
|
195
|
-
}
|
|
200
|
+
process(message: ActionMessage<Action>): void {}
|
|
196
201
|
}
|
|
197
202
|
|
|
198
203
|
export class StubGLSPServerListener implements GLSPServerListener {
|
|
199
|
-
serverInitialized(server: GLSPServer): void {
|
|
200
|
-
// no-op
|
|
201
|
-
}
|
|
204
|
+
serverInitialized(server: GLSPServer): void {}
|
|
202
205
|
|
|
203
|
-
serverShutDown(server: GLSPServer): void {
|
|
204
|
-
// no-op
|
|
205
|
-
}
|
|
206
|
+
serverShutDown(server: GLSPServer): void {}
|
|
206
207
|
}
|
|
207
208
|
|
|
208
209
|
export class StubDiagramConfiguration implements DiagramConfiguration {
|
|
@@ -250,7 +251,12 @@ export class TestContextEditValidator implements ContextEditValidator {
|
|
|
250
251
|
export const stubActionHandlerFactory: ActionHandlerFactory = constructor => new constructor();
|
|
251
252
|
|
|
252
253
|
export class StubClientSessionInitializer implements ClientSessionInitializer {
|
|
253
|
-
initialize(args?: Args): void {
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
initialize(args?: Args): void {}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export class StubCommand implements Command {
|
|
258
|
+
execute(): void {}
|
|
259
|
+
undo(): void {}
|
|
260
|
+
redo(): void {}
|
|
261
|
+
canUndo?(): boolean;
|
|
256
262
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apply-label-edit-operation-handler.spec.d.ts","sourceRoot":"","sources":["../../../src/common/gmodel/apply-label-edit-operation-handler.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/********************************************************************************
|
|
4
|
-
* Copyright (c) 2022-2023 STMicroelectronics and others.
|
|
5
|
-
*
|
|
6
|
-
* This program and the accompanying materials are made available under the
|
|
7
|
-
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
8
|
-
* http://www.eclipse.org/legal/epl-2.0.
|
|
9
|
-
*
|
|
10
|
-
* This Source Code may also be made available under the following Secondary
|
|
11
|
-
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
12
|
-
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
13
|
-
* with the GNU Classpath Exception which is available at
|
|
14
|
-
* https://www.gnu.org/software/classpath/license.html.
|
|
15
|
-
*
|
|
16
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
17
|
-
********************************************************************************/
|
|
18
|
-
const graph_1 = require("@eclipse-glsp/graph");
|
|
19
|
-
const protocol_1 = require("@eclipse-glsp/protocol");
|
|
20
|
-
const chai_1 = require("chai");
|
|
21
|
-
const sinon = require("sinon");
|
|
22
|
-
const gmodel_index_1 = require("../features/model/gmodel-index");
|
|
23
|
-
const model_state_1 = require("../features/model/model-state");
|
|
24
|
-
const apply_label_edit_operation_handler_1 = require("./apply-label-edit-operation-handler");
|
|
25
|
-
const assert = require("assert");
|
|
26
|
-
describe('Test ApplyLabelEditOperationHandler', () => {
|
|
27
|
-
const label = new graph_1.GLabel();
|
|
28
|
-
const modelState = new model_state_1.DefaultModelState();
|
|
29
|
-
Object.defineProperty(modelState, 'index', { value: new gmodel_index_1.GModelIndex() });
|
|
30
|
-
sinon.stub(modelState.index, 'findByClass').returns(label);
|
|
31
|
-
const applyLabelEditOperationHandler = new apply_label_edit_operation_handler_1.ApplyLabelEditOperationHandler();
|
|
32
|
-
Object.defineProperty(applyLabelEditOperationHandler, 'modelState', { value: modelState });
|
|
33
|
-
it('text is changed after ApplyLabelEditOperation', async () => {
|
|
34
|
-
assert.doesNotThrow(() => applyLabelEditOperationHandler.execute(protocol_1.ApplyLabelEditOperation.create({ labelId: 'myId', text: 'test' })));
|
|
35
|
-
(0, chai_1.expect)(label.text).to.be.equal('test');
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
//# sourceMappingURL=apply-label-edit-operation-handler.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apply-label-edit-operation-handler.spec.js","sourceRoot":"","sources":["../../../src/common/gmodel/apply-label-edit-operation-handler.spec.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,+CAA6C;AAC7C,qDAAiE;AACjE,+BAA8B;AAC9B,+BAA+B;AAC/B,iEAA6D;AAC7D,+DAAkE;AAClE,6FAAsF;AAEtF,iCAAkC;AAElC,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACjD,MAAM,KAAK,GAAG,IAAI,cAAM,EAAE,CAAC;IAC3B,MAAM,UAAU,GAAG,IAAI,+BAAiB,EAAE,CAAC;IAC3C,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,0BAAW,EAAE,EAAE,CAAC,CAAC;IACzE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3D,MAAM,8BAA8B,GAAG,IAAI,mEAA8B,EAAE,CAAC;IAC5E,MAAM,CAAC,cAAc,CAAC,8BAA8B,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;IAE3F,EAAE,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC3D,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CACrB,8BAA8B,CAAC,OAAO,CAAC,kCAAuB,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAC5G,CAAC;QACF,IAAA,aAAM,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"computed-bounds-action-handler.d.ts","sourceRoot":"","sources":["../../../src/common/gmodel/computed-bounds-action-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAGpF,qBACa,2BAA4B,YAAW,aAAa;IAE7D,SAAS,CAAC,iBAAiB,EAAE,sBAAsB,CAAC;IAGpD,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;IAEjC,WAAW,WAA+B;IAC1C,OAAO,CAAC,MAAM,EAAE,oBAAoB,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC;IAU7D,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,GAAG,IAAI;IAO3E,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"computed-bounds-action-handler.js","sourceRoot":"","sources":["../../../src/common/gmodel/computed-bounds-action-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgBA,qDAAoF;AACpF,yCAA+C;AAE/C,+DAA2D;AAC3D,yFAAoF;AACpF,sDAA+E;AAGxE,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAAjC;QAOH,gBAAW,GAAG,CAAC,+BAAoB,CAAC,IAAI,CAAC,CAAC;IAmB9C,CAAC;IAlBG,OAAO,CAAC,MAA4B;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QACnC,IAAI,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,EAAE;YACpC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAChC,OAAO,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,CAAC;SACvD;QAED,OAAO,EAAE,CAAC;IACd,CAAC;IAES,WAAW,CAAC,IAAgB,EAAE,MAA4B;;QAChE,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QACpC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAA,yBAAW,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAC5D,CAAC,MAAA,MAAM,CAAC,UAAU,mCAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,IAAA,4BAAc,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QACjF,CAAC,MAAA,MAAM,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAA,wBAAU,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IACrE,CAAC;CAGJ,CAAA;AAzBG;IAAC,IAAA,kBAAM,EAAC,iDAAsB,CAAC;8BACF,iDAAsB;sEAAC;AAEpD;IAAC,IAAA,kBAAM,EAAC,wBAAU,CAAC;;+DACc;AALxB,2BAA2B;IADvC,IAAA,sBAAU,GAAE;GACA,2BAA2B,CA0BvC;AA1BY,kEAA2B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cut-operation-handler.d.ts","sourceRoot":"","sources":["../../../src/common/operations/cut-operation-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,YAAY,EAA0B,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,qBACa,mBAAoB,YAAW,gBAAgB;IACxD,aAAa,SAAqB;IAGlC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAE7C,OAAO,CAAC,SAAS,EAAE,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC;IAOpD,SAAS,CAAC,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE;CAGlE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cut-operation-handler.js","sourceRoot":"","sources":["../../../src/common/operations/cut-operation-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,qDAA4F;AAC5F,yCAA+C;AAC/C,oEAAgE;AAIzD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAAzB;QACH,kBAAa,GAAG,uBAAY,CAAC,IAAI,CAAC;IAetC,CAAC;IAVG,OAAO,CAAC,SAAuB;QAC3B,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAC1D,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9B,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,iCAAsB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;SACpF;IACL,CAAC;IAES,eAAe,CAAC,YAA0B;QAChD,OAAO,YAAY,CAAC,aAAa,CAAC,kBAAkB,CAAC;IACzD,CAAC;CACJ,CAAA;AAbG;IAAC,IAAA,kBAAM,EAAC,oCAAgB,CAAC;;6DACoB;AAJpC,mBAAmB;IAD/B,IAAA,sBAAU,GAAE;GACA,mBAAmB,CAgB/B;AAhBY,kDAAmB"}
|
|
@@ -1,40 +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 { GLabel } from '@eclipse-glsp/graph';
|
|
17
|
-
import { ApplyLabelEditOperation } from '@eclipse-glsp/protocol';
|
|
18
|
-
import { expect } from 'chai';
|
|
19
|
-
import * as sinon from 'sinon';
|
|
20
|
-
import { GModelIndex } from '../features/model/gmodel-index';
|
|
21
|
-
import { DefaultModelState } from '../features/model/model-state';
|
|
22
|
-
import { ApplyLabelEditOperationHandler } from './apply-label-edit-operation-handler';
|
|
23
|
-
|
|
24
|
-
import assert = require('assert');
|
|
25
|
-
|
|
26
|
-
describe('Test ApplyLabelEditOperationHandler', () => {
|
|
27
|
-
const label = new GLabel();
|
|
28
|
-
const modelState = new DefaultModelState();
|
|
29
|
-
Object.defineProperty(modelState, 'index', { value: new GModelIndex() });
|
|
30
|
-
sinon.stub(modelState.index, 'findByClass').returns(label);
|
|
31
|
-
const applyLabelEditOperationHandler = new ApplyLabelEditOperationHandler();
|
|
32
|
-
Object.defineProperty(applyLabelEditOperationHandler, 'modelState', { value: modelState });
|
|
33
|
-
|
|
34
|
-
it('text is changed after ApplyLabelEditOperation', async () => {
|
|
35
|
-
assert.doesNotThrow(() =>
|
|
36
|
-
applyLabelEditOperationHandler.execute(ApplyLabelEditOperation.create({ labelId: 'myId', text: 'test' }))
|
|
37
|
-
);
|
|
38
|
-
expect(label.text).to.be.equal('test');
|
|
39
|
-
});
|
|
40
|
-
});
|