@theia/markers 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.
Files changed (81) hide show
  1. package/README.md +33 -33
  2. package/lib/browser/index.d.ts +2 -2
  3. package/lib/browser/index.js +29 -29
  4. package/lib/browser/marker-manager.d.ts +47 -47
  5. package/lib/browser/marker-manager.js +187 -187
  6. package/lib/browser/marker-tree-label-provider.d.ts +15 -15
  7. package/lib/browser/marker-tree-label-provider.js +84 -84
  8. package/lib/browser/marker-tree-label-provider.spec.d.ts +1 -1
  9. package/lib/browser/marker-tree-label-provider.spec.js +201 -201
  10. package/lib/browser/marker-tree-model.d.ts +12 -12
  11. package/lib/browser/marker-tree-model.js +60 -60
  12. package/lib/browser/marker-tree.d.ts +42 -42
  13. package/lib/browser/marker-tree.js +143 -143
  14. package/lib/browser/problem/problem-composite-tree-node.d.ts +11 -11
  15. package/lib/browser/problem/problem-composite-tree-node.js +76 -76
  16. package/lib/browser/problem/problem-composite-tree-node.spec.d.ts +1 -1
  17. package/lib/browser/problem/problem-composite-tree-node.spec.js +238 -238
  18. package/lib/browser/problem/problem-container.d.ts +8 -8
  19. package/lib/browser/problem/problem-container.js +46 -46
  20. package/lib/browser/problem/problem-contribution.d.ts +51 -51
  21. package/lib/browser/problem/problem-contribution.js +247 -247
  22. package/lib/browser/problem/problem-decorations-provider.d.ts +21 -21
  23. package/lib/browser/problem/problem-decorations-provider.js +95 -95
  24. package/lib/browser/problem/problem-decorator.d.ts +57 -57
  25. package/lib/browser/problem/problem-decorator.js +233 -233
  26. package/lib/browser/problem/problem-frontend-module.d.ts +4 -4
  27. package/lib/browser/problem/problem-frontend-module.js +55 -55
  28. package/lib/browser/problem/problem-layout-migrations.d.ts +5 -5
  29. package/lib/browser/problem/problem-layout-migrations.js +43 -43
  30. package/lib/browser/problem/problem-manager.d.ts +11 -11
  31. package/lib/browser/problem/problem-manager.js +53 -53
  32. package/lib/browser/problem/problem-manager.spec.d.ts +1 -1
  33. package/lib/browser/problem/problem-manager.spec.js +167 -167
  34. package/lib/browser/problem/problem-preferences.d.ts +13 -13
  35. package/lib/browser/problem/problem-preferences.js +56 -56
  36. package/lib/browser/problem/problem-selection.d.ts +12 -12
  37. package/lib/browser/problem/problem-selection.js +34 -34
  38. package/lib/browser/problem/problem-tabbar-decorator.d.ts +42 -42
  39. package/lib/browser/problem/problem-tabbar-decorator.js +160 -160
  40. package/lib/browser/problem/problem-tree-model.d.ts +32 -32
  41. package/lib/browser/problem/problem-tree-model.js +131 -131
  42. package/lib/browser/problem/problem-tree-model.spec.d.ts +1 -1
  43. package/lib/browser/problem/problem-tree-model.spec.js +172 -172
  44. package/lib/browser/problem/problem-utils.d.ts +44 -44
  45. package/lib/browser/problem/problem-utils.js +84 -84
  46. package/lib/browser/problem/problem-widget-tab-bar-decorator.d.ts +14 -14
  47. package/lib/browser/problem/problem-widget-tab-bar-decorator.js +69 -69
  48. package/lib/browser/problem/problem-widget.d.ts +46 -46
  49. package/lib/browser/problem/problem-widget.js +235 -235
  50. package/lib/common/marker.d.ts +16 -16
  51. package/lib/common/marker.js +31 -31
  52. package/lib/common/problem-marker.d.ts +9 -9
  53. package/lib/common/problem-marker.js +27 -27
  54. package/package.json +6 -6
  55. package/src/browser/index.ts +18 -18
  56. package/src/browser/marker-manager.ts +205 -205
  57. package/src/browser/marker-tree-label-provider.spec.ts +245 -245
  58. package/src/browser/marker-tree-label-provider.ts +75 -75
  59. package/src/browser/marker-tree-model.ts +47 -47
  60. package/src/browser/marker-tree.ts +154 -154
  61. package/src/browser/problem/problem-composite-tree-node.spec.ts +277 -277
  62. package/src/browser/problem/problem-composite-tree-node.ts +81 -81
  63. package/src/browser/problem/problem-container.ts +47 -47
  64. package/src/browser/problem/problem-contribution.ts +247 -247
  65. package/src/browser/problem/problem-decorations-provider.ts +72 -72
  66. package/src/browser/problem/problem-decorator.ts +222 -222
  67. package/src/browser/problem/problem-frontend-module.ts +64 -64
  68. package/src/browser/problem/problem-layout-migrations.ts +32 -32
  69. package/src/browser/problem/problem-manager.spec.ts +216 -216
  70. package/src/browser/problem/problem-manager.ts +51 -51
  71. package/src/browser/problem/problem-preferences.ts +64 -64
  72. package/src/browser/problem/problem-selection.ts +45 -45
  73. package/src/browser/problem/problem-tabbar-decorator.ts +151 -151
  74. package/src/browser/problem/problem-tree-model.spec.ts +189 -189
  75. package/src/browser/problem/problem-tree-model.ts +124 -124
  76. package/src/browser/problem/problem-utils.ts +90 -90
  77. package/src/browser/problem/problem-widget-tab-bar-decorator.ts +55 -55
  78. package/src/browser/problem/problem-widget.tsx +246 -246
  79. package/src/browser/style/index.css +92 -92
  80. package/src/common/marker.ts +53 -53
  81. package/src/common/problem-marker.ts +30 -30
@@ -1,222 +1,222 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
- import { Diagnostic, DiagnosticSeverity } from '@theia/core/shared/vscode-languageserver-protocol';
19
- import URI from '@theia/core/lib/common/uri';
20
- import { Event, Emitter } from '@theia/core/lib/common/event';
21
- import { Tree, TreeNode } from '@theia/core/lib/browser/tree/tree';
22
- import { DepthFirstTreeIterator } from '@theia/core/lib/browser/tree/tree-iterator';
23
- import { TreeDecorator, TreeDecoration } from '@theia/core/lib/browser/tree/tree-decorator';
24
- import { FileStatNode } from '@theia/filesystem/lib/browser';
25
- import { Marker } from '../../common/marker';
26
- import { ProblemManager } from './problem-manager';
27
- import { ProblemPreferences } from './problem-preferences';
28
- import { ProblemUtils } from './problem-utils';
29
- import { LabelProvider } from '@theia/core/lib/browser';
30
- import { WorkspaceService } from '@theia/workspace/lib/browser';
31
-
32
- /**
33
- * @deprecated since 1.25.0
34
- * URI-based decorators should implement `DecorationsProvider` and contribute decorations via the `DecorationsService`.
35
- */
36
- @injectable()
37
- export class ProblemDecorator implements TreeDecorator {
38
-
39
- @inject(ProblemPreferences)
40
- protected problemPreferences: ProblemPreferences;
41
- @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
42
- @inject(LabelProvider) protected readonly labelProvider: LabelProvider;
43
-
44
- readonly id = 'theia-problem-decorator';
45
-
46
- protected readonly emitter: Emitter<(tree: Tree) => Map<string, TreeDecoration.Data>>;
47
-
48
- constructor(@inject(ProblemManager) protected readonly problemManager: ProblemManager) {
49
- this.emitter = new Emitter();
50
- this.problemManager.onDidChangeMarkers(() => this.fireDidChangeDecorations((tree: Tree) => this.collectDecorators(tree)));
51
- }
52
-
53
- @postConstruct()
54
- protected init(): void {
55
- this.problemPreferences.onPreferenceChanged(event => {
56
- if (event.preferenceName === 'problems.decorations.enabled') {
57
- this.fireDidChangeDecorations(tree => this.collectDecorators(tree));
58
- }
59
- });
60
- this.workspaceService.onWorkspaceChanged(() => {
61
- this.fireDidChangeDecorations((tree: Tree) => this.collectDecorators(tree));
62
- });
63
- this.workspaceService.onWorkspaceLocationChanged(() => {
64
- this.fireDidChangeDecorations((tree: Tree) => this.collectDecorators(tree));
65
- });
66
- }
67
-
68
- async decorations(tree: Tree): Promise<Map<string, TreeDecoration.Data>> {
69
- return this.collectDecorators(tree);
70
- }
71
-
72
- get onDidChangeDecorations(): Event<(tree: Tree) => Map<string, TreeDecoration.Data>> {
73
- return this.emitter.event;
74
- }
75
-
76
- protected fireDidChangeDecorations(event: (tree: Tree) => Map<string, TreeDecoration.Data>): void {
77
- this.emitter.fire(event);
78
- }
79
-
80
- protected collectDecorators(tree: Tree): Map<string, TreeDecoration.Data> {
81
- const decorations = new Map<string, TreeDecoration.Data>();
82
- // If the tree root is undefined or the preference for the decorations is disabled, return an empty result map.
83
- if (!tree.root || !this.problemPreferences['problems.decorations.enabled']) {
84
- return decorations;
85
- }
86
- const baseDecorations = this.collectMarkers(tree);
87
- for (const node of new DepthFirstTreeIterator(tree.root)) {
88
- const nodeUri = this.getUriFromNode(node);
89
- if (nodeUri) {
90
- const decorator = baseDecorations.get(nodeUri);
91
- if (decorator) {
92
- this.appendContainerMarkers(node, decorator, decorations);
93
- }
94
- if (decorator) {
95
- decorations.set(node.id, decorator);
96
- }
97
- }
98
- }
99
- return decorations;
100
- }
101
-
102
- protected generateCaptionSuffix(nodeURI: URI): string {
103
- const workspaceRoots = this.workspaceService.tryGetRoots();
104
- const parentWorkspace = this.workspaceService.getWorkspaceRootUri(nodeURI);
105
- let workspacePrefixString = '';
106
- let separator = '';
107
- let filePathString = '';
108
- const nodeURIDir = nodeURI.parent;
109
- if (parentWorkspace) {
110
- const relativeDirFromWorkspace = parentWorkspace.relative(nodeURIDir);
111
- workspacePrefixString = workspaceRoots.length > 1 ? this.labelProvider.getName(parentWorkspace) : '';
112
- filePathString = relativeDirFromWorkspace?.fsPath() ?? '';
113
- separator = filePathString && workspacePrefixString ? ' \u2022 ' : ''; // add a bullet point between workspace and path
114
- } else {
115
- workspacePrefixString = nodeURIDir.path.fsPath();
116
- }
117
- return `${workspacePrefixString}${separator}${filePathString}`;
118
- }
119
-
120
- /**
121
- * Traverses up the tree from the given node and attaches decorations to any parents.
122
- */
123
- protected appendContainerMarkers(node: TreeNode, decoration: TreeDecoration.Data, decorations: Map<string, TreeDecoration.Data>): void {
124
- let parent = node?.parent;
125
- while (parent) {
126
- const existing = decorations.get(parent.id);
127
- // Make sure the highest diagnostic severity (smaller number) will be propagated to the container directory.
128
- if (existing === undefined || this.compareDecorators(existing, decoration) < 0) {
129
- decorations.set(parent.id, decoration);
130
- parent = parent.parent;
131
- } else {
132
- break;
133
- }
134
- }
135
- }
136
-
137
- /**
138
- * @returns a map matching stringified URI's to a decoration whose features reflect the highest-severity problem found
139
- * and the number of problems found (based on {@link ProblemDecorator.toDecorator })
140
- */
141
- protected collectMarkers(tree: Tree): Map<string, TreeDecoration.Data> {
142
- const decorationsForUri = new Map();
143
- const compare = this.compare.bind(this);
144
- const filter = this.filterMarker.bind(this);
145
- for (const [, markers] of this.problemManager.getMarkersByUri()) {
146
- const relevant = markers.findMarkers({}).filter(filter).sort(compare);
147
- if (relevant.length) {
148
- decorationsForUri.set(relevant[0].uri, this.toDecorator(relevant));
149
- }
150
- }
151
- return decorationsForUri;
152
- }
153
-
154
- protected toDecorator(markers: Marker<Diagnostic>[]): TreeDecoration.Data {
155
- const color = this.getColor(markers[0]);
156
- const priority = this.getPriority(markers[0]);
157
- return {
158
- priority,
159
- fontData: {
160
- color,
161
- },
162
- tailDecorations: [{
163
- color,
164
- data: markers.length.toString(),
165
- }],
166
- };
167
- }
168
-
169
- protected getColor(marker: Marker<Diagnostic>): TreeDecoration.Color {
170
- const { severity } = marker.data;
171
- switch (severity) {
172
- case 1: return 'var(--theia-list-errorForeground)';
173
- case 2: return 'var(--theia-list-warningForeground)';
174
- default: return 'var(--theia-successBackground)';
175
- }
176
- }
177
-
178
- /**
179
- * Get the decoration for a given marker diagnostic.
180
- * Markers with higher severity have a higher priority and should be displayed.
181
- * @param marker the diagnostic marker.
182
- */
183
- protected getPriority(marker: Marker<Diagnostic>): number {
184
- const { severity } = marker.data;
185
- switch (severity) {
186
- case 1: return 30; // Errors.
187
- case 2: return 20; // Warnings.
188
- case 3: return 10; // Infos.
189
- default: return 0;
190
- }
191
- }
192
-
193
- /**
194
- * Returns `true` if the diagnostic (`data`) of the marker argument has `Error`, `Warning`, or `Information` severity.
195
- * Otherwise, returns `false`.
196
- */
197
- protected filterMarker(marker: Marker<Diagnostic>): boolean {
198
- const { severity } = marker.data;
199
- return severity === DiagnosticSeverity.Error
200
- || severity === DiagnosticSeverity.Warning
201
- || severity === DiagnosticSeverity.Information;
202
- }
203
-
204
- protected getUriFromNode(node: TreeNode): string | undefined {
205
- return FileStatNode.getUri(node);
206
- }
207
-
208
- protected compare(left: Marker<Diagnostic>, right: Marker<Diagnostic>): number {
209
- return ProblemDecorator.severityCompare(left, right);
210
- }
211
-
212
- protected compareDecorators(left: TreeDecoration.Data, right: TreeDecoration.Data): number {
213
- return TreeDecoration.Data.comparePriority(left, right);
214
- }
215
- }
216
-
217
- export namespace ProblemDecorator {
218
-
219
- // Highest severities (errors) come first, then the others. Undefined severities treated as the last ones.
220
- export const severityCompare = ProblemUtils.severityCompareMarker;
221
-
222
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
+ import { Diagnostic, DiagnosticSeverity } from '@theia/core/shared/vscode-languageserver-protocol';
19
+ import URI from '@theia/core/lib/common/uri';
20
+ import { Event, Emitter } from '@theia/core/lib/common/event';
21
+ import { Tree, TreeNode } from '@theia/core/lib/browser/tree/tree';
22
+ import { DepthFirstTreeIterator } from '@theia/core/lib/browser/tree/tree-iterator';
23
+ import { TreeDecorator, TreeDecoration } from '@theia/core/lib/browser/tree/tree-decorator';
24
+ import { FileStatNode } from '@theia/filesystem/lib/browser';
25
+ import { Marker } from '../../common/marker';
26
+ import { ProblemManager } from './problem-manager';
27
+ import { ProblemPreferences } from './problem-preferences';
28
+ import { ProblemUtils } from './problem-utils';
29
+ import { LabelProvider } from '@theia/core/lib/browser';
30
+ import { WorkspaceService } from '@theia/workspace/lib/browser';
31
+
32
+ /**
33
+ * @deprecated since 1.25.0
34
+ * URI-based decorators should implement `DecorationsProvider` and contribute decorations via the `DecorationsService`.
35
+ */
36
+ @injectable()
37
+ export class ProblemDecorator implements TreeDecorator {
38
+
39
+ @inject(ProblemPreferences)
40
+ protected problemPreferences: ProblemPreferences;
41
+ @inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
42
+ @inject(LabelProvider) protected readonly labelProvider: LabelProvider;
43
+
44
+ readonly id = 'theia-problem-decorator';
45
+
46
+ protected readonly emitter: Emitter<(tree: Tree) => Map<string, TreeDecoration.Data>>;
47
+
48
+ constructor(@inject(ProblemManager) protected readonly problemManager: ProblemManager) {
49
+ this.emitter = new Emitter();
50
+ this.problemManager.onDidChangeMarkers(() => this.fireDidChangeDecorations((tree: Tree) => this.collectDecorators(tree)));
51
+ }
52
+
53
+ @postConstruct()
54
+ protected init(): void {
55
+ this.problemPreferences.onPreferenceChanged(event => {
56
+ if (event.preferenceName === 'problems.decorations.enabled') {
57
+ this.fireDidChangeDecorations(tree => this.collectDecorators(tree));
58
+ }
59
+ });
60
+ this.workspaceService.onWorkspaceChanged(() => {
61
+ this.fireDidChangeDecorations((tree: Tree) => this.collectDecorators(tree));
62
+ });
63
+ this.workspaceService.onWorkspaceLocationChanged(() => {
64
+ this.fireDidChangeDecorations((tree: Tree) => this.collectDecorators(tree));
65
+ });
66
+ }
67
+
68
+ async decorations(tree: Tree): Promise<Map<string, TreeDecoration.Data>> {
69
+ return this.collectDecorators(tree);
70
+ }
71
+
72
+ get onDidChangeDecorations(): Event<(tree: Tree) => Map<string, TreeDecoration.Data>> {
73
+ return this.emitter.event;
74
+ }
75
+
76
+ protected fireDidChangeDecorations(event: (tree: Tree) => Map<string, TreeDecoration.Data>): void {
77
+ this.emitter.fire(event);
78
+ }
79
+
80
+ protected collectDecorators(tree: Tree): Map<string, TreeDecoration.Data> {
81
+ const decorations = new Map<string, TreeDecoration.Data>();
82
+ // If the tree root is undefined or the preference for the decorations is disabled, return an empty result map.
83
+ if (!tree.root || !this.problemPreferences['problems.decorations.enabled']) {
84
+ return decorations;
85
+ }
86
+ const baseDecorations = this.collectMarkers(tree);
87
+ for (const node of new DepthFirstTreeIterator(tree.root)) {
88
+ const nodeUri = this.getUriFromNode(node);
89
+ if (nodeUri) {
90
+ const decorator = baseDecorations.get(nodeUri);
91
+ if (decorator) {
92
+ this.appendContainerMarkers(node, decorator, decorations);
93
+ }
94
+ if (decorator) {
95
+ decorations.set(node.id, decorator);
96
+ }
97
+ }
98
+ }
99
+ return decorations;
100
+ }
101
+
102
+ protected generateCaptionSuffix(nodeURI: URI): string {
103
+ const workspaceRoots = this.workspaceService.tryGetRoots();
104
+ const parentWorkspace = this.workspaceService.getWorkspaceRootUri(nodeURI);
105
+ let workspacePrefixString = '';
106
+ let separator = '';
107
+ let filePathString = '';
108
+ const nodeURIDir = nodeURI.parent;
109
+ if (parentWorkspace) {
110
+ const relativeDirFromWorkspace = parentWorkspace.relative(nodeURIDir);
111
+ workspacePrefixString = workspaceRoots.length > 1 ? this.labelProvider.getName(parentWorkspace) : '';
112
+ filePathString = relativeDirFromWorkspace?.fsPath() ?? '';
113
+ separator = filePathString && workspacePrefixString ? ' \u2022 ' : ''; // add a bullet point between workspace and path
114
+ } else {
115
+ workspacePrefixString = nodeURIDir.path.fsPath();
116
+ }
117
+ return `${workspacePrefixString}${separator}${filePathString}`;
118
+ }
119
+
120
+ /**
121
+ * Traverses up the tree from the given node and attaches decorations to any parents.
122
+ */
123
+ protected appendContainerMarkers(node: TreeNode, decoration: TreeDecoration.Data, decorations: Map<string, TreeDecoration.Data>): void {
124
+ let parent = node?.parent;
125
+ while (parent) {
126
+ const existing = decorations.get(parent.id);
127
+ // Make sure the highest diagnostic severity (smaller number) will be propagated to the container directory.
128
+ if (existing === undefined || this.compareDecorators(existing, decoration) < 0) {
129
+ decorations.set(parent.id, decoration);
130
+ parent = parent.parent;
131
+ } else {
132
+ break;
133
+ }
134
+ }
135
+ }
136
+
137
+ /**
138
+ * @returns a map matching stringified URI's to a decoration whose features reflect the highest-severity problem found
139
+ * and the number of problems found (based on {@link ProblemDecorator.toDecorator })
140
+ */
141
+ protected collectMarkers(tree: Tree): Map<string, TreeDecoration.Data> {
142
+ const decorationsForUri = new Map();
143
+ const compare = this.compare.bind(this);
144
+ const filter = this.filterMarker.bind(this);
145
+ for (const [, markers] of this.problemManager.getMarkersByUri()) {
146
+ const relevant = markers.findMarkers({}).filter(filter).sort(compare);
147
+ if (relevant.length) {
148
+ decorationsForUri.set(relevant[0].uri, this.toDecorator(relevant));
149
+ }
150
+ }
151
+ return decorationsForUri;
152
+ }
153
+
154
+ protected toDecorator(markers: Marker<Diagnostic>[]): TreeDecoration.Data {
155
+ const color = this.getColor(markers[0]);
156
+ const priority = this.getPriority(markers[0]);
157
+ return {
158
+ priority,
159
+ fontData: {
160
+ color,
161
+ },
162
+ tailDecorations: [{
163
+ color,
164
+ data: markers.length.toString(),
165
+ }],
166
+ };
167
+ }
168
+
169
+ protected getColor(marker: Marker<Diagnostic>): TreeDecoration.Color {
170
+ const { severity } = marker.data;
171
+ switch (severity) {
172
+ case 1: return 'var(--theia-list-errorForeground)';
173
+ case 2: return 'var(--theia-list-warningForeground)';
174
+ default: return 'var(--theia-successBackground)';
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Get the decoration for a given marker diagnostic.
180
+ * Markers with higher severity have a higher priority and should be displayed.
181
+ * @param marker the diagnostic marker.
182
+ */
183
+ protected getPriority(marker: Marker<Diagnostic>): number {
184
+ const { severity } = marker.data;
185
+ switch (severity) {
186
+ case 1: return 30; // Errors.
187
+ case 2: return 20; // Warnings.
188
+ case 3: return 10; // Infos.
189
+ default: return 0;
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Returns `true` if the diagnostic (`data`) of the marker argument has `Error`, `Warning`, or `Information` severity.
195
+ * Otherwise, returns `false`.
196
+ */
197
+ protected filterMarker(marker: Marker<Diagnostic>): boolean {
198
+ const { severity } = marker.data;
199
+ return severity === DiagnosticSeverity.Error
200
+ || severity === DiagnosticSeverity.Warning
201
+ || severity === DiagnosticSeverity.Information;
202
+ }
203
+
204
+ protected getUriFromNode(node: TreeNode): string | undefined {
205
+ return FileStatNode.getUri(node);
206
+ }
207
+
208
+ protected compare(left: Marker<Diagnostic>, right: Marker<Diagnostic>): number {
209
+ return ProblemDecorator.severityCompare(left, right);
210
+ }
211
+
212
+ protected compareDecorators(left: TreeDecoration.Data, right: TreeDecoration.Data): number {
213
+ return TreeDecoration.Data.comparePriority(left, right);
214
+ }
215
+ }
216
+
217
+ export namespace ProblemDecorator {
218
+
219
+ // Highest severities (errors) come first, then the others. Undefined severities treated as the last ones.
220
+ export const severityCompare = ProblemUtils.severityCompareMarker;
221
+
222
+ }
@@ -1,64 +1,64 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2017 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import '../../../src/browser/style/index.css';
18
-
19
- import { ContainerModule } from '@theia/core/shared/inversify';
20
- import { ProblemWidget, PROBLEMS_WIDGET_ID } from './problem-widget';
21
- import { ProblemContribution } from './problem-contribution';
22
- import { createProblemWidget } from './problem-container';
23
- import { FrontendApplicationContribution, bindViewContribution, ApplicationShellLayoutMigration, LabelProviderContribution } from '@theia/core/lib/browser';
24
- import { ProblemManager } from './problem-manager';
25
- import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
26
- import { ProblemTabBarDecorator } from './problem-tabbar-decorator';
27
- import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
28
- import { ProblemLayoutVersion3Migration } from './problem-layout-migrations';
29
- import { TabBarDecorator } from '@theia/core/lib/browser/shell/tab-bar-decorator';
30
- import { bindProblemPreferences } from './problem-preferences';
31
- import { MarkerTreeLabelProvider } from '../marker-tree-label-provider';
32
- import { ProblemWidgetTabBarDecorator } from './problem-widget-tab-bar-decorator';
33
- import { ProblemDecorationContribution, ProblemDecorationsProvider } from './problem-decorations-provider';
34
-
35
- export default new ContainerModule(bind => {
36
- bindProblemPreferences(bind);
37
-
38
- bind(ProblemManager).toSelf().inSingletonScope();
39
-
40
- bind(ProblemWidget).toDynamicValue(ctx =>
41
- createProblemWidget(ctx.container)
42
- );
43
- bind(WidgetFactory).toDynamicValue(context => ({
44
- id: PROBLEMS_WIDGET_ID,
45
- createWidget: () => context.container.get<ProblemWidget>(ProblemWidget)
46
- }));
47
- bind(ApplicationShellLayoutMigration).to(ProblemLayoutVersion3Migration).inSingletonScope();
48
-
49
- bindViewContribution(bind, ProblemContribution);
50
- bind(FrontendApplicationContribution).toService(ProblemContribution);
51
- bind(TabBarToolbarContribution).toService(ProblemContribution);
52
-
53
- bind(ProblemDecorationsProvider).toSelf().inSingletonScope();
54
- bind(ProblemTabBarDecorator).toSelf().inSingletonScope();
55
- bind(TabBarDecorator).toService(ProblemTabBarDecorator);
56
- bind(ProblemDecorationContribution).toSelf().inSingletonScope();
57
- bind(FrontendApplicationContribution).toService(ProblemDecorationContribution);
58
-
59
- bind(MarkerTreeLabelProvider).toSelf().inSingletonScope();
60
- bind(LabelProviderContribution).toService(MarkerTreeLabelProvider);
61
-
62
- bind(ProblemWidgetTabBarDecorator).toSelf().inSingletonScope();
63
- bind(TabBarDecorator).toService(ProblemWidgetTabBarDecorator);
64
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2017 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import '../../../src/browser/style/index.css';
18
+
19
+ import { ContainerModule } from '@theia/core/shared/inversify';
20
+ import { ProblemWidget, PROBLEMS_WIDGET_ID } from './problem-widget';
21
+ import { ProblemContribution } from './problem-contribution';
22
+ import { createProblemWidget } from './problem-container';
23
+ import { FrontendApplicationContribution, bindViewContribution, ApplicationShellLayoutMigration, LabelProviderContribution } from '@theia/core/lib/browser';
24
+ import { ProblemManager } from './problem-manager';
25
+ import { WidgetFactory } from '@theia/core/lib/browser/widget-manager';
26
+ import { ProblemTabBarDecorator } from './problem-tabbar-decorator';
27
+ import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
28
+ import { ProblemLayoutVersion3Migration } from './problem-layout-migrations';
29
+ import { TabBarDecorator } from '@theia/core/lib/browser/shell/tab-bar-decorator';
30
+ import { bindProblemPreferences } from './problem-preferences';
31
+ import { MarkerTreeLabelProvider } from '../marker-tree-label-provider';
32
+ import { ProblemWidgetTabBarDecorator } from './problem-widget-tab-bar-decorator';
33
+ import { ProblemDecorationContribution, ProblemDecorationsProvider } from './problem-decorations-provider';
34
+
35
+ export default new ContainerModule(bind => {
36
+ bindProblemPreferences(bind);
37
+
38
+ bind(ProblemManager).toSelf().inSingletonScope();
39
+
40
+ bind(ProblemWidget).toDynamicValue(ctx =>
41
+ createProblemWidget(ctx.container)
42
+ );
43
+ bind(WidgetFactory).toDynamicValue(context => ({
44
+ id: PROBLEMS_WIDGET_ID,
45
+ createWidget: () => context.container.get<ProblemWidget>(ProblemWidget)
46
+ }));
47
+ bind(ApplicationShellLayoutMigration).to(ProblemLayoutVersion3Migration).inSingletonScope();
48
+
49
+ bindViewContribution(bind, ProblemContribution);
50
+ bind(FrontendApplicationContribution).toService(ProblemContribution);
51
+ bind(TabBarToolbarContribution).toService(ProblemContribution);
52
+
53
+ bind(ProblemDecorationsProvider).toSelf().inSingletonScope();
54
+ bind(ProblemTabBarDecorator).toSelf().inSingletonScope();
55
+ bind(TabBarDecorator).toService(ProblemTabBarDecorator);
56
+ bind(ProblemDecorationContribution).toSelf().inSingletonScope();
57
+ bind(FrontendApplicationContribution).toService(ProblemDecorationContribution);
58
+
59
+ bind(MarkerTreeLabelProvider).toSelf().inSingletonScope();
60
+ bind(LabelProviderContribution).toService(MarkerTreeLabelProvider);
61
+
62
+ bind(ProblemWidgetTabBarDecorator).toSelf().inSingletonScope();
63
+ bind(TabBarDecorator).toService(ProblemWidgetTabBarDecorator);
64
+ });
@@ -1,32 +1,32 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable } from '@theia/core/shared/inversify';
18
- import { ApplicationShellLayoutMigration, WidgetDescription } from '@theia/core/lib/browser/shell/shell-layout-restorer';
19
- import { PROBLEM_KIND } from '../../common/problem-marker';
20
- import { PROBLEMS_WIDGET_ID } from './problem-widget';
21
-
22
- @injectable()
23
- export class ProblemLayoutVersion3Migration implements ApplicationShellLayoutMigration {
24
- readonly layoutVersion = 3.0;
25
- onWillInflateWidget(desc: WidgetDescription): WidgetDescription | undefined {
26
- if (desc.constructionOptions.factoryId === PROBLEM_KIND) {
27
- desc.constructionOptions.factoryId = PROBLEMS_WIDGET_ID;
28
- return desc;
29
- }
30
- return undefined;
31
- }
32
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2019 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable } from '@theia/core/shared/inversify';
18
+ import { ApplicationShellLayoutMigration, WidgetDescription } from '@theia/core/lib/browser/shell/shell-layout-restorer';
19
+ import { PROBLEM_KIND } from '../../common/problem-marker';
20
+ import { PROBLEMS_WIDGET_ID } from './problem-widget';
21
+
22
+ @injectable()
23
+ export class ProblemLayoutVersion3Migration implements ApplicationShellLayoutMigration {
24
+ readonly layoutVersion = 3.0;
25
+ onWillInflateWidget(desc: WidgetDescription): WidgetDescription | undefined {
26
+ if (desc.constructionOptions.factoryId === PROBLEM_KIND) {
27
+ desc.constructionOptions.factoryId = PROBLEMS_WIDGET_ID;
28
+ return desc;
29
+ }
30
+ return undefined;
31
+ }
32
+ }