1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.DecoratedTreeNode = exports.TreeDecoration = exports.AbstractTreeDecoratorService = exports.NoopTreeDecoratorService = exports.TreeDecoratorService = void 0;
|
19 | const tslib_1 = require("tslib");
|
20 | const inversify_1 = require("inversify");
|
21 | const common_1 = require("../../common");
|
22 | const widget_decoration_1 = require("../widget-decoration");
|
23 | exports.TreeDecoratorService = Symbol('TreeDecoratorService');
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | let NoopTreeDecoratorService = class NoopTreeDecoratorService {
|
29 | constructor() {
|
30 | this.emitter = new common_1.Emitter();
|
31 | this.onDidChangeDecorations = this.emitter.event;
|
32 | }
|
33 | dispose() {
|
34 | this.emitter.dispose();
|
35 | }
|
36 |
|
37 | getDecorations() {
|
38 | return new Map();
|
39 | }
|
40 | deflateDecorators() {
|
41 | return {};
|
42 | }
|
43 | inflateDecorators() {
|
44 | return new Map();
|
45 | }
|
46 | };
|
47 | NoopTreeDecoratorService = (0, tslib_1.__decorate)([
|
48 | (0, inversify_1.injectable)()
|
49 | ], NoopTreeDecoratorService);
|
50 | exports.NoopTreeDecoratorService = NoopTreeDecoratorService;
|
51 |
|
52 |
|
53 |
|
54 | let AbstractTreeDecoratorService = class AbstractTreeDecoratorService {
|
55 | constructor(decorators) {
|
56 | this.decorators = decorators;
|
57 | this.onDidChangeDecorationsEmitter = new common_1.Emitter();
|
58 | this.onDidChangeDecorations = this.onDidChangeDecorationsEmitter.event;
|
59 | this.toDispose = new common_1.DisposableCollection();
|
60 | this.toDispose.push(this.onDidChangeDecorationsEmitter);
|
61 | this.toDispose.pushAll(this.decorators.map(decorator => decorator.onDidChangeDecorations(data => this.onDidChangeDecorationsEmitter.fire(undefined))));
|
62 | }
|
63 | dispose() {
|
64 | this.toDispose.dispose();
|
65 | }
|
66 | async getDecorations(tree) {
|
67 | const changes = new Map();
|
68 | for (const decorator of this.decorators) {
|
69 | for (const [id, data] of (await decorator.decorations(tree)).entries()) {
|
70 | if (changes.has(id)) {
|
71 | changes.get(id).push(data);
|
72 | }
|
73 | else {
|
74 | changes.set(id, [data]);
|
75 | }
|
76 | }
|
77 | }
|
78 | return changes;
|
79 | }
|
80 | deflateDecorators(decorations) {
|
81 |
|
82 | const state = Object.create(null);
|
83 | for (const [id, data] of decorations) {
|
84 | state[id] = data;
|
85 | }
|
86 | return state;
|
87 | }
|
88 |
|
89 | inflateDecorators(state) {
|
90 | const decorators = new Map();
|
91 | for (const id of Object.keys(state)) {
|
92 | decorators.set(id, state[id]);
|
93 | }
|
94 | return decorators;
|
95 | }
|
96 | };
|
97 | AbstractTreeDecoratorService = (0, tslib_1.__decorate)([
|
98 | (0, inversify_1.injectable)(),
|
99 | (0, tslib_1.__metadata)("design:paramtypes", [Array])
|
100 | ], AbstractTreeDecoratorService);
|
101 | exports.AbstractTreeDecoratorService = AbstractTreeDecoratorService;
|
102 |
|
103 |
|
104 |
|
105 | exports.TreeDecoration = widget_decoration_1.WidgetDecoration;
|
106 | var DecoratedTreeNode;
|
107 | (function (DecoratedTreeNode) {
|
108 | |
109 |
|
110 |
|
111 | function is(node) {
|
112 | return !!node && 'decorationData' in node;
|
113 | }
|
114 | DecoratedTreeNode.is = is;
|
115 | })(DecoratedTreeNode = exports.DecoratedTreeNode || (exports.DecoratedTreeNode = {}));
|
116 |
|
\ | No newline at end of file |