@theia/workspace 1.67.0-next.13 → 1.67.0-next.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +5 -5
- package/src/browser/diff-service.ts +6 -12
- package/src/browser/workspace-schema-updater.ts +3 -3
- package/src/browser/workspace-service.ts +2 -2
- package/src/browser/workspace-variable-contribution.ts +13 -12
- package/lib/browser/canonical-uri-service.d.ts +0 -12
- package/lib/browser/canonical-uri-service.d.ts.map +0 -1
- package/lib/browser/canonical-uri-service.js +0 -55
- package/lib/browser/canonical-uri-service.js.map +0 -1
- package/lib/browser/diff-service.d.ts +0 -11
- package/lib/browser/diff-service.d.ts.map +0 -1
- package/lib/browser/diff-service.js +0 -78
- package/lib/browser/diff-service.js.map +0 -1
- package/lib/browser/index.d.ts +0 -7
- package/lib/browser/index.d.ts.map +0 -1
- package/lib/browser/index.js +0 -25
- package/lib/browser/index.js.map +0 -1
- package/lib/browser/quick-open-workspace.d.ts +0 -18
- package/lib/browser/quick-open-workspace.d.ts.map +0 -1
- package/lib/browser/quick-open-workspace.js +0 -112
- package/lib/browser/quick-open-workspace.js.map +0 -1
- package/lib/browser/untitled-workspace-exit-dialog.d.ts +0 -20
- package/lib/browser/untitled-workspace-exit-dialog.d.ts.map +0 -1
- package/lib/browser/untitled-workspace-exit-dialog.js +0 -64
- package/lib/browser/untitled-workspace-exit-dialog.js.map +0 -1
- package/lib/browser/workspace-breadcrumbs-contribution.d.ts +0 -11
- package/lib/browser/workspace-breadcrumbs-contribution.d.ts.map +0 -1
- package/lib/browser/workspace-breadcrumbs-contribution.js +0 -59
- package/lib/browser/workspace-breadcrumbs-contribution.js.map +0 -1
- package/lib/browser/workspace-commands.d.ts +0 -116
- package/lib/browser/workspace-commands.d.ts.map +0 -1
- package/lib/browser/workspace-commands.js +0 -568
- package/lib/browser/workspace-commands.js.map +0 -1
- package/lib/browser/workspace-commands.spec.d.ts +0 -2
- package/lib/browser/workspace-commands.spec.d.ts.map +0 -1
- package/lib/browser/workspace-commands.spec.js +0 -128
- package/lib/browser/workspace-commands.spec.js.map +0 -1
- package/lib/browser/workspace-compare-handler.d.ts +0 -27
- package/lib/browser/workspace-compare-handler.d.ts.map +0 -1
- package/lib/browser/workspace-compare-handler.js +0 -59
- package/lib/browser/workspace-compare-handler.js.map +0 -1
- package/lib/browser/workspace-delete-handler.d.ts +0 -76
- package/lib/browser/workspace-delete-handler.d.ts.map +0 -1
- package/lib/browser/workspace-delete-handler.js +0 -207
- package/lib/browser/workspace-delete-handler.js.map +0 -1
- package/lib/browser/workspace-duplicate-handler.d.ts +0 -31
- package/lib/browser/workspace-duplicate-handler.d.ts.map +0 -1
- package/lib/browser/workspace-duplicate-handler.js +0 -79
- package/lib/browser/workspace-duplicate-handler.js.map +0 -1
- package/lib/browser/workspace-frontend-contribution.d.ts +0 -111
- package/lib/browser/workspace-frontend-contribution.d.ts.map +0 -1
- package/lib/browser/workspace-frontend-contribution.js +0 -538
- package/lib/browser/workspace-frontend-contribution.js.map +0 -1
- package/lib/browser/workspace-frontend-module.d.ts +0 -4
- package/lib/browser/workspace-frontend-module.d.ts.map +0 -1
- package/lib/browser/workspace-frontend-module.js +0 -93
- package/lib/browser/workspace-frontend-module.js.map +0 -1
- package/lib/browser/workspace-input-dialog.d.ts +0 -20
- package/lib/browser/workspace-input-dialog.d.ts.map +0 -1
- package/lib/browser/workspace-input-dialog.js +0 -64
- package/lib/browser/workspace-input-dialog.js.map +0 -1
- package/lib/browser/workspace-schema-updater.d.ts +0 -34
- package/lib/browser/workspace-schema-updater.d.ts.map +0 -1
- package/lib/browser/workspace-schema-updater.js +0 -147
- package/lib/browser/workspace-schema-updater.js.map +0 -1
- package/lib/browser/workspace-service.d.ts +0 -201
- package/lib/browser/workspace-service.d.ts.map +0 -1
- package/lib/browser/workspace-service.js +0 -753
- package/lib/browser/workspace-service.js.map +0 -1
- package/lib/browser/workspace-storage-service.d.ts +0 -16
- package/lib/browser/workspace-storage-service.d.ts.map +0 -1
- package/lib/browser/workspace-storage-service.js +0 -73
- package/lib/browser/workspace-storage-service.js.map +0 -1
- package/lib/browser/workspace-trust-service.d.ts +0 -30
- package/lib/browser/workspace-trust-service.d.ts.map +0 -1
- package/lib/browser/workspace-trust-service.js +0 -153
- package/lib/browser/workspace-trust-service.js.map +0 -1
- package/lib/browser/workspace-uri-contribution.d.ts +0 -21
- package/lib/browser/workspace-uri-contribution.d.ts.map +0 -1
- package/lib/browser/workspace-uri-contribution.js +0 -106
- package/lib/browser/workspace-uri-contribution.js.map +0 -1
- package/lib/browser/workspace-uri-contribution.spec.d.ts +0 -2
- package/lib/browser/workspace-uri-contribution.spec.d.ts.map +0 -1
- package/lib/browser/workspace-uri-contribution.spec.js +0 -170
- package/lib/browser/workspace-uri-contribution.spec.js.map +0 -1
- package/lib/browser/workspace-user-working-directory-provider.d.ts +0 -13
- package/lib/browser/workspace-user-working-directory-provider.d.ts.map +0 -1
- package/lib/browser/workspace-user-working-directory-provider.js +0 -55
- package/lib/browser/workspace-user-working-directory-provider.js.map +0 -1
- package/lib/browser/workspace-utils.d.ts +0 -16
- package/lib/browser/workspace-utils.d.ts.map +0 -1
- package/lib/browser/workspace-utils.js +0 -47
- package/lib/browser/workspace-utils.js.map +0 -1
- package/lib/browser/workspace-variable-contribution.d.ts +0 -24
- package/lib/browser/workspace-variable-contribution.d.ts.map +0 -1
- package/lib/browser/workspace-variable-contribution.js +0 -230
- package/lib/browser/workspace-variable-contribution.js.map +0 -1
- package/lib/browser/workspace-window-title-updater.d.ts +0 -8
- package/lib/browser/workspace-window-title-updater.d.ts.map +0 -1
- package/lib/browser/workspace-window-title-updater.js +0 -50
- package/lib/browser/workspace-window-title-updater.js.map +0 -1
- package/lib/browser-only/browser-only-workspace-server.d.ts +0 -13
- package/lib/browser-only/browser-only-workspace-server.d.ts.map +0 -1
- package/lib/browser-only/browser-only-workspace-server.js +0 -73
- package/lib/browser-only/browser-only-workspace-server.js.map +0 -1
- package/lib/browser-only/workspace-frontend-only-module.d.ts +0 -4
- package/lib/browser-only/workspace-frontend-only-module.d.ts.map +0 -1
- package/lib/browser-only/workspace-frontend-only-module.js +0 -30
- package/lib/browser-only/workspace-frontend-only-module.js.map +0 -1
- package/lib/common/index.d.ts +0 -5
- package/lib/common/index.d.ts.map +0 -1
- package/lib/common/index.js +0 -23
- package/lib/common/index.js.map +0 -1
- package/lib/common/test/mock-workspace-server.d.ts +0 -8
- package/lib/common/test/mock-workspace-server.d.ts.map +0 -1
- package/lib/common/test/mock-workspace-server.js +0 -31
- package/lib/common/test/mock-workspace-server.js.map +0 -1
- package/lib/common/untitled-workspace-service.d.ts +0 -9
- package/lib/common/untitled-workspace-service.d.ts.map +0 -1
- package/lib/common/untitled-workspace-service.js +0 -53
- package/lib/common/untitled-workspace-service.js.map +0 -1
- package/lib/common/workspace-file-service.d.ts +0 -27
- package/lib/common/workspace-file-service.d.ts.map +0 -1
- package/lib/common/workspace-file-service.js +0 -67
- package/lib/common/workspace-file-service.js.map +0 -1
- package/lib/common/workspace-preferences.d.ts +0 -12
- package/lib/common/workspace-preferences.d.ts.map +0 -1
- package/lib/common/workspace-preferences.js +0 -46
- package/lib/common/workspace-preferences.js.map +0 -1
- package/lib/common/workspace-protocol.d.ts +0 -27
- package/lib/common/workspace-protocol.d.ts.map +0 -1
- package/lib/common/workspace-protocol.js +0 -24
- package/lib/common/workspace-protocol.js.map +0 -1
- package/lib/common/workspace-trust-preferences.d.ts +0 -22
- package/lib/common/workspace-trust-preferences.d.ts.map +0 -1
- package/lib/common/workspace-trust-preferences.js +0 -66
- package/lib/common/workspace-trust-preferences.js.map +0 -1
- package/lib/node/default-workspace-server.d.ts +0 -78
- package/lib/node/default-workspace-server.d.ts.map +0 -1
- package/lib/node/default-workspace-server.js +0 -265
- package/lib/node/default-workspace-server.js.map +0 -1
- package/lib/node/default-workspace-server.spec.d.ts +0 -2
- package/lib/node/default-workspace-server.spec.d.ts.map +0 -1
- package/lib/node/default-workspace-server.spec.js +0 -96
- package/lib/node/default-workspace-server.spec.js.map +0 -1
- package/lib/node/index.d.ts +0 -3
- package/lib/node/index.d.ts.map +0 -1
- package/lib/node/index.js +0 -21
- package/lib/node/index.js.map +0 -1
- package/lib/node/workspace-backend-module.d.ts +0 -4
- package/lib/node/workspace-backend-module.d.ts.map +0 -1
- package/lib/node/workspace-backend-module.js +0 -40
- package/lib/node/workspace-backend-module.js.map +0 -1
|
@@ -1,753 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2017 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-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.WorkspaceData = exports.WorkspaceService = exports.WorkspaceOpenHandlerContribution = void 0;
|
|
19
|
-
const tslib_1 = require("tslib");
|
|
20
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
-
const uri_1 = require("@theia/core/lib/common/uri");
|
|
22
|
-
const common_1 = require("../common");
|
|
23
|
-
const window_service_1 = require("@theia/core/lib/browser/window/window-service");
|
|
24
|
-
const window_1 = require("@theia/core/lib/common/window");
|
|
25
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
26
|
-
const promise_util_1 = require("@theia/core/lib/common/promise-util");
|
|
27
|
-
const env_variables_1 = require("@theia/core/lib/common/env-variables");
|
|
28
|
-
const core_1 = require("@theia/core");
|
|
29
|
-
const workspace_preferences_1 = require("../common/workspace-preferences");
|
|
30
|
-
const jsoncparser = require("jsonc-parser");
|
|
31
|
-
const Ajv = require("@theia/core/shared/ajv");
|
|
32
|
-
const files_1 = require("@theia/filesystem/lib/common/files");
|
|
33
|
-
const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
|
|
34
|
-
const window_title_service_1 = require("@theia/core/lib/browser/window/window-title-service");
|
|
35
|
-
const common_2 = require("@theia/filesystem/lib/common");
|
|
36
|
-
const workspace_schema_updater_1 = require("./workspace-schema-updater");
|
|
37
|
-
const frontend_application_state_1 = require("@theia/core/lib/common/frontend-application-state");
|
|
38
|
-
const preferences_1 = require("@theia/core/lib/common/preferences");
|
|
39
|
-
exports.WorkspaceOpenHandlerContribution = Symbol('WorkspaceOpenHandlerContribution');
|
|
40
|
-
/**
|
|
41
|
-
* The workspace service.
|
|
42
|
-
*/
|
|
43
|
-
let WorkspaceService = class WorkspaceService {
|
|
44
|
-
constructor() {
|
|
45
|
-
this._roots = [];
|
|
46
|
-
this.deferredRoots = new promise_util_1.Deferred();
|
|
47
|
-
this._ready = new promise_util_1.Deferred();
|
|
48
|
-
this.onWorkspaceChangeEmitter = new core_1.Emitter();
|
|
49
|
-
this.onWorkspaceLocationChangedEmitter = new core_1.Emitter();
|
|
50
|
-
this.toDisposeOnWorkspace = new core_1.DisposableCollection();
|
|
51
|
-
this.rootWatchers = new Map();
|
|
52
|
-
}
|
|
53
|
-
get ready() {
|
|
54
|
-
return this._ready.promise;
|
|
55
|
-
}
|
|
56
|
-
init() {
|
|
57
|
-
this.doInit();
|
|
58
|
-
}
|
|
59
|
-
async doInit() {
|
|
60
|
-
const wsUriString = await this.getDefaultWorkspaceUri();
|
|
61
|
-
const wsStat = await this.toFileStat(wsUriString);
|
|
62
|
-
await this.setWorkspace(wsStat);
|
|
63
|
-
this.fileService.onDidFilesChange(event => {
|
|
64
|
-
if (this._workspace && this._workspace.isFile && event.contains(this._workspace.resource)) {
|
|
65
|
-
this.updateWorkspace();
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
this.fsPreferences.onPreferenceChanged(event => {
|
|
69
|
-
if (event.preferenceName === 'files.watcherExclude') {
|
|
70
|
-
this.refreshRootWatchers();
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
this._ready.resolve();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Resolves to the default workspace URI as string.
|
|
77
|
-
*
|
|
78
|
-
* The default implementation tries to extract the default workspace location
|
|
79
|
-
* from the `window.location.hash`, then falls-back to the most recently
|
|
80
|
-
* used workspace root from the server.
|
|
81
|
-
*
|
|
82
|
-
* It is not ensured that the resolved workspace URI is valid, it can point
|
|
83
|
-
* to a non-existing location.
|
|
84
|
-
*/
|
|
85
|
-
getDefaultWorkspaceUri() {
|
|
86
|
-
return this.doGetDefaultWorkspaceUri();
|
|
87
|
-
}
|
|
88
|
-
async doGetDefaultWorkspaceUri() {
|
|
89
|
-
// If an empty window is explicitly requested do not restore a previous workspace.
|
|
90
|
-
// Note: `window.location.hash` includes leading "#" if non-empty.
|
|
91
|
-
if (window.location.hash === `#${window_1.DEFAULT_WINDOW_HASH}`) {
|
|
92
|
-
window.location.hash = '';
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
// Prefer the workspace path specified as the URL fragment, if present.
|
|
96
|
-
if (window.location.hash.length > 1) {
|
|
97
|
-
// Remove the leading # and decode the URI.
|
|
98
|
-
const wpPath = decodeURI(window.location.hash.substring(1));
|
|
99
|
-
const workspaceUri = new uri_1.default().withPath(wpPath).withScheme('file');
|
|
100
|
-
let workspaceStat;
|
|
101
|
-
try {
|
|
102
|
-
workspaceStat = await this.fileService.resolve(workspaceUri);
|
|
103
|
-
}
|
|
104
|
-
catch { }
|
|
105
|
-
if (workspaceStat && !workspaceStat.isDirectory && !this.isWorkspaceFile(workspaceStat)) {
|
|
106
|
-
this.messageService.error(`Not a valid workspace file: ${workspaceUri}`);
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
|
-
return workspaceUri.toString();
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
// Else, ask the server for its suggested workspace (usually the one
|
|
113
|
-
// specified on the CLI, or the most recent).
|
|
114
|
-
return this.server.getMostRecentlyUsedWorkspace();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Set the URL fragment to the given workspace path.
|
|
119
|
-
*/
|
|
120
|
-
setURLFragment(workspacePath) {
|
|
121
|
-
window.location.hash = encodeURI(workspacePath);
|
|
122
|
-
}
|
|
123
|
-
get roots() {
|
|
124
|
-
return this.deferredRoots.promise;
|
|
125
|
-
}
|
|
126
|
-
tryGetRoots() {
|
|
127
|
-
return this._roots;
|
|
128
|
-
}
|
|
129
|
-
get workspace() {
|
|
130
|
-
return this._workspace;
|
|
131
|
-
}
|
|
132
|
-
get onWorkspaceChanged() {
|
|
133
|
-
return this.onWorkspaceChangeEmitter.event;
|
|
134
|
-
}
|
|
135
|
-
get onWorkspaceLocationChanged() {
|
|
136
|
-
return this.onWorkspaceLocationChangedEmitter.event;
|
|
137
|
-
}
|
|
138
|
-
async setWorkspace(workspaceStat) {
|
|
139
|
-
if (this._workspace && workspaceStat &&
|
|
140
|
-
this._workspace.resource === workspaceStat.resource &&
|
|
141
|
-
this._workspace.mtime === workspaceStat.mtime &&
|
|
142
|
-
this._workspace.etag === workspaceStat.etag &&
|
|
143
|
-
this._workspace.size === workspaceStat.size) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
this.toDisposeOnWorkspace.dispose();
|
|
147
|
-
this._workspace = workspaceStat;
|
|
148
|
-
if (this._workspace) {
|
|
149
|
-
const uri = this._workspace.resource;
|
|
150
|
-
if (this._workspace.isFile) {
|
|
151
|
-
this.toDisposeOnWorkspace.push(this.fileService.watch(uri));
|
|
152
|
-
this.onWorkspaceLocationChangedEmitter.fire(this._workspace);
|
|
153
|
-
}
|
|
154
|
-
this.setURLFragment(uri.path.toString());
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
this.setURLFragment('');
|
|
158
|
-
}
|
|
159
|
-
this.updateTitle();
|
|
160
|
-
await this.server.setMostRecentlyUsedWorkspace(this._workspace ? this._workspace.resource.toString() : '');
|
|
161
|
-
await this.updateWorkspace();
|
|
162
|
-
}
|
|
163
|
-
async updateWorkspace() {
|
|
164
|
-
await this.updateRoots();
|
|
165
|
-
this.watchRoots();
|
|
166
|
-
}
|
|
167
|
-
async updateRoots() {
|
|
168
|
-
const newRoots = await this.computeRoots();
|
|
169
|
-
let rootsChanged = false;
|
|
170
|
-
if (newRoots.length !== this._roots.length || newRoots.length === 0) {
|
|
171
|
-
rootsChanged = true;
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
for (const newRoot of newRoots) {
|
|
175
|
-
if (!this._roots.some(r => r.resource.toString() === newRoot.resource.toString())) {
|
|
176
|
-
rootsChanged = true;
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (rootsChanged) {
|
|
182
|
-
this._roots = newRoots;
|
|
183
|
-
this.deferredRoots.resolve(this._roots); // in order to resolve first
|
|
184
|
-
this.deferredRoots = new promise_util_1.Deferred();
|
|
185
|
-
this.deferredRoots.resolve(this._roots);
|
|
186
|
-
this.onWorkspaceChangeEmitter.fire(this._roots);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
async computeRoots() {
|
|
190
|
-
const roots = [];
|
|
191
|
-
if (this._workspace) {
|
|
192
|
-
if (this._workspace.isDirectory) {
|
|
193
|
-
return [this._workspace];
|
|
194
|
-
}
|
|
195
|
-
const workspaceData = await this.getWorkspaceDataFromFile();
|
|
196
|
-
if (workspaceData) {
|
|
197
|
-
for (const { path } of workspaceData.folders) {
|
|
198
|
-
const valid = await this.toValidRoot(path);
|
|
199
|
-
if (valid) {
|
|
200
|
-
roots.push(valid);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
roots.push(files_1.FileStat.dir(path));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return roots;
|
|
209
|
-
}
|
|
210
|
-
async getWorkspaceDataFromFile() {
|
|
211
|
-
if (this._workspace && await this.fileService.exists(this._workspace.resource)) {
|
|
212
|
-
if (this._workspace.isDirectory) {
|
|
213
|
-
return {
|
|
214
|
-
folders: [{ path: this._workspace.resource.toString() }]
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
else if (this.isWorkspaceFile(this._workspace)) {
|
|
218
|
-
const stat = await this.fileService.read(this._workspace.resource);
|
|
219
|
-
const strippedContent = jsoncparser.stripComments(stat.value);
|
|
220
|
-
const data = jsoncparser.parse(strippedContent);
|
|
221
|
-
if (data && WorkspaceData.is(data)) {
|
|
222
|
-
return WorkspaceData.transformToAbsolute(data, stat);
|
|
223
|
-
}
|
|
224
|
-
this.logger.error(`Unable to retrieve workspace data from the file: '${this.labelProvider.getLongName(this._workspace)}'. Please check if the file is corrupted.`);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
this.logger.warn(`Not a valid workspace file: ${this.labelProvider.getLongName(this._workspace)}`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
updateTitle() {
|
|
232
|
-
let rootName;
|
|
233
|
-
let rootPath;
|
|
234
|
-
if (this._workspace) {
|
|
235
|
-
const displayName = this._workspace.name;
|
|
236
|
-
const fullName = this._workspace.resource.path.toString();
|
|
237
|
-
if (this.isWorkspaceFile(this._workspace)) {
|
|
238
|
-
if (this.isUntitledWorkspace(this._workspace.resource)) {
|
|
239
|
-
const untitled = core_1.nls.localizeByDefault('Untitled (Workspace)');
|
|
240
|
-
rootName = untitled;
|
|
241
|
-
rootPath = untitled;
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
rootName = displayName.slice(0, displayName.lastIndexOf('.'));
|
|
245
|
-
rootPath = fullName.slice(0, fullName.lastIndexOf('.'));
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
rootName = displayName;
|
|
250
|
-
rootPath = fullName;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
this.windowTitleService.update({
|
|
254
|
-
rootName,
|
|
255
|
-
rootPath
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* on unload, we set our workspace root as the last recently used on the backend.
|
|
260
|
-
*/
|
|
261
|
-
onStop() {
|
|
262
|
-
this.server.setMostRecentlyUsedWorkspace(this._workspace ? this._workspace.resource.toString() : '');
|
|
263
|
-
}
|
|
264
|
-
async recentWorkspaces() {
|
|
265
|
-
return this.server.getRecentWorkspaces();
|
|
266
|
-
}
|
|
267
|
-
async removeRecentWorkspace(uri) {
|
|
268
|
-
return this.server.removeRecentWorkspace(uri);
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Returns `true` if theia has an opened workspace or folder
|
|
272
|
-
* @returns {boolean}
|
|
273
|
-
*/
|
|
274
|
-
get opened() {
|
|
275
|
-
return !!this._workspace;
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Returns `true` if a multiple-root workspace is currently open.
|
|
279
|
-
* @returns {boolean}
|
|
280
|
-
*/
|
|
281
|
-
get isMultiRootWorkspaceOpened() {
|
|
282
|
-
return !!this.workspace && !this.workspace.isDirectory;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Opens directory, or recreates a workspace from the file that `uri` points to.
|
|
286
|
-
*/
|
|
287
|
-
open(uri, options) {
|
|
288
|
-
this.doOpen(uri, options);
|
|
289
|
-
}
|
|
290
|
-
async doOpen(uri, options) {
|
|
291
|
-
for (const handler of [...this.openHandlerContribution.getContributions(), this]) {
|
|
292
|
-
if (await handler.canHandle(uri)) {
|
|
293
|
-
handler.openWorkspace(uri, options);
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
throw new Error(`Could not find a handler to open the workspace with uri ${uri.toString()}.`);
|
|
298
|
-
}
|
|
299
|
-
async canHandle(uri) {
|
|
300
|
-
return uri.scheme === 'file';
|
|
301
|
-
}
|
|
302
|
-
async openWorkspace(uri, options) {
|
|
303
|
-
const stat = await this.toFileStat(uri);
|
|
304
|
-
if (stat) {
|
|
305
|
-
if (!stat.isDirectory && !this.isWorkspaceFile(stat)) {
|
|
306
|
-
const message = `Not a valid workspace: ${uri.path.toString()}`;
|
|
307
|
-
this.messageService.error(message);
|
|
308
|
-
throw new Error(message);
|
|
309
|
-
}
|
|
310
|
-
// The same window has to be preserved too (instead of opening a new one), if the workspace root is not yet available and we are setting it for the first time.
|
|
311
|
-
// Option passed as parameter has the highest priority (for api developers), then the preference, then the default.
|
|
312
|
-
await this.roots;
|
|
313
|
-
const { preserveWindow } = {
|
|
314
|
-
preserveWindow: this.preferences['workspace.preserveWindow'] || !this.opened,
|
|
315
|
-
...options
|
|
316
|
-
};
|
|
317
|
-
this.openWindow(stat, Object.assign(options !== null && options !== void 0 ? options : {}, { preserveWindow }));
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
throw new Error('Invalid workspace root URI. Expected an existing directory or workspace file.');
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Adds root folder(s) to the workspace
|
|
324
|
-
* @param uris URI or URIs of the root folder(s) to add
|
|
325
|
-
*/
|
|
326
|
-
async addRoot(uris) {
|
|
327
|
-
const toAdd = Array.isArray(uris) ? uris : [uris];
|
|
328
|
-
await this.spliceRoots(this._roots.length, 0, ...toAdd);
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Removes root folder(s) from workspace.
|
|
332
|
-
*/
|
|
333
|
-
async removeRoots(uris) {
|
|
334
|
-
if (!this.opened) {
|
|
335
|
-
throw new Error('Folder cannot be removed as there is no active folder in the current workspace.');
|
|
336
|
-
}
|
|
337
|
-
if (this._workspace) {
|
|
338
|
-
const workspaceData = await this.getWorkspaceDataFromFile();
|
|
339
|
-
this._workspace = await this.writeWorkspaceFile(this._workspace, WorkspaceData.buildWorkspaceData(this._roots.filter(root => uris.findIndex(u => u.toString() === root.resource.toString()) < 0), workspaceData));
|
|
340
|
-
await this.updateWorkspace();
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
async spliceRoots(start, deleteCount, ...rootsToAdd) {
|
|
344
|
-
if (!this._workspace || this._workspace.isDirectory) {
|
|
345
|
-
const untitledWorkspace = await this.getUntitledWorkspace();
|
|
346
|
-
await this.save(untitledWorkspace);
|
|
347
|
-
if (!this._workspace) {
|
|
348
|
-
throw new Error('Could not create new untitled workspace');
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
const dedup = new Set();
|
|
352
|
-
const roots = this._roots.map(root => (dedup.add(root.resource.toString()), root.resource.toString()));
|
|
353
|
-
const toAdd = [];
|
|
354
|
-
for (const root of rootsToAdd) {
|
|
355
|
-
const uri = root.toString();
|
|
356
|
-
if (!dedup.has(uri)) {
|
|
357
|
-
dedup.add(uri);
|
|
358
|
-
toAdd.push(uri);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
const toRemove = roots.splice(start, deleteCount || 0, ...toAdd);
|
|
362
|
-
if (!toRemove.length && !toAdd.length) {
|
|
363
|
-
return [];
|
|
364
|
-
}
|
|
365
|
-
const currentData = await this.getWorkspaceDataFromFile();
|
|
366
|
-
const newData = WorkspaceData.buildWorkspaceData(roots, currentData);
|
|
367
|
-
await this.writeWorkspaceFile(this._workspace, newData);
|
|
368
|
-
await this.updateWorkspace();
|
|
369
|
-
return toRemove.map(root => new uri_1.default(root));
|
|
370
|
-
}
|
|
371
|
-
async getUntitledWorkspace() {
|
|
372
|
-
const configDirURI = new uri_1.default(await this.envVariableServer.getConfigDirUri());
|
|
373
|
-
return this.untitledWorkspaceService.getUntitledWorkspaceUri(configDirURI, uri => this.fileService.exists(uri).then(exists => !exists), () => this.messageService.warn(core_1.nls.localize('theia/workspace/untitled-cleanup', 'There appear to be many untitled workspace files. Please check {0} and remove any unused files.', configDirURI.resolve('workspaces').path.fsPath())));
|
|
374
|
-
}
|
|
375
|
-
async writeWorkspaceFile(workspaceFile, workspaceData) {
|
|
376
|
-
if (workspaceFile) {
|
|
377
|
-
const data = JSON.stringify(WorkspaceData.transformToRelative(workspaceData, workspaceFile));
|
|
378
|
-
const edits = jsoncparser.format(data, undefined, { tabSize: 2, insertSpaces: true, eol: '' });
|
|
379
|
-
const result = jsoncparser.applyEdits(data, edits);
|
|
380
|
-
await this.fileService.write(workspaceFile.resource, result);
|
|
381
|
-
return this.fileService.resolve(workspaceFile.resource);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Clears current workspace root.
|
|
386
|
-
*/
|
|
387
|
-
async close() {
|
|
388
|
-
if (await this.windowService.isSafeToShutDown(frontend_application_state_1.StopReason.Reload)) {
|
|
389
|
-
this.windowService.setSafeToShutDown();
|
|
390
|
-
this._workspace = undefined;
|
|
391
|
-
this._roots.length = 0;
|
|
392
|
-
await this.server.setMostRecentlyUsedWorkspace('');
|
|
393
|
-
this.reloadWindow('');
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* returns a FileStat if the argument URI points to an existing directory. Otherwise, `undefined`.
|
|
398
|
-
*/
|
|
399
|
-
async toValidRoot(uri) {
|
|
400
|
-
const fileStat = await this.toFileStat(uri);
|
|
401
|
-
if (fileStat && fileStat.isDirectory) {
|
|
402
|
-
return fileStat;
|
|
403
|
-
}
|
|
404
|
-
return undefined;
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* returns a FileStat if the argument URI points to a file or directory. Otherwise, `undefined`.
|
|
408
|
-
*/
|
|
409
|
-
async toFileStat(uri) {
|
|
410
|
-
if (!uri) {
|
|
411
|
-
return undefined;
|
|
412
|
-
}
|
|
413
|
-
let uriStr = uri.toString();
|
|
414
|
-
try {
|
|
415
|
-
if (uriStr.endsWith('/')) {
|
|
416
|
-
uriStr = uriStr.slice(0, -1);
|
|
417
|
-
}
|
|
418
|
-
const normalizedUri = new uri_1.default(uriStr).normalizePath();
|
|
419
|
-
return await this.fileService.resolve(normalizedUri);
|
|
420
|
-
}
|
|
421
|
-
catch (error) {
|
|
422
|
-
return undefined;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
openWindow(uri, options) {
|
|
426
|
-
const workspacePath = uri.resource.path.toString();
|
|
427
|
-
if (this.shouldPreserveWindow(options)) {
|
|
428
|
-
this.reloadWindow(workspacePath, options);
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
431
|
-
try {
|
|
432
|
-
this.openNewWindow(workspacePath, options);
|
|
433
|
-
}
|
|
434
|
-
catch (error) {
|
|
435
|
-
// Fall back to reloading the current window in case the browser has blocked the new window
|
|
436
|
-
this.logger.error(error.toString()).then(() => this.reloadWindow(workspacePath));
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
reloadWindow(workspacePath, options) {
|
|
441
|
-
// Set the new workspace path as the URL fragment.
|
|
442
|
-
this.setURLFragment(workspacePath);
|
|
443
|
-
this.windowService.reload();
|
|
444
|
-
}
|
|
445
|
-
openNewWindow(workspacePath, options) {
|
|
446
|
-
const url = new URL(window.location.href);
|
|
447
|
-
url.hash = encodeURI(workspacePath);
|
|
448
|
-
this.windowService.openNewWindow(url.toString());
|
|
449
|
-
}
|
|
450
|
-
shouldPreserveWindow(options) {
|
|
451
|
-
return options !== undefined && !!options.preserveWindow;
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Return true if one of the paths in paths array is present in the workspace
|
|
455
|
-
* NOTE: You should always explicitly use `/` as the separator between the path segments.
|
|
456
|
-
*/
|
|
457
|
-
async containsSome(paths) {
|
|
458
|
-
await this.roots;
|
|
459
|
-
if (this.opened) {
|
|
460
|
-
for (const root of this._roots) {
|
|
461
|
-
const uri = root.resource;
|
|
462
|
-
for (const path of paths) {
|
|
463
|
-
const fileUri = uri.resolve(path);
|
|
464
|
-
const exists = await this.fileService.exists(fileUri);
|
|
465
|
-
if (exists) {
|
|
466
|
-
return exists;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
return false;
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* `true` if the current workspace is configured using a configuration file.
|
|
475
|
-
*
|
|
476
|
-
* `false` if there is no workspace or the workspace is simply a folder.
|
|
477
|
-
*/
|
|
478
|
-
get saved() {
|
|
479
|
-
return !!this._workspace && !this._workspace.isDirectory;
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Save workspace data into a file
|
|
483
|
-
* @param uri URI or FileStat of the workspace file
|
|
484
|
-
*/
|
|
485
|
-
async save(uri) {
|
|
486
|
-
var _a;
|
|
487
|
-
const resource = uri instanceof uri_1.default ? uri : uri.resource;
|
|
488
|
-
if (!await this.fileService.exists(resource)) {
|
|
489
|
-
await this.fileService.create(resource);
|
|
490
|
-
}
|
|
491
|
-
const workspaceData = { folders: [], settings: {} };
|
|
492
|
-
if (!this.saved) {
|
|
493
|
-
for (const p of Object.keys(this.schemaService.getJSONSchema(preferences_1.PreferenceScope.Workspace).properties)) {
|
|
494
|
-
const preferences = this.preferenceImpl.inspect(p);
|
|
495
|
-
if (preferences && preferences.workspaceValue) {
|
|
496
|
-
workspaceData.settings[p] = preferences.workspaceValue;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
let stat = await this.toFileStat(resource);
|
|
501
|
-
Object.assign(workspaceData, await this.getWorkspaceDataFromFile());
|
|
502
|
-
stat = await this.writeWorkspaceFile(stat, WorkspaceData.buildWorkspaceData(this._roots, workspaceData));
|
|
503
|
-
await this.server.setMostRecentlyUsedWorkspace(resource.toString());
|
|
504
|
-
// If saving a workspace based on an untitled workspace, delete the old file.
|
|
505
|
-
const toDelete = this.isUntitledWorkspace((_a = this.workspace) === null || _a === void 0 ? void 0 : _a.resource) && this.workspace.resource;
|
|
506
|
-
await this.setWorkspace(stat);
|
|
507
|
-
if (toDelete && stat && !toDelete.isEqual(stat.resource)) {
|
|
508
|
-
await this.fileService.delete(toDelete).catch(() => { });
|
|
509
|
-
}
|
|
510
|
-
this.onWorkspaceLocationChangedEmitter.fire(stat);
|
|
511
|
-
}
|
|
512
|
-
async watchRoots() {
|
|
513
|
-
const rootUris = new Set(this._roots.map(r => r.resource.toString()));
|
|
514
|
-
for (const [uri, watcher] of this.rootWatchers.entries()) {
|
|
515
|
-
if (!rootUris.has(uri)) {
|
|
516
|
-
watcher.dispose();
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
for (const root of this._roots) {
|
|
520
|
-
this.watchRoot(root);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
async refreshRootWatchers() {
|
|
524
|
-
for (const watcher of this.rootWatchers.values()) {
|
|
525
|
-
watcher.dispose();
|
|
526
|
-
}
|
|
527
|
-
await this.watchRoots();
|
|
528
|
-
}
|
|
529
|
-
async watchRoot(root) {
|
|
530
|
-
const uriStr = root.resource.toString();
|
|
531
|
-
if (this.rootWatchers.has(uriStr)) {
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
const excludes = this.getExcludes(uriStr);
|
|
535
|
-
const watcher = this.fileService.watch(new uri_1.default(uriStr), {
|
|
536
|
-
recursive: true,
|
|
537
|
-
excludes
|
|
538
|
-
});
|
|
539
|
-
this.rootWatchers.set(uriStr, new core_1.DisposableCollection(watcher, core_1.Disposable.create(() => this.rootWatchers.delete(uriStr))));
|
|
540
|
-
}
|
|
541
|
-
getExcludes(uri) {
|
|
542
|
-
const patterns = this.fsPreferences.get('files.watcherExclude', undefined, uri);
|
|
543
|
-
return Object.keys(patterns).filter(pattern => patterns[pattern]);
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Returns the workspace root uri that the given file belongs to.
|
|
547
|
-
* In case that the file is found in more than one workspace roots, returns the root that is closest to the file.
|
|
548
|
-
* If the file is not from the current workspace, returns `undefined`.
|
|
549
|
-
* @param uri URI of the file
|
|
550
|
-
*/
|
|
551
|
-
getWorkspaceRootUri(uri) {
|
|
552
|
-
if (!uri) {
|
|
553
|
-
const root = this.tryGetRoots()[0];
|
|
554
|
-
if (root) {
|
|
555
|
-
return root.resource;
|
|
556
|
-
}
|
|
557
|
-
return undefined;
|
|
558
|
-
}
|
|
559
|
-
const rootUris = [];
|
|
560
|
-
for (const root of this.tryGetRoots()) {
|
|
561
|
-
const rootUri = root.resource;
|
|
562
|
-
if (rootUri && rootUri.scheme === uri.scheme && rootUri.isEqualOrParent(uri)) {
|
|
563
|
-
rootUris.push(rootUri);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
return rootUris.sort((r1, r2) => r2.toString().length - r1.toString().length)[0];
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* Returns the relative path of the given file to the workspace root.
|
|
570
|
-
* @param uri URI of the file
|
|
571
|
-
* @see getWorkspaceRootUri(uri)
|
|
572
|
-
*/
|
|
573
|
-
async getWorkspaceRelativePath(uri) {
|
|
574
|
-
const wsUri = this.getWorkspaceRootUri(uri);
|
|
575
|
-
if (wsUri) {
|
|
576
|
-
const wsRelative = wsUri.relative(uri);
|
|
577
|
-
if (wsRelative) {
|
|
578
|
-
return wsRelative.toString();
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return uri.path.fsPath();
|
|
582
|
-
}
|
|
583
|
-
areWorkspaceRoots(uris) {
|
|
584
|
-
if (!uris.length) {
|
|
585
|
-
return false;
|
|
586
|
-
}
|
|
587
|
-
const rootUris = new Set(this.tryGetRoots().map(root => root.resource.toString()));
|
|
588
|
-
return uris.every(uri => rootUris.has(uri.toString()));
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Check if the file should be considered as a workspace file.
|
|
592
|
-
*
|
|
593
|
-
* Example: We should not try to read the contents of an .exe file.
|
|
594
|
-
*/
|
|
595
|
-
isWorkspaceFile(candidate) {
|
|
596
|
-
return this.workspaceFileService.isWorkspaceFile(candidate);
|
|
597
|
-
}
|
|
598
|
-
isUntitledWorkspace(candidate) {
|
|
599
|
-
return this.untitledWorkspaceService.isUntitledWorkspace(candidate);
|
|
600
|
-
}
|
|
601
|
-
async isSafeToReload(withURI) {
|
|
602
|
-
return !withURI || !this.untitledWorkspaceService.isUntitledWorkspace(withURI) || new uri_1.default(await this.getDefaultWorkspaceUri()).isEqual(withURI);
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
*
|
|
606
|
-
* @param key the property key under which to store the schema (e.g. tasks, launch)
|
|
607
|
-
* @param schema the schema for the property. If none is supplied, the update is treated as a deletion.
|
|
608
|
-
*/
|
|
609
|
-
async updateSchema(key, schema) {
|
|
610
|
-
return this.schemaUpdater.updateSchema({ key, schema });
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
exports.WorkspaceService = WorkspaceService;
|
|
614
|
-
tslib_1.__decorate([
|
|
615
|
-
(0, inversify_1.inject)(file_service_1.FileService),
|
|
616
|
-
tslib_1.__metadata("design:type", file_service_1.FileService)
|
|
617
|
-
], WorkspaceService.prototype, "fileService", void 0);
|
|
618
|
-
tslib_1.__decorate([
|
|
619
|
-
(0, inversify_1.inject)(common_1.WorkspaceServer),
|
|
620
|
-
tslib_1.__metadata("design:type", Object)
|
|
621
|
-
], WorkspaceService.prototype, "server", void 0);
|
|
622
|
-
tslib_1.__decorate([
|
|
623
|
-
(0, inversify_1.inject)(window_service_1.WindowService),
|
|
624
|
-
tslib_1.__metadata("design:type", Object)
|
|
625
|
-
], WorkspaceService.prototype, "windowService", void 0);
|
|
626
|
-
tslib_1.__decorate([
|
|
627
|
-
(0, inversify_1.inject)(core_1.ILogger),
|
|
628
|
-
tslib_1.__metadata("design:type", Object)
|
|
629
|
-
], WorkspaceService.prototype, "logger", void 0);
|
|
630
|
-
tslib_1.__decorate([
|
|
631
|
-
(0, inversify_1.inject)(workspace_preferences_1.WorkspacePreferences),
|
|
632
|
-
tslib_1.__metadata("design:type", Object)
|
|
633
|
-
], WorkspaceService.prototype, "preferences", void 0);
|
|
634
|
-
tslib_1.__decorate([
|
|
635
|
-
(0, inversify_1.inject)(preferences_1.PreferenceService),
|
|
636
|
-
tslib_1.__metadata("design:type", Object)
|
|
637
|
-
], WorkspaceService.prototype, "preferenceImpl", void 0);
|
|
638
|
-
tslib_1.__decorate([
|
|
639
|
-
(0, inversify_1.inject)(preferences_1.PreferenceSchemaService),
|
|
640
|
-
tslib_1.__metadata("design:type", Object)
|
|
641
|
-
], WorkspaceService.prototype, "schemaService", void 0);
|
|
642
|
-
tslib_1.__decorate([
|
|
643
|
-
(0, inversify_1.inject)(env_variables_1.EnvVariablesServer),
|
|
644
|
-
tslib_1.__metadata("design:type", Object)
|
|
645
|
-
], WorkspaceService.prototype, "envVariableServer", void 0);
|
|
646
|
-
tslib_1.__decorate([
|
|
647
|
-
(0, inversify_1.inject)(core_1.MessageService),
|
|
648
|
-
tslib_1.__metadata("design:type", core_1.MessageService)
|
|
649
|
-
], WorkspaceService.prototype, "messageService", void 0);
|
|
650
|
-
tslib_1.__decorate([
|
|
651
|
-
(0, inversify_1.inject)(browser_1.LabelProvider),
|
|
652
|
-
tslib_1.__metadata("design:type", browser_1.LabelProvider)
|
|
653
|
-
], WorkspaceService.prototype, "labelProvider", void 0);
|
|
654
|
-
tslib_1.__decorate([
|
|
655
|
-
(0, inversify_1.inject)(common_2.FileSystemPreferences),
|
|
656
|
-
tslib_1.__metadata("design:type", Object)
|
|
657
|
-
], WorkspaceService.prototype, "fsPreferences", void 0);
|
|
658
|
-
tslib_1.__decorate([
|
|
659
|
-
(0, inversify_1.inject)(workspace_schema_updater_1.WorkspaceSchemaUpdater),
|
|
660
|
-
tslib_1.__metadata("design:type", workspace_schema_updater_1.WorkspaceSchemaUpdater)
|
|
661
|
-
], WorkspaceService.prototype, "schemaUpdater", void 0);
|
|
662
|
-
tslib_1.__decorate([
|
|
663
|
-
(0, inversify_1.inject)(common_1.UntitledWorkspaceService),
|
|
664
|
-
tslib_1.__metadata("design:type", common_1.UntitledWorkspaceService)
|
|
665
|
-
], WorkspaceService.prototype, "untitledWorkspaceService", void 0);
|
|
666
|
-
tslib_1.__decorate([
|
|
667
|
-
(0, inversify_1.inject)(common_1.WorkspaceFileService),
|
|
668
|
-
tslib_1.__metadata("design:type", common_1.WorkspaceFileService)
|
|
669
|
-
], WorkspaceService.prototype, "workspaceFileService", void 0);
|
|
670
|
-
tslib_1.__decorate([
|
|
671
|
-
(0, inversify_1.inject)(window_title_service_1.WindowTitleService),
|
|
672
|
-
tslib_1.__metadata("design:type", window_title_service_1.WindowTitleService)
|
|
673
|
-
], WorkspaceService.prototype, "windowTitleService", void 0);
|
|
674
|
-
tslib_1.__decorate([
|
|
675
|
-
(0, inversify_1.inject)(core_1.ContributionProvider),
|
|
676
|
-
(0, inversify_1.named)(exports.WorkspaceOpenHandlerContribution),
|
|
677
|
-
tslib_1.__metadata("design:type", Object)
|
|
678
|
-
], WorkspaceService.prototype, "openHandlerContribution", void 0);
|
|
679
|
-
tslib_1.__decorate([
|
|
680
|
-
(0, inversify_1.postConstruct)(),
|
|
681
|
-
tslib_1.__metadata("design:type", Function),
|
|
682
|
-
tslib_1.__metadata("design:paramtypes", []),
|
|
683
|
-
tslib_1.__metadata("design:returntype", void 0)
|
|
684
|
-
], WorkspaceService.prototype, "init", null);
|
|
685
|
-
exports.WorkspaceService = WorkspaceService = tslib_1.__decorate([
|
|
686
|
-
(0, inversify_1.injectable)()
|
|
687
|
-
], WorkspaceService);
|
|
688
|
-
var WorkspaceData;
|
|
689
|
-
(function (WorkspaceData) {
|
|
690
|
-
const validateSchema = new Ajv().compile(workspace_schema_updater_1.workspaceSchema);
|
|
691
|
-
function is(data) {
|
|
692
|
-
return !!validateSchema(data);
|
|
693
|
-
}
|
|
694
|
-
WorkspaceData.is = is;
|
|
695
|
-
function buildWorkspaceData(folders, additionalFields) {
|
|
696
|
-
const roots = new Set();
|
|
697
|
-
if (folders.length > 0) {
|
|
698
|
-
if (typeof folders[0] !== 'string') {
|
|
699
|
-
folders.forEach(folder => roots.add(folder.resource.toString()));
|
|
700
|
-
}
|
|
701
|
-
else {
|
|
702
|
-
folders.forEach(folder => roots.add(folder));
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
const data = {
|
|
706
|
-
folders: Array.from(roots, folder => ({ path: folder }))
|
|
707
|
-
};
|
|
708
|
-
if (additionalFields) {
|
|
709
|
-
delete additionalFields.folders;
|
|
710
|
-
Object.assign(data, additionalFields);
|
|
711
|
-
}
|
|
712
|
-
return data;
|
|
713
|
-
}
|
|
714
|
-
WorkspaceData.buildWorkspaceData = buildWorkspaceData;
|
|
715
|
-
function transformToRelative(data, workspaceFile) {
|
|
716
|
-
const folderUris = [];
|
|
717
|
-
const workspaceFileUri = new uri_1.default(workspaceFile ? workspaceFile.resource.toString() : '').withScheme('file');
|
|
718
|
-
for (const { path } of data.folders) {
|
|
719
|
-
const folderUri = new uri_1.default(path).withScheme('file');
|
|
720
|
-
const rel = workspaceFileUri.parent.relative(folderUri);
|
|
721
|
-
if (rel) {
|
|
722
|
-
folderUris.push(rel.toString());
|
|
723
|
-
}
|
|
724
|
-
else {
|
|
725
|
-
folderUris.push(folderUri.toString());
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
return buildWorkspaceData(folderUris, data);
|
|
729
|
-
}
|
|
730
|
-
WorkspaceData.transformToRelative = transformToRelative;
|
|
731
|
-
function transformToAbsolute(data, workspaceFile) {
|
|
732
|
-
var _a;
|
|
733
|
-
if (workspaceFile) {
|
|
734
|
-
const folders = [];
|
|
735
|
-
for (const folder of data.folders) {
|
|
736
|
-
const path = folder.path;
|
|
737
|
-
if (path.startsWith('file:///')) {
|
|
738
|
-
folders.push(path);
|
|
739
|
-
}
|
|
740
|
-
else {
|
|
741
|
-
const absolutePath = (_a = workspaceFile.resource.withScheme('file').parent.resolveToAbsolute(path)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
742
|
-
if (absolutePath) {
|
|
743
|
-
folders.push(absolutePath.toString());
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
return Object.assign(data, buildWorkspaceData(folders, data));
|
|
748
|
-
}
|
|
749
|
-
return data;
|
|
750
|
-
}
|
|
751
|
-
WorkspaceData.transformToAbsolute = transformToAbsolute;
|
|
752
|
-
})(WorkspaceData || (exports.WorkspaceData = WorkspaceData = {}));
|
|
753
|
-
//# sourceMappingURL=workspace-service.js.map
|