@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
|
@@ -1,37 +1,68 @@
|
|
|
1
|
+
import { MaybePromise } from '..';
|
|
2
|
+
import { Logger } from '../utils/logger';
|
|
1
3
|
import { Command } from './command';
|
|
2
4
|
export declare const CommandStack: unique symbol;
|
|
3
5
|
/**
|
|
4
|
-
* A
|
|
5
|
-
*
|
|
6
|
+
* A command stack keeps track of {@link Command commands} that have been executed.
|
|
7
|
+
* Executed commands can be undone in the reverse order of their original execution.
|
|
8
|
+
* Unless a new command has been executed after an undo operation, commands can be
|
|
9
|
+
* redone in the original order of their execution.
|
|
10
|
+
*
|
|
6
11
|
*/
|
|
7
12
|
export interface CommandStack {
|
|
8
13
|
/**
|
|
9
|
-
* Clears any redoable commands not yet redone, adds the command
|
|
14
|
+
* Clears any redoable commands not yet redone, adds the command to the stack and then invokes {@link Command.execute}.
|
|
10
15
|
* @param command the command to execute.
|
|
11
16
|
*/
|
|
12
|
-
execute(command: Command): void
|
|
17
|
+
execute(command: Command): MaybePromise<void>;
|
|
13
18
|
/**
|
|
14
|
-
*
|
|
19
|
+
* Removes the topmost (i.e. last executed) command from the stack and invokes {@link Command.undo}.
|
|
15
20
|
*/
|
|
16
|
-
undo(): void
|
|
21
|
+
undo(): MaybePromise<void>;
|
|
17
22
|
/**
|
|
18
|
-
*
|
|
23
|
+
* Returns `true` if the top command on the stack can be undone.
|
|
19
24
|
*/
|
|
20
|
-
|
|
25
|
+
canUndo(): boolean;
|
|
21
26
|
/**
|
|
22
|
-
*
|
|
27
|
+
* Re-adds the last undo command on top of the stack and invokes {@link Command.redo}
|
|
23
28
|
*/
|
|
24
|
-
|
|
29
|
+
redo(): MaybePromise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns `true` if there are redoable commands in the stack.
|
|
32
|
+
*/
|
|
33
|
+
canRedo(): boolean;
|
|
25
34
|
/**
|
|
26
35
|
* Called after a save has been successfully performed.
|
|
27
36
|
*/
|
|
28
37
|
saveIsDone(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Indicates wether the command stack has unsaved changes.
|
|
40
|
+
*/
|
|
41
|
+
readonly isDirty: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Disposes all the commands in the stack.
|
|
44
|
+
*/
|
|
45
|
+
flush(): void;
|
|
29
46
|
}
|
|
30
47
|
export declare class DefaultCommandStack implements CommandStack {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
protected logger: Logger;
|
|
49
|
+
protected commands: Command[];
|
|
50
|
+
/**
|
|
51
|
+
* The current position within the command list from which the next execute, undo, or redo, will be performed.
|
|
52
|
+
*/
|
|
53
|
+
protected top: number;
|
|
54
|
+
/**
|
|
55
|
+
* The current position within the command list when {@link DefaultCommandStack.saveIsDone} is called.
|
|
56
|
+
*/
|
|
57
|
+
protected saveIndex: number;
|
|
58
|
+
execute(command: Command): Promise<void>;
|
|
59
|
+
undo(): Promise<void>;
|
|
60
|
+
canUndo(): boolean;
|
|
61
|
+
redo(): Promise<void>;
|
|
62
|
+
canRedo(): boolean;
|
|
63
|
+
get isDirty(): boolean;
|
|
35
64
|
saveIsDone(): void;
|
|
65
|
+
flush(): void;
|
|
66
|
+
protected handleError(error: any): never;
|
|
36
67
|
}
|
|
37
68
|
//# sourceMappingURL=command-stack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-stack.d.ts","sourceRoot":"","sources":["../../../src/common/command/command-stack.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,eAAO,MAAM,YAAY,eAAyB,CAAC;AA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AI,IAAI;IAIlB,KAAK,IAAI,IAAI;IAMb,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK;CAM3C"}
|
|
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.DefaultCommandStack = exports.CommandStack = void 0;
|
|
10
13
|
/********************************************************************************
|
|
@@ -23,24 +26,90 @@ exports.DefaultCommandStack = exports.CommandStack = void 0;
|
|
|
23
26
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
24
27
|
********************************************************************************/
|
|
25
28
|
const inversify_1 = require("inversify");
|
|
29
|
+
const logger_1 = require("../utils/logger");
|
|
30
|
+
const command_1 = require("./command");
|
|
26
31
|
exports.CommandStack = Symbol('CommandStack');
|
|
27
32
|
let DefaultCommandStack = class DefaultCommandStack {
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
constructor() {
|
|
34
|
+
this.commands = [];
|
|
35
|
+
/**
|
|
36
|
+
* The current position within the command list from which the next execute, undo, or redo, will be performed.
|
|
37
|
+
*/
|
|
38
|
+
this.top = -1;
|
|
39
|
+
/**
|
|
40
|
+
* The current position within the command list when {@link DefaultCommandStack.saveIsDone} is called.
|
|
41
|
+
*/
|
|
42
|
+
this.saveIndex = -1;
|
|
43
|
+
}
|
|
44
|
+
async execute(command) {
|
|
45
|
+
try {
|
|
46
|
+
await command.execute();
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
this.handleError(error);
|
|
50
|
+
}
|
|
51
|
+
// Clear the command list past the top (i.e. the old redo list)
|
|
52
|
+
this.commands = this.commands.slice(0, this.top + 1);
|
|
53
|
+
this.commands.push(command);
|
|
54
|
+
++this.top;
|
|
55
|
+
// if the saveIndex points to the old redo list we can never reach a state again
|
|
56
|
+
// where save is not necessary. => ensure that `isDirty` always returns true
|
|
57
|
+
if (this.saveIndex >= this.top) {
|
|
58
|
+
this.saveIndex = -2;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async undo() {
|
|
62
|
+
if (this.canUndo()) {
|
|
63
|
+
const command = this.commands[this.top--];
|
|
64
|
+
try {
|
|
65
|
+
await command.undo();
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
this.handleError(error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
30
71
|
}
|
|
31
|
-
|
|
32
|
-
|
|
72
|
+
canUndo() {
|
|
73
|
+
return this.top !== -1 //
|
|
74
|
+
? command_1.Command.canUndo(this.commands[this.top])
|
|
75
|
+
: false;
|
|
33
76
|
}
|
|
34
|
-
redo() {
|
|
35
|
-
|
|
77
|
+
async redo() {
|
|
78
|
+
if (this.canRedo()) {
|
|
79
|
+
const command = this.commands[++this.top];
|
|
80
|
+
try {
|
|
81
|
+
await command.redo();
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
this.handleError(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
36
87
|
}
|
|
37
|
-
|
|
38
|
-
return
|
|
88
|
+
canRedo() {
|
|
89
|
+
return this.top < this.commands.length - 1;
|
|
90
|
+
}
|
|
91
|
+
get isDirty() {
|
|
92
|
+
return this.saveIndex !== this.top;
|
|
39
93
|
}
|
|
40
94
|
saveIsDone() {
|
|
41
|
-
|
|
95
|
+
this.saveIndex = this.top;
|
|
96
|
+
}
|
|
97
|
+
flush() {
|
|
98
|
+
this.commands = [];
|
|
99
|
+
this.top = -1;
|
|
100
|
+
this.saveIndex = -1;
|
|
101
|
+
}
|
|
102
|
+
handleError(error) {
|
|
103
|
+
// if an error occurred during the command execution the stack might be in an erroneous state => we have to flush the command stack
|
|
104
|
+
this.flush();
|
|
105
|
+
this.logger.error('An error occurred during command execution. CommandStack will be flushed!', error);
|
|
106
|
+
throw error;
|
|
42
107
|
}
|
|
43
108
|
};
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, inversify_1.inject)(logger_1.Logger),
|
|
111
|
+
__metadata("design:type", logger_1.Logger)
|
|
112
|
+
], DefaultCommandStack.prototype, "logger", void 0);
|
|
44
113
|
DefaultCommandStack = __decorate([
|
|
45
114
|
(0, inversify_1.injectable)()
|
|
46
115
|
], DefaultCommandStack);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-stack.js","sourceRoot":"","sources":["../../../src/common/command/command-stack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-stack.js","sourceRoot":"","sources":["../../../src/common/command/command-stack.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,yCAA+C;AAE/C,4CAAyC;AACzC,uCAAoC;AAEvB,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAqD5C,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAAzB;QAIO,aAAQ,GAAc,EAAE,CAAC;QAEnC;;WAEG;QACO,QAAG,GAAG,CAAC,CAAC,CAAC;QAEnB;;WAEG;QACO,cAAS,GAAG,CAAC,CAAC,CAAC;IAwE7B,CAAC;IAtEG,KAAK,CAAC,OAAO,CAAC,OAAgB;QAC1B,IAAI;YACA,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;SAC3B;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;SAC3B;QACD,+DAA+D;QAC/D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,Q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MAAM,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,GAAG,CAAC;IACvC,CAAC;IAED,UAAU;QACN,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC;IAC9B,CAAC;IAED,KAAK;QACD,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACd,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IACxB,CAAC;IAES,WAAW,CAAC,KAAU;QAC5B,mIAAmI;QACnI,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2EAA2E,EAAE,KAAK,CAAC,CAAC;QACtG,MAAM,KAAK,CAAC;IAChB,CAAC;CACJ,CAAA;AArFG;IAAC,IAAA,kBAAM,EAAC,eAAM,CAAC;8BACG,eAAM;mDAAC;AAFhB,mBAAmB;IAD/B,IAAA,sBAAU,GAAE;GACA,mBAAmB,CAsF/B;AAtFY,kDAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-stack.spec.d.ts","sourceRoot":"","sources":["../../../src/common/command/command-stack.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/********************************************************************************
|
|
4
|
+
* Copyright (c) 2023 EclipseSource 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 chai_1 = require("chai");
|
|
19
|
+
const inversify_1 = require("inversify");
|
|
20
|
+
const sinon = require("sinon");
|
|
21
|
+
const mock_util_1 = require("../test/mock-util");
|
|
22
|
+
const logger_1 = require("../utils/logger");
|
|
23
|
+
const command_stack_1 = require("./command-stack");
|
|
24
|
+
describe('test DefaultCommandStack', () => {
|
|
25
|
+
const sandbox = sinon.createSandbox();
|
|
26
|
+
const container = new inversify_1.Container();
|
|
27
|
+
const command1 = sandbox.stub(new mock_util_1.StubCommand());
|
|
28
|
+
const command2 = sandbox.stub(new mock_util_1.StubCommand());
|
|
29
|
+
let commandStack;
|
|
30
|
+
container.load(new inversify_1.ContainerModule(bind => {
|
|
31
|
+
bind(logger_1.Logger).toConstantValue(new mock_util_1.StubLogger());
|
|
32
|
+
}));
|
|
33
|
+
commandStack = container.resolve(command_stack_1.DefaultCommandStack);
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
sandbox.reset();
|
|
36
|
+
commandStack = container.resolve(command_stack_1.DefaultCommandStack);
|
|
37
|
+
});
|
|
38
|
+
describe('execute', () => {
|
|
39
|
+
it('should execute the given command and become dirty', async () => {
|
|
40
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
41
|
+
await commandStack.execute(command1);
|
|
42
|
+
(0, chai_1.expect)(command1.execute.calledOnce).to.be.true;
|
|
43
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.true;
|
|
44
|
+
});
|
|
45
|
+
it('should execute the given commands in order and become dirty', async () => {
|
|
46
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
47
|
+
await commandStack.execute(command1);
|
|
48
|
+
await commandStack.execute(command2);
|
|
49
|
+
(0, chai_1.expect)(command1.execute.calledOnce).to.be.true;
|
|
50
|
+
(0, chai_1.expect)(command2.execute.calledOnce).to.be.true;
|
|
51
|
+
(0, chai_1.expect)(command2.execute.calledAfter(command1.execute)).to.be.true;
|
|
52
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.true;
|
|
53
|
+
});
|
|
54
|
+
it('should be able to undo after execute', async () => {
|
|
55
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.false;
|
|
56
|
+
await commandStack.execute(command1);
|
|
57
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.true;
|
|
58
|
+
});
|
|
59
|
+
it('should clear the redo stack after execution', async () => {
|
|
60
|
+
commandStack['commands'].push(command2);
|
|
61
|
+
commandStack['top'] = -1;
|
|
62
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.true;
|
|
63
|
+
await commandStack.execute(command1);
|
|
64
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.false;
|
|
65
|
+
});
|
|
66
|
+
it('should flush the stack in case of an execution error', async () => {
|
|
67
|
+
command2.execute.throwsException();
|
|
68
|
+
const flushSpy = sandbox.spy(commandStack, 'flush');
|
|
69
|
+
await (0, mock_util_1.expectToThrowAsync)(() => commandStack.execute(command2));
|
|
70
|
+
(0, chai_1.expect)(command2.execute.calledOnce).to.be.true;
|
|
71
|
+
(0, chai_1.expect)(flushSpy.calledOnce).to.be.true;
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('undo', () => {
|
|
75
|
+
it('should do nothing if the command stack is empty', async () => {
|
|
76
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
77
|
+
await commandStack.undo();
|
|
78
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.false;
|
|
79
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.false;
|
|
80
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
81
|
+
});
|
|
82
|
+
it('should undo the command and become non-dirty again', async () => {
|
|
83
|
+
commandStack['commands'].push(command1);
|
|
84
|
+
commandStack['top'] = 0;
|
|
85
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.true;
|
|
86
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.true;
|
|
87
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.false;
|
|
88
|
+
await commandStack.undo();
|
|
89
|
+
(0, chai_1.expect)(command1.undo.calledOnce).to.be.true;
|
|
90
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
91
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.true;
|
|
92
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.false;
|
|
93
|
+
});
|
|
94
|
+
it('should undo multiple command and become non-dirty again', async () => {
|
|
95
|
+
commandStack['commands'].push(command1, command2);
|
|
96
|
+
commandStack['top'] = 1;
|
|
97
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.true;
|
|
98
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.true;
|
|
99
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.false;
|
|
100
|
+
await commandStack.undo();
|
|
101
|
+
(0, chai_1.expect)(command2.undo.calledOnce).to.be.true;
|
|
102
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.true;
|
|
103
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.true;
|
|
104
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.true;
|
|
105
|
+
await commandStack.undo();
|
|
106
|
+
(0, chai_1.expect)(command1.undo.calledOnce).to.be.true;
|
|
107
|
+
(0, chai_1.expect)(command1.undo.calledAfter(command2.undo)).to.be.true;
|
|
108
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
109
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.true;
|
|
110
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.false;
|
|
111
|
+
});
|
|
112
|
+
it('should flush the stack in case of an execution error', async () => {
|
|
113
|
+
command2.undo.throwsException();
|
|
114
|
+
const flushSpy = sandbox.spy(commandStack, 'flush');
|
|
115
|
+
commandStack['commands'].push(command2);
|
|
116
|
+
commandStack['top'] = 0;
|
|
117
|
+
await (0, mock_util_1.expectToThrowAsync)(() => commandStack.undo());
|
|
118
|
+
(0, chai_1.expect)(command2.undo.calledOnce).to.be.true;
|
|
119
|
+
(0, chai_1.expect)(flushSpy.calledOnce).to.be.true;
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
describe('redo', () => {
|
|
123
|
+
it('should do nothing if the command stack is empty', async () => {
|
|
124
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
125
|
+
await commandStack.redo();
|
|
126
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.false;
|
|
127
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.false;
|
|
128
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
129
|
+
});
|
|
130
|
+
it('should redo the command and become dirty again', async () => {
|
|
131
|
+
commandStack['commands'].push(command1);
|
|
132
|
+
commandStack['top'] = -1;
|
|
133
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
134
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.false;
|
|
135
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.true;
|
|
136
|
+
await commandStack.redo();
|
|
137
|
+
(0, chai_1.expect)(command1.redo.calledOnce).to.be.true;
|
|
138
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.true;
|
|
139
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.false;
|
|
140
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.true;
|
|
141
|
+
});
|
|
142
|
+
it('should undo multiple command and become non-dirty again', async () => {
|
|
143
|
+
commandStack['commands'].push(command2, command1);
|
|
144
|
+
commandStack['top'] = -1;
|
|
145
|
+
commandStack['saveIndex'] = -1;
|
|
146
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
147
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.false;
|
|
148
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.true;
|
|
149
|
+
await commandStack.redo();
|
|
150
|
+
(0, chai_1.expect)(command2.redo.calledOnce).to.be.true;
|
|
151
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.true;
|
|
152
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.true;
|
|
153
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.true;
|
|
154
|
+
await commandStack.redo();
|
|
155
|
+
(0, chai_1.expect)(command1.redo.calledOnce).to.be.true;
|
|
156
|
+
(0, chai_1.expect)(command1.redo.calledAfter(command2.redo)).to.be.true;
|
|
157
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.true;
|
|
158
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.false;
|
|
159
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.true;
|
|
160
|
+
});
|
|
161
|
+
it('should flush the stack in case of an execution error', async () => {
|
|
162
|
+
command2.redo.throwsException();
|
|
163
|
+
const flushSpy = sandbox.spy(commandStack, 'flush');
|
|
164
|
+
commandStack['commands'].push(command2);
|
|
165
|
+
commandStack['top'] = -1;
|
|
166
|
+
await (0, mock_util_1.expectToThrowAsync)(() => commandStack.redo());
|
|
167
|
+
(0, chai_1.expect)(command2.redo.calledOnce).to.be.true;
|
|
168
|
+
(0, chai_1.expect)(flushSpy.calledOnce).to.be.true;
|
|
169
|
+
});
|
|
170
|
+
it('should be able to undo after redo', async () => {
|
|
171
|
+
commandStack['commands'].push(command1);
|
|
172
|
+
commandStack['top'] = -1;
|
|
173
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.false;
|
|
174
|
+
await commandStack.redo();
|
|
175
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.true;
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
describe('flush', () => {
|
|
179
|
+
it('should reset the internal state of the command stack', () => {
|
|
180
|
+
commandStack['commands'].push(command1, command1);
|
|
181
|
+
commandStack['top'] = 0;
|
|
182
|
+
commandStack.flush();
|
|
183
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
184
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.false;
|
|
185
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.false;
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
describe('isSaveDone', () => {
|
|
189
|
+
it('should become non-dirty after execution', () => {
|
|
190
|
+
commandStack['commands'].push(command1);
|
|
191
|
+
commandStack['top'] = 0;
|
|
192
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.true;
|
|
193
|
+
commandStack.saveIsDone();
|
|
194
|
+
(0, chai_1.expect)(commandStack.isDirty).to.be.false;
|
|
195
|
+
});
|
|
196
|
+
it('should maintain undo/redo history after execution', () => {
|
|
197
|
+
commandStack['commands'].push(command1, command2);
|
|
198
|
+
commandStack['top'] = 0;
|
|
199
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.true;
|
|
200
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.true;
|
|
201
|
+
commandStack.saveIsDone();
|
|
202
|
+
(0, chai_1.expect)(commandStack.canUndo()).to.be.true;
|
|
203
|
+
(0, chai_1.expect)(commandStack.canRedo()).to.be.true;
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
//# sourceMappingURL=command-stack.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-stack.spec.js","sourceRoot":"","sources":["../../../src/common/command/command-stack.spec.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,+BAA8B;AAC9B,yCAAuD;AACvD,+BAA+B;AAC/B,iDAAgF;AAChF,4CAAyC;AACzC,mDAAsD;AAEtD,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,EAAE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AE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAC9C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -13,25 +13,52 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
import { MaybePromise } from '@eclipse-glsp/protocol';
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
18
|
+
* A command implements a specific modification of the source model, which can be applied by invoking `execute()`.
|
|
19
|
+
* Commands may also provide implementations to `undo()` and `redo()` the effect they had.
|
|
20
|
+
* To maintain an order in which commands can be undone and redone, they are managed in the context of a {@link CommandStack}.
|
|
21
|
+
*
|
|
22
|
+
* Each command is self contained and stores all the information it needs to execute, undo or redo itself.
|
|
23
|
+
*
|
|
24
|
+
* In theory commands can be used to execute arbitrary activities and not only modify the source model.
|
|
25
|
+
* However, it is mostly used to record and manage changes made to the source model via GLSP operations.
|
|
19
26
|
*/
|
|
20
27
|
export interface Command {
|
|
21
28
|
/**
|
|
22
|
-
* Performs the command activity required for the effect.
|
|
29
|
+
* Performs the command activity required for the effect (e.g. source model change).
|
|
23
30
|
*/
|
|
24
|
-
execute(): void
|
|
31
|
+
execute(): MaybePromise<void>;
|
|
25
32
|
/**
|
|
26
33
|
* Performs the command activity required to `undo` the effects of a preceding `execute` (or `redo`).
|
|
27
34
|
* The effect, if any, of calling `undo` before `execute` or `redo` have been called, is undefined.
|
|
28
35
|
*/
|
|
29
|
-
undo(): void
|
|
36
|
+
undo(): MaybePromise<void>;
|
|
30
37
|
/**
|
|
31
38
|
* Performs the command activity required to `redo` the effect after undoing the effect.
|
|
32
39
|
* The effect, if any, of calling `redo` before `undo` is called is undefined.
|
|
33
|
-
* Note that if you implement `redo` to call `execute` then any derived class will be restricted by that decision also.
|
|
34
40
|
*/
|
|
35
|
-
redo(): void
|
|
41
|
+
redo(): MaybePromise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns whether the command can be undone.
|
|
44
|
+
* This function is optional. If not implemented, it is assumed that the command can be undone.
|
|
45
|
+
* @returns whether the command can be undone
|
|
46
|
+
*/
|
|
47
|
+
canUndo?(): boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare namespace Command {
|
|
50
|
+
function canUndo(command: Command): boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A command that comprises a sequence of subcommands.
|
|
54
|
+
*/
|
|
55
|
+
export declare class CompoundCommand implements Command {
|
|
56
|
+
protected readonly commands: Command[];
|
|
57
|
+
constructor(commands: Command[]);
|
|
58
|
+
constructor(...commands: Command[]);
|
|
59
|
+
execute(): Promise<void>;
|
|
60
|
+
undo(): Promise<void>;
|
|
61
|
+
redo(): Promise<void>;
|
|
62
|
+
canUndo(): boolean;
|
|
36
63
|
}
|
|
37
64
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/common/command/command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/common/command/command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAwB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE5E;;;;;;;;;GASG;AACH,MAAM,WAAW,OAAO;IACpB;;OAEG;IACH,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAE9B;;;OAGG;IACH,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAE3B;;;OAGG;IACH,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAE3B;;;;OAIG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC;CACvB;AAED,yBAAiB,OAAO,CAAC;IACrB,SAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEjD;CACJ;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,OAAO;IAC3C,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;gBAE3B,QAAQ,EAAE,OAAO,EAAE;gBACnB,GAAG,QAAQ,EAAE,OAAO,EAAE;IAM5B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBxB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAerB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB3B,OAAO,IAAI,OAAO;CAGrB"}
|
|
@@ -15,4 +15,77 @@
|
|
|
15
15
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
16
|
********************************************************************************/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.CompoundCommand = exports.Command = void 0;
|
|
19
|
+
const protocol_1 = require("@eclipse-glsp/protocol");
|
|
20
|
+
var Command;
|
|
21
|
+
(function (Command) {
|
|
22
|
+
function canUndo(command) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
return (_b = (_a = command.canUndo) === null || _a === void 0 ? void 0 : _a.call(command)) !== null && _b !== void 0 ? _b : true;
|
|
25
|
+
}
|
|
26
|
+
Command.canUndo = canUndo;
|
|
27
|
+
})(Command = exports.Command || (exports.Command = {}));
|
|
28
|
+
/**
|
|
29
|
+
* A command that comprises a sequence of subcommands.
|
|
30
|
+
*/
|
|
31
|
+
class CompoundCommand {
|
|
32
|
+
constructor(...commands) {
|
|
33
|
+
this.commands = [];
|
|
34
|
+
(0, protocol_1.flatPush)(this.commands, commands);
|
|
35
|
+
}
|
|
36
|
+
async execute() {
|
|
37
|
+
const alreadyExecuted = [];
|
|
38
|
+
try {
|
|
39
|
+
for (const command of this.commands) {
|
|
40
|
+
await command.execute();
|
|
41
|
+
alreadyExecuted.unshift(command);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
for (const command of alreadyExecuted) {
|
|
46
|
+
if (Command.canUndo(command)) {
|
|
47
|
+
await command.undo();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async undo() {
|
|
57
|
+
const alreadyUndone = [];
|
|
58
|
+
try {
|
|
59
|
+
for (const command of [...this.commands].reverse()) {
|
|
60
|
+
await command.undo();
|
|
61
|
+
alreadyUndone.unshift(command);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
for (const command of alreadyUndone) {
|
|
66
|
+
await command.redo();
|
|
67
|
+
}
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async redo() {
|
|
72
|
+
const alreadyRedone = [];
|
|
73
|
+
try {
|
|
74
|
+
for (const command of this.commands) {
|
|
75
|
+
await command.redo();
|
|
76
|
+
alreadyRedone.unshift(command);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
for (const command of alreadyRedone) {
|
|
81
|
+
await command.undo();
|
|
82
|
+
}
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
canUndo() {
|
|
87
|
+
return this.commands.every(Command.canUndo);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.CompoundCommand = CompoundCommand;
|
|
18
91
|
//# sourceMappingURL=command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/common/command/command.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF"}
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/common/command/command.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;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AAO,IAAI,aAAa,EAAE;gBACjC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;aACxB;YACD,MAAM,GAAG,CAAC;SACb;IACL,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,aAAa,GAAc,EAAE,CAAC;QAEpC,IAAI;YACA,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACjC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;gBACrB,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aAClC;SACJ;QAAC,OAAO,GAAG,EAAE;YACV,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE;gBACjC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;aACxB;YACD,MAAM,GAAG,CAAC;SACb;IACL,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;CACJ;AAhED,0CAgEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.spec.d.ts","sourceRoot":"","sources":["../../../src/common/command/command.spec.ts"],"names":[],"mappings":""}
|