@theia/markers 1.34.3 → 1.34.4

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 (82) 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 -16
  52. package/lib/common/marker.js +31 -31
  53. package/lib/common/problem-marker.d.ts +9 -9
  54. package/lib/common/problem-marker.js +27 -27
  55. package/package.json +6 -6
  56. package/src/browser/index.ts +18 -18
  57. package/src/browser/marker-manager.ts +205 -205
  58. package/src/browser/marker-tree-label-provider.spec.ts +245 -245
  59. package/src/browser/marker-tree-label-provider.ts +75 -75
  60. package/src/browser/marker-tree-model.ts +47 -47
  61. package/src/browser/marker-tree.ts +154 -154
  62. package/src/browser/problem/problem-composite-tree-node.spec.ts +255 -255
  63. package/src/browser/problem/problem-composite-tree-node.ts +68 -68
  64. package/src/browser/problem/problem-container.ts +47 -47
  65. package/src/browser/problem/problem-contribution.ts +247 -247
  66. package/src/browser/problem/problem-decorations-provider.ts +67 -67
  67. package/src/browser/problem/problem-decorator.ts +222 -222
  68. package/src/browser/problem/problem-frontend-module.ts +64 -64
  69. package/src/browser/problem/problem-layout-migrations.ts +32 -32
  70. package/src/browser/problem/problem-manager.spec.ts +216 -216
  71. package/src/browser/problem/problem-manager.ts +51 -51
  72. package/src/browser/problem/problem-preferences.ts +64 -64
  73. package/src/browser/problem/problem-selection.ts +45 -45
  74. package/src/browser/problem/problem-tabbar-decorator.ts +151 -151
  75. package/src/browser/problem/problem-tree-model.spec.ts +189 -189
  76. package/src/browser/problem/problem-tree-model.ts +113 -113
  77. package/src/browser/problem/problem-utils.ts +90 -90
  78. package/src/browser/problem/problem-widget-tab-bar-decorator.ts +55 -55
  79. package/src/browser/problem/problem-widget.tsx +241 -241
  80. package/src/browser/style/index.css +92 -92
  81. package/src/common/marker.ts +53 -53
  82. package/src/common/problem-marker.ts +30 -30
@@ -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 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 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 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 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,216 +1,216 @@
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 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
18
-
19
- const disableJSDOM = enableJSDOM();
20
-
21
- import * as chai from 'chai';
22
- import URI from '@theia/core/lib/common/uri';
23
-
24
- import { Container } from '@theia/core/shared/inversify';
25
- import { ProblemManager } from './problem-manager';
26
- import { Event } from '@theia/core/lib/common/event';
27
- import { ILogger } from '@theia/core/lib/common/logger';
28
- import { DiagnosticSeverity, Range } from '@theia/core/shared/vscode-languageserver-protocol';
29
- import { MockLogger } from '@theia/core/lib/common/test/mock-logger';
30
- import { FileService } from '@theia/filesystem/lib/browser/file-service';
31
- import { LocalStorageService, StorageService } from '@theia/core/lib/browser/storage-service';
32
-
33
- disableJSDOM();
34
-
35
- const expect = chai.expect;
36
-
37
- let manager: ProblemManager;
38
- let container: Container;
39
-
40
- /**
41
- * The default range for test purposes.
42
- */
43
- const range: Range = { start: { line: 0, character: 10 }, end: { line: 0, character: 10 } };
44
-
45
- describe('problem-manager', () => {
46
-
47
- beforeEach(() => {
48
- container = new Container();
49
- container.bind(ILogger).to(MockLogger);
50
- container.bind(StorageService).to(LocalStorageService).inSingletonScope();
51
- container.bind(LocalStorageService).toSelf().inSingletonScope();
52
- container.bind(FileService).toConstantValue(<FileService>{
53
- onDidFilesChange: Event.None
54
- });
55
- container.bind(ProblemManager).toSelf();
56
- manager = container.get(ProblemManager);
57
- });
58
-
59
- describe('#setMarkers', () => {
60
-
61
- it('should successfully set new markers', () => {
62
- expect(Array.from(manager.getUris()).length).to.equal(0);
63
- manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range }]);
64
- expect(Array.from(manager.getUris()).length).to.equal(1);
65
- });
66
-
67
- it('should replace markers', () => {
68
- const uri = new URI('a');
69
-
70
- let events = 0;
71
- manager.onDidChangeMarkers(() => events++);
72
- expect(events).equal(0);
73
-
74
- const initial = manager.setMarkers(uri, 'a', [{ message: 'a', range }]);
75
- expect(initial.length).equal(0);
76
- expect(events).equal(1);
77
-
78
- const updated = manager.setMarkers(uri, 'a', [{ message: 'a', range }]);
79
- expect(updated.length).equal(1);
80
- expect(events).equal(2);
81
-
82
- expect(manager.findMarkers({ uri }).length).equal(1);
83
- });
84
-
85
- });
86
-
87
- describe('#cleanAllMarkers', () => {
88
-
89
- it('should successfully clean all markers', () => {
90
- // Create mock markers.
91
- manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range }]);
92
- manager.setMarkers(new URI('b'), 'b', [{ message: 'a', range }]);
93
- manager.setMarkers(new URI('c'), 'c', [{ message: 'a', range }]);
94
- expect(Array.from(manager.getUris()).length).to.equal(3);
95
-
96
- // Clean the markers.
97
- manager.cleanAllMarkers();
98
- expect(Array.from(manager.getUris()).length).to.equal(0);
99
- });
100
-
101
- });
102
-
103
- describe('#findMarkers', () => {
104
-
105
- it('should find markers by `owner`', () => {
106
- const owner: string = 'foo';
107
- manager.setMarkers(new URI('a'), owner, [{ message: 'a', range }]);
108
- manager.setMarkers(new URI('b'), owner, [{ message: 'a', range }]);
109
-
110
- expect(manager.findMarkers({ owner }).length).equal(2);
111
- expect(manager.findMarkers({ owner: 'unknown' }).length).equal(0);
112
- });
113
-
114
- it('should find markers by `owner` and `uri`', () => {
115
- const owner: string = 'foo';
116
- const uri = new URI('bar');
117
-
118
- // Create a marker to match the filter.
119
- manager.setMarkers(uri, owner, [{ message: 'a', range }]);
120
-
121
- // Create 2 markers that do not match the filter.
122
- manager.setMarkers(new URI('invalid'), 'invalid-owner', [{ message: 'a', range }]);
123
- manager.setMarkers(new URI('invalid'), 'invalid-owner', [{ message: 'a', range }]);
124
-
125
- // Expect to find the markers which satisfy the filter only.
126
- expect(manager.findMarkers({ owner, uri }).length).equal(1);
127
- });
128
-
129
- describe('dataFilter', () => {
130
-
131
- it('should find markers that satisfy filter for `severity`', () => {
132
- manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
133
- expect(manager.findMarkers({ dataFilter: d => d.severity === DiagnosticSeverity.Error }).length).equal(1);
134
- expect(manager.findMarkers({ dataFilter: d => d.severity !== DiagnosticSeverity.Error }).length).equal(0);
135
- });
136
-
137
- it('should find markers that satisfy filter for `code`', () => {
138
- const code = 100;
139
- manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range, code }]);
140
- expect(manager.findMarkers({ dataFilter: d => d.code === code }).length).equal(1);
141
- expect(manager.findMarkers({ dataFilter: d => d.code !== code }).length).equal(0);
142
- });
143
-
144
- it('should find markers that satisfy filter for `message`', () => {
145
- const message = 'foo';
146
- manager.setMarkers(new URI('a'), 'a', [{ message, range }]);
147
- expect(manager.findMarkers({ dataFilter: d => d.message === message }).length).equal(1);
148
- expect(manager.findMarkers({ dataFilter: d => d.message !== message }).length).equal(0);
149
- });
150
-
151
- it('should find markers that satisfy filter for `source`', () => {
152
- const source = 'typescript';
153
- manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range, source }]);
154
- expect(manager.findMarkers({ dataFilter: d => d.source === source }).length).equal(1);
155
- expect(manager.findMarkers({ dataFilter: d => d.source !== source }).length).equal(0);
156
- });
157
-
158
- it('should find markers that satisfy filter for `range`', () => {
159
- manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range }]);
160
- // The default `range` has a start line number of 0.
161
- expect(manager.findMarkers({ dataFilter: d => d.range.start.line === 0 }).length).equal(1);
162
- expect(manager.findMarkers({ dataFilter: d => d.range.start.line > 0 }).length).equal(0);
163
- });
164
-
165
- });
166
-
167
- });
168
-
169
- describe('#getUris', () => {
170
-
171
- it('should return 0 uris when no markers are present', () => {
172
- expect(Array.from(manager.getUris()).length).to.equal(0);
173
- });
174
-
175
- it('should return the list of uris', () => {
176
- manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
177
- manager.setMarkers(new URI('b'), 'b', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
178
- expect(Array.from(manager.getUris()).length).to.equal(2);
179
- });
180
-
181
- });
182
-
183
- describe('#getProblemStat', () => {
184
-
185
- it('should return 0 stats when no markers are present', () => {
186
- const { errors, warnings, infos } = manager.getProblemStat();
187
- expect(errors).to.equal(0);
188
- expect(warnings).to.equal(0);
189
- expect(infos).to.equal(0);
190
- });
191
-
192
- it('should return the proper problem stats', () => {
193
-
194
- // Create 3 error markers.
195
- manager.setMarkers(new URI('error-1'), 'error-1', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
196
- manager.setMarkers(new URI('error-2'), 'error-2', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
197
- manager.setMarkers(new URI('error-3'), 'error-3', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
198
-
199
- // Create 2 warning markers.
200
- manager.setMarkers(new URI('warning-1'), 'warning-1', [{ message: 'a', range, severity: DiagnosticSeverity.Warning }]);
201
- manager.setMarkers(new URI('warning-2'), 'warning-2', [{ message: 'a', range, severity: DiagnosticSeverity.Warning }]);
202
-
203
- // Create 1 info marker.
204
- manager.setMarkers(new URI('info-1'), 'info-1', [{ message: 'a', range, severity: DiagnosticSeverity.Information }]);
205
-
206
- // Collect the total problem stats for the application.
207
- const { errors, warnings, infos } = manager.getProblemStat();
208
-
209
- expect(errors).to.equal(3);
210
- expect(warnings).to.equal(2);
211
- expect(infos).to.equal(1);
212
- });
213
-
214
- });
215
-
216
- });
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 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
18
+
19
+ const disableJSDOM = enableJSDOM();
20
+
21
+ import * as chai from 'chai';
22
+ import URI from '@theia/core/lib/common/uri';
23
+
24
+ import { Container } from '@theia/core/shared/inversify';
25
+ import { ProblemManager } from './problem-manager';
26
+ import { Event } from '@theia/core/lib/common/event';
27
+ import { ILogger } from '@theia/core/lib/common/logger';
28
+ import { DiagnosticSeverity, Range } from '@theia/core/shared/vscode-languageserver-protocol';
29
+ import { MockLogger } from '@theia/core/lib/common/test/mock-logger';
30
+ import { FileService } from '@theia/filesystem/lib/browser/file-service';
31
+ import { LocalStorageService, StorageService } from '@theia/core/lib/browser/storage-service';
32
+
33
+ disableJSDOM();
34
+
35
+ const expect = chai.expect;
36
+
37
+ let manager: ProblemManager;
38
+ let container: Container;
39
+
40
+ /**
41
+ * The default range for test purposes.
42
+ */
43
+ const range: Range = { start: { line: 0, character: 10 }, end: { line: 0, character: 10 } };
44
+
45
+ describe('problem-manager', () => {
46
+
47
+ beforeEach(() => {
48
+ container = new Container();
49
+ container.bind(ILogger).to(MockLogger);
50
+ container.bind(StorageService).to(LocalStorageService).inSingletonScope();
51
+ container.bind(LocalStorageService).toSelf().inSingletonScope();
52
+ container.bind(FileService).toConstantValue(<FileService>{
53
+ onDidFilesChange: Event.None
54
+ });
55
+ container.bind(ProblemManager).toSelf();
56
+ manager = container.get(ProblemManager);
57
+ });
58
+
59
+ describe('#setMarkers', () => {
60
+
61
+ it('should successfully set new markers', () => {
62
+ expect(Array.from(manager.getUris()).length).to.equal(0);
63
+ manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range }]);
64
+ expect(Array.from(manager.getUris()).length).to.equal(1);
65
+ });
66
+
67
+ it('should replace markers', () => {
68
+ const uri = new URI('a');
69
+
70
+ let events = 0;
71
+ manager.onDidChangeMarkers(() => events++);
72
+ expect(events).equal(0);
73
+
74
+ const initial = manager.setMarkers(uri, 'a', [{ message: 'a', range }]);
75
+ expect(initial.length).equal(0);
76
+ expect(events).equal(1);
77
+
78
+ const updated = manager.setMarkers(uri, 'a', [{ message: 'a', range }]);
79
+ expect(updated.length).equal(1);
80
+ expect(events).equal(2);
81
+
82
+ expect(manager.findMarkers({ uri }).length).equal(1);
83
+ });
84
+
85
+ });
86
+
87
+ describe('#cleanAllMarkers', () => {
88
+
89
+ it('should successfully clean all markers', () => {
90
+ // Create mock markers.
91
+ manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range }]);
92
+ manager.setMarkers(new URI('b'), 'b', [{ message: 'a', range }]);
93
+ manager.setMarkers(new URI('c'), 'c', [{ message: 'a', range }]);
94
+ expect(Array.from(manager.getUris()).length).to.equal(3);
95
+
96
+ // Clean the markers.
97
+ manager.cleanAllMarkers();
98
+ expect(Array.from(manager.getUris()).length).to.equal(0);
99
+ });
100
+
101
+ });
102
+
103
+ describe('#findMarkers', () => {
104
+
105
+ it('should find markers by `owner`', () => {
106
+ const owner: string = 'foo';
107
+ manager.setMarkers(new URI('a'), owner, [{ message: 'a', range }]);
108
+ manager.setMarkers(new URI('b'), owner, [{ message: 'a', range }]);
109
+
110
+ expect(manager.findMarkers({ owner }).length).equal(2);
111
+ expect(manager.findMarkers({ owner: 'unknown' }).length).equal(0);
112
+ });
113
+
114
+ it('should find markers by `owner` and `uri`', () => {
115
+ const owner: string = 'foo';
116
+ const uri = new URI('bar');
117
+
118
+ // Create a marker to match the filter.
119
+ manager.setMarkers(uri, owner, [{ message: 'a', range }]);
120
+
121
+ // Create 2 markers that do not match the filter.
122
+ manager.setMarkers(new URI('invalid'), 'invalid-owner', [{ message: 'a', range }]);
123
+ manager.setMarkers(new URI('invalid'), 'invalid-owner', [{ message: 'a', range }]);
124
+
125
+ // Expect to find the markers which satisfy the filter only.
126
+ expect(manager.findMarkers({ owner, uri }).length).equal(1);
127
+ });
128
+
129
+ describe('dataFilter', () => {
130
+
131
+ it('should find markers that satisfy filter for `severity`', () => {
132
+ manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
133
+ expect(manager.findMarkers({ dataFilter: d => d.severity === DiagnosticSeverity.Error }).length).equal(1);
134
+ expect(manager.findMarkers({ dataFilter: d => d.severity !== DiagnosticSeverity.Error }).length).equal(0);
135
+ });
136
+
137
+ it('should find markers that satisfy filter for `code`', () => {
138
+ const code = 100;
139
+ manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range, code }]);
140
+ expect(manager.findMarkers({ dataFilter: d => d.code === code }).length).equal(1);
141
+ expect(manager.findMarkers({ dataFilter: d => d.code !== code }).length).equal(0);
142
+ });
143
+
144
+ it('should find markers that satisfy filter for `message`', () => {
145
+ const message = 'foo';
146
+ manager.setMarkers(new URI('a'), 'a', [{ message, range }]);
147
+ expect(manager.findMarkers({ dataFilter: d => d.message === message }).length).equal(1);
148
+ expect(manager.findMarkers({ dataFilter: d => d.message !== message }).length).equal(0);
149
+ });
150
+
151
+ it('should find markers that satisfy filter for `source`', () => {
152
+ const source = 'typescript';
153
+ manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range, source }]);
154
+ expect(manager.findMarkers({ dataFilter: d => d.source === source }).length).equal(1);
155
+ expect(manager.findMarkers({ dataFilter: d => d.source !== source }).length).equal(0);
156
+ });
157
+
158
+ it('should find markers that satisfy filter for `range`', () => {
159
+ manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range }]);
160
+ // The default `range` has a start line number of 0.
161
+ expect(manager.findMarkers({ dataFilter: d => d.range.start.line === 0 }).length).equal(1);
162
+ expect(manager.findMarkers({ dataFilter: d => d.range.start.line > 0 }).length).equal(0);
163
+ });
164
+
165
+ });
166
+
167
+ });
168
+
169
+ describe('#getUris', () => {
170
+
171
+ it('should return 0 uris when no markers are present', () => {
172
+ expect(Array.from(manager.getUris()).length).to.equal(0);
173
+ });
174
+
175
+ it('should return the list of uris', () => {
176
+ manager.setMarkers(new URI('a'), 'a', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
177
+ manager.setMarkers(new URI('b'), 'b', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
178
+ expect(Array.from(manager.getUris()).length).to.equal(2);
179
+ });
180
+
181
+ });
182
+
183
+ describe('#getProblemStat', () => {
184
+
185
+ it('should return 0 stats when no markers are present', () => {
186
+ const { errors, warnings, infos } = manager.getProblemStat();
187
+ expect(errors).to.equal(0);
188
+ expect(warnings).to.equal(0);
189
+ expect(infos).to.equal(0);
190
+ });
191
+
192
+ it('should return the proper problem stats', () => {
193
+
194
+ // Create 3 error markers.
195
+ manager.setMarkers(new URI('error-1'), 'error-1', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
196
+ manager.setMarkers(new URI('error-2'), 'error-2', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
197
+ manager.setMarkers(new URI('error-3'), 'error-3', [{ message: 'a', range, severity: DiagnosticSeverity.Error }]);
198
+
199
+ // Create 2 warning markers.
200
+ manager.setMarkers(new URI('warning-1'), 'warning-1', [{ message: 'a', range, severity: DiagnosticSeverity.Warning }]);
201
+ manager.setMarkers(new URI('warning-2'), 'warning-2', [{ message: 'a', range, severity: DiagnosticSeverity.Warning }]);
202
+
203
+ // Create 1 info marker.
204
+ manager.setMarkers(new URI('info-1'), 'info-1', [{ message: 'a', range, severity: DiagnosticSeverity.Information }]);
205
+
206
+ // Collect the total problem stats for the application.
207
+ const { errors, warnings, infos } = manager.getProblemStat();
208
+
209
+ expect(errors).to.equal(3);
210
+ expect(warnings).to.equal(2);
211
+ expect(infos).to.equal(1);
212
+ });
213
+
214
+ });
215
+
216
+ });