@theia/markers 1.45.1 → 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/README.md +33 -33
- package/lib/browser/index.d.ts +2 -2
- package/lib/browser/index.js +29 -29
- package/lib/browser/marker-manager.d.ts +47 -47
- package/lib/browser/marker-manager.js +187 -187
- package/lib/browser/marker-tree-label-provider.d.ts +15 -15
- package/lib/browser/marker-tree-label-provider.js +84 -84
- package/lib/browser/marker-tree-label-provider.spec.d.ts +1 -1
- package/lib/browser/marker-tree-label-provider.spec.js +201 -201
- package/lib/browser/marker-tree-model.d.ts +12 -12
- package/lib/browser/marker-tree-model.js +60 -60
- package/lib/browser/marker-tree.d.ts +42 -42
- package/lib/browser/marker-tree.js +143 -143
- package/lib/browser/problem/problem-composite-tree-node.d.ts +11 -11
- package/lib/browser/problem/problem-composite-tree-node.js +76 -76
- package/lib/browser/problem/problem-composite-tree-node.spec.d.ts +1 -1
- package/lib/browser/problem/problem-composite-tree-node.spec.js +238 -238
- package/lib/browser/problem/problem-container.d.ts +8 -8
- package/lib/browser/problem/problem-container.js +46 -46
- package/lib/browser/problem/problem-contribution.d.ts +51 -51
- package/lib/browser/problem/problem-contribution.js +247 -247
- package/lib/browser/problem/problem-decorations-provider.d.ts +21 -21
- package/lib/browser/problem/problem-decorations-provider.js +95 -95
- package/lib/browser/problem/problem-decorator.d.ts +57 -57
- package/lib/browser/problem/problem-decorator.js +233 -233
- package/lib/browser/problem/problem-frontend-module.d.ts +4 -4
- package/lib/browser/problem/problem-frontend-module.js +55 -55
- package/lib/browser/problem/problem-layout-migrations.d.ts +5 -5
- package/lib/browser/problem/problem-layout-migrations.js +43 -43
- package/lib/browser/problem/problem-manager.d.ts +11 -11
- package/lib/browser/problem/problem-manager.js +53 -53
- package/lib/browser/problem/problem-manager.spec.d.ts +1 -1
- package/lib/browser/problem/problem-manager.spec.js +167 -167
- package/lib/browser/problem/problem-preferences.d.ts +13 -13
- package/lib/browser/problem/problem-preferences.js +56 -56
- package/lib/browser/problem/problem-selection.d.ts +12 -12
- package/lib/browser/problem/problem-selection.js +34 -34
- package/lib/browser/problem/problem-tabbar-decorator.d.ts +42 -42
- package/lib/browser/problem/problem-tabbar-decorator.js +160 -160
- package/lib/browser/problem/problem-tree-model.d.ts +32 -32
- package/lib/browser/problem/problem-tree-model.js +131 -131
- package/lib/browser/problem/problem-tree-model.spec.d.ts +1 -1
- package/lib/browser/problem/problem-tree-model.spec.js +172 -172
- package/lib/browser/problem/problem-utils.d.ts +44 -44
- package/lib/browser/problem/problem-utils.js +84 -84
- package/lib/browser/problem/problem-widget-tab-bar-decorator.d.ts +14 -14
- package/lib/browser/problem/problem-widget-tab-bar-decorator.js +69 -69
- package/lib/browser/problem/problem-widget.d.ts +46 -46
- package/lib/browser/problem/problem-widget.js +235 -235
- package/lib/common/marker.d.ts +16 -16
- package/lib/common/marker.js +31 -31
- package/lib/common/problem-marker.d.ts +9 -9
- package/lib/common/problem-marker.js +27 -27
- package/package.json +6 -6
- package/src/browser/index.ts +18 -18
- package/src/browser/marker-manager.ts +205 -205
- package/src/browser/marker-tree-label-provider.spec.ts +245 -245
- package/src/browser/marker-tree-label-provider.ts +75 -75
- package/src/browser/marker-tree-model.ts +47 -47
- package/src/browser/marker-tree.ts +154 -154
- package/src/browser/problem/problem-composite-tree-node.spec.ts +277 -277
- package/src/browser/problem/problem-composite-tree-node.ts +81 -81
- package/src/browser/problem/problem-container.ts +47 -47
- package/src/browser/problem/problem-contribution.ts +247 -247
- package/src/browser/problem/problem-decorations-provider.ts +72 -72
- package/src/browser/problem/problem-decorator.ts +222 -222
- package/src/browser/problem/problem-frontend-module.ts +64 -64
- package/src/browser/problem/problem-layout-migrations.ts +32 -32
- package/src/browser/problem/problem-manager.spec.ts +216 -216
- package/src/browser/problem/problem-manager.ts +51 -51
- package/src/browser/problem/problem-preferences.ts +64 -64
- package/src/browser/problem/problem-selection.ts +45 -45
- package/src/browser/problem/problem-tabbar-decorator.ts +151 -151
- package/src/browser/problem/problem-tree-model.spec.ts +189 -189
- package/src/browser/problem/problem-tree-model.ts +124 -124
- package/src/browser/problem/problem-utils.ts +90 -90
- package/src/browser/problem/problem-widget-tab-bar-decorator.ts +55 -55
- package/src/browser/problem/problem-widget.tsx +246 -246
- package/src/browser/style/index.css +92 -92
- package/src/common/marker.ts +53 -53
- package/src/common/problem-marker.ts +30 -30
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Ericsson 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 { interfaces } from '@theia/core/shared/inversify';
|
|
18
|
-
import { createPreferenceProxy, PreferenceProxy, PreferenceService, PreferenceContribution, PreferenceSchema } from '@theia/core/lib/browser';
|
|
19
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
20
|
-
|
|
21
|
-
export const ProblemConfigSchema: PreferenceSchema = {
|
|
22
|
-
'type': 'object',
|
|
23
|
-
'properties': {
|
|
24
|
-
'problems.decorations.enabled': {
|
|
25
|
-
'type': 'boolean',
|
|
26
|
-
'description': nls.localizeByDefault('Show Errors & Warnings on files and folder.'),
|
|
27
|
-
'default': true,
|
|
28
|
-
},
|
|
29
|
-
'problems.decorations.tabbar.enabled': {
|
|
30
|
-
'type': 'boolean',
|
|
31
|
-
'description': nls.localize('theia/markers/tabbarDecorationsEnabled', 'Show problem decorators (diagnostic markers) in the tab bars.'),
|
|
32
|
-
'default': true
|
|
33
|
-
},
|
|
34
|
-
'problems.autoReveal': {
|
|
35
|
-
'type': 'boolean',
|
|
36
|
-
'description': nls.localizeByDefault('Controls whether Problems view should automatically reveal files when opening them.'),
|
|
37
|
-
'default': true
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export interface ProblemConfiguration {
|
|
43
|
-
'problems.decorations.enabled': boolean,
|
|
44
|
-
'problems.decorations.tabbar.enabled': boolean,
|
|
45
|
-
'problems.autoReveal': boolean
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const ProblemPreferenceContribution = Symbol('ProblemPreferenceContribution');
|
|
49
|
-
export const ProblemPreferences = Symbol('ProblemPreferences');
|
|
50
|
-
export type ProblemPreferences = PreferenceProxy<ProblemConfiguration>;
|
|
51
|
-
|
|
52
|
-
export function createProblemPreferences(preferences: PreferenceService, schema: PreferenceSchema = ProblemConfigSchema): ProblemPreferences {
|
|
53
|
-
return createPreferenceProxy(preferences, schema);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const bindProblemPreferences = (bind: interfaces.Bind): void => {
|
|
57
|
-
bind(ProblemPreferences).toDynamicValue(ctx => {
|
|
58
|
-
const preferences = ctx.container.get<PreferenceService>(PreferenceService);
|
|
59
|
-
const contribution = ctx.container.get<PreferenceContribution>(ProblemPreferenceContribution);
|
|
60
|
-
return createProblemPreferences(preferences, contribution.schema);
|
|
61
|
-
}).inSingletonScope();
|
|
62
|
-
bind(ProblemPreferenceContribution).toConstantValue({ schema: ProblemConfigSchema });
|
|
63
|
-
bind(PreferenceContribution).toService(ProblemPreferenceContribution);
|
|
64
|
-
};
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Ericsson 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 { interfaces } from '@theia/core/shared/inversify';
|
|
18
|
+
import { createPreferenceProxy, PreferenceProxy, PreferenceService, PreferenceContribution, PreferenceSchema } from '@theia/core/lib/browser';
|
|
19
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
20
|
+
|
|
21
|
+
export const ProblemConfigSchema: PreferenceSchema = {
|
|
22
|
+
'type': 'object',
|
|
23
|
+
'properties': {
|
|
24
|
+
'problems.decorations.enabled': {
|
|
25
|
+
'type': 'boolean',
|
|
26
|
+
'description': nls.localizeByDefault('Show Errors & Warnings on files and folder.'),
|
|
27
|
+
'default': true,
|
|
28
|
+
},
|
|
29
|
+
'problems.decorations.tabbar.enabled': {
|
|
30
|
+
'type': 'boolean',
|
|
31
|
+
'description': nls.localize('theia/markers/tabbarDecorationsEnabled', 'Show problem decorators (diagnostic markers) in the tab bars.'),
|
|
32
|
+
'default': true
|
|
33
|
+
},
|
|
34
|
+
'problems.autoReveal': {
|
|
35
|
+
'type': 'boolean',
|
|
36
|
+
'description': nls.localizeByDefault('Controls whether Problems view should automatically reveal files when opening them.'),
|
|
37
|
+
'default': true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export interface ProblemConfiguration {
|
|
43
|
+
'problems.decorations.enabled': boolean,
|
|
44
|
+
'problems.decorations.tabbar.enabled': boolean,
|
|
45
|
+
'problems.autoReveal': boolean
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const ProblemPreferenceContribution = Symbol('ProblemPreferenceContribution');
|
|
49
|
+
export const ProblemPreferences = Symbol('ProblemPreferences');
|
|
50
|
+
export type ProblemPreferences = PreferenceProxy<ProblemConfiguration>;
|
|
51
|
+
|
|
52
|
+
export function createProblemPreferences(preferences: PreferenceService, schema: PreferenceSchema = ProblemConfigSchema): ProblemPreferences {
|
|
53
|
+
return createPreferenceProxy(preferences, schema);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const bindProblemPreferences = (bind: interfaces.Bind): void => {
|
|
57
|
+
bind(ProblemPreferences).toDynamicValue(ctx => {
|
|
58
|
+
const preferences = ctx.container.get<PreferenceService>(PreferenceService);
|
|
59
|
+
const contribution = ctx.container.get<PreferenceContribution>(ProblemPreferenceContribution);
|
|
60
|
+
return createProblemPreferences(preferences, contribution.schema);
|
|
61
|
+
}).inSingletonScope();
|
|
62
|
+
bind(ProblemPreferenceContribution).toConstantValue({ schema: ProblemConfigSchema });
|
|
63
|
+
bind(PreferenceContribution).toService(ProblemPreferenceContribution);
|
|
64
|
+
};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Ericsson 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 { SelectionService } from '@theia/core/lib/common/selection-service';
|
|
18
|
-
import { SelectionCommandHandler } from '@theia/core/lib/common/selection-command-handler';
|
|
19
|
-
import { isObject } from '@theia/core/lib/common';
|
|
20
|
-
import { Marker } from '../../common/marker';
|
|
21
|
-
import { ProblemMarker } from '../../common/problem-marker';
|
|
22
|
-
|
|
23
|
-
export interface ProblemSelection {
|
|
24
|
-
marker: Marker<object>;
|
|
25
|
-
}
|
|
26
|
-
export namespace ProblemSelection {
|
|
27
|
-
export function is(arg: unknown): arg is ProblemSelection {
|
|
28
|
-
return isObject<ProblemSelection>(arg) && ProblemMarker.is(arg.marker);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class CommandHandler extends SelectionCommandHandler<ProblemSelection> {
|
|
32
|
-
|
|
33
|
-
constructor(
|
|
34
|
-
selectionService: SelectionService,
|
|
35
|
-
options: SelectionCommandHandler.Options<ProblemSelection>
|
|
36
|
-
) {
|
|
37
|
-
super(
|
|
38
|
-
selectionService,
|
|
39
|
-
arg => ProblemSelection.is(arg) ? arg : undefined,
|
|
40
|
-
options
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Ericsson 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 { SelectionService } from '@theia/core/lib/common/selection-service';
|
|
18
|
+
import { SelectionCommandHandler } from '@theia/core/lib/common/selection-command-handler';
|
|
19
|
+
import { isObject } from '@theia/core/lib/common';
|
|
20
|
+
import { Marker } from '../../common/marker';
|
|
21
|
+
import { ProblemMarker } from '../../common/problem-marker';
|
|
22
|
+
|
|
23
|
+
export interface ProblemSelection {
|
|
24
|
+
marker: Marker<object>;
|
|
25
|
+
}
|
|
26
|
+
export namespace ProblemSelection {
|
|
27
|
+
export function is(arg: unknown): arg is ProblemSelection {
|
|
28
|
+
return isObject<ProblemSelection>(arg) && ProblemMarker.is(arg.marker);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class CommandHandler extends SelectionCommandHandler<ProblemSelection> {
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
selectionService: SelectionService,
|
|
35
|
+
options: SelectionCommandHandler.Options<ProblemSelection>
|
|
36
|
+
) {
|
|
37
|
+
super(
|
|
38
|
+
selectionService,
|
|
39
|
+
arg => ProblemSelection.is(arg) ? arg : undefined,
|
|
40
|
+
options
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 Ericsson 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 { Event, Emitter } from '@theia/core/lib/common/event';
|
|
20
|
-
import { Title, Widget } from '@theia/core/shared/@phosphor/widgets';
|
|
21
|
-
import { WidgetDecoration } from '@theia/core/lib/browser/widget-decoration';
|
|
22
|
-
import { TabBarDecorator } from '@theia/core/lib/browser/shell/tab-bar-decorator';
|
|
23
|
-
import { Marker } from '../../common/marker';
|
|
24
|
-
import { ProblemManager } from './problem-manager';
|
|
25
|
-
import { ProblemPreferences, ProblemConfiguration } from './problem-preferences';
|
|
26
|
-
import { PreferenceChangeEvent, Navigatable } from '@theia/core/lib/browser';
|
|
27
|
-
|
|
28
|
-
@injectable()
|
|
29
|
-
export class ProblemTabBarDecorator implements TabBarDecorator {
|
|
30
|
-
|
|
31
|
-
readonly id = 'theia-problem-tabbar-decorator';
|
|
32
|
-
|
|
33
|
-
protected readonly emitter = new Emitter<void>();
|
|
34
|
-
|
|
35
|
-
@inject(ProblemPreferences)
|
|
36
|
-
protected readonly preferences: ProblemPreferences;
|
|
37
|
-
|
|
38
|
-
@inject(ProblemManager)
|
|
39
|
-
protected readonly problemManager: ProblemManager;
|
|
40
|
-
|
|
41
|
-
@postConstruct()
|
|
42
|
-
protected init(): void {
|
|
43
|
-
this.problemManager.onDidChangeMarkers(() => this.fireDidChangeDecorations());
|
|
44
|
-
this.preferences.onPreferenceChanged(event => this.handlePreferenceChange(event));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
decorate(title: Title<Widget>): WidgetDecoration.Data[] {
|
|
48
|
-
if (!this.preferences['problems.decorations.tabbar.enabled']) {
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
const widget = title.owner;
|
|
52
|
-
if (Navigatable.is(widget)) {
|
|
53
|
-
const resourceUri = widget.getResourceUri();
|
|
54
|
-
if (resourceUri) {
|
|
55
|
-
// Get the list of problem markers for the given resource URI.
|
|
56
|
-
const markers: Marker<Diagnostic>[] = this.problemManager.findMarkers({ uri: resourceUri });
|
|
57
|
-
// If no markers are available, return early.
|
|
58
|
-
if (markers.length === 0) {
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
// Store the marker with the highest severity.
|
|
62
|
-
let maxSeverity: Marker<Diagnostic> | undefined;
|
|
63
|
-
// Iterate over available markers to determine that which has the highest severity.
|
|
64
|
-
// Only display a decoration if an error or warning marker is available.
|
|
65
|
-
for (const marker of markers) {
|
|
66
|
-
// Break early if an error marker is present, since it represents the highest severity.
|
|
67
|
-
if (marker.data.severity === DiagnosticSeverity.Error) {
|
|
68
|
-
maxSeverity = marker;
|
|
69
|
-
break;
|
|
70
|
-
} else if (marker.data.severity === DiagnosticSeverity.Warning) {
|
|
71
|
-
maxSeverity = marker;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// Decorate the tabbar with the highest marker severity if available.
|
|
75
|
-
return maxSeverity ? [this.toDecorator(maxSeverity)] : [];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
get onDidChangeDecorations(): Event<void> {
|
|
82
|
-
return this.emitter.event;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
protected fireDidChangeDecorations(): void {
|
|
86
|
-
this.emitter.fire(undefined);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Handle changes in preference.
|
|
91
|
-
* @param {PreferenceChangeEvent<ProblemConfiguration>} event The event of the changes in preference.
|
|
92
|
-
*/
|
|
93
|
-
protected async handlePreferenceChange(event: PreferenceChangeEvent<ProblemConfiguration>): Promise<void> {
|
|
94
|
-
const { preferenceName } = event;
|
|
95
|
-
if (preferenceName === 'problems.decorations.tabbar.enabled') {
|
|
96
|
-
this.fireDidChangeDecorations();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Convert a diagnostic marker to a decorator.
|
|
102
|
-
* @param {Marker<Diagnostic>} marker A diagnostic marker.
|
|
103
|
-
* @returns {WidgetDecoration.Data} The decoration data.
|
|
104
|
-
*/
|
|
105
|
-
protected toDecorator(marker: Marker<Diagnostic>): WidgetDecoration.Data {
|
|
106
|
-
const position = WidgetDecoration.IconOverlayPosition.BOTTOM_RIGHT;
|
|
107
|
-
const icon = this.getOverlayIcon(marker);
|
|
108
|
-
const color = this.getOverlayIconColor(marker);
|
|
109
|
-
return {
|
|
110
|
-
iconOverlay: {
|
|
111
|
-
position,
|
|
112
|
-
icon,
|
|
113
|
-
color,
|
|
114
|
-
background: {
|
|
115
|
-
shape: 'circle',
|
|
116
|
-
color: 'transparent'
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Get the appropriate overlay icon for decoration.
|
|
124
|
-
* @param {Marker<Diagnostic>} marker A diagnostic marker.
|
|
125
|
-
* @returns {string} A string representing the overlay icon class.
|
|
126
|
-
*/
|
|
127
|
-
protected getOverlayIcon(marker: Marker<Diagnostic>): string {
|
|
128
|
-
const { severity } = marker.data;
|
|
129
|
-
switch (severity) {
|
|
130
|
-
case 1: return 'times-circle';
|
|
131
|
-
case 2: return 'exclamation-circle';
|
|
132
|
-
case 3: return 'info-circle';
|
|
133
|
-
default: return 'hand-o-up';
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Get the appropriate overlay icon color for decoration.
|
|
139
|
-
* @param {Marker<Diagnostic>} marker A diagnostic marker.
|
|
140
|
-
* @returns {WidgetDecoration.Color} The decoration color.
|
|
141
|
-
*/
|
|
142
|
-
protected getOverlayIconColor(marker: Marker<Diagnostic>): WidgetDecoration.Color {
|
|
143
|
-
const { severity } = marker.data;
|
|
144
|
-
switch (severity) {
|
|
145
|
-
case 1: return 'var(--theia-list-errorForeground)';
|
|
146
|
-
case 2: return 'var(--theia-list-warningForeground)';
|
|
147
|
-
default: return 'var(--theia-successBackground)';
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 Ericsson 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 { Event, Emitter } from '@theia/core/lib/common/event';
|
|
20
|
+
import { Title, Widget } from '@theia/core/shared/@phosphor/widgets';
|
|
21
|
+
import { WidgetDecoration } from '@theia/core/lib/browser/widget-decoration';
|
|
22
|
+
import { TabBarDecorator } from '@theia/core/lib/browser/shell/tab-bar-decorator';
|
|
23
|
+
import { Marker } from '../../common/marker';
|
|
24
|
+
import { ProblemManager } from './problem-manager';
|
|
25
|
+
import { ProblemPreferences, ProblemConfiguration } from './problem-preferences';
|
|
26
|
+
import { PreferenceChangeEvent, Navigatable } from '@theia/core/lib/browser';
|
|
27
|
+
|
|
28
|
+
@injectable()
|
|
29
|
+
export class ProblemTabBarDecorator implements TabBarDecorator {
|
|
30
|
+
|
|
31
|
+
readonly id = 'theia-problem-tabbar-decorator';
|
|
32
|
+
|
|
33
|
+
protected readonly emitter = new Emitter<void>();
|
|
34
|
+
|
|
35
|
+
@inject(ProblemPreferences)
|
|
36
|
+
protected readonly preferences: ProblemPreferences;
|
|
37
|
+
|
|
38
|
+
@inject(ProblemManager)
|
|
39
|
+
protected readonly problemManager: ProblemManager;
|
|
40
|
+
|
|
41
|
+
@postConstruct()
|
|
42
|
+
protected init(): void {
|
|
43
|
+
this.problemManager.onDidChangeMarkers(() => this.fireDidChangeDecorations());
|
|
44
|
+
this.preferences.onPreferenceChanged(event => this.handlePreferenceChange(event));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
decorate(title: Title<Widget>): WidgetDecoration.Data[] {
|
|
48
|
+
if (!this.preferences['problems.decorations.tabbar.enabled']) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const widget = title.owner;
|
|
52
|
+
if (Navigatable.is(widget)) {
|
|
53
|
+
const resourceUri = widget.getResourceUri();
|
|
54
|
+
if (resourceUri) {
|
|
55
|
+
// Get the list of problem markers for the given resource URI.
|
|
56
|
+
const markers: Marker<Diagnostic>[] = this.problemManager.findMarkers({ uri: resourceUri });
|
|
57
|
+
// If no markers are available, return early.
|
|
58
|
+
if (markers.length === 0) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
// Store the marker with the highest severity.
|
|
62
|
+
let maxSeverity: Marker<Diagnostic> | undefined;
|
|
63
|
+
// Iterate over available markers to determine that which has the highest severity.
|
|
64
|
+
// Only display a decoration if an error or warning marker is available.
|
|
65
|
+
for (const marker of markers) {
|
|
66
|
+
// Break early if an error marker is present, since it represents the highest severity.
|
|
67
|
+
if (marker.data.severity === DiagnosticSeverity.Error) {
|
|
68
|
+
maxSeverity = marker;
|
|
69
|
+
break;
|
|
70
|
+
} else if (marker.data.severity === DiagnosticSeverity.Warning) {
|
|
71
|
+
maxSeverity = marker;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Decorate the tabbar with the highest marker severity if available.
|
|
75
|
+
return maxSeverity ? [this.toDecorator(maxSeverity)] : [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get onDidChangeDecorations(): Event<void> {
|
|
82
|
+
return this.emitter.event;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected fireDidChangeDecorations(): void {
|
|
86
|
+
this.emitter.fire(undefined);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Handle changes in preference.
|
|
91
|
+
* @param {PreferenceChangeEvent<ProblemConfiguration>} event The event of the changes in preference.
|
|
92
|
+
*/
|
|
93
|
+
protected async handlePreferenceChange(event: PreferenceChangeEvent<ProblemConfiguration>): Promise<void> {
|
|
94
|
+
const { preferenceName } = event;
|
|
95
|
+
if (preferenceName === 'problems.decorations.tabbar.enabled') {
|
|
96
|
+
this.fireDidChangeDecorations();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Convert a diagnostic marker to a decorator.
|
|
102
|
+
* @param {Marker<Diagnostic>} marker A diagnostic marker.
|
|
103
|
+
* @returns {WidgetDecoration.Data} The decoration data.
|
|
104
|
+
*/
|
|
105
|
+
protected toDecorator(marker: Marker<Diagnostic>): WidgetDecoration.Data {
|
|
106
|
+
const position = WidgetDecoration.IconOverlayPosition.BOTTOM_RIGHT;
|
|
107
|
+
const icon = this.getOverlayIcon(marker);
|
|
108
|
+
const color = this.getOverlayIconColor(marker);
|
|
109
|
+
return {
|
|
110
|
+
iconOverlay: {
|
|
111
|
+
position,
|
|
112
|
+
icon,
|
|
113
|
+
color,
|
|
114
|
+
background: {
|
|
115
|
+
shape: 'circle',
|
|
116
|
+
color: 'transparent'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get the appropriate overlay icon for decoration.
|
|
124
|
+
* @param {Marker<Diagnostic>} marker A diagnostic marker.
|
|
125
|
+
* @returns {string} A string representing the overlay icon class.
|
|
126
|
+
*/
|
|
127
|
+
protected getOverlayIcon(marker: Marker<Diagnostic>): string {
|
|
128
|
+
const { severity } = marker.data;
|
|
129
|
+
switch (severity) {
|
|
130
|
+
case 1: return 'times-circle';
|
|
131
|
+
case 2: return 'exclamation-circle';
|
|
132
|
+
case 3: return 'info-circle';
|
|
133
|
+
default: return 'hand-o-up';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Get the appropriate overlay icon color for decoration.
|
|
139
|
+
* @param {Marker<Diagnostic>} marker A diagnostic marker.
|
|
140
|
+
* @returns {WidgetDecoration.Color} The decoration color.
|
|
141
|
+
*/
|
|
142
|
+
protected getOverlayIconColor(marker: Marker<Diagnostic>): WidgetDecoration.Color {
|
|
143
|
+
const { severity } = marker.data;
|
|
144
|
+
switch (severity) {
|
|
145
|
+
case 1: return 'var(--theia-list-errorForeground)';
|
|
146
|
+
case 2: return 'var(--theia-list-warningForeground)';
|
|
147
|
+
default: return 'var(--theia-successBackground)';
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|