@theia/workspace 1.53.0-next.55 → 1.53.0-next.64

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 (45) hide show
  1. package/README.md +30 -30
  2. package/lib/browser/workspace-trust-preferences.d.ts.map +1 -1
  3. package/lib/browser/workspace-trust-preferences.js +1 -0
  4. package/lib/browser/workspace-trust-preferences.js.map +1 -1
  5. package/lib/browser/workspace-trust-service.d.ts.map +1 -1
  6. package/lib/browser/workspace-trust-service.js +11 -9
  7. package/lib/browser/workspace-trust-service.js.map +1 -1
  8. package/package.json +5 -5
  9. package/src/browser/canonical-uri-service.ts +57 -57
  10. package/src/browser/diff-service.ts +62 -62
  11. package/src/browser/index.ts +23 -23
  12. package/src/browser/quick-open-workspace.ts +112 -112
  13. package/src/browser/untitled-workspace-exit-dialog.ts +70 -70
  14. package/src/browser/workspace-breadcrumbs-contribution.ts +56 -56
  15. package/src/browser/workspace-commands.spec.ts +153 -153
  16. package/src/browser/workspace-commands.ts +557 -557
  17. package/src/browser/workspace-compare-handler.ts +56 -56
  18. package/src/browser/workspace-delete-handler.ts +212 -212
  19. package/src/browser/workspace-duplicate-handler.ts +75 -75
  20. package/src/browser/workspace-frontend-contribution.ts +537 -537
  21. package/src/browser/workspace-frontend-module.ts +118 -118
  22. package/src/browser/workspace-input-dialog.ts +61 -61
  23. package/src/browser/workspace-preferences.ts +58 -58
  24. package/src/browser/workspace-schema-updater.ts +150 -150
  25. package/src/browser/workspace-service.ts +780 -780
  26. package/src/browser/workspace-storage-service.ts +67 -67
  27. package/src/browser/workspace-trust-preferences.ts +77 -76
  28. package/src/browser/workspace-trust-service.ts +154 -152
  29. package/src/browser/workspace-uri-contribution.spec.ts +191 -191
  30. package/src/browser/workspace-uri-contribution.ts +97 -97
  31. package/src/browser/workspace-user-working-directory-provider.ts +49 -49
  32. package/src/browser/workspace-utils.ts +45 -45
  33. package/src/browser/workspace-variable-contribution.ts +222 -222
  34. package/src/browser/workspace-window-title-updater.ts +45 -45
  35. package/src/browser-only/browser-only-workspace-server.ts +69 -69
  36. package/src/browser-only/workspace-frontend-only-module.ts +28 -28
  37. package/src/common/index.ts +19 -19
  38. package/src/common/test/mock-workspace-server.ts +29 -29
  39. package/src/common/untitled-workspace-service.ts +50 -50
  40. package/src/common/workspace-file-service.ts +72 -72
  41. package/src/common/workspace-protocol.ts +47 -47
  42. package/src/node/default-workspace-server.spec.ts +100 -100
  43. package/src/node/default-workspace-server.ts +244 -244
  44. package/src/node/index.ts +18 -18
  45. package/src/node/workspace-backend-module.ts +38 -38
@@ -1,153 +1,153 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 Ericsson and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
18
- let disableJSDOM = enableJSDOM();
19
-
20
- import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
21
- FrontendApplicationConfigProvider.set({});
22
-
23
- import { expect } from 'chai';
24
- import URI from '@theia/core/lib/common/uri';
25
- import { Container } from '@theia/core/shared/inversify';
26
- import { FileDialogService } from '@theia/filesystem/lib/browser';
27
- import { FileService } from '@theia/filesystem/lib/browser/file-service';
28
- import { FileStat } from '@theia/filesystem/lib/common/files';
29
- import { LabelProvider, OpenerService, FrontendApplication } from '@theia/core/lib/browser';
30
- import { MessageService, OS } from '@theia/core/lib/common';
31
- import { SelectionService } from '@theia/core/lib/common/selection-service';
32
- import { WorkspaceCommandContribution } from './workspace-commands';
33
- import { WorkspaceCompareHandler } from './workspace-compare-handler';
34
- import { WorkspaceDeleteHandler } from './workspace-delete-handler';
35
- import { WorkspaceDuplicateHandler } from './workspace-duplicate-handler';
36
- import { WorkspacePreferences } from './workspace-preferences';
37
- import { WorkspaceService } from './workspace-service';
38
- import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
39
- import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
40
-
41
- disableJSDOM();
42
-
43
- describe('workspace-commands', () => {
44
-
45
- let commands: WorkspaceCommandContribution;
46
-
47
- const childStat: FileStat = {
48
- isFile: true,
49
- isDirectory: false,
50
- isSymbolicLink: false,
51
- isReadonly: false,
52
- resource: new URI('foo/bar'),
53
- name: 'bar',
54
- };
55
-
56
- const parent: FileStat = {
57
- isFile: false,
58
- isDirectory: true,
59
- isSymbolicLink: false,
60
- isReadonly: false,
61
- resource: new URI('foo'),
62
- name: 'foo',
63
- children: [
64
- childStat
65
- ]
66
- };
67
-
68
- before(() => disableJSDOM = enableJSDOM());
69
- after(() => disableJSDOM());
70
-
71
- beforeEach(() => {
72
- const container = new Container();
73
-
74
- container.bind(FileDialogService).toConstantValue(<FileDialogService>{});
75
- container.bind(FileService).toConstantValue(<FileService>{
76
- async exists(resource: URI): Promise<boolean> {
77
- return resource.path.base.includes('bar'); // 'bar' exists for test purposes.
78
- }
79
- });
80
- container.bind(FrontendApplication).toConstantValue(<FrontendApplication>{});
81
- container.bind(LabelProvider).toConstantValue(<LabelProvider>{});
82
- container.bind(MessageService).toConstantValue(<MessageService>{});
83
- container.bind(OpenerService).toConstantValue(<OpenerService>{});
84
- container.bind(SelectionService).toConstantValue(<SelectionService>{});
85
- container.bind(WorkspaceCommandContribution).toSelf().inSingletonScope();
86
- container.bind(WorkspaceCompareHandler).toConstantValue(<WorkspaceCompareHandler>{});
87
- container.bind(WorkspaceDeleteHandler).toConstantValue(<WorkspaceDeleteHandler>{});
88
- container.bind(WorkspaceDuplicateHandler).toConstantValue(<WorkspaceDuplicateHandler>{});
89
- container.bind(WorkspacePreferences).toConstantValue(<WorkspacePreferences>{});
90
- container.bind(WorkspaceService).toConstantValue(<WorkspaceService>{});
91
- container.bind(ClipboardService).toConstantValue(<ClipboardService>{});
92
- container.bind(ApplicationServer).toConstantValue(<ApplicationServer>{
93
- getBackendOS(): Promise<OS.Type> {
94
- return Promise.resolve(OS.type());
95
- }
96
- });
97
-
98
- commands = container.get(WorkspaceCommandContribution);
99
- });
100
-
101
- describe('#validateFileName', () => {
102
-
103
- it('should not validate an empty file name', async () => {
104
- const message = await commands['validateFileName']('', parent);
105
- expect(message).to.equal('');
106
- });
107
-
108
- it('should accept the resource does not exist', async () => {
109
- const message = await commands['validateFileName']('a.ts', parent);
110
- expect(message).to.equal('');
111
- });
112
-
113
- it('should not accept if the resource exists', async () => {
114
- const message = await commands['validateFileName']('bar', parent);
115
- expect(message).to.not.equal(''); // a non empty message indicates an error.
116
- });
117
-
118
- it('should not accept invalid filenames', async () => {
119
- let message = await commands['validateFileName']('.', parent, true); // invalid filename.
120
- expect(message).to.not.equal('');
121
-
122
- message = await commands['validateFileName']('/a', parent, true); // invalid starts-with `\`.
123
- expect(message).to.not.equal('');
124
-
125
- message = await commands['validateFileName'](' a', parent, true); // invalid leading whitespace.
126
- expect(message).to.not.equal('');
127
-
128
- message = await commands['validateFileName']('a ', parent, true); // invalid trailing whitespace.
129
- expect(message).to.not.equal('');
130
-
131
- });
132
-
133
- });
134
-
135
- describe('#validateFileRename', () => {
136
-
137
- it('should accept if the resource exists case-insensitively', async () => {
138
- const oldName: string = 'bar';
139
- const newName = 'Bar';
140
- const message = await commands['validateFileRename'](oldName, newName, parent);
141
- expect(message).to.equal('');
142
- });
143
-
144
- it('should accept if the resource does not exist case-insensitively', async () => {
145
- const oldName: string = 'bar';
146
- const newName = 'foo';
147
- const message = await commands['validateFileRename'](oldName, newName, parent);
148
- expect(message).to.equal('');
149
- });
150
-
151
- });
152
-
153
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
18
+ let disableJSDOM = enableJSDOM();
19
+
20
+ import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
21
+ FrontendApplicationConfigProvider.set({});
22
+
23
+ import { expect } from 'chai';
24
+ import URI from '@theia/core/lib/common/uri';
25
+ import { Container } from '@theia/core/shared/inversify';
26
+ import { FileDialogService } from '@theia/filesystem/lib/browser';
27
+ import { FileService } from '@theia/filesystem/lib/browser/file-service';
28
+ import { FileStat } from '@theia/filesystem/lib/common/files';
29
+ import { LabelProvider, OpenerService, FrontendApplication } from '@theia/core/lib/browser';
30
+ import { MessageService, OS } from '@theia/core/lib/common';
31
+ import { SelectionService } from '@theia/core/lib/common/selection-service';
32
+ import { WorkspaceCommandContribution } from './workspace-commands';
33
+ import { WorkspaceCompareHandler } from './workspace-compare-handler';
34
+ import { WorkspaceDeleteHandler } from './workspace-delete-handler';
35
+ import { WorkspaceDuplicateHandler } from './workspace-duplicate-handler';
36
+ import { WorkspacePreferences } from './workspace-preferences';
37
+ import { WorkspaceService } from './workspace-service';
38
+ import { ApplicationServer } from '@theia/core/lib/common/application-protocol';
39
+ import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
40
+
41
+ disableJSDOM();
42
+
43
+ describe('workspace-commands', () => {
44
+
45
+ let commands: WorkspaceCommandContribution;
46
+
47
+ const childStat: FileStat = {
48
+ isFile: true,
49
+ isDirectory: false,
50
+ isSymbolicLink: false,
51
+ isReadonly: false,
52
+ resource: new URI('foo/bar'),
53
+ name: 'bar',
54
+ };
55
+
56
+ const parent: FileStat = {
57
+ isFile: false,
58
+ isDirectory: true,
59
+ isSymbolicLink: false,
60
+ isReadonly: false,
61
+ resource: new URI('foo'),
62
+ name: 'foo',
63
+ children: [
64
+ childStat
65
+ ]
66
+ };
67
+
68
+ before(() => disableJSDOM = enableJSDOM());
69
+ after(() => disableJSDOM());
70
+
71
+ beforeEach(() => {
72
+ const container = new Container();
73
+
74
+ container.bind(FileDialogService).toConstantValue(<FileDialogService>{});
75
+ container.bind(FileService).toConstantValue(<FileService>{
76
+ async exists(resource: URI): Promise<boolean> {
77
+ return resource.path.base.includes('bar'); // 'bar' exists for test purposes.
78
+ }
79
+ });
80
+ container.bind(FrontendApplication).toConstantValue(<FrontendApplication>{});
81
+ container.bind(LabelProvider).toConstantValue(<LabelProvider>{});
82
+ container.bind(MessageService).toConstantValue(<MessageService>{});
83
+ container.bind(OpenerService).toConstantValue(<OpenerService>{});
84
+ container.bind(SelectionService).toConstantValue(<SelectionService>{});
85
+ container.bind(WorkspaceCommandContribution).toSelf().inSingletonScope();
86
+ container.bind(WorkspaceCompareHandler).toConstantValue(<WorkspaceCompareHandler>{});
87
+ container.bind(WorkspaceDeleteHandler).toConstantValue(<WorkspaceDeleteHandler>{});
88
+ container.bind(WorkspaceDuplicateHandler).toConstantValue(<WorkspaceDuplicateHandler>{});
89
+ container.bind(WorkspacePreferences).toConstantValue(<WorkspacePreferences>{});
90
+ container.bind(WorkspaceService).toConstantValue(<WorkspaceService>{});
91
+ container.bind(ClipboardService).toConstantValue(<ClipboardService>{});
92
+ container.bind(ApplicationServer).toConstantValue(<ApplicationServer>{
93
+ getBackendOS(): Promise<OS.Type> {
94
+ return Promise.resolve(OS.type());
95
+ }
96
+ });
97
+
98
+ commands = container.get(WorkspaceCommandContribution);
99
+ });
100
+
101
+ describe('#validateFileName', () => {
102
+
103
+ it('should not validate an empty file name', async () => {
104
+ const message = await commands['validateFileName']('', parent);
105
+ expect(message).to.equal('');
106
+ });
107
+
108
+ it('should accept the resource does not exist', async () => {
109
+ const message = await commands['validateFileName']('a.ts', parent);
110
+ expect(message).to.equal('');
111
+ });
112
+
113
+ it('should not accept if the resource exists', async () => {
114
+ const message = await commands['validateFileName']('bar', parent);
115
+ expect(message).to.not.equal(''); // a non empty message indicates an error.
116
+ });
117
+
118
+ it('should not accept invalid filenames', async () => {
119
+ let message = await commands['validateFileName']('.', parent, true); // invalid filename.
120
+ expect(message).to.not.equal('');
121
+
122
+ message = await commands['validateFileName']('/a', parent, true); // invalid starts-with `\`.
123
+ expect(message).to.not.equal('');
124
+
125
+ message = await commands['validateFileName'](' a', parent, true); // invalid leading whitespace.
126
+ expect(message).to.not.equal('');
127
+
128
+ message = await commands['validateFileName']('a ', parent, true); // invalid trailing whitespace.
129
+ expect(message).to.not.equal('');
130
+
131
+ });
132
+
133
+ });
134
+
135
+ describe('#validateFileRename', () => {
136
+
137
+ it('should accept if the resource exists case-insensitively', async () => {
138
+ const oldName: string = 'bar';
139
+ const newName = 'Bar';
140
+ const message = await commands['validateFileRename'](oldName, newName, parent);
141
+ expect(message).to.equal('');
142
+ });
143
+
144
+ it('should accept if the resource does not exist case-insensitively', async () => {
145
+ const oldName: string = 'bar';
146
+ const newName = 'foo';
147
+ const message = await commands['validateFileRename'](oldName, newName, parent);
148
+ expect(message).to.equal('');
149
+ });
150
+
151
+ });
152
+
153
+ });