@theia/markers 1.34.1 → 1.34.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +33 -33
  3. package/lib/browser/index.d.ts +2 -2
  4. package/lib/browser/index.js +29 -29
  5. package/lib/browser/marker-manager.d.ts +47 -47
  6. package/lib/browser/marker-manager.js +187 -187
  7. package/lib/browser/marker-tree-label-provider.d.ts +15 -15
  8. package/lib/browser/marker-tree-label-provider.js +84 -84
  9. package/lib/browser/marker-tree-label-provider.spec.d.ts +1 -1
  10. package/lib/browser/marker-tree-label-provider.spec.js +201 -201
  11. package/lib/browser/marker-tree-model.d.ts +12 -12
  12. package/lib/browser/marker-tree-model.js +60 -60
  13. package/lib/browser/marker-tree.d.ts +42 -42
  14. package/lib/browser/marker-tree.js +143 -143
  15. package/lib/browser/problem/problem-composite-tree-node.d.ts +8 -8
  16. package/lib/browser/problem/problem-composite-tree-node.js +68 -68
  17. package/lib/browser/problem/problem-composite-tree-node.spec.d.ts +1 -1
  18. package/lib/browser/problem/problem-composite-tree-node.spec.js +216 -216
  19. package/lib/browser/problem/problem-container.d.ts +8 -8
  20. package/lib/browser/problem/problem-container.js +42 -42
  21. package/lib/browser/problem/problem-contribution.d.ts +51 -51
  22. package/lib/browser/problem/problem-contribution.js +247 -247
  23. package/lib/browser/problem/problem-decorations-provider.d.ts +18 -18
  24. package/lib/browser/problem/problem-decorations-provider.js +92 -92
  25. package/lib/browser/problem/problem-decorator.d.ts +57 -57
  26. package/lib/browser/problem/problem-decorator.js +233 -233
  27. package/lib/browser/problem/problem-frontend-module.d.ts +4 -4
  28. package/lib/browser/problem/problem-frontend-module.js +55 -55
  29. package/lib/browser/problem/problem-layout-migrations.d.ts +5 -5
  30. package/lib/browser/problem/problem-layout-migrations.js +43 -43
  31. package/lib/browser/problem/problem-manager.d.ts +11 -11
  32. package/lib/browser/problem/problem-manager.js +53 -53
  33. package/lib/browser/problem/problem-manager.spec.d.ts +1 -1
  34. package/lib/browser/problem/problem-manager.spec.js +167 -167
  35. package/lib/browser/problem/problem-preferences.d.ts +13 -13
  36. package/lib/browser/problem/problem-preferences.js +56 -56
  37. package/lib/browser/problem/problem-selection.d.ts +12 -12
  38. package/lib/browser/problem/problem-selection.js +34 -34
  39. package/lib/browser/problem/problem-tabbar-decorator.d.ts +42 -42
  40. package/lib/browser/problem/problem-tabbar-decorator.js +160 -160
  41. package/lib/browser/problem/problem-tree-model.d.ts +26 -26
  42. package/lib/browser/problem/problem-tree-model.js +122 -122
  43. package/lib/browser/problem/problem-tree-model.spec.d.ts +1 -1
  44. package/lib/browser/problem/problem-tree-model.spec.js +172 -172
  45. package/lib/browser/problem/problem-utils.d.ts +44 -44
  46. package/lib/browser/problem/problem-utils.js +84 -84
  47. package/lib/browser/problem/problem-widget-tab-bar-decorator.d.ts +14 -14
  48. package/lib/browser/problem/problem-widget-tab-bar-decorator.js +69 -69
  49. package/lib/browser/problem/problem-widget.d.ts +45 -45
  50. package/lib/browser/problem/problem-widget.js +231 -231
  51. package/lib/common/marker.d.ts +16 -12
  52. package/lib/common/marker.d.ts.map +1 -1
  53. package/lib/common/marker.js +31 -17
  54. package/lib/common/marker.js.map +1 -1
  55. package/lib/common/problem-marker.d.ts +9 -9
  56. package/lib/common/problem-marker.d.ts.map +1 -1
  57. package/lib/common/problem-marker.js +27 -26
  58. package/lib/common/problem-marker.js.map +1 -1
  59. package/package.json +6 -6
  60. package/src/browser/index.ts +18 -18
  61. package/src/browser/marker-manager.ts +205 -205
  62. package/src/browser/marker-tree-label-provider.spec.ts +245 -245
  63. package/src/browser/marker-tree-label-provider.ts +75 -75
  64. package/src/browser/marker-tree-model.ts +47 -47
  65. package/src/browser/marker-tree.ts +154 -154
  66. package/src/browser/problem/problem-composite-tree-node.spec.ts +255 -255
  67. package/src/browser/problem/problem-composite-tree-node.ts +68 -68
  68. package/src/browser/problem/problem-container.ts +47 -47
  69. package/src/browser/problem/problem-contribution.ts +247 -247
  70. package/src/browser/problem/problem-decorations-provider.ts +67 -67
  71. package/src/browser/problem/problem-decorator.ts +222 -222
  72. package/src/browser/problem/problem-frontend-module.ts +64 -64
  73. package/src/browser/problem/problem-layout-migrations.ts +32 -32
  74. package/src/browser/problem/problem-manager.spec.ts +216 -216
  75. package/src/browser/problem/problem-manager.ts +51 -51
  76. package/src/browser/problem/problem-preferences.ts +64 -64
  77. package/src/browser/problem/problem-selection.ts +45 -45
  78. package/src/browser/problem/problem-tabbar-decorator.ts +151 -151
  79. package/src/browser/problem/problem-tree-model.spec.ts +189 -189
  80. package/src/browser/problem/problem-tree-model.ts +113 -113
  81. package/src/browser/problem/problem-utils.ts +90 -90
  82. package/src/browser/problem/problem-widget-tab-bar-decorator.ts +55 -55
  83. package/src/browser/problem/problem-widget.tsx +241 -241
  84. package/src/browser/style/index.css +92 -92
  85. package/src/common/marker.ts +53 -39
  86. package/src/common/problem-marker.ts +30 -30
package/README.md CHANGED
@@ -1,33 +1,33 @@
1
- <div align='center'>
2
-
3
- <br />
4
-
5
- <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
-
7
- <h2>ECLIPSE THEIA - MARKERS EXTENSION</h2>
8
-
9
- <hr />
10
-
11
- </div>
12
-
13
- ## Description
14
-
15
- The `@theia/markers` adds support for file markers (diagnostic markers (`errors`, `warnings`, `infos`, `hint`)) for a given file.
16
- The extension contributes, the following:
17
- - `problems view`: a dedicated view to viewing diagnostic markers contributed by language-servers, linters, task problem matchers for the workspace
18
- - `marker decoration`: ability to decorate different components of the application based on markers (ex: file explorer)
19
-
20
- ## Additional Information
21
-
22
- - [API documentation for `@theia/markers`](https://eclipse-theia.github.io/theia/docs/next/modules/markers.html)
23
- - [Theia - GitHub](https://github.com/eclipse-theia/theia)
24
- - [Theia - Website](https://theia-ide.org/)
25
-
26
- ## License
27
-
28
- - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
29
- - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
30
-
31
- ## Trademark
32
- "Theia" is a trademark of the Eclipse Foundation
33
- https://www.eclipse.org/theia
1
+ <div align='center'>
2
+
3
+ <br />
4
+
5
+ <img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
6
+
7
+ <h2>ECLIPSE THEIA - MARKERS EXTENSION</h2>
8
+
9
+ <hr />
10
+
11
+ </div>
12
+
13
+ ## Description
14
+
15
+ The `@theia/markers` adds support for file markers (diagnostic markers (`errors`, `warnings`, `infos`, `hint`)) for a given file.
16
+ The extension contributes, the following:
17
+ - `problems view`: a dedicated view to viewing diagnostic markers contributed by language-servers, linters, task problem matchers for the workspace
18
+ - `marker decoration`: ability to decorate different components of the application based on markers (ex: file explorer)
19
+
20
+ ## Additional Information
21
+
22
+ - [API documentation for `@theia/markers`](https://eclipse-theia.github.io/theia/docs/next/modules/markers.html)
23
+ - [Theia - GitHub](https://github.com/eclipse-theia/theia)
24
+ - [Theia - Website](https://theia-ide.org/)
25
+
26
+ ## License
27
+
28
+ - [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
29
+ - [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
30
+
31
+ ## Trademark
32
+ "Theia" is a trademark of the Eclipse Foundation
33
+ https://www.eclipse.org/theia
@@ -1,3 +1,3 @@
1
- export * from './marker-manager';
2
- export * from './problem/problem-manager';
1
+ export * from './marker-manager';
2
+ export * from './problem/problem-manager';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,30 +1,30 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 TypeFox 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 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
- };
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- __exportStar(require("./marker-manager"), exports);
29
- __exportStar(require("./problem/problem-manager"), exports);
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 TypeFox 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 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ __exportStar(require("./marker-manager"), exports);
29
+ __exportStar(require("./problem/problem-manager"), exports);
30
30
  //# sourceMappingURL=index.js.map
@@ -1,48 +1,48 @@
1
- import { Event, Emitter } from '@theia/core/lib/common';
2
- import URI from '@theia/core/lib/common/uri';
3
- import { Marker } from '../common/marker';
4
- import { FileService } from '@theia/filesystem/lib/browser/file-service';
5
- import { FileChangesEvent } from '@theia/filesystem/lib/common/files';
6
- export interface SearchFilter<D> {
7
- uri?: URI;
8
- owner?: string;
9
- dataFilter?: (data: D) => boolean;
10
- }
11
- export declare class MarkerCollection<T> {
12
- readonly uri: URI;
13
- readonly kind: string;
14
- protected readonly owner2Markers: Map<string, Readonly<Marker<T>>[]>;
15
- constructor(uri: URI, kind: string);
16
- get empty(): boolean;
17
- getOwners(): string[];
18
- getMarkers(owner: string): Readonly<Marker<T>>[];
19
- setMarkers(owner: string, markerData: T[]): Marker<T>[];
20
- protected createMarker(owner: string, data: T): Readonly<Marker<T>>;
21
- findMarkers(filter: SearchFilter<T>): Marker<T>[];
22
- protected filterMarkers(filter: SearchFilter<T>, toFilter?: Marker<T>[]): Marker<T>[];
23
- }
24
- export interface Uri2MarkerEntry {
25
- uri: string;
26
- markers: Owner2MarkerEntry[];
27
- }
28
- export interface Owner2MarkerEntry {
29
- owner: string;
30
- markerData: object[];
31
- }
32
- export declare abstract class MarkerManager<D extends object> {
33
- abstract getKind(): string;
34
- protected readonly uri2MarkerCollection: Map<string, MarkerCollection<D>>;
35
- protected readonly onDidChangeMarkersEmitter: Emitter<URI>;
36
- protected readonly fileService: FileService;
37
- protected init(): void;
38
- protected cleanMarkers(event: FileChangesEvent): void;
39
- get onDidChangeMarkers(): Event<URI>;
40
- protected fireOnDidChangeMarkers(uri: URI): void;
41
- setMarkers(uri: URI, owner: string, data: D[]): Marker<D>[];
42
- findMarkers(filter?: SearchFilter<D>): Marker<D>[];
43
- getMarkersByUri(): IterableIterator<[string, MarkerCollection<D>]>;
44
- getUris(): IterableIterator<string>;
45
- cleanAllMarkers(uri?: URI): void;
46
- protected doCleanAllMarkers(uri: URI): void;
47
- }
1
+ import { Event, Emitter } from '@theia/core/lib/common';
2
+ import URI from '@theia/core/lib/common/uri';
3
+ import { Marker } from '../common/marker';
4
+ import { FileService } from '@theia/filesystem/lib/browser/file-service';
5
+ import { FileChangesEvent } from '@theia/filesystem/lib/common/files';
6
+ export interface SearchFilter<D> {
7
+ uri?: URI;
8
+ owner?: string;
9
+ dataFilter?: (data: D) => boolean;
10
+ }
11
+ export declare class MarkerCollection<T> {
12
+ readonly uri: URI;
13
+ readonly kind: string;
14
+ protected readonly owner2Markers: Map<string, Readonly<Marker<T>>[]>;
15
+ constructor(uri: URI, kind: string);
16
+ get empty(): boolean;
17
+ getOwners(): string[];
18
+ getMarkers(owner: string): Readonly<Marker<T>>[];
19
+ setMarkers(owner: string, markerData: T[]): Marker<T>[];
20
+ protected createMarker(owner: string, data: T): Readonly<Marker<T>>;
21
+ findMarkers(filter: SearchFilter<T>): Marker<T>[];
22
+ protected filterMarkers(filter: SearchFilter<T>, toFilter?: Marker<T>[]): Marker<T>[];
23
+ }
24
+ export interface Uri2MarkerEntry {
25
+ uri: string;
26
+ markers: Owner2MarkerEntry[];
27
+ }
28
+ export interface Owner2MarkerEntry {
29
+ owner: string;
30
+ markerData: object[];
31
+ }
32
+ export declare abstract class MarkerManager<D extends object> {
33
+ abstract getKind(): string;
34
+ protected readonly uri2MarkerCollection: Map<string, MarkerCollection<D>>;
35
+ protected readonly onDidChangeMarkersEmitter: Emitter<URI>;
36
+ protected readonly fileService: FileService;
37
+ protected init(): void;
38
+ protected cleanMarkers(event: FileChangesEvent): void;
39
+ get onDidChangeMarkers(): Event<URI>;
40
+ protected fireOnDidChangeMarkers(uri: URI): void;
41
+ setMarkers(uri: URI, owner: string, data: D[]): Marker<D>[];
42
+ findMarkers(filter?: SearchFilter<D>): Marker<D>[];
43
+ getMarkersByUri(): IterableIterator<[string, MarkerCollection<D>]>;
44
+ getUris(): IterableIterator<string>;
45
+ cleanAllMarkers(uri?: URI): void;
46
+ protected doCleanAllMarkers(uri: URI): void;
47
+ }
48
48
  //# sourceMappingURL=marker-manager.d.ts.map
@@ -1,188 +1,188 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 TypeFox 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 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- 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;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.MarkerManager = exports.MarkerCollection = void 0;
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const common_1 = require("@theia/core/lib/common");
30
- const uri_1 = require("@theia/core/lib/common/uri");
31
- const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
32
- class MarkerCollection {
33
- constructor(uri, kind) {
34
- this.uri = uri;
35
- this.kind = kind;
36
- this.owner2Markers = new Map();
37
- }
38
- get empty() {
39
- return !this.owner2Markers.size;
40
- }
41
- getOwners() {
42
- return Array.from(this.owner2Markers.keys());
43
- }
44
- getMarkers(owner) {
45
- return this.owner2Markers.get(owner) || [];
46
- }
47
- setMarkers(owner, markerData) {
48
- const before = this.owner2Markers.get(owner);
49
- if (markerData.length > 0) {
50
- this.owner2Markers.set(owner, markerData.map(data => this.createMarker(owner, data)));
51
- }
52
- else {
53
- this.owner2Markers.delete(owner);
54
- }
55
- return before || [];
56
- }
57
- createMarker(owner, data) {
58
- return Object.freeze({
59
- uri: this.uri.toString(),
60
- kind: this.kind,
61
- owner: owner,
62
- data
63
- });
64
- }
65
- findMarkers(filter) {
66
- if (filter.owner) {
67
- if (this.owner2Markers.has(filter.owner)) {
68
- return this.filterMarkers(filter, this.owner2Markers.get(filter.owner));
69
- }
70
- return [];
71
- }
72
- else {
73
- const result = [];
74
- for (const markers of this.owner2Markers.values()) {
75
- result.push(...this.filterMarkers(filter, markers));
76
- }
77
- return result;
78
- }
79
- }
80
- filterMarkers(filter, toFilter) {
81
- if (!toFilter) {
82
- return [];
83
- }
84
- if (filter.dataFilter) {
85
- return toFilter.filter(d => filter.dataFilter(d.data));
86
- }
87
- else {
88
- return toFilter;
89
- }
90
- }
91
- }
92
- exports.MarkerCollection = MarkerCollection;
93
- let MarkerManager = class MarkerManager {
94
- constructor() {
95
- this.uri2MarkerCollection = new Map();
96
- this.onDidChangeMarkersEmitter = new common_1.Emitter();
97
- }
98
- init() {
99
- this.fileService.onDidFilesChange(event => {
100
- if (event.gotDeleted()) {
101
- this.cleanMarkers(event);
102
- }
103
- });
104
- }
105
- cleanMarkers(event) {
106
- for (const uriString of this.uri2MarkerCollection.keys()) {
107
- const uri = new uri_1.default(uriString);
108
- if (event.contains(uri, 2 /* DELETED */)) {
109
- this.cleanAllMarkers(uri);
110
- }
111
- }
112
- }
113
- get onDidChangeMarkers() {
114
- return this.onDidChangeMarkersEmitter.event;
115
- }
116
- fireOnDidChangeMarkers(uri) {
117
- this.onDidChangeMarkersEmitter.fire(uri);
118
- }
119
- /*
120
- * replaces the current markers for the given uri and owner with the given data.
121
- */
122
- setMarkers(uri, owner, data) {
123
- const uriString = uri.toString();
124
- const collection = this.uri2MarkerCollection.get(uriString) || new MarkerCollection(uri, this.getKind());
125
- const oldMarkers = collection.setMarkers(owner, data);
126
- if (collection.empty) {
127
- this.uri2MarkerCollection.delete(uri.toString());
128
- }
129
- else {
130
- this.uri2MarkerCollection.set(uriString, collection);
131
- }
132
- this.fireOnDidChangeMarkers(uri);
133
- return oldMarkers;
134
- }
135
- /*
136
- * returns all markers that satisfy the given filter.
137
- */
138
- findMarkers(filter = {}) {
139
- if (filter.uri) {
140
- const collection = this.uri2MarkerCollection.get(filter.uri.toString());
141
- return collection ? collection.findMarkers(filter) : [];
142
- }
143
- const result = [];
144
- for (const uri of this.getUris()) {
145
- result.push(...this.uri2MarkerCollection.get(uri).findMarkers(filter));
146
- }
147
- return result;
148
- }
149
- getMarkersByUri() {
150
- return this.uri2MarkerCollection.entries();
151
- }
152
- getUris() {
153
- return this.uri2MarkerCollection.keys();
154
- }
155
- cleanAllMarkers(uri) {
156
- if (uri) {
157
- this.doCleanAllMarkers(uri);
158
- }
159
- else {
160
- for (const uriString of this.getUris()) {
161
- this.doCleanAllMarkers(new uri_1.default(uriString));
162
- }
163
- }
164
- }
165
- doCleanAllMarkers(uri) {
166
- const uriString = uri.toString();
167
- const collection = this.uri2MarkerCollection.get(uriString);
168
- if (collection !== undefined) {
169
- this.uri2MarkerCollection.delete(uriString);
170
- this.fireOnDidChangeMarkers(uri);
171
- }
172
- }
173
- };
174
- __decorate([
175
- (0, inversify_1.inject)(file_service_1.FileService),
176
- __metadata("design:type", file_service_1.FileService)
177
- ], MarkerManager.prototype, "fileService", void 0);
178
- __decorate([
179
- (0, inversify_1.postConstruct)(),
180
- __metadata("design:type", Function),
181
- __metadata("design:paramtypes", []),
182
- __metadata("design:returntype", void 0)
183
- ], MarkerManager.prototype, "init", null);
184
- MarkerManager = __decorate([
185
- (0, inversify_1.injectable)()
186
- ], MarkerManager);
187
- exports.MarkerManager = MarkerManager;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 TypeFox 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 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ 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;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.MarkerManager = exports.MarkerCollection = void 0;
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const common_1 = require("@theia/core/lib/common");
30
+ const uri_1 = require("@theia/core/lib/common/uri");
31
+ const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
32
+ class MarkerCollection {
33
+ constructor(uri, kind) {
34
+ this.uri = uri;
35
+ this.kind = kind;
36
+ this.owner2Markers = new Map();
37
+ }
38
+ get empty() {
39
+ return !this.owner2Markers.size;
40
+ }
41
+ getOwners() {
42
+ return Array.from(this.owner2Markers.keys());
43
+ }
44
+ getMarkers(owner) {
45
+ return this.owner2Markers.get(owner) || [];
46
+ }
47
+ setMarkers(owner, markerData) {
48
+ const before = this.owner2Markers.get(owner);
49
+ if (markerData.length > 0) {
50
+ this.owner2Markers.set(owner, markerData.map(data => this.createMarker(owner, data)));
51
+ }
52
+ else {
53
+ this.owner2Markers.delete(owner);
54
+ }
55
+ return before || [];
56
+ }
57
+ createMarker(owner, data) {
58
+ return Object.freeze({
59
+ uri: this.uri.toString(),
60
+ kind: this.kind,
61
+ owner: owner,
62
+ data
63
+ });
64
+ }
65
+ findMarkers(filter) {
66
+ if (filter.owner) {
67
+ if (this.owner2Markers.has(filter.owner)) {
68
+ return this.filterMarkers(filter, this.owner2Markers.get(filter.owner));
69
+ }
70
+ return [];
71
+ }
72
+ else {
73
+ const result = [];
74
+ for (const markers of this.owner2Markers.values()) {
75
+ result.push(...this.filterMarkers(filter, markers));
76
+ }
77
+ return result;
78
+ }
79
+ }
80
+ filterMarkers(filter, toFilter) {
81
+ if (!toFilter) {
82
+ return [];
83
+ }
84
+ if (filter.dataFilter) {
85
+ return toFilter.filter(d => filter.dataFilter(d.data));
86
+ }
87
+ else {
88
+ return toFilter;
89
+ }
90
+ }
91
+ }
92
+ exports.MarkerCollection = MarkerCollection;
93
+ let MarkerManager = class MarkerManager {
94
+ constructor() {
95
+ this.uri2MarkerCollection = new Map();
96
+ this.onDidChangeMarkersEmitter = new common_1.Emitter();
97
+ }
98
+ init() {
99
+ this.fileService.onDidFilesChange(event => {
100
+ if (event.gotDeleted()) {
101
+ this.cleanMarkers(event);
102
+ }
103
+ });
104
+ }
105
+ cleanMarkers(event) {
106
+ for (const uriString of this.uri2MarkerCollection.keys()) {
107
+ const uri = new uri_1.default(uriString);
108
+ if (event.contains(uri, 2 /* DELETED */)) {
109
+ this.cleanAllMarkers(uri);
110
+ }
111
+ }
112
+ }
113
+ get onDidChangeMarkers() {
114
+ return this.onDidChangeMarkersEmitter.event;
115
+ }
116
+ fireOnDidChangeMarkers(uri) {
117
+ this.onDidChangeMarkersEmitter.fire(uri);
118
+ }
119
+ /*
120
+ * replaces the current markers for the given uri and owner with the given data.
121
+ */
122
+ setMarkers(uri, owner, data) {
123
+ const uriString = uri.toString();
124
+ const collection = this.uri2MarkerCollection.get(uriString) || new MarkerCollection(uri, this.getKind());
125
+ const oldMarkers = collection.setMarkers(owner, data);
126
+ if (collection.empty) {
127
+ this.uri2MarkerCollection.delete(uri.toString());
128
+ }
129
+ else {
130
+ this.uri2MarkerCollection.set(uriString, collection);
131
+ }
132
+ this.fireOnDidChangeMarkers(uri);
133
+ return oldMarkers;
134
+ }
135
+ /*
136
+ * returns all markers that satisfy the given filter.
137
+ */
138
+ findMarkers(filter = {}) {
139
+ if (filter.uri) {
140
+ const collection = this.uri2MarkerCollection.get(filter.uri.toString());
141
+ return collection ? collection.findMarkers(filter) : [];
142
+ }
143
+ const result = [];
144
+ for (const uri of this.getUris()) {
145
+ result.push(...this.uri2MarkerCollection.get(uri).findMarkers(filter));
146
+ }
147
+ return result;
148
+ }
149
+ getMarkersByUri() {
150
+ return this.uri2MarkerCollection.entries();
151
+ }
152
+ getUris() {
153
+ return this.uri2MarkerCollection.keys();
154
+ }
155
+ cleanAllMarkers(uri) {
156
+ if (uri) {
157
+ this.doCleanAllMarkers(uri);
158
+ }
159
+ else {
160
+ for (const uriString of this.getUris()) {
161
+ this.doCleanAllMarkers(new uri_1.default(uriString));
162
+ }
163
+ }
164
+ }
165
+ doCleanAllMarkers(uri) {
166
+ const uriString = uri.toString();
167
+ const collection = this.uri2MarkerCollection.get(uriString);
168
+ if (collection !== undefined) {
169
+ this.uri2MarkerCollection.delete(uriString);
170
+ this.fireOnDidChangeMarkers(uri);
171
+ }
172
+ }
173
+ };
174
+ __decorate([
175
+ (0, inversify_1.inject)(file_service_1.FileService),
176
+ __metadata("design:type", file_service_1.FileService)
177
+ ], MarkerManager.prototype, "fileService", void 0);
178
+ __decorate([
179
+ (0, inversify_1.postConstruct)(),
180
+ __metadata("design:type", Function),
181
+ __metadata("design:paramtypes", []),
182
+ __metadata("design:returntype", void 0)
183
+ ], MarkerManager.prototype, "init", null);
184
+ MarkerManager = __decorate([
185
+ (0, inversify_1.injectable)()
186
+ ], MarkerManager);
187
+ exports.MarkerManager = MarkerManager;
188
188
  //# sourceMappingURL=marker-manager.js.map
@@ -1,16 +1,16 @@
1
- import { LabelProvider, LabelProviderContribution, DidChangeLabelEvent } from '@theia/core/lib/browser/label-provider';
2
- import { MarkerInfoNode } from './marker-tree';
3
- import { TreeLabelProvider } from '@theia/core/lib/browser/tree/tree-label-provider';
4
- import { WorkspaceService } from '@theia/workspace/lib/browser';
5
- export declare class MarkerTreeLabelProvider implements LabelProviderContribution {
6
- protected readonly labelProvider: LabelProvider;
7
- protected readonly treeLabelProvider: TreeLabelProvider;
8
- protected readonly workspaceService: WorkspaceService;
9
- canHandle(element: object): number;
10
- getIcon(node: MarkerInfoNode): string;
11
- getName(node: MarkerInfoNode): string;
12
- getLongName(node: MarkerInfoNode): string;
13
- getDescription(node: MarkerInfoNode): string;
14
- affects(node: MarkerInfoNode, event: DidChangeLabelEvent): boolean;
15
- }
1
+ import { LabelProvider, LabelProviderContribution, DidChangeLabelEvent } from '@theia/core/lib/browser/label-provider';
2
+ import { MarkerInfoNode } from './marker-tree';
3
+ import { TreeLabelProvider } from '@theia/core/lib/browser/tree/tree-label-provider';
4
+ import { WorkspaceService } from '@theia/workspace/lib/browser';
5
+ export declare class MarkerTreeLabelProvider implements LabelProviderContribution {
6
+ protected readonly labelProvider: LabelProvider;
7
+ protected readonly treeLabelProvider: TreeLabelProvider;
8
+ protected readonly workspaceService: WorkspaceService;
9
+ canHandle(element: object): number;
10
+ getIcon(node: MarkerInfoNode): string;
11
+ getName(node: MarkerInfoNode): string;
12
+ getLongName(node: MarkerInfoNode): string;
13
+ getDescription(node: MarkerInfoNode): string;
14
+ affects(node: MarkerInfoNode, event: DidChangeLabelEvent): boolean;
15
+ }
16
16
  //# sourceMappingURL=marker-tree-label-provider.d.ts.map