@theia/workspace 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.
Files changed (118) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/canonical-uri-service.d.ts +11 -11
  3. package/lib/browser/canonical-uri-service.js +59 -59
  4. package/lib/browser/diff-service.d.ts +10 -10
  5. package/lib/browser/diff-service.js +85 -85
  6. package/lib/browser/index.d.ts +7 -7
  7. package/lib/browser/index.js +34 -34
  8. package/lib/browser/quick-open-workspace.d.ts +25 -25
  9. package/lib/browser/quick-open-workspace.js +137 -137
  10. package/lib/browser/untitled-workspace-exit-dialog.d.ts +19 -19
  11. package/lib/browser/untitled-workspace-exit-dialog.js +74 -74
  12. package/lib/browser/workspace-breadcrumbs-contribution.d.ts +10 -10
  13. package/lib/browser/workspace-breadcrumbs-contribution.js +66 -66
  14. package/lib/browser/workspace-commands.d.ts +117 -117
  15. package/lib/browser/workspace-commands.js +601 -601
  16. package/lib/browser/workspace-commands.spec.d.ts +1 -1
  17. package/lib/browser/workspace-commands.spec.js +127 -127
  18. package/lib/browser/workspace-compare-handler.d.ts +26 -26
  19. package/lib/browser/workspace-compare-handler.js +66 -66
  20. package/lib/browser/workspace-delete-handler.d.ts +75 -75
  21. package/lib/browser/workspace-delete-handler.js +214 -214
  22. package/lib/browser/workspace-duplicate-handler.d.ts +30 -30
  23. package/lib/browser/workspace-duplicate-handler.js +86 -86
  24. package/lib/browser/workspace-frontend-contribution.d.ts +110 -110
  25. package/lib/browser/workspace-frontend-contribution.js +546 -546
  26. package/lib/browser/workspace-frontend-contribution.js.map +1 -1
  27. package/lib/browser/workspace-frontend-module.d.ts +3 -3
  28. package/lib/browser/workspace-frontend-module.js +91 -91
  29. package/lib/browser/workspace-input-dialog.d.ts +19 -19
  30. package/lib/browser/workspace-input-dialog.js +74 -74
  31. package/lib/browser/workspace-preferences.d.ts +11 -11
  32. package/lib/browser/workspace-preferences.js +46 -46
  33. package/lib/browser/workspace-schema-updater.d.ts +34 -34
  34. package/lib/browser/workspace-schema-updater.js +153 -153
  35. package/lib/browser/workspace-service.d.ts +184 -184
  36. package/lib/browser/workspace-service.js +739 -739
  37. package/lib/browser/workspace-storage-service.d.ts +15 -15
  38. package/lib/browser/workspace-storage-service.js +80 -80
  39. package/lib/browser/workspace-trust-preferences.d.ts +21 -21
  40. package/lib/browser/workspace-trust-preferences.js +65 -65
  41. package/lib/browser/workspace-trust-service.d.ts +27 -27
  42. package/lib/browser/workspace-trust-service.js +152 -152
  43. package/lib/browser/workspace-uri-contribution.d.ts +20 -20
  44. package/lib/browser/workspace-uri-contribution.js +113 -113
  45. package/lib/browser/workspace-uri-contribution.spec.d.ts +1 -1
  46. package/lib/browser/workspace-uri-contribution.spec.js +169 -169
  47. package/lib/browser/workspace-user-working-directory-provider.d.ts +12 -12
  48. package/lib/browser/workspace-user-working-directory-provider.js +62 -62
  49. package/lib/browser/workspace-utils.d.ts +15 -15
  50. package/lib/browser/workspace-utils.js +54 -54
  51. package/lib/browser/workspace-variable-contribution.d.ts +23 -23
  52. package/lib/browser/workspace-variable-contribution.js +237 -237
  53. package/lib/browser/workspace-window-title-updater.d.ts +7 -7
  54. package/lib/browser/workspace-window-title-updater.js +57 -57
  55. package/lib/browser-only/browser-only-workspace-server.d.ts +13 -0
  56. package/lib/browser-only/browser-only-workspace-server.d.ts.map +1 -0
  57. package/lib/browser-only/browser-only-workspace-server.js +81 -0
  58. package/lib/browser-only/browser-only-workspace-server.js.map +1 -0
  59. package/lib/browser-only/workspace-frontend-only-module.d.ts +4 -0
  60. package/lib/browser-only/workspace-frontend-only-module.d.ts.map +1 -0
  61. package/lib/browser-only/workspace-frontend-only-module.js +30 -0
  62. package/lib/browser-only/workspace-frontend-only-module.js.map +1 -0
  63. package/lib/common/index.d.ts +3 -3
  64. package/lib/common/index.js +30 -30
  65. package/lib/common/test/mock-workspace-server.d.ts +7 -7
  66. package/lib/common/test/mock-workspace-server.js +35 -35
  67. package/lib/common/untitled-workspace-service.d.ts +8 -8
  68. package/lib/common/untitled-workspace-service.js +60 -60
  69. package/lib/common/workspace-file-service.d.ts +26 -26
  70. package/lib/common/workspace-file-service.js +71 -71
  71. package/lib/common/workspace-protocol.d.ts +26 -26
  72. package/lib/common/workspace-protocol.js +23 -23
  73. package/lib/node/default-workspace-server.d.ts +65 -65
  74. package/lib/node/default-workspace-server.js +248 -248
  75. package/lib/node/default-workspace-server.spec.d.ts +1 -1
  76. package/lib/node/default-workspace-server.spec.js +85 -85
  77. package/lib/node/index.d.ts +2 -2
  78. package/lib/node/index.js +29 -29
  79. package/lib/node/workspace-backend-module.d.ts +3 -3
  80. package/lib/node/workspace-backend-module.js +33 -33
  81. package/package.json +9 -6
  82. package/src/browser/canonical-uri-service.ts +57 -57
  83. package/src/browser/diff-service.ts +62 -62
  84. package/src/browser/index.ts +23 -23
  85. package/src/browser/quick-open-workspace.ts +112 -112
  86. package/src/browser/untitled-workspace-exit-dialog.ts +70 -70
  87. package/src/browser/workspace-breadcrumbs-contribution.ts +56 -56
  88. package/src/browser/workspace-commands.spec.ts +153 -153
  89. package/src/browser/workspace-commands.ts +588 -588
  90. package/src/browser/workspace-compare-handler.ts +56 -56
  91. package/src/browser/workspace-delete-handler.ts +212 -212
  92. package/src/browser/workspace-duplicate-handler.ts +75 -75
  93. package/src/browser/workspace-frontend-contribution.ts +537 -537
  94. package/src/browser/workspace-frontend-module.ts +118 -118
  95. package/src/browser/workspace-input-dialog.ts +61 -61
  96. package/src/browser/workspace-preferences.ts +58 -58
  97. package/src/browser/workspace-schema-updater.ts +150 -150
  98. package/src/browser/workspace-service.ts +780 -780
  99. package/src/browser/workspace-storage-service.ts +67 -67
  100. package/src/browser/workspace-trust-preferences.ts +76 -76
  101. package/src/browser/workspace-trust-service.ts +147 -147
  102. package/src/browser/workspace-uri-contribution.spec.ts +191 -191
  103. package/src/browser/workspace-uri-contribution.ts +97 -97
  104. package/src/browser/workspace-user-working-directory-provider.ts +49 -49
  105. package/src/browser/workspace-utils.ts +45 -45
  106. package/src/browser/workspace-variable-contribution.ts +222 -222
  107. package/src/browser/workspace-window-title-updater.ts +45 -45
  108. package/src/browser-only/browser-only-workspace-server.ts +69 -0
  109. package/src/browser-only/workspace-frontend-only-module.ts +28 -0
  110. package/src/common/index.ts +19 -19
  111. package/src/common/test/mock-workspace-server.ts +29 -29
  112. package/src/common/untitled-workspace-service.ts +50 -50
  113. package/src/common/workspace-file-service.ts +72 -72
  114. package/src/common/workspace-protocol.ts +47 -47
  115. package/src/node/default-workspace-server.spec.ts +100 -100
  116. package/src/node/default-workspace-server.ts +244 -244
  117. package/src/node/index.ts +18 -18
  118. package/src/node/workspace-backend-module.ts +38 -38
@@ -1,170 +1,170 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2018 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-only 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
- const disableJSDOM = (0, jsdom_1.enableJSDOM)();
20
- const chai_1 = require("chai");
21
- const sinon = require("sinon");
22
- const inversify_1 = require("@theia/core/shared/inversify");
23
- const event_1 = require("@theia/core/lib/common/event");
24
- const browser_1 = require("@theia/core/lib/browser");
25
- const label_provider_1 = require("@theia/core/lib/browser/label-provider");
26
- const workspace_uri_contribution_1 = require("./workspace-uri-contribution");
27
- const uri_1 = require("@theia/core/lib/common/uri");
28
- const workspace_variable_contribution_1 = require("./workspace-variable-contribution");
29
- const workspace_service_1 = require("./workspace-service");
30
- const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
31
- const files_1 = require("@theia/filesystem/lib/common/files");
32
- const env_variables_1 = require("@theia/core/lib/common/env-variables");
33
- const mock_env_variables_server_1 = require("@theia/core/lib/browser/test/mock-env-variables-server");
34
- const node_1 = require("@theia/core/lib/node");
35
- const os_1 = require("@theia/core/lib/common/os");
36
- const temp = require("temp");
37
- after(() => disableJSDOM());
38
- let container;
39
- let labelProvider;
40
- let roots;
41
- beforeEach(() => {
42
- roots = [files_1.FileStat.dir('file:///workspace')];
43
- container = new inversify_1.Container();
44
- container.bind(browser_1.ApplicationShell).toConstantValue({
45
- onDidChangeCurrentWidget: () => undefined,
46
- widgets: []
47
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- });
49
- container.bind(browser_1.WidgetManager).toConstantValue({
50
- onDidCreateWidget: event_1.Event.None
51
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
- });
53
- const workspaceService = new workspace_service_1.WorkspaceService();
54
- workspaceService.tryGetRoots = () => roots;
55
- container.bind(workspace_service_1.WorkspaceService).toConstantValue(workspaceService);
56
- container.bind(workspace_variable_contribution_1.WorkspaceVariableContribution).toSelf().inSingletonScope();
57
- container.bind(workspace_uri_contribution_1.WorkspaceUriLabelProviderContribution).toSelf().inSingletonScope();
58
- container.bind(file_service_1.FileService).toConstantValue({});
59
- container.bind(env_variables_1.EnvVariablesServer).toConstantValue(new mock_env_variables_server_1.MockEnvVariablesServerImpl(node_1.FileUri.create(temp.track().mkdirSync())));
60
- labelProvider = container.get(workspace_uri_contribution_1.WorkspaceUriLabelProviderContribution);
61
- });
62
- afterEach(() => {
63
- roots = undefined;
64
- labelProvider = undefined;
65
- container = undefined;
66
- });
67
- describe('WorkspaceUriLabelProviderContribution class', () => {
68
- const stubs = [];
69
- afterEach(() => {
70
- stubs.forEach(s => s.restore());
71
- stubs.length = 0;
72
- });
73
- describe('canHandle()', () => {
74
- it('should return 0 if the passed in argument is not a FileStat or URI with the "file" scheme', () => {
75
- (0, chai_1.expect)(labelProvider.canHandle(new uri_1.default('user-storage:settings.json'))).eq(0);
76
- (0, chai_1.expect)(labelProvider.canHandle({ uri: 'file:///home/settings.json' })).eq(0);
77
- });
78
- it('should return 10 if the passed in argument is a FileStat or URI with the "file" scheme', () => {
79
- (0, chai_1.expect)(labelProvider.canHandle(new uri_1.default('file:///home/settings.json'))).eq(10);
80
- (0, chai_1.expect)(labelProvider.canHandle(files_1.FileStat.file('file:///home/settings.json'))).eq(10);
81
- });
82
- });
83
- describe('getIcon()', () => {
84
- it('should return folder icon from the FileStat of a folder', async () => {
85
- (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.dir('file:///home/'))).eq(labelProvider.defaultFolderIcon);
86
- });
87
- it('should return file icon from a non-folder FileStat', async () => {
88
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
- stubs.push(sinon.stub(label_provider_1.DefaultUriLabelProviderContribution.prototype, 'getFileIcon').returns(undefined));
90
- (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.file('file:///home/test'))).eq(labelProvider.defaultFileIcon);
91
- });
92
- it('should return folder icon from a folder FileStat', async () => {
93
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
- stubs.push(sinon.stub(label_provider_1.DefaultUriLabelProviderContribution.prototype, 'getFileIcon').returns(undefined));
95
- (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.dir('file:///home/test'))).eq(labelProvider.defaultFolderIcon);
96
- });
97
- it('should return file icon from a file FileStat', async () => {
98
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
- stubs.push(sinon.stub(label_provider_1.DefaultUriLabelProviderContribution.prototype, 'getFileIcon').returns(undefined));
100
- (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.file('file:///home/test'))).eq(labelProvider.defaultFileIcon);
101
- });
102
- it('should return what getFileIcon() returns from a URI or non-folder FileStat, if getFileIcon() does not return null or undefined', async () => {
103
- const ret = 'TestString';
104
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
- stubs.push(sinon.stub(label_provider_1.DefaultUriLabelProviderContribution.prototype, 'getFileIcon').returns(ret));
106
- (0, chai_1.expect)(labelProvider.getIcon(new uri_1.default('file:///home/test'))).eq(ret);
107
- (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.file('file:///home/test'))).eq(ret);
108
- });
109
- it('should return the default folder icon for a URI or file stat that corresponds to a workspace root', () => {
110
- (0, chai_1.expect)(labelProvider.getIcon(new uri_1.default('file:///workspace'))).eq(labelProvider.defaultFolderIcon);
111
- (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.dir('file:///workspace'))).eq(labelProvider.defaultFolderIcon);
112
- });
113
- });
114
- describe('getName()', () => {
115
- it('should return the display name of a file from its URI', () => {
116
- const file = new uri_1.default('file:///workspace-2/jacques.doc');
117
- const name = labelProvider.getName(file);
118
- (0, chai_1.expect)(name).eq('jacques.doc');
119
- });
120
- it('should return the display name of a file from its FileStat', () => {
121
- const file = files_1.FileStat.file('file:///workspace-2/jacques.doc');
122
- const name = labelProvider.getName(file);
123
- (0, chai_1.expect)(name).eq('jacques.doc');
124
- });
125
- });
126
- describe('getLongName()', () => {
127
- it('should return the path of a file relative to the workspace from the file\'s URI if the file is in the workspace', () => {
128
- const file = new uri_1.default('file:///workspace/some/very-long/path.js');
129
- const longName = labelProvider.getLongName(file);
130
- (0, chai_1.expect)(longName).eq('some/very-long/path.js');
131
- });
132
- it('should return the path of a file relative to the workspace from the file\'s FileStat if the file is in the workspace', () => {
133
- const file = files_1.FileStat.file('file:///workspace/some/very-long/path.js');
134
- const longName = labelProvider.getLongName(file);
135
- (0, chai_1.expect)(longName).eq('some/very-long/path.js');
136
- });
137
- it('should return the absolute path of a file from the file\'s URI if the file is not in the workspace', () => {
138
- const file = new uri_1.default('file:///tmp/prout.txt');
139
- const longName = labelProvider.getLongName(file);
140
- if (os_1.OS.backend.isWindows) {
141
- (0, chai_1.expect)(longName).eq('\\tmp\\prout.txt');
142
- }
143
- else {
144
- (0, chai_1.expect)(longName).eq('/tmp/prout.txt');
145
- }
146
- });
147
- it('should return the absolute path of a file from the file\'s FileStat if the file is not in the workspace', () => {
148
- const file = files_1.FileStat.file('file:///tmp/prout.txt');
149
- const longName = labelProvider.getLongName(file);
150
- if (os_1.OS.backend.isWindows) {
151
- (0, chai_1.expect)(longName).eq('\\tmp\\prout.txt');
152
- }
153
- else {
154
- (0, chai_1.expect)(longName).eq('/tmp/prout.txt');
155
- }
156
- });
157
- it('should return the path of a file if WorkspaceService returns no roots', () => {
158
- roots = [];
159
- const file = new uri_1.default('file:///tmp/prout.txt');
160
- const longName = labelProvider.getLongName(file);
161
- if (os_1.OS.backend.isWindows) {
162
- (0, chai_1.expect)(longName).eq('\\tmp\\prout.txt');
163
- }
164
- else {
165
- (0, chai_1.expect)(longName).eq('/tmp/prout.txt');
166
- }
167
- });
168
- });
169
- });
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2018 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-only 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
+ const disableJSDOM = (0, jsdom_1.enableJSDOM)();
20
+ const chai_1 = require("chai");
21
+ const sinon = require("sinon");
22
+ const inversify_1 = require("@theia/core/shared/inversify");
23
+ const event_1 = require("@theia/core/lib/common/event");
24
+ const browser_1 = require("@theia/core/lib/browser");
25
+ const label_provider_1 = require("@theia/core/lib/browser/label-provider");
26
+ const workspace_uri_contribution_1 = require("./workspace-uri-contribution");
27
+ const uri_1 = require("@theia/core/lib/common/uri");
28
+ const workspace_variable_contribution_1 = require("./workspace-variable-contribution");
29
+ const workspace_service_1 = require("./workspace-service");
30
+ const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
31
+ const files_1 = require("@theia/filesystem/lib/common/files");
32
+ const env_variables_1 = require("@theia/core/lib/common/env-variables");
33
+ const mock_env_variables_server_1 = require("@theia/core/lib/browser/test/mock-env-variables-server");
34
+ const node_1 = require("@theia/core/lib/node");
35
+ const os_1 = require("@theia/core/lib/common/os");
36
+ const temp = require("temp");
37
+ after(() => disableJSDOM());
38
+ let container;
39
+ let labelProvider;
40
+ let roots;
41
+ beforeEach(() => {
42
+ roots = [files_1.FileStat.dir('file:///workspace')];
43
+ container = new inversify_1.Container();
44
+ container.bind(browser_1.ApplicationShell).toConstantValue({
45
+ onDidChangeCurrentWidget: () => undefined,
46
+ widgets: []
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ });
49
+ container.bind(browser_1.WidgetManager).toConstantValue({
50
+ onDidCreateWidget: event_1.Event.None
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ });
53
+ const workspaceService = new workspace_service_1.WorkspaceService();
54
+ workspaceService.tryGetRoots = () => roots;
55
+ container.bind(workspace_service_1.WorkspaceService).toConstantValue(workspaceService);
56
+ container.bind(workspace_variable_contribution_1.WorkspaceVariableContribution).toSelf().inSingletonScope();
57
+ container.bind(workspace_uri_contribution_1.WorkspaceUriLabelProviderContribution).toSelf().inSingletonScope();
58
+ container.bind(file_service_1.FileService).toConstantValue({});
59
+ container.bind(env_variables_1.EnvVariablesServer).toConstantValue(new mock_env_variables_server_1.MockEnvVariablesServerImpl(node_1.FileUri.create(temp.track().mkdirSync())));
60
+ labelProvider = container.get(workspace_uri_contribution_1.WorkspaceUriLabelProviderContribution);
61
+ });
62
+ afterEach(() => {
63
+ roots = undefined;
64
+ labelProvider = undefined;
65
+ container = undefined;
66
+ });
67
+ describe('WorkspaceUriLabelProviderContribution class', () => {
68
+ const stubs = [];
69
+ afterEach(() => {
70
+ stubs.forEach(s => s.restore());
71
+ stubs.length = 0;
72
+ });
73
+ describe('canHandle()', () => {
74
+ it('should return 0 if the passed in argument is not a FileStat or URI with the "file" scheme', () => {
75
+ (0, chai_1.expect)(labelProvider.canHandle(new uri_1.default('user-storage:settings.json'))).eq(0);
76
+ (0, chai_1.expect)(labelProvider.canHandle({ uri: 'file:///home/settings.json' })).eq(0);
77
+ });
78
+ it('should return 10 if the passed in argument is a FileStat or URI with the "file" scheme', () => {
79
+ (0, chai_1.expect)(labelProvider.canHandle(new uri_1.default('file:///home/settings.json'))).eq(10);
80
+ (0, chai_1.expect)(labelProvider.canHandle(files_1.FileStat.file('file:///home/settings.json'))).eq(10);
81
+ });
82
+ });
83
+ describe('getIcon()', () => {
84
+ it('should return folder icon from the FileStat of a folder', async () => {
85
+ (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.dir('file:///home/'))).eq(labelProvider.defaultFolderIcon);
86
+ });
87
+ it('should return file icon from a non-folder FileStat', async () => {
88
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
+ stubs.push(sinon.stub(label_provider_1.DefaultUriLabelProviderContribution.prototype, 'getFileIcon').returns(undefined));
90
+ (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.file('file:///home/test'))).eq(labelProvider.defaultFileIcon);
91
+ });
92
+ it('should return folder icon from a folder FileStat', async () => {
93
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
+ stubs.push(sinon.stub(label_provider_1.DefaultUriLabelProviderContribution.prototype, 'getFileIcon').returns(undefined));
95
+ (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.dir('file:///home/test'))).eq(labelProvider.defaultFolderIcon);
96
+ });
97
+ it('should return file icon from a file FileStat', async () => {
98
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
+ stubs.push(sinon.stub(label_provider_1.DefaultUriLabelProviderContribution.prototype, 'getFileIcon').returns(undefined));
100
+ (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.file('file:///home/test'))).eq(labelProvider.defaultFileIcon);
101
+ });
102
+ it('should return what getFileIcon() returns from a URI or non-folder FileStat, if getFileIcon() does not return null or undefined', async () => {
103
+ const ret = 'TestString';
104
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
+ stubs.push(sinon.stub(label_provider_1.DefaultUriLabelProviderContribution.prototype, 'getFileIcon').returns(ret));
106
+ (0, chai_1.expect)(labelProvider.getIcon(new uri_1.default('file:///home/test'))).eq(ret);
107
+ (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.file('file:///home/test'))).eq(ret);
108
+ });
109
+ it('should return the default folder icon for a URI or file stat that corresponds to a workspace root', () => {
110
+ (0, chai_1.expect)(labelProvider.getIcon(new uri_1.default('file:///workspace'))).eq(labelProvider.defaultFolderIcon);
111
+ (0, chai_1.expect)(labelProvider.getIcon(files_1.FileStat.dir('file:///workspace'))).eq(labelProvider.defaultFolderIcon);
112
+ });
113
+ });
114
+ describe('getName()', () => {
115
+ it('should return the display name of a file from its URI', () => {
116
+ const file = new uri_1.default('file:///workspace-2/jacques.doc');
117
+ const name = labelProvider.getName(file);
118
+ (0, chai_1.expect)(name).eq('jacques.doc');
119
+ });
120
+ it('should return the display name of a file from its FileStat', () => {
121
+ const file = files_1.FileStat.file('file:///workspace-2/jacques.doc');
122
+ const name = labelProvider.getName(file);
123
+ (0, chai_1.expect)(name).eq('jacques.doc');
124
+ });
125
+ });
126
+ describe('getLongName()', () => {
127
+ it('should return the path of a file relative to the workspace from the file\'s URI if the file is in the workspace', () => {
128
+ const file = new uri_1.default('file:///workspace/some/very-long/path.js');
129
+ const longName = labelProvider.getLongName(file);
130
+ (0, chai_1.expect)(longName).eq('some/very-long/path.js');
131
+ });
132
+ it('should return the path of a file relative to the workspace from the file\'s FileStat if the file is in the workspace', () => {
133
+ const file = files_1.FileStat.file('file:///workspace/some/very-long/path.js');
134
+ const longName = labelProvider.getLongName(file);
135
+ (0, chai_1.expect)(longName).eq('some/very-long/path.js');
136
+ });
137
+ it('should return the absolute path of a file from the file\'s URI if the file is not in the workspace', () => {
138
+ const file = new uri_1.default('file:///tmp/prout.txt');
139
+ const longName = labelProvider.getLongName(file);
140
+ if (os_1.OS.backend.isWindows) {
141
+ (0, chai_1.expect)(longName).eq('\\tmp\\prout.txt');
142
+ }
143
+ else {
144
+ (0, chai_1.expect)(longName).eq('/tmp/prout.txt');
145
+ }
146
+ });
147
+ it('should return the absolute path of a file from the file\'s FileStat if the file is not in the workspace', () => {
148
+ const file = files_1.FileStat.file('file:///tmp/prout.txt');
149
+ const longName = labelProvider.getLongName(file);
150
+ if (os_1.OS.backend.isWindows) {
151
+ (0, chai_1.expect)(longName).eq('\\tmp\\prout.txt');
152
+ }
153
+ else {
154
+ (0, chai_1.expect)(longName).eq('/tmp/prout.txt');
155
+ }
156
+ });
157
+ it('should return the path of a file if WorkspaceService returns no roots', () => {
158
+ roots = [];
159
+ const file = new uri_1.default('file:///tmp/prout.txt');
160
+ const longName = labelProvider.getLongName(file);
161
+ if (os_1.OS.backend.isWindows) {
162
+ (0, chai_1.expect)(longName).eq('\\tmp\\prout.txt');
163
+ }
164
+ else {
165
+ (0, chai_1.expect)(longName).eq('/tmp/prout.txt');
166
+ }
167
+ });
168
+ });
169
+ });
170
170
  //# sourceMappingURL=workspace-uri-contribution.spec.js.map
@@ -1,13 +1,13 @@
1
- import { UserWorkingDirectoryProvider } from '@theia/core/lib/browser/user-working-directory-provider';
2
- import URI from '@theia/core/lib/common/uri';
3
- import { WorkspaceService } from './workspace-service';
4
- import { MaybePromise } from '@theia/core';
5
- import { FileService } from '@theia/filesystem/lib/browser/file-service';
6
- export declare class WorkspaceUserWorkingDirectoryProvider extends UserWorkingDirectoryProvider {
7
- protected readonly workspaceService: WorkspaceService;
8
- protected readonly fileService: FileService;
9
- getUserWorkingDir(): Promise<URI>;
10
- protected getFromWorkspace(): MaybePromise<URI | undefined>;
11
- protected ensureIsDirectory(uri?: URI): Promise<URI | undefined>;
12
- }
1
+ import { UserWorkingDirectoryProvider } from '@theia/core/lib/browser/user-working-directory-provider';
2
+ import URI from '@theia/core/lib/common/uri';
3
+ import { WorkspaceService } from './workspace-service';
4
+ import { MaybePromise } from '@theia/core';
5
+ import { FileService } from '@theia/filesystem/lib/browser/file-service';
6
+ export declare class WorkspaceUserWorkingDirectoryProvider extends UserWorkingDirectoryProvider {
7
+ protected readonly workspaceService: WorkspaceService;
8
+ protected readonly fileService: FileService;
9
+ getUserWorkingDir(): Promise<URI>;
10
+ protected getFromWorkspace(): MaybePromise<URI | undefined>;
11
+ protected ensureIsDirectory(uri?: URI): Promise<URI | undefined>;
12
+ }
13
13
  //# sourceMappingURL=workspace-user-working-directory-provider.d.ts.map
@@ -1,63 +1,63 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2022 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-only 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.WorkspaceUserWorkingDirectoryProvider = void 0;
28
- const inversify_1 = require("@theia/core/shared/inversify");
29
- const user_working_directory_provider_1 = require("@theia/core/lib/browser/user-working-directory-provider");
30
- const workspace_service_1 = require("./workspace-service");
31
- const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
32
- let WorkspaceUserWorkingDirectoryProvider = class WorkspaceUserWorkingDirectoryProvider extends user_working_directory_provider_1.UserWorkingDirectoryProvider {
33
- async getUserWorkingDir() {
34
- var _a, _b, _c;
35
- return (_c = (_b = (_a = await this.getFromSelection()) !== null && _a !== void 0 ? _a : await this.getFromLastOpenResource()) !== null && _b !== void 0 ? _b : await this.getFromWorkspace()) !== null && _c !== void 0 ? _c : this.getFromUserHome();
36
- }
37
- getFromWorkspace() {
38
- var _a;
39
- return (_a = this.workspaceService.tryGetRoots()[0]) === null || _a === void 0 ? void 0 : _a.resource;
40
- }
41
- async ensureIsDirectory(uri) {
42
- if (uri) {
43
- const asFile = uri.withScheme('file');
44
- const stat = await this.fileService.resolve(asFile)
45
- .catch(() => this.fileService.resolve(asFile.parent))
46
- .catch(() => undefined);
47
- return (stat === null || stat === void 0 ? void 0 : stat.isDirectory) ? stat.resource : stat === null || stat === void 0 ? void 0 : stat.resource.parent;
48
- }
49
- }
50
- };
51
- __decorate([
52
- (0, inversify_1.inject)(workspace_service_1.WorkspaceService),
53
- __metadata("design:type", workspace_service_1.WorkspaceService)
54
- ], WorkspaceUserWorkingDirectoryProvider.prototype, "workspaceService", void 0);
55
- __decorate([
56
- (0, inversify_1.inject)(file_service_1.FileService),
57
- __metadata("design:type", file_service_1.FileService)
58
- ], WorkspaceUserWorkingDirectoryProvider.prototype, "fileService", void 0);
59
- WorkspaceUserWorkingDirectoryProvider = __decorate([
60
- (0, inversify_1.injectable)()
61
- ], WorkspaceUserWorkingDirectoryProvider);
62
- exports.WorkspaceUserWorkingDirectoryProvider = WorkspaceUserWorkingDirectoryProvider;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2022 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-only 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.WorkspaceUserWorkingDirectoryProvider = void 0;
28
+ const inversify_1 = require("@theia/core/shared/inversify");
29
+ const user_working_directory_provider_1 = require("@theia/core/lib/browser/user-working-directory-provider");
30
+ const workspace_service_1 = require("./workspace-service");
31
+ const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
32
+ let WorkspaceUserWorkingDirectoryProvider = class WorkspaceUserWorkingDirectoryProvider extends user_working_directory_provider_1.UserWorkingDirectoryProvider {
33
+ async getUserWorkingDir() {
34
+ var _a, _b, _c;
35
+ return (_c = (_b = (_a = await this.getFromSelection()) !== null && _a !== void 0 ? _a : await this.getFromLastOpenResource()) !== null && _b !== void 0 ? _b : await this.getFromWorkspace()) !== null && _c !== void 0 ? _c : this.getFromUserHome();
36
+ }
37
+ getFromWorkspace() {
38
+ var _a;
39
+ return (_a = this.workspaceService.tryGetRoots()[0]) === null || _a === void 0 ? void 0 : _a.resource;
40
+ }
41
+ async ensureIsDirectory(uri) {
42
+ if (uri) {
43
+ const asFile = uri.withScheme('file');
44
+ const stat = await this.fileService.resolve(asFile)
45
+ .catch(() => this.fileService.resolve(asFile.parent))
46
+ .catch(() => undefined);
47
+ return (stat === null || stat === void 0 ? void 0 : stat.isDirectory) ? stat.resource : stat === null || stat === void 0 ? void 0 : stat.resource.parent;
48
+ }
49
+ }
50
+ };
51
+ __decorate([
52
+ (0, inversify_1.inject)(workspace_service_1.WorkspaceService),
53
+ __metadata("design:type", workspace_service_1.WorkspaceService)
54
+ ], WorkspaceUserWorkingDirectoryProvider.prototype, "workspaceService", void 0);
55
+ __decorate([
56
+ (0, inversify_1.inject)(file_service_1.FileService),
57
+ __metadata("design:type", file_service_1.FileService)
58
+ ], WorkspaceUserWorkingDirectoryProvider.prototype, "fileService", void 0);
59
+ WorkspaceUserWorkingDirectoryProvider = __decorate([
60
+ (0, inversify_1.injectable)()
61
+ ], WorkspaceUserWorkingDirectoryProvider);
62
+ exports.WorkspaceUserWorkingDirectoryProvider = WorkspaceUserWorkingDirectoryProvider;
63
63
  //# sourceMappingURL=workspace-user-working-directory-provider.js.map
@@ -1,16 +1,16 @@
1
- import URI from '@theia/core/lib/common/uri';
2
- import { WorkspaceService } from './workspace-service';
3
- /**
4
- * Collection of workspace utility functions
5
- * @class
6
- */
7
- export declare class WorkspaceUtils {
8
- protected readonly workspaceService: WorkspaceService;
9
- /**
10
- * Determine if root directory exists
11
- * for a given array of URIs
12
- * @param uris
13
- */
14
- containsRootDirectory(uris: URI[]): boolean;
15
- }
1
+ import URI from '@theia/core/lib/common/uri';
2
+ import { WorkspaceService } from './workspace-service';
3
+ /**
4
+ * Collection of workspace utility functions
5
+ * @class
6
+ */
7
+ export declare class WorkspaceUtils {
8
+ protected readonly workspaceService: WorkspaceService;
9
+ /**
10
+ * Determine if root directory exists
11
+ * for a given array of URIs
12
+ * @param uris
13
+ */
14
+ containsRootDirectory(uris: URI[]): boolean;
15
+ }
16
16
  //# sourceMappingURL=workspace-utils.d.ts.map