@theia/markers 1.34.2 → 1.34.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +33 -33
  3. package/lib/browser/index.d.ts +2 -2
  4. package/lib/browser/index.js +29 -29
  5. package/lib/browser/marker-manager.d.ts +47 -47
  6. package/lib/browser/marker-manager.js +187 -187
  7. package/lib/browser/marker-tree-label-provider.d.ts +15 -15
  8. package/lib/browser/marker-tree-label-provider.js +84 -84
  9. package/lib/browser/marker-tree-label-provider.spec.d.ts +1 -1
  10. package/lib/browser/marker-tree-label-provider.spec.js +201 -201
  11. package/lib/browser/marker-tree-model.d.ts +12 -12
  12. package/lib/browser/marker-tree-model.js +60 -60
  13. package/lib/browser/marker-tree.d.ts +42 -42
  14. package/lib/browser/marker-tree.js +143 -143
  15. package/lib/browser/problem/problem-composite-tree-node.d.ts +8 -8
  16. package/lib/browser/problem/problem-composite-tree-node.js +68 -68
  17. package/lib/browser/problem/problem-composite-tree-node.spec.d.ts +1 -1
  18. package/lib/browser/problem/problem-composite-tree-node.spec.js +216 -216
  19. package/lib/browser/problem/problem-container.d.ts +8 -8
  20. package/lib/browser/problem/problem-container.js +42 -42
  21. package/lib/browser/problem/problem-contribution.d.ts +51 -51
  22. package/lib/browser/problem/problem-contribution.js +247 -247
  23. package/lib/browser/problem/problem-decorations-provider.d.ts +18 -18
  24. package/lib/browser/problem/problem-decorations-provider.js +92 -92
  25. package/lib/browser/problem/problem-decorator.d.ts +57 -57
  26. package/lib/browser/problem/problem-decorator.js +233 -233
  27. package/lib/browser/problem/problem-frontend-module.d.ts +4 -4
  28. package/lib/browser/problem/problem-frontend-module.js +55 -55
  29. package/lib/browser/problem/problem-layout-migrations.d.ts +5 -5
  30. package/lib/browser/problem/problem-layout-migrations.js +43 -43
  31. package/lib/browser/problem/problem-manager.d.ts +11 -11
  32. package/lib/browser/problem/problem-manager.js +53 -53
  33. package/lib/browser/problem/problem-manager.spec.d.ts +1 -1
  34. package/lib/browser/problem/problem-manager.spec.js +167 -167
  35. package/lib/browser/problem/problem-preferences.d.ts +13 -13
  36. package/lib/browser/problem/problem-preferences.js +56 -56
  37. package/lib/browser/problem/problem-selection.d.ts +12 -12
  38. package/lib/browser/problem/problem-selection.js +34 -34
  39. package/lib/browser/problem/problem-tabbar-decorator.d.ts +42 -42
  40. package/lib/browser/problem/problem-tabbar-decorator.js +160 -160
  41. package/lib/browser/problem/problem-tree-model.d.ts +26 -26
  42. package/lib/browser/problem/problem-tree-model.js +122 -122
  43. package/lib/browser/problem/problem-tree-model.spec.d.ts +1 -1
  44. package/lib/browser/problem/problem-tree-model.spec.js +172 -172
  45. package/lib/browser/problem/problem-utils.d.ts +44 -44
  46. package/lib/browser/problem/problem-utils.js +84 -84
  47. package/lib/browser/problem/problem-widget-tab-bar-decorator.d.ts +14 -14
  48. package/lib/browser/problem/problem-widget-tab-bar-decorator.js +69 -69
  49. package/lib/browser/problem/problem-widget.d.ts +45 -45
  50. package/lib/browser/problem/problem-widget.js +231 -231
  51. package/lib/common/marker.d.ts +16 -12
  52. package/lib/common/marker.d.ts.map +1 -1
  53. package/lib/common/marker.js +31 -17
  54. package/lib/common/marker.js.map +1 -1
  55. package/lib/common/problem-marker.d.ts +9 -9
  56. package/lib/common/problem-marker.d.ts.map +1 -1
  57. package/lib/common/problem-marker.js +27 -26
  58. package/lib/common/problem-marker.js.map +1 -1
  59. package/package.json +6 -6
  60. package/src/browser/index.ts +18 -18
  61. package/src/browser/marker-manager.ts +205 -205
  62. package/src/browser/marker-tree-label-provider.spec.ts +245 -245
  63. package/src/browser/marker-tree-label-provider.ts +75 -75
  64. package/src/browser/marker-tree-model.ts +47 -47
  65. package/src/browser/marker-tree.ts +154 -154
  66. package/src/browser/problem/problem-composite-tree-node.spec.ts +255 -255
  67. package/src/browser/problem/problem-composite-tree-node.ts +68 -68
  68. package/src/browser/problem/problem-container.ts +47 -47
  69. package/src/browser/problem/problem-contribution.ts +247 -247
  70. package/src/browser/problem/problem-decorations-provider.ts +67 -67
  71. package/src/browser/problem/problem-decorator.ts +222 -222
  72. package/src/browser/problem/problem-frontend-module.ts +64 -64
  73. package/src/browser/problem/problem-layout-migrations.ts +32 -32
  74. package/src/browser/problem/problem-manager.spec.ts +216 -216
  75. package/src/browser/problem/problem-manager.ts +51 -51
  76. package/src/browser/problem/problem-preferences.ts +64 -64
  77. package/src/browser/problem/problem-selection.ts +45 -45
  78. package/src/browser/problem/problem-tabbar-decorator.ts +151 -151
  79. package/src/browser/problem/problem-tree-model.spec.ts +189 -189
  80. package/src/browser/problem/problem-tree-model.ts +113 -113
  81. package/src/browser/problem/problem-utils.ts +90 -90
  82. package/src/browser/problem/problem-widget-tab-bar-decorator.ts +55 -55
  83. package/src/browser/problem/problem-widget.tsx +241 -241
  84. package/src/browser/style/index.css +92 -92
  85. package/src/common/marker.ts +53 -39
  86. package/src/common/problem-marker.ts +30 -30
@@ -1,85 +1,85 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2019 TypeFox and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.MarkerTreeLabelProvider = void 0;
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const label_provider_1 = require("@theia/core/lib/browser/label-provider");
30
- const marker_tree_1 = require("./marker-tree");
31
- const tree_label_provider_1 = require("@theia/core/lib/browser/tree/tree-label-provider");
32
- const browser_1 = require("@theia/workspace/lib/browser");
33
- let MarkerTreeLabelProvider = class MarkerTreeLabelProvider {
34
- canHandle(element) {
35
- return marker_tree_1.MarkerInfoNode.is(element) ?
36
- this.treeLabelProvider.canHandle(element) + 1 :
37
- 0;
38
- }
39
- getIcon(node) {
40
- return this.labelProvider.getIcon(node.uri);
41
- }
42
- getName(node) {
43
- return this.labelProvider.getName(node.uri);
44
- }
45
- getLongName(node) {
46
- const description = [];
47
- const rootUri = this.workspaceService.getWorkspaceRootUri(node.uri);
48
- // In a multiple-root workspace include the root name to the label before the parent directory.
49
- if (this.workspaceService.isMultiRootWorkspaceOpened && rootUri) {
50
- description.push(this.labelProvider.getName(rootUri));
51
- }
52
- // If the given resource is not at the workspace root, include the parent directory to the label.
53
- if (rootUri && rootUri.toString() !== node.uri.parent.toString()) {
54
- description.push(this.labelProvider.getLongName(node.uri.parent));
55
- }
56
- // Get the full path of a resource which does not exist in the given workspace.
57
- if (!rootUri) {
58
- description.push(this.labelProvider.getLongName(node.uri.parent.withScheme('markers')));
59
- }
60
- return description.join(' ● ');
61
- }
62
- getDescription(node) {
63
- return this.labelProvider.getLongName(node.uri.parent);
64
- }
65
- affects(node, event) {
66
- return event.affects(node.uri) || event.affects(node.uri.parent);
67
- }
68
- };
69
- __decorate([
70
- (0, inversify_1.inject)(label_provider_1.LabelProvider),
71
- __metadata("design:type", label_provider_1.LabelProvider)
72
- ], MarkerTreeLabelProvider.prototype, "labelProvider", void 0);
73
- __decorate([
74
- (0, inversify_1.inject)(tree_label_provider_1.TreeLabelProvider),
75
- __metadata("design:type", tree_label_provider_1.TreeLabelProvider)
76
- ], MarkerTreeLabelProvider.prototype, "treeLabelProvider", void 0);
77
- __decorate([
78
- (0, inversify_1.inject)(browser_1.WorkspaceService),
79
- __metadata("design:type", browser_1.WorkspaceService)
80
- ], MarkerTreeLabelProvider.prototype, "workspaceService", void 0);
81
- MarkerTreeLabelProvider = __decorate([
82
- (0, inversify_1.injectable)()
83
- ], MarkerTreeLabelProvider);
84
- exports.MarkerTreeLabelProvider = MarkerTreeLabelProvider;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2019 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.MarkerTreeLabelProvider = void 0;
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const label_provider_1 = require("@theia/core/lib/browser/label-provider");
30
+ const marker_tree_1 = require("./marker-tree");
31
+ const tree_label_provider_1 = require("@theia/core/lib/browser/tree/tree-label-provider");
32
+ const browser_1 = require("@theia/workspace/lib/browser");
33
+ let MarkerTreeLabelProvider = class MarkerTreeLabelProvider {
34
+ canHandle(element) {
35
+ return marker_tree_1.MarkerInfoNode.is(element) ?
36
+ this.treeLabelProvider.canHandle(element) + 1 :
37
+ 0;
38
+ }
39
+ getIcon(node) {
40
+ return this.labelProvider.getIcon(node.uri);
41
+ }
42
+ getName(node) {
43
+ return this.labelProvider.getName(node.uri);
44
+ }
45
+ getLongName(node) {
46
+ const description = [];
47
+ const rootUri = this.workspaceService.getWorkspaceRootUri(node.uri);
48
+ // In a multiple-root workspace include the root name to the label before the parent directory.
49
+ if (this.workspaceService.isMultiRootWorkspaceOpened && rootUri) {
50
+ description.push(this.labelProvider.getName(rootUri));
51
+ }
52
+ // If the given resource is not at the workspace root, include the parent directory to the label.
53
+ if (rootUri && rootUri.toString() !== node.uri.parent.toString()) {
54
+ description.push(this.labelProvider.getLongName(node.uri.parent));
55
+ }
56
+ // Get the full path of a resource which does not exist in the given workspace.
57
+ if (!rootUri) {
58
+ description.push(this.labelProvider.getLongName(node.uri.parent.withScheme('markers')));
59
+ }
60
+ return description.join(' ● ');
61
+ }
62
+ getDescription(node) {
63
+ return this.labelProvider.getLongName(node.uri.parent);
64
+ }
65
+ affects(node, event) {
66
+ return event.affects(node.uri) || event.affects(node.uri.parent);
67
+ }
68
+ };
69
+ __decorate([
70
+ (0, inversify_1.inject)(label_provider_1.LabelProvider),
71
+ __metadata("design:type", label_provider_1.LabelProvider)
72
+ ], MarkerTreeLabelProvider.prototype, "labelProvider", void 0);
73
+ __decorate([
74
+ (0, inversify_1.inject)(tree_label_provider_1.TreeLabelProvider),
75
+ __metadata("design:type", tree_label_provider_1.TreeLabelProvider)
76
+ ], MarkerTreeLabelProvider.prototype, "treeLabelProvider", void 0);
77
+ __decorate([
78
+ (0, inversify_1.inject)(browser_1.WorkspaceService),
79
+ __metadata("design:type", browser_1.WorkspaceService)
80
+ ], MarkerTreeLabelProvider.prototype, "workspaceService", void 0);
81
+ MarkerTreeLabelProvider = __decorate([
82
+ (0, inversify_1.injectable)()
83
+ ], MarkerTreeLabelProvider);
84
+ exports.MarkerTreeLabelProvider = MarkerTreeLabelProvider;
85
85
  //# sourceMappingURL=marker-tree-label-provider.js.map
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=marker-tree-label-provider.spec.d.ts.map
@@ -1,202 +1,202 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2020 Ericsson and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
19
- let disableJSDOM = (0, jsdom_1.enableJSDOM)();
20
- const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
21
- frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
22
- const uri_1 = require("@theia/core/lib/common/uri");
23
- const chai_1 = require("chai");
24
- const inversify_1 = require("@theia/core/shared/inversify");
25
- const common_1 = require("@theia/core/lib/common");
26
- const browser_1 = require("@theia/core/lib/browser");
27
- const marker_tree_label_provider_1 = require("./marker-tree-label-provider");
28
- const tree_label_provider_1 = require("@theia/core/lib/browser/tree/tree-label-provider");
29
- const browser_2 = require("@theia/workspace/lib/browser");
30
- const workspace_uri_contribution_1 = require("@theia/workspace/lib/browser/workspace-uri-contribution");
31
- const workspace_variable_contribution_1 = require("@theia/workspace/lib/browser/workspace-variable-contribution");
32
- const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
33
- const files_1 = require("@theia/filesystem/lib/common/files");
34
- const env_variables_1 = require("@theia/core/lib/common/env-variables");
35
- const mock_env_variables_server_1 = require("@theia/core/lib/browser/test/mock-env-variables-server");
36
- const node_1 = require("@theia/core/lib/node");
37
- const os_1 = require("@theia/core/lib/common/os");
38
- const temp = require("temp");
39
- disableJSDOM();
40
- let markerTreeLabelProvider;
41
- let workspaceService;
42
- before(() => {
43
- disableJSDOM = (0, jsdom_1.enableJSDOM)();
44
- const testContainer = new inversify_1.Container();
45
- workspaceService = new browser_2.WorkspaceService();
46
- testContainer.bind(browser_2.WorkspaceService).toConstantValue(workspaceService);
47
- testContainer.bind(workspace_variable_contribution_1.WorkspaceVariableContribution).toSelf().inSingletonScope();
48
- testContainer.bind(browser_1.ApplicationShell).toConstantValue({
49
- onDidChangeCurrentWidget: () => undefined,
50
- widgets: []
51
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
- });
53
- testContainer.bind(browser_1.WidgetManager).toConstantValue({
54
- onDidCreateWidget: common_1.Event.None
55
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
- });
57
- testContainer.bind(file_service_1.FileService).toConstantValue({});
58
- testContainer.bind(browser_1.DefaultUriLabelProviderContribution).toSelf().inSingletonScope();
59
- testContainer.bind(workspace_uri_contribution_1.WorkspaceUriLabelProviderContribution).toSelf().inSingletonScope();
60
- testContainer.bind(browser_1.LabelProvider).toSelf().inSingletonScope();
61
- testContainer.bind(marker_tree_label_provider_1.MarkerTreeLabelProvider).toSelf().inSingletonScope();
62
- testContainer.bind(tree_label_provider_1.TreeLabelProvider).toSelf().inSingletonScope();
63
- testContainer.bind(env_variables_1.EnvVariablesServer).toConstantValue(new mock_env_variables_server_1.MockEnvVariablesServerImpl(node_1.FileUri.create(temp.track().mkdirSync())));
64
- testContainer.bind(common_1.ContributionProvider).toDynamicValue(ctx => ({
65
- getContributions() {
66
- return [
67
- ctx.container.get(marker_tree_label_provider_1.MarkerTreeLabelProvider),
68
- ctx.container.get(tree_label_provider_1.TreeLabelProvider),
69
- ctx.container.get(workspace_uri_contribution_1.WorkspaceUriLabelProviderContribution),
70
- ctx.container.get(browser_1.DefaultUriLabelProviderContribution)
71
- ];
72
- }
73
- })).inSingletonScope();
74
- markerTreeLabelProvider = testContainer.get(marker_tree_label_provider_1.MarkerTreeLabelProvider);
75
- workspaceService = testContainer.get(browser_2.WorkspaceService);
76
- });
77
- after(() => {
78
- disableJSDOM();
79
- });
80
- describe('Marker Tree Label Provider', () => {
81
- describe('#getName', () => {
82
- it('should return the correct filename and extension', () => {
83
- const label = markerTreeLabelProvider.getName(createMarkerInfoNode('a/b/c/foo.ts'));
84
- (0, chai_1.expect)(label).equals('foo.ts');
85
- });
86
- });
87
- describe('getLongName', () => {
88
- describe('single-root workspace', () => {
89
- beforeEach(() => {
90
- const root = files_1.FileStat.dir('file:///home/a');
91
- workspaceService['_workspace'] = root;
92
- workspaceService['_roots'] = [root];
93
- });
94
- it('should return the proper label for a directory', () => {
95
- const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///home/a/b/c/foo.ts'));
96
- (0, chai_1.expect)(label).equals('b/c');
97
- });
98
- it('should return the proper label for a directory starting with \'.\'', () => {
99
- const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///home/a/b/.c/foo.ts'));
100
- (0, chai_1.expect)(label).equals('b/.c');
101
- });
102
- it('should return the proper label when the resource is located at the workspace root', () => {
103
- const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///home/a/foo.ts'));
104
- (0, chai_1.expect)(label).equals('');
105
- });
106
- it('should return the full path when the resource does not exist in the workspace root', () => {
107
- const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///home/b/foo.ts'));
108
- if (os_1.OS.backend.isWindows) {
109
- (0, chai_1.expect)(label).eq('\\home\\b');
110
- }
111
- else {
112
- (0, chai_1.expect)(label).eq('/home/b');
113
- }
114
- });
115
- });
116
- describe('multi-root workspace', () => {
117
- beforeEach(() => {
118
- const uri = 'file:///file';
119
- const file = files_1.FileStat.file(uri);
120
- const root1 = files_1.FileStat.dir('file:///root1');
121
- const root2 = files_1.FileStat.dir('file:///root2');
122
- workspaceService['_workspace'] = file;
123
- workspaceService['_roots'] = [root1, root2];
124
- });
125
- it('should return the proper root \'root1\' and directory', () => {
126
- const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///root1/foo/foo.ts'));
127
- (0, chai_1.expect)(label).equals('root1 ● foo');
128
- });
129
- it('should return the proper root \'root2\' and directory', () => {
130
- const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///root2/foo/foo.ts'));
131
- (0, chai_1.expect)(label).equals('root2 ● foo');
132
- });
133
- it('should only return the root when the resource is located at the workspace root', () => {
134
- const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///root1/foo.ts'));
135
- (0, chai_1.expect)(label).equals('root1');
136
- });
137
- it('should return the full path when the resource does not exist in any workspace root', () => {
138
- const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///home/a/b/foo.ts'));
139
- if (os_1.OS.backend.isWindows) {
140
- (0, chai_1.expect)(label).eq('\\home\\a\\b');
141
- }
142
- else {
143
- (0, chai_1.expect)(label).eq('/home/a/b');
144
- }
145
- });
146
- });
147
- });
148
- describe('#getIcon', () => {
149
- it('should return a typescript icon for a typescript file', () => {
150
- const icon = markerTreeLabelProvider.getIcon(createMarkerInfoNode('a/b/c/foo.ts'));
151
- (0, chai_1.expect)(icon).contain('ts-icon');
152
- });
153
- it('should return a json icon for a json file', () => {
154
- const icon = markerTreeLabelProvider.getIcon(createMarkerInfoNode('a/b/c/foo.json'));
155
- (0, chai_1.expect)(icon).contain('database-icon');
156
- });
157
- it('should return a generic icon for a file with no extension', () => {
158
- const icon = markerTreeLabelProvider.getIcon(createMarkerInfoNode('a/b/c/foo.md'));
159
- (0, chai_1.expect)(icon).contain('markdown-icon');
160
- });
161
- });
162
- describe('#getDescription', () => {
163
- beforeEach(() => {
164
- const root = files_1.FileStat.dir('file:///home/a');
165
- workspaceService['_workspace'] = root;
166
- workspaceService['_roots'] = [root];
167
- });
168
- it('should return the parent\' long name', () => {
169
- const label = markerTreeLabelProvider.getDescription(createMarkerInfoNode('file:///home/a/b/c/foo.ts'));
170
- (0, chai_1.expect)(label).equals('b/c');
171
- });
172
- });
173
- describe('#canHandle', () => {
174
- it('should successfully handle \'MarkerInfoNodes\'', () => {
175
- const node = createMarkerInfoNode('a/b/c/foo.ts');
176
- (0, chai_1.expect)(markerTreeLabelProvider.canHandle(node)).greaterThan(0);
177
- });
178
- });
179
- });
180
- /**
181
- * Create a marker info node for test purposes.
182
- * @param uri the marker uri.
183
- *
184
- * @returns a mock marker info node.
185
- */
186
- function createMarkerInfoNode(uri) {
187
- return {
188
- id: 'id',
189
- parent: {
190
- id: 'parent-id',
191
- kind: '',
192
- parent: undefined,
193
- children: []
194
- },
195
- numberOfMarkers: 1,
196
- children: [],
197
- expanded: true,
198
- selected: true,
199
- uri: new uri_1.default(uri)
200
- };
201
- }
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2020 Ericsson and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
19
+ let disableJSDOM = (0, jsdom_1.enableJSDOM)();
20
+ const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
21
+ frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
22
+ const uri_1 = require("@theia/core/lib/common/uri");
23
+ const chai_1 = require("chai");
24
+ const inversify_1 = require("@theia/core/shared/inversify");
25
+ const common_1 = require("@theia/core/lib/common");
26
+ const browser_1 = require("@theia/core/lib/browser");
27
+ const marker_tree_label_provider_1 = require("./marker-tree-label-provider");
28
+ const tree_label_provider_1 = require("@theia/core/lib/browser/tree/tree-label-provider");
29
+ const browser_2 = require("@theia/workspace/lib/browser");
30
+ const workspace_uri_contribution_1 = require("@theia/workspace/lib/browser/workspace-uri-contribution");
31
+ const workspace_variable_contribution_1 = require("@theia/workspace/lib/browser/workspace-variable-contribution");
32
+ const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
33
+ const files_1 = require("@theia/filesystem/lib/common/files");
34
+ const env_variables_1 = require("@theia/core/lib/common/env-variables");
35
+ const mock_env_variables_server_1 = require("@theia/core/lib/browser/test/mock-env-variables-server");
36
+ const node_1 = require("@theia/core/lib/node");
37
+ const os_1 = require("@theia/core/lib/common/os");
38
+ const temp = require("temp");
39
+ disableJSDOM();
40
+ let markerTreeLabelProvider;
41
+ let workspaceService;
42
+ before(() => {
43
+ disableJSDOM = (0, jsdom_1.enableJSDOM)();
44
+ const testContainer = new inversify_1.Container();
45
+ workspaceService = new browser_2.WorkspaceService();
46
+ testContainer.bind(browser_2.WorkspaceService).toConstantValue(workspaceService);
47
+ testContainer.bind(workspace_variable_contribution_1.WorkspaceVariableContribution).toSelf().inSingletonScope();
48
+ testContainer.bind(browser_1.ApplicationShell).toConstantValue({
49
+ onDidChangeCurrentWidget: () => undefined,
50
+ widgets: []
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ });
53
+ testContainer.bind(browser_1.WidgetManager).toConstantValue({
54
+ onDidCreateWidget: common_1.Event.None
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ });
57
+ testContainer.bind(file_service_1.FileService).toConstantValue({});
58
+ testContainer.bind(browser_1.DefaultUriLabelProviderContribution).toSelf().inSingletonScope();
59
+ testContainer.bind(workspace_uri_contribution_1.WorkspaceUriLabelProviderContribution).toSelf().inSingletonScope();
60
+ testContainer.bind(browser_1.LabelProvider).toSelf().inSingletonScope();
61
+ testContainer.bind(marker_tree_label_provider_1.MarkerTreeLabelProvider).toSelf().inSingletonScope();
62
+ testContainer.bind(tree_label_provider_1.TreeLabelProvider).toSelf().inSingletonScope();
63
+ testContainer.bind(env_variables_1.EnvVariablesServer).toConstantValue(new mock_env_variables_server_1.MockEnvVariablesServerImpl(node_1.FileUri.create(temp.track().mkdirSync())));
64
+ testContainer.bind(common_1.ContributionProvider).toDynamicValue(ctx => ({
65
+ getContributions() {
66
+ return [
67
+ ctx.container.get(marker_tree_label_provider_1.MarkerTreeLabelProvider),
68
+ ctx.container.get(tree_label_provider_1.TreeLabelProvider),
69
+ ctx.container.get(workspace_uri_contribution_1.WorkspaceUriLabelProviderContribution),
70
+ ctx.container.get(browser_1.DefaultUriLabelProviderContribution)
71
+ ];
72
+ }
73
+ })).inSingletonScope();
74
+ markerTreeLabelProvider = testContainer.get(marker_tree_label_provider_1.MarkerTreeLabelProvider);
75
+ workspaceService = testContainer.get(browser_2.WorkspaceService);
76
+ });
77
+ after(() => {
78
+ disableJSDOM();
79
+ });
80
+ describe('Marker Tree Label Provider', () => {
81
+ describe('#getName', () => {
82
+ it('should return the correct filename and extension', () => {
83
+ const label = markerTreeLabelProvider.getName(createMarkerInfoNode('a/b/c/foo.ts'));
84
+ (0, chai_1.expect)(label).equals('foo.ts');
85
+ });
86
+ });
87
+ describe('getLongName', () => {
88
+ describe('single-root workspace', () => {
89
+ beforeEach(() => {
90
+ const root = files_1.FileStat.dir('file:///home/a');
91
+ workspaceService['_workspace'] = root;
92
+ workspaceService['_roots'] = [root];
93
+ });
94
+ it('should return the proper label for a directory', () => {
95
+ const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///home/a/b/c/foo.ts'));
96
+ (0, chai_1.expect)(label).equals('b/c');
97
+ });
98
+ it('should return the proper label for a directory starting with \'.\'', () => {
99
+ const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///home/a/b/.c/foo.ts'));
100
+ (0, chai_1.expect)(label).equals('b/.c');
101
+ });
102
+ it('should return the proper label when the resource is located at the workspace root', () => {
103
+ const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///home/a/foo.ts'));
104
+ (0, chai_1.expect)(label).equals('');
105
+ });
106
+ it('should return the full path when the resource does not exist in the workspace root', () => {
107
+ const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///home/b/foo.ts'));
108
+ if (os_1.OS.backend.isWindows) {
109
+ (0, chai_1.expect)(label).eq('\\home\\b');
110
+ }
111
+ else {
112
+ (0, chai_1.expect)(label).eq('/home/b');
113
+ }
114
+ });
115
+ });
116
+ describe('multi-root workspace', () => {
117
+ beforeEach(() => {
118
+ const uri = 'file:///file';
119
+ const file = files_1.FileStat.file(uri);
120
+ const root1 = files_1.FileStat.dir('file:///root1');
121
+ const root2 = files_1.FileStat.dir('file:///root2');
122
+ workspaceService['_workspace'] = file;
123
+ workspaceService['_roots'] = [root1, root2];
124
+ });
125
+ it('should return the proper root \'root1\' and directory', () => {
126
+ const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///root1/foo/foo.ts'));
127
+ (0, chai_1.expect)(label).equals('root1 ● foo');
128
+ });
129
+ it('should return the proper root \'root2\' and directory', () => {
130
+ const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///root2/foo/foo.ts'));
131
+ (0, chai_1.expect)(label).equals('root2 ● foo');
132
+ });
133
+ it('should only return the root when the resource is located at the workspace root', () => {
134
+ const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///root1/foo.ts'));
135
+ (0, chai_1.expect)(label).equals('root1');
136
+ });
137
+ it('should return the full path when the resource does not exist in any workspace root', () => {
138
+ const label = markerTreeLabelProvider.getLongName(createMarkerInfoNode('file:///home/a/b/foo.ts'));
139
+ if (os_1.OS.backend.isWindows) {
140
+ (0, chai_1.expect)(label).eq('\\home\\a\\b');
141
+ }
142
+ else {
143
+ (0, chai_1.expect)(label).eq('/home/a/b');
144
+ }
145
+ });
146
+ });
147
+ });
148
+ describe('#getIcon', () => {
149
+ it('should return a typescript icon for a typescript file', () => {
150
+ const icon = markerTreeLabelProvider.getIcon(createMarkerInfoNode('a/b/c/foo.ts'));
151
+ (0, chai_1.expect)(icon).contain('ts-icon');
152
+ });
153
+ it('should return a json icon for a json file', () => {
154
+ const icon = markerTreeLabelProvider.getIcon(createMarkerInfoNode('a/b/c/foo.json'));
155
+ (0, chai_1.expect)(icon).contain('database-icon');
156
+ });
157
+ it('should return a generic icon for a file with no extension', () => {
158
+ const icon = markerTreeLabelProvider.getIcon(createMarkerInfoNode('a/b/c/foo.md'));
159
+ (0, chai_1.expect)(icon).contain('markdown-icon');
160
+ });
161
+ });
162
+ describe('#getDescription', () => {
163
+ beforeEach(() => {
164
+ const root = files_1.FileStat.dir('file:///home/a');
165
+ workspaceService['_workspace'] = root;
166
+ workspaceService['_roots'] = [root];
167
+ });
168
+ it('should return the parent\' long name', () => {
169
+ const label = markerTreeLabelProvider.getDescription(createMarkerInfoNode('file:///home/a/b/c/foo.ts'));
170
+ (0, chai_1.expect)(label).equals('b/c');
171
+ });
172
+ });
173
+ describe('#canHandle', () => {
174
+ it('should successfully handle \'MarkerInfoNodes\'', () => {
175
+ const node = createMarkerInfoNode('a/b/c/foo.ts');
176
+ (0, chai_1.expect)(markerTreeLabelProvider.canHandle(node)).greaterThan(0);
177
+ });
178
+ });
179
+ });
180
+ /**
181
+ * Create a marker info node for test purposes.
182
+ * @param uri the marker uri.
183
+ *
184
+ * @returns a mock marker info node.
185
+ */
186
+ function createMarkerInfoNode(uri) {
187
+ return {
188
+ id: 'id',
189
+ parent: {
190
+ id: 'parent-id',
191
+ kind: '',
192
+ parent: undefined,
193
+ children: []
194
+ },
195
+ numberOfMarkers: 1,
196
+ children: [],
197
+ expanded: true,
198
+ selected: true,
199
+ uri: new uri_1.default(uri)
200
+ };
201
+ }
202
202
  //# sourceMappingURL=marker-tree-label-provider.spec.js.map
@@ -1,13 +1,13 @@
1
- import { MarkerNode } from './marker-tree';
2
- import { TreeModelImpl, OpenerService, TreeNode, OpenerOptions } from '@theia/core/lib/browser';
3
- export declare class MarkerTreeModel extends TreeModelImpl {
4
- protected readonly openerService: OpenerService;
5
- protected doOpenNode(node: TreeNode): void;
6
- protected getOpenerOptionsByMarker(node: MarkerNode): OpenerOptions | undefined;
7
- /**
8
- * Reveal the corresponding node at the marker.
9
- * @param node {TreeNode} the tree node.
10
- */
11
- revealNode(node: TreeNode): void;
12
- }
1
+ import { MarkerNode } from './marker-tree';
2
+ import { TreeModelImpl, OpenerService, TreeNode, OpenerOptions } from '@theia/core/lib/browser';
3
+ export declare class MarkerTreeModel extends TreeModelImpl {
4
+ protected readonly openerService: OpenerService;
5
+ protected doOpenNode(node: TreeNode): void;
6
+ protected getOpenerOptionsByMarker(node: MarkerNode): OpenerOptions | undefined;
7
+ /**
8
+ * Reveal the corresponding node at the marker.
9
+ * @param node {TreeNode} the tree node.
10
+ */
11
+ revealNode(node: TreeNode): void;
12
+ }
13
13
  //# sourceMappingURL=marker-tree-model.d.ts.map