@theia/test 1.45.0 → 1.46.0-next.72
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/browser/constants.d.ts +45 -45
- package/lib/browser/constants.js +17 -17
- package/lib/browser/test-service.d.ts +154 -154
- package/lib/browser/test-service.js +247 -247
- package/lib/browser/view/test-context-key-service.d.ts +7 -7
- package/lib/browser/view/test-context-key-service.js +51 -51
- package/lib/browser/view/test-execution-state-manager.d.ts +13 -13
- package/lib/browser/view/test-execution-state-manager.js +173 -173
- package/lib/browser/view/test-output-ui-model.d.ts +47 -47
- package/lib/browser/view/test-output-ui-model.js +151 -151
- package/lib/browser/view/test-output-view-contribution.d.ts +5 -5
- package/lib/browser/view/test-output-view-contribution.js +47 -47
- package/lib/browser/view/test-output-widget.d.ts +24 -24
- package/lib/browser/view/test-output-widget.js +158 -158
- package/lib/browser/view/test-result-view-contribution.d.ts +5 -5
- package/lib/browser/view/test-result-view-contribution.js +47 -47
- package/lib/browser/view/test-result-widget.d.ts +20 -20
- package/lib/browser/view/test-result-widget.js +108 -108
- package/lib/browser/view/test-run-view-contribution.d.ts +17 -17
- package/lib/browser/view/test-run-view-contribution.js +100 -100
- package/lib/browser/view/test-run-widget.d.ts +58 -58
- package/lib/browser/view/test-run-widget.js +310 -310
- package/lib/browser/view/test-tree-widget.d.ts +67 -67
- package/lib/browser/view/test-tree-widget.js +386 -386
- package/lib/browser/view/test-view-contribution.d.ts +45 -45
- package/lib/browser/view/test-view-contribution.js +288 -288
- package/lib/browser/view/test-view-frontend-module.d.ts +6 -6
- package/lib/browser/view/test-view-frontend-module.js +121 -121
- package/lib/common/collections.d.ts +46 -46
- package/lib/common/collections.js +210 -210
- package/lib/common/tree-delta.d.ts +51 -51
- package/lib/common/tree-delta.js +240 -240
- package/lib/common/tree-delta.spec.d.ts +1 -1
- package/lib/common/tree-delta.spec.js +139 -139
- package/package.json +8 -8
- package/src/browser/constants.ts +71 -71
- package/src/browser/style/index.css +41 -41
- package/src/browser/test-service.ts +355 -355
- package/src/browser/view/test-context-key-service.ts +36 -36
- package/src/browser/view/test-execution-state-manager.ts +147 -147
- package/src/browser/view/test-output-ui-model.ts +156 -156
- package/src/browser/view/test-output-view-contribution.ts +34 -34
- package/src/browser/view/test-output-widget.ts +148 -148
- package/src/browser/view/test-result-view-contribution.ts +34 -34
- package/src/browser/view/test-result-widget.ts +92 -92
- package/src/browser/view/test-run-view-contribution.ts +89 -89
- package/src/browser/view/test-run-widget.tsx +271 -271
- package/src/browser/view/test-tree-widget.tsx +360 -360
- package/src/browser/view/test-view-contribution.ts +300 -300
- package/src/browser/view/test-view-frontend-module.ts +134 -134
- package/src/common/collections.ts +223 -223
- package/src/common/tree-delta.spec.ts +166 -166
- package/src/common/tree-delta.ts +259 -259
package/lib/common/tree-delta.js
CHANGED
|
@@ -1,241 +1,241 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2022 STMicroelectronics and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.AccumulatingTreeDeltaEmitter = exports.TreeDeltaBuilderImpl = exports.MappingTreeDeltaBuilder = exports.DeltaKind = void 0;
|
|
19
|
-
const core_1 = require("@theia/core");
|
|
20
|
-
const collections_1 = require("./collections");
|
|
21
|
-
var DeltaKind;
|
|
22
|
-
(function (DeltaKind) {
|
|
23
|
-
DeltaKind[DeltaKind["NONE"] = 0] = "NONE";
|
|
24
|
-
DeltaKind[DeltaKind["ADDED"] = 1] = "ADDED";
|
|
25
|
-
DeltaKind[DeltaKind["REMOVED"] = 2] = "REMOVED";
|
|
26
|
-
DeltaKind[DeltaKind["CHANGED"] = 3] = "CHANGED";
|
|
27
|
-
})(DeltaKind = exports.DeltaKind || (exports.DeltaKind = {}));
|
|
28
|
-
class MappingTreeDeltaBuilder {
|
|
29
|
-
constructor(wrapped, map, mapPartial) {
|
|
30
|
-
this.wrapped = wrapped;
|
|
31
|
-
this.map = map;
|
|
32
|
-
this.mapPartial = mapPartial;
|
|
33
|
-
}
|
|
34
|
-
reportAdded(path, added) {
|
|
35
|
-
this.wrapped.reportAdded(path, this.map(added));
|
|
36
|
-
}
|
|
37
|
-
reportRemoved(path) {
|
|
38
|
-
this.wrapped.reportRemoved(path);
|
|
39
|
-
}
|
|
40
|
-
reportChanged(path, change) {
|
|
41
|
-
this.wrapped.reportChanged(path, this.mapPartial(change));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.MappingTreeDeltaBuilder = MappingTreeDeltaBuilder;
|
|
45
|
-
class TreeDeltaBuilderImpl {
|
|
46
|
-
constructor() {
|
|
47
|
-
this._currentDelta = [];
|
|
48
|
-
}
|
|
49
|
-
get currentDelta() {
|
|
50
|
-
return this._currentDelta;
|
|
51
|
-
}
|
|
52
|
-
reportAdded(path, added) {
|
|
53
|
-
this.findNode(path, (parentCollection, nodeIndex, residual) => {
|
|
54
|
-
if (residual.length === 0) {
|
|
55
|
-
// we matched an exact node
|
|
56
|
-
const child = parentCollection[nodeIndex];
|
|
57
|
-
if (child.type === DeltaKind.REMOVED) {
|
|
58
|
-
child.type = DeltaKind.CHANGED;
|
|
59
|
-
}
|
|
60
|
-
else if (child.type === DeltaKind.NONE) {
|
|
61
|
-
child.type = DeltaKind.ADDED;
|
|
62
|
-
}
|
|
63
|
-
child.value = added;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this.insert(parentCollection, nodeIndex, {
|
|
67
|
-
path: residual,
|
|
68
|
-
type: DeltaKind.ADDED,
|
|
69
|
-
value: added,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
reportRemoved(path) {
|
|
75
|
-
this.findNode(path, (parentCollection, nodeIndex, residual) => {
|
|
76
|
-
if (residual.length === 0) {
|
|
77
|
-
// we matched an exact node
|
|
78
|
-
const child = parentCollection[nodeIndex];
|
|
79
|
-
if (child.type === DeltaKind.CHANGED) {
|
|
80
|
-
child.type = DeltaKind.REMOVED;
|
|
81
|
-
delete child.value;
|
|
82
|
-
}
|
|
83
|
-
else if (child.type === DeltaKind.ADDED) {
|
|
84
|
-
parentCollection.splice(nodeIndex, 1);
|
|
85
|
-
}
|
|
86
|
-
else if (child.type === DeltaKind.NONE) {
|
|
87
|
-
child.type = DeltaKind.REMOVED;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
this.insert(parentCollection, nodeIndex, {
|
|
92
|
-
path: residual,
|
|
93
|
-
type: DeltaKind.REMOVED,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
reportChanged(path, change) {
|
|
99
|
-
this.findNode(path, (parentCollection, nodeIndex, residual) => {
|
|
100
|
-
if (residual.length === 0) {
|
|
101
|
-
// we matched an exact node
|
|
102
|
-
const child = parentCollection[nodeIndex];
|
|
103
|
-
if (child.type === DeltaKind.NONE) {
|
|
104
|
-
child.type = DeltaKind.CHANGED;
|
|
105
|
-
child.value = change;
|
|
106
|
-
}
|
|
107
|
-
else if (child.type === DeltaKind.CHANGED) {
|
|
108
|
-
Object.assign(child.value, change);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
this.insert(parentCollection, nodeIndex, {
|
|
113
|
-
path: residual,
|
|
114
|
-
type: DeltaKind.CHANGED,
|
|
115
|
-
value: change,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
insert(parentCollection, nodeIndex, delta) {
|
|
121
|
-
if (nodeIndex < 0) {
|
|
122
|
-
parentCollection.push(delta);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
const child = parentCollection[nodeIndex];
|
|
126
|
-
const prefixLength = computePrefixLength(delta.path, child.path);
|
|
127
|
-
if (prefixLength === delta.path.length) {
|
|
128
|
-
child.path = child.path.slice(prefixLength);
|
|
129
|
-
delta.childDeltas = [child];
|
|
130
|
-
parentCollection[nodeIndex] = delta;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
const newNode = {
|
|
134
|
-
path: child.path.slice(0, prefixLength),
|
|
135
|
-
type: DeltaKind.NONE,
|
|
136
|
-
childDeltas: []
|
|
137
|
-
};
|
|
138
|
-
parentCollection[nodeIndex] = newNode;
|
|
139
|
-
delta.path = delta.path.slice(prefixLength);
|
|
140
|
-
newNode.childDeltas.push(delta);
|
|
141
|
-
child.path = child.path.slice(prefixLength);
|
|
142
|
-
newNode.childDeltas.push(child);
|
|
143
|
-
if (newNode.path.length === 0) {
|
|
144
|
-
console.log('newNode');
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (delta.path.length === 0) {
|
|
148
|
-
console.log('delta');
|
|
149
|
-
}
|
|
150
|
-
if (child.path.length === 0) {
|
|
151
|
-
console.log('child');
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
findNode(path, handler) {
|
|
156
|
-
doFindNode(this._currentDelta, path, handler);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
exports.TreeDeltaBuilderImpl = TreeDeltaBuilderImpl;
|
|
160
|
-
function doFindNode(rootCollection, path, handler) {
|
|
161
|
-
// handler parameters:
|
|
162
|
-
// parent collection: the collection the node index refers to, if valid
|
|
163
|
-
// nodeIndex: the index of the node that has a common path prefix with the path of the path we're searching
|
|
164
|
-
// residual path: the path that has not been consumed looking for the path: if empty, we found the exact node
|
|
165
|
-
let commonPrefixLength = 0;
|
|
166
|
-
const childIndex = rootCollection.findIndex(delta => {
|
|
167
|
-
commonPrefixLength = computePrefixLength(delta.path, path);
|
|
168
|
-
return commonPrefixLength > 0;
|
|
169
|
-
});
|
|
170
|
-
if (childIndex >= 0) {
|
|
171
|
-
// we know which child to insert into
|
|
172
|
-
const child = rootCollection[childIndex];
|
|
173
|
-
if (commonPrefixLength === child.path.length) {
|
|
174
|
-
// we matched a child
|
|
175
|
-
if (commonPrefixLength === path.length) {
|
|
176
|
-
// it's an exact match: we already have a node for the given path
|
|
177
|
-
handler(rootCollection, childIndex, []);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
// we know the node is below the child
|
|
181
|
-
if (child.type === DeltaKind.REMOVED || child.type === DeltaKind.ADDED) {
|
|
182
|
-
// there will be no children deltas beneath added/remove nodes
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (!child.childDeltas) {
|
|
186
|
-
child.childDeltas = [];
|
|
187
|
-
}
|
|
188
|
-
doFindNode(child.childDeltas, path.slice(child.path.length), handler);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
handler(rootCollection, childIndex, path);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
// we have no node to insert into
|
|
196
|
-
handler(rootCollection, -1, path);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function computePrefixLength(left, right) {
|
|
200
|
-
let i = 0;
|
|
201
|
-
while (i < left.length && i < right.length && left[i] === right[i]) {
|
|
202
|
-
i++;
|
|
203
|
-
}
|
|
204
|
-
return i;
|
|
205
|
-
}
|
|
206
|
-
class AccumulatingTreeDeltaEmitter extends TreeDeltaBuilderImpl {
|
|
207
|
-
constructor(timeoutMillis) {
|
|
208
|
-
super();
|
|
209
|
-
this.onDidFlushEmitter = new core_1.Emitter();
|
|
210
|
-
this.onDidFlush = this.onDidFlushEmitter.event;
|
|
211
|
-
this.batcher = new collections_1.ChangeBatcher(() => this.doEmitDelta(), timeoutMillis);
|
|
212
|
-
}
|
|
213
|
-
flush() {
|
|
214
|
-
this.batcher.flush();
|
|
215
|
-
}
|
|
216
|
-
doEmitDelta() {
|
|
217
|
-
const batch = this._currentDelta;
|
|
218
|
-
this._currentDelta = [];
|
|
219
|
-
this.onDidFlushEmitter.fire(batch);
|
|
220
|
-
}
|
|
221
|
-
reportAdded(path, added) {
|
|
222
|
-
super.reportAdded(path, added);
|
|
223
|
-
// console.debug(`reported added, now: ${JSON.stringify(path, undefined, 3)}`);
|
|
224
|
-
// logging levels don't work in plugin host: https://github.com/eclipse-theia/theia/issues/12234
|
|
225
|
-
this.batcher.changeOccurred();
|
|
226
|
-
}
|
|
227
|
-
reportChanged(path, change) {
|
|
228
|
-
super.reportChanged(path, change);
|
|
229
|
-
// console.debug(`reported changed, now: ${JSON.stringify(path, undefined, 3)}`);
|
|
230
|
-
// logging levels don't work in plugin host: https://github.com/eclipse-theia/theia/issues/12234
|
|
231
|
-
this.batcher.changeOccurred();
|
|
232
|
-
}
|
|
233
|
-
reportRemoved(path) {
|
|
234
|
-
super.reportRemoved(path);
|
|
235
|
-
// console.debug(`reported removed, now: ${JSON.stringify(path, undefined, 3)}`);
|
|
236
|
-
// logging levels don't work in plugin host: https://github.com/eclipse-theia/theia/issues/12234
|
|
237
|
-
this.batcher.changeOccurred();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
exports.AccumulatingTreeDeltaEmitter = AccumulatingTreeDeltaEmitter;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2022 STMicroelectronics and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AccumulatingTreeDeltaEmitter = exports.TreeDeltaBuilderImpl = exports.MappingTreeDeltaBuilder = exports.DeltaKind = void 0;
|
|
19
|
+
const core_1 = require("@theia/core");
|
|
20
|
+
const collections_1 = require("./collections");
|
|
21
|
+
var DeltaKind;
|
|
22
|
+
(function (DeltaKind) {
|
|
23
|
+
DeltaKind[DeltaKind["NONE"] = 0] = "NONE";
|
|
24
|
+
DeltaKind[DeltaKind["ADDED"] = 1] = "ADDED";
|
|
25
|
+
DeltaKind[DeltaKind["REMOVED"] = 2] = "REMOVED";
|
|
26
|
+
DeltaKind[DeltaKind["CHANGED"] = 3] = "CHANGED";
|
|
27
|
+
})(DeltaKind = exports.DeltaKind || (exports.DeltaKind = {}));
|
|
28
|
+
class MappingTreeDeltaBuilder {
|
|
29
|
+
constructor(wrapped, map, mapPartial) {
|
|
30
|
+
this.wrapped = wrapped;
|
|
31
|
+
this.map = map;
|
|
32
|
+
this.mapPartial = mapPartial;
|
|
33
|
+
}
|
|
34
|
+
reportAdded(path, added) {
|
|
35
|
+
this.wrapped.reportAdded(path, this.map(added));
|
|
36
|
+
}
|
|
37
|
+
reportRemoved(path) {
|
|
38
|
+
this.wrapped.reportRemoved(path);
|
|
39
|
+
}
|
|
40
|
+
reportChanged(path, change) {
|
|
41
|
+
this.wrapped.reportChanged(path, this.mapPartial(change));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.MappingTreeDeltaBuilder = MappingTreeDeltaBuilder;
|
|
45
|
+
class TreeDeltaBuilderImpl {
|
|
46
|
+
constructor() {
|
|
47
|
+
this._currentDelta = [];
|
|
48
|
+
}
|
|
49
|
+
get currentDelta() {
|
|
50
|
+
return this._currentDelta;
|
|
51
|
+
}
|
|
52
|
+
reportAdded(path, added) {
|
|
53
|
+
this.findNode(path, (parentCollection, nodeIndex, residual) => {
|
|
54
|
+
if (residual.length === 0) {
|
|
55
|
+
// we matched an exact node
|
|
56
|
+
const child = parentCollection[nodeIndex];
|
|
57
|
+
if (child.type === DeltaKind.REMOVED) {
|
|
58
|
+
child.type = DeltaKind.CHANGED;
|
|
59
|
+
}
|
|
60
|
+
else if (child.type === DeltaKind.NONE) {
|
|
61
|
+
child.type = DeltaKind.ADDED;
|
|
62
|
+
}
|
|
63
|
+
child.value = added;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.insert(parentCollection, nodeIndex, {
|
|
67
|
+
path: residual,
|
|
68
|
+
type: DeltaKind.ADDED,
|
|
69
|
+
value: added,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
reportRemoved(path) {
|
|
75
|
+
this.findNode(path, (parentCollection, nodeIndex, residual) => {
|
|
76
|
+
if (residual.length === 0) {
|
|
77
|
+
// we matched an exact node
|
|
78
|
+
const child = parentCollection[nodeIndex];
|
|
79
|
+
if (child.type === DeltaKind.CHANGED) {
|
|
80
|
+
child.type = DeltaKind.REMOVED;
|
|
81
|
+
delete child.value;
|
|
82
|
+
}
|
|
83
|
+
else if (child.type === DeltaKind.ADDED) {
|
|
84
|
+
parentCollection.splice(nodeIndex, 1);
|
|
85
|
+
}
|
|
86
|
+
else if (child.type === DeltaKind.NONE) {
|
|
87
|
+
child.type = DeltaKind.REMOVED;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.insert(parentCollection, nodeIndex, {
|
|
92
|
+
path: residual,
|
|
93
|
+
type: DeltaKind.REMOVED,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
reportChanged(path, change) {
|
|
99
|
+
this.findNode(path, (parentCollection, nodeIndex, residual) => {
|
|
100
|
+
if (residual.length === 0) {
|
|
101
|
+
// we matched an exact node
|
|
102
|
+
const child = parentCollection[nodeIndex];
|
|
103
|
+
if (child.type === DeltaKind.NONE) {
|
|
104
|
+
child.type = DeltaKind.CHANGED;
|
|
105
|
+
child.value = change;
|
|
106
|
+
}
|
|
107
|
+
else if (child.type === DeltaKind.CHANGED) {
|
|
108
|
+
Object.assign(child.value, change);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.insert(parentCollection, nodeIndex, {
|
|
113
|
+
path: residual,
|
|
114
|
+
type: DeltaKind.CHANGED,
|
|
115
|
+
value: change,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
insert(parentCollection, nodeIndex, delta) {
|
|
121
|
+
if (nodeIndex < 0) {
|
|
122
|
+
parentCollection.push(delta);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const child = parentCollection[nodeIndex];
|
|
126
|
+
const prefixLength = computePrefixLength(delta.path, child.path);
|
|
127
|
+
if (prefixLength === delta.path.length) {
|
|
128
|
+
child.path = child.path.slice(prefixLength);
|
|
129
|
+
delta.childDeltas = [child];
|
|
130
|
+
parentCollection[nodeIndex] = delta;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
const newNode = {
|
|
134
|
+
path: child.path.slice(0, prefixLength),
|
|
135
|
+
type: DeltaKind.NONE,
|
|
136
|
+
childDeltas: []
|
|
137
|
+
};
|
|
138
|
+
parentCollection[nodeIndex] = newNode;
|
|
139
|
+
delta.path = delta.path.slice(prefixLength);
|
|
140
|
+
newNode.childDeltas.push(delta);
|
|
141
|
+
child.path = child.path.slice(prefixLength);
|
|
142
|
+
newNode.childDeltas.push(child);
|
|
143
|
+
if (newNode.path.length === 0) {
|
|
144
|
+
console.log('newNode');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (delta.path.length === 0) {
|
|
148
|
+
console.log('delta');
|
|
149
|
+
}
|
|
150
|
+
if (child.path.length === 0) {
|
|
151
|
+
console.log('child');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
findNode(path, handler) {
|
|
156
|
+
doFindNode(this._currentDelta, path, handler);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.TreeDeltaBuilderImpl = TreeDeltaBuilderImpl;
|
|
160
|
+
function doFindNode(rootCollection, path, handler) {
|
|
161
|
+
// handler parameters:
|
|
162
|
+
// parent collection: the collection the node index refers to, if valid
|
|
163
|
+
// nodeIndex: the index of the node that has a common path prefix with the path of the path we're searching
|
|
164
|
+
// residual path: the path that has not been consumed looking for the path: if empty, we found the exact node
|
|
165
|
+
let commonPrefixLength = 0;
|
|
166
|
+
const childIndex = rootCollection.findIndex(delta => {
|
|
167
|
+
commonPrefixLength = computePrefixLength(delta.path, path);
|
|
168
|
+
return commonPrefixLength > 0;
|
|
169
|
+
});
|
|
170
|
+
if (childIndex >= 0) {
|
|
171
|
+
// we know which child to insert into
|
|
172
|
+
const child = rootCollection[childIndex];
|
|
173
|
+
if (commonPrefixLength === child.path.length) {
|
|
174
|
+
// we matched a child
|
|
175
|
+
if (commonPrefixLength === path.length) {
|
|
176
|
+
// it's an exact match: we already have a node for the given path
|
|
177
|
+
handler(rootCollection, childIndex, []);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
// we know the node is below the child
|
|
181
|
+
if (child.type === DeltaKind.REMOVED || child.type === DeltaKind.ADDED) {
|
|
182
|
+
// there will be no children deltas beneath added/remove nodes
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (!child.childDeltas) {
|
|
186
|
+
child.childDeltas = [];
|
|
187
|
+
}
|
|
188
|
+
doFindNode(child.childDeltas, path.slice(child.path.length), handler);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
handler(rootCollection, childIndex, path);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
// we have no node to insert into
|
|
196
|
+
handler(rootCollection, -1, path);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function computePrefixLength(left, right) {
|
|
200
|
+
let i = 0;
|
|
201
|
+
while (i < left.length && i < right.length && left[i] === right[i]) {
|
|
202
|
+
i++;
|
|
203
|
+
}
|
|
204
|
+
return i;
|
|
205
|
+
}
|
|
206
|
+
class AccumulatingTreeDeltaEmitter extends TreeDeltaBuilderImpl {
|
|
207
|
+
constructor(timeoutMillis) {
|
|
208
|
+
super();
|
|
209
|
+
this.onDidFlushEmitter = new core_1.Emitter();
|
|
210
|
+
this.onDidFlush = this.onDidFlushEmitter.event;
|
|
211
|
+
this.batcher = new collections_1.ChangeBatcher(() => this.doEmitDelta(), timeoutMillis);
|
|
212
|
+
}
|
|
213
|
+
flush() {
|
|
214
|
+
this.batcher.flush();
|
|
215
|
+
}
|
|
216
|
+
doEmitDelta() {
|
|
217
|
+
const batch = this._currentDelta;
|
|
218
|
+
this._currentDelta = [];
|
|
219
|
+
this.onDidFlushEmitter.fire(batch);
|
|
220
|
+
}
|
|
221
|
+
reportAdded(path, added) {
|
|
222
|
+
super.reportAdded(path, added);
|
|
223
|
+
// console.debug(`reported added, now: ${JSON.stringify(path, undefined, 3)}`);
|
|
224
|
+
// logging levels don't work in plugin host: https://github.com/eclipse-theia/theia/issues/12234
|
|
225
|
+
this.batcher.changeOccurred();
|
|
226
|
+
}
|
|
227
|
+
reportChanged(path, change) {
|
|
228
|
+
super.reportChanged(path, change);
|
|
229
|
+
// console.debug(`reported changed, now: ${JSON.stringify(path, undefined, 3)}`);
|
|
230
|
+
// logging levels don't work in plugin host: https://github.com/eclipse-theia/theia/issues/12234
|
|
231
|
+
this.batcher.changeOccurred();
|
|
232
|
+
}
|
|
233
|
+
reportRemoved(path) {
|
|
234
|
+
super.reportRemoved(path);
|
|
235
|
+
// console.debug(`reported removed, now: ${JSON.stringify(path, undefined, 3)}`);
|
|
236
|
+
// logging levels don't work in plugin host: https://github.com/eclipse-theia/theia/issues/12234
|
|
237
|
+
this.batcher.changeOccurred();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
exports.AccumulatingTreeDeltaEmitter = AccumulatingTreeDeltaEmitter;
|
|
241
241
|
//# sourceMappingURL=tree-delta.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=tree-delta.spec.d.ts.map
|