@codingame/monaco-vscode-api 1.69.7 → 1.69.8
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/dist/api.js +8 -7
- package/dist/configuration.js +384 -73
- package/dist/contextkey.js +13 -1
- package/dist/dialogs.js +13 -12
- package/dist/extHost.js +2063 -1396
- package/dist/files.js +100 -105
- package/dist/keybindings.js +358 -307
- package/dist/languageConfiguration.js +5 -4
- package/dist/languageService.js +3 -3
- package/dist/languages.js +4 -3
- package/dist/layout.js +294 -311
- package/dist/messages.js +2 -0
- package/dist/missing-services.js +5304 -5954
- package/dist/modelEditor.js +69 -68
- package/dist/monaco.js +14 -13
- package/dist/notifications.js +268 -337
- package/dist/polyfill.js +446 -913
- package/dist/services.js +1 -1
- package/dist/services2.js +659 -26
- package/dist/snippets.js +102 -109
- package/dist/textmate.js +82 -89
- package/dist/theme.js +396 -407
- package/dist/tokenClassification.js +4 -3
- package/dist/tokenClassificationRegistry.js +78 -84
- package/dist/tools.js +2 -1
- package/dist/workbenchThemeService.js +1 -1
- package/dist/workspaceContext.js +2 -1
- package/package.json +1 -1
package/dist/services2.js
CHANGED
|
@@ -1,24 +1,305 @@
|
|
|
1
|
-
import { createDecorator } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
1
|
+
import { createDecorator, IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
2
2
|
import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
|
|
3
|
+
import { b as __decorate, d as __param, i as insert } from './contextkey.js';
|
|
4
|
+
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
5
|
+
import { isWindows, OS } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
6
|
+
import { IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
7
|
+
import { basename } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
8
|
+
import { win32, posix } from 'monaco-editor/esm/vs/base/common/path.js';
|
|
9
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
10
|
+
import { DisposableStore, SafeDisposable, Disposable, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
11
|
+
import { LinkedList } from 'monaco-editor/esm/vs/base/common/linkedList.js';
|
|
12
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
13
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
3
14
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
|
|
4
15
|
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
16
|
+
import { raceCancellation, Promises } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
17
|
+
import { IProgressService } from 'monaco-editor/esm/vs/platform/progress/common/progress.js';
|
|
5
18
|
import { TernarySearchTree } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
19
|
+
import { onUnexpectedError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
20
|
+
import { StopWatch } from 'monaco-editor/esm/vs/base/common/stopwatch.js';
|
|
21
|
+
import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
|
|
22
|
+
import 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
|
|
23
|
+
import 'monaco-editor/esm/vs/platform/commands/common/commands.js';
|
|
24
|
+
import 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
25
|
+
import 'monaco-editor/esm/vs/editor/browser/services/bulkEditService.js';
|
|
26
|
+
import 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
|
|
27
|
+
import 'monaco-editor/esm/vs/editor/common/languages/language.js';
|
|
28
|
+
import 'monaco-editor/esm/vs/editor/common/languages/languageConfigurationRegistry.js';
|
|
29
|
+
import 'monaco-editor/esm/vs/editor/common/services/editorWorker.js';
|
|
30
|
+
import 'monaco-editor/esm/vs/editor/common/services/languageFeatures.js';
|
|
31
|
+
import 'monaco-editor/esm/vs/editor/common/services/model.js';
|
|
32
|
+
import 'monaco-editor/esm/vs/editor/common/services/resolverService.js';
|
|
33
|
+
import 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
|
|
34
|
+
import 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
|
|
35
|
+
import 'monaco-editor/esm/vs/platform/markers/common/markers.js';
|
|
36
|
+
import 'monaco-editor/esm/vs/platform/opener/common/opener.js';
|
|
37
|
+
import 'monaco-editor/esm/vs/platform/quickinput/common/quickInput.js';
|
|
38
|
+
import 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
|
|
39
|
+
import 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
|
|
40
|
+
import 'monaco-editor/esm/vs/base/common/severity.js';
|
|
41
|
+
class EventProfiling {
|
|
42
|
+
constructor(name) {
|
|
43
|
+
this._listenerCount = 0;
|
|
44
|
+
this._invocationCount = 0;
|
|
45
|
+
this._elapsedOverall = 0;
|
|
46
|
+
this._name = `${name}_${EventProfiling._idPool++}`;
|
|
47
|
+
}
|
|
48
|
+
start(listenerCount) {
|
|
49
|
+
this._stopWatch = ( new StopWatch(true));
|
|
50
|
+
this._listenerCount = listenerCount;
|
|
51
|
+
}
|
|
52
|
+
stop() {
|
|
53
|
+
if (this._stopWatch) {
|
|
54
|
+
const elapsed = this._stopWatch.elapsed();
|
|
55
|
+
this._elapsedOverall += elapsed;
|
|
56
|
+
this._invocationCount += 1;
|
|
57
|
+
console.info(`did FIRE ${this._name}: elapsed_ms: ${elapsed.toFixed(5)}, listener: ${this._listenerCount} (elapsed_overall: ${this._elapsedOverall.toFixed(2)}, invocations: ${this._invocationCount})`);
|
|
58
|
+
this._stopWatch = undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
EventProfiling._idPool = 0;
|
|
63
|
+
class Stacktrace {
|
|
64
|
+
constructor(value) {
|
|
65
|
+
this.value = value;
|
|
66
|
+
}
|
|
67
|
+
static create() {
|
|
68
|
+
return ( new Stacktrace(( new Error()).stack ?? ''));
|
|
69
|
+
}
|
|
70
|
+
print() {
|
|
71
|
+
console.warn(this.value.split('\n').slice(2).join('\n'));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
class Listener {
|
|
75
|
+
constructor(callback, callbackThis, stack) {
|
|
76
|
+
this.callback = callback;
|
|
77
|
+
this.callbackThis = callbackThis;
|
|
78
|
+
this.stack = stack;
|
|
79
|
+
this.subscription = ( new SafeDisposable());
|
|
80
|
+
}
|
|
81
|
+
invoke(e) {
|
|
82
|
+
this.callback.call(this.callbackThis, e);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
class Emitter {
|
|
86
|
+
constructor(options) {
|
|
87
|
+
this._disposed = false;
|
|
88
|
+
this._options = options;
|
|
89
|
+
this._leakageMon = undefined;
|
|
90
|
+
this._perfMon = this._options?._profName ? ( new EventProfiling(this._options._profName)) : undefined;
|
|
91
|
+
this._deliveryQueue = this._options?.deliveryQueue;
|
|
92
|
+
}
|
|
93
|
+
dispose() {
|
|
94
|
+
if (!this._disposed) {
|
|
95
|
+
this._disposed = true;
|
|
96
|
+
if (this._listeners) {
|
|
97
|
+
this._listeners.clear();
|
|
98
|
+
}
|
|
99
|
+
this._deliveryQueue?.clear(this);
|
|
100
|
+
this._options?.onLastListenerRemove?.();
|
|
101
|
+
this._leakageMon?.dispose();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
get event() {
|
|
105
|
+
if (!this._event) {
|
|
106
|
+
this._event = (callback, thisArgs, disposables) => {
|
|
107
|
+
if (!this._listeners) {
|
|
108
|
+
this._listeners = ( new LinkedList());
|
|
109
|
+
}
|
|
110
|
+
const firstListener = this._listeners.isEmpty();
|
|
111
|
+
if (firstListener && this._options?.onFirstListenerAdd) {
|
|
112
|
+
this._options.onFirstListenerAdd(this);
|
|
113
|
+
}
|
|
114
|
+
let removeMonitor;
|
|
115
|
+
let stack;
|
|
116
|
+
if (this._leakageMon && this._listeners.size >= 30) {
|
|
117
|
+
stack = Stacktrace.create();
|
|
118
|
+
removeMonitor = this._leakageMon.check(stack, this._listeners.size + 1);
|
|
119
|
+
}
|
|
120
|
+
const listener = ( new Listener(callback, thisArgs, stack));
|
|
121
|
+
const removeListener = this._listeners.push(listener);
|
|
122
|
+
if (firstListener && this._options?.onFirstListenerDidAdd) {
|
|
123
|
+
this._options.onFirstListenerDidAdd(this);
|
|
124
|
+
}
|
|
125
|
+
if (this._options?.onListenerDidAdd) {
|
|
126
|
+
this._options.onListenerDidAdd(this, callback, thisArgs);
|
|
127
|
+
}
|
|
128
|
+
const result = listener.subscription.set(() => {
|
|
129
|
+
removeMonitor?.();
|
|
130
|
+
if (!this._disposed) {
|
|
131
|
+
removeListener();
|
|
132
|
+
if (this._options && this._options.onLastListenerRemove) {
|
|
133
|
+
const hasListeners = (this._listeners && !this._listeners.isEmpty());
|
|
134
|
+
if (!hasListeners) {
|
|
135
|
+
this._options.onLastListenerRemove(this);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
if (disposables instanceof DisposableStore) {
|
|
141
|
+
disposables.add(result);
|
|
142
|
+
}
|
|
143
|
+
else if (Array.isArray(disposables)) {
|
|
144
|
+
disposables.push(result);
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return this._event;
|
|
150
|
+
}
|
|
151
|
+
fire(event) {
|
|
152
|
+
if (this._listeners) {
|
|
153
|
+
if (!this._deliveryQueue) {
|
|
154
|
+
this._deliveryQueue = ( new PrivateEventDeliveryQueue());
|
|
155
|
+
}
|
|
156
|
+
for (const listener of this._listeners) {
|
|
157
|
+
this._deliveryQueue.push(this, listener, event);
|
|
158
|
+
}
|
|
159
|
+
this._perfMon?.start(this._deliveryQueue.size);
|
|
160
|
+
this._deliveryQueue.deliver();
|
|
161
|
+
this._perfMon?.stop();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
hasListeners() {
|
|
165
|
+
if (!this._listeners) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
return (!this._listeners.isEmpty());
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
class EventDeliveryQueue {
|
|
172
|
+
constructor() {
|
|
173
|
+
this._queue = ( new LinkedList());
|
|
174
|
+
}
|
|
175
|
+
get size() {
|
|
176
|
+
return this._queue.size;
|
|
177
|
+
}
|
|
178
|
+
push(emitter, listener, event) {
|
|
179
|
+
this._queue.push(( new EventDeliveryQueueElement(emitter, listener, event)));
|
|
180
|
+
}
|
|
181
|
+
clear(emitter) {
|
|
182
|
+
const newQueue = ( new LinkedList());
|
|
183
|
+
for (const element of this._queue) {
|
|
184
|
+
if (element.emitter !== emitter) {
|
|
185
|
+
newQueue.push(element);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
this._queue = newQueue;
|
|
189
|
+
}
|
|
190
|
+
deliver() {
|
|
191
|
+
while (this._queue.size > 0) {
|
|
192
|
+
const element = this._queue.shift();
|
|
193
|
+
try {
|
|
194
|
+
element.listener.invoke(element.event);
|
|
195
|
+
}
|
|
196
|
+
catch (e) {
|
|
197
|
+
onUnexpectedError(e);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
class PrivateEventDeliveryQueue extends EventDeliveryQueue {
|
|
203
|
+
clear(emitter) {
|
|
204
|
+
this._queue.clear();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
class EventDeliveryQueueElement {
|
|
208
|
+
constructor(emitter, listener, event) {
|
|
209
|
+
this.emitter = emitter;
|
|
210
|
+
this.listener = listener;
|
|
211
|
+
this.event = event;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
class AsyncEmitter extends Emitter {
|
|
215
|
+
async fireAsync(data, token, promiseJoin) {
|
|
216
|
+
if (!this._listeners) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (!this._asyncDeliveryQueue) {
|
|
220
|
+
this._asyncDeliveryQueue = ( new LinkedList());
|
|
221
|
+
}
|
|
222
|
+
for (const listener of this._listeners) {
|
|
223
|
+
this._asyncDeliveryQueue.push([listener, data]);
|
|
224
|
+
}
|
|
225
|
+
while (this._asyncDeliveryQueue.size > 0 && !token.isCancellationRequested) {
|
|
226
|
+
const [listener, data] = this._asyncDeliveryQueue.shift();
|
|
227
|
+
const thenables = [];
|
|
228
|
+
const event = {
|
|
229
|
+
...data,
|
|
230
|
+
token,
|
|
231
|
+
waitUntil: (p) => {
|
|
232
|
+
if (Object.isFrozen(thenables)) {
|
|
233
|
+
throw new Error('waitUntil can NOT be called asynchronous');
|
|
234
|
+
}
|
|
235
|
+
if (promiseJoin) {
|
|
236
|
+
p = promiseJoin(p, listener.callback);
|
|
237
|
+
}
|
|
238
|
+
thenables.push(p);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
try {
|
|
242
|
+
listener.invoke(event);
|
|
243
|
+
}
|
|
244
|
+
catch (e) {
|
|
245
|
+
onUnexpectedError(e);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
await Promise.allSettled(thenables).then(values => {
|
|
249
|
+
for (const value of values) {
|
|
250
|
+
if (value.status === 'rejected') {
|
|
251
|
+
onUnexpectedError(value.reason);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
6
258
|
function refineServiceDecorator(serviceIdentifier) {
|
|
7
259
|
return serviceIdentifier;
|
|
8
260
|
}
|
|
9
261
|
const CancellationTokenSource = monaco.CancellationTokenSource;
|
|
10
|
-
const
|
|
262
|
+
const WINDOWS_INVALID_FILE_CHARS = /[\\/:\*\?"<>\|]/g;
|
|
263
|
+
const UNIX_INVALID_FILE_CHARS = /[\\/]/g;
|
|
264
|
+
const WINDOWS_FORBIDDEN_NAMES = /^(con|prn|aux|clock\$|nul|lpt[0-9]|com[0-9])(\.(.*?))?$/i;
|
|
265
|
+
function isValidBasename(name, isWindowsOS = isWindows) {
|
|
266
|
+
const invalidFileChars = isWindowsOS ? WINDOWS_INVALID_FILE_CHARS : UNIX_INVALID_FILE_CHARS;
|
|
267
|
+
if (!name || name.length === 0 || /^\s+$/.test(name)) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
invalidFileChars.lastIndex = 0;
|
|
271
|
+
if (invalidFileChars.test(name)) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
if (isWindowsOS && WINDOWS_FORBIDDEN_NAMES.test(name)) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
if (name === '.' || name === '..') {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
if (isWindowsOS && name[name.length - 1] === '.') {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
if (isWindowsOS && name.length !== name.trim().length) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
if (name.length > 255) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
const IFileService = ( createDecorator('fileService'));
|
|
11
292
|
var FileType;
|
|
12
|
-
( (
|
|
293
|
+
( (function(FileType) {
|
|
13
294
|
FileType[FileType["Unknown"] = 0] = "Unknown";
|
|
14
295
|
FileType[FileType["File"] = 1] = "File";
|
|
15
296
|
FileType[FileType["Directory"] = 2] = "Directory";
|
|
16
297
|
FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
|
|
17
|
-
})(FileType || (FileType = {})))
|
|
298
|
+
})(FileType || (FileType = {})));
|
|
18
299
|
var FilePermission;
|
|
19
|
-
( (
|
|
300
|
+
( (function(FilePermission) {
|
|
20
301
|
FilePermission[FilePermission["Readonly"] = 1] = "Readonly";
|
|
21
|
-
})(FilePermission || (FilePermission = {})))
|
|
302
|
+
})(FilePermission || (FilePermission = {})));
|
|
22
303
|
function hasReadWriteCapability(provider) {
|
|
23
304
|
return !!((provider.capabilities & 2) );
|
|
24
305
|
}
|
|
@@ -41,7 +322,7 @@ function hasFileAtomicReadCapability(provider) {
|
|
|
41
322
|
return !!((provider.capabilities & 16384) );
|
|
42
323
|
}
|
|
43
324
|
var FileSystemProviderErrorCode;
|
|
44
|
-
( (
|
|
325
|
+
( (function(FileSystemProviderErrorCode) {
|
|
45
326
|
FileSystemProviderErrorCode["FileExists"] = "EntryExists";
|
|
46
327
|
FileSystemProviderErrorCode["FileNotFound"] = "EntryNotFound";
|
|
47
328
|
FileSystemProviderErrorCode["FileNotADirectory"] = "EntryNotADirectory";
|
|
@@ -52,7 +333,7 @@ var FileSystemProviderErrorCode;
|
|
|
52
333
|
FileSystemProviderErrorCode["NoPermissions"] = "NoPermissions";
|
|
53
334
|
FileSystemProviderErrorCode["Unavailable"] = "Unavailable";
|
|
54
335
|
FileSystemProviderErrorCode["Unknown"] = "Unknown";
|
|
55
|
-
})(FileSystemProviderErrorCode || (FileSystemProviderErrorCode = {})))
|
|
336
|
+
})(FileSystemProviderErrorCode || (FileSystemProviderErrorCode = {})));
|
|
56
337
|
class FileSystemProviderError extends Error {
|
|
57
338
|
constructor(message, code) {
|
|
58
339
|
super(message);
|
|
@@ -60,13 +341,13 @@ class FileSystemProviderError extends Error {
|
|
|
60
341
|
}
|
|
61
342
|
}
|
|
62
343
|
function createFileSystemProviderError(error, code) {
|
|
63
|
-
const providerError = (
|
|
344
|
+
const providerError = ( new FileSystemProviderError(( error.toString()), code));
|
|
64
345
|
markAsFileSystemProviderError(providerError, code);
|
|
65
346
|
return providerError;
|
|
66
347
|
}
|
|
67
348
|
function ensureFileSystemProviderError(error) {
|
|
68
349
|
if (!error) {
|
|
69
|
-
return createFileSystemProviderError((
|
|
350
|
+
return createFileSystemProviderError(( localize('unknownError', "Unknown Error")), FileSystemProviderErrorCode.Unknown);
|
|
70
351
|
}
|
|
71
352
|
return error;
|
|
72
353
|
}
|
|
@@ -143,7 +424,7 @@ class FileChangesEvent {
|
|
|
143
424
|
this.rawUpdated = [];
|
|
144
425
|
this.rawDeleted = [];
|
|
145
426
|
this.rawChanges = changes;
|
|
146
|
-
const entriesByType = (
|
|
427
|
+
const entriesByType = ( new Map());
|
|
147
428
|
for (const change of changes) {
|
|
148
429
|
const array = entriesByType.get(change.type);
|
|
149
430
|
if (array) {
|
|
@@ -247,34 +528,386 @@ function etag(stat) {
|
|
|
247
528
|
if (typeof stat.size !== 'number' || typeof stat.mtime !== 'number') {
|
|
248
529
|
return undefined;
|
|
249
530
|
}
|
|
250
|
-
return (
|
|
531
|
+
return ( stat.mtime.toString(29)) + ( stat.size.toString(31));
|
|
251
532
|
}
|
|
252
|
-
const IUriIdentityService = (
|
|
253
|
-
const IEditorGroupsService = (
|
|
533
|
+
const IUriIdentityService = ( createDecorator('IUriIdentityService'));
|
|
534
|
+
const IEditorGroupsService = ( createDecorator('editorGroupsService'));
|
|
254
535
|
function isEditorGroup(obj) {
|
|
255
536
|
const group = obj;
|
|
256
537
|
return !!group && typeof group.id === 'number' && Array.isArray(group.editors);
|
|
257
538
|
}
|
|
258
|
-
const IEditorService = (
|
|
539
|
+
const IEditorService = ( createDecorator('editorService'));
|
|
259
540
|
const ACTIVE_GROUP = -1;
|
|
260
541
|
const SIDE_GROUP = -2;
|
|
261
542
|
function isPreferredGroup(obj) {
|
|
262
543
|
const candidate = obj;
|
|
263
544
|
return typeof obj === 'number' || isEditorGroup(candidate);
|
|
264
545
|
}
|
|
265
|
-
const ITextFileService = (
|
|
546
|
+
const ITextFileService = ( createDecorator('textFileService'));
|
|
266
547
|
const IWorkbenchEnvironmentService = refineServiceDecorator(IEnvironmentService);
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
548
|
+
const IWorkingCopyService = ( createDecorator('workingCopyService'));
|
|
549
|
+
let WorkingCopyFileOperationParticipant = class WorkingCopyFileOperationParticipant extends Disposable {
|
|
550
|
+
constructor(logService, configurationService) {
|
|
551
|
+
super();
|
|
552
|
+
this.logService = logService;
|
|
553
|
+
this.configurationService = configurationService;
|
|
554
|
+
this.participants = ( new LinkedList());
|
|
555
|
+
}
|
|
556
|
+
addFileOperationParticipant(participant) {
|
|
557
|
+
const remove = this.participants.push(participant);
|
|
558
|
+
return toDisposable(() => remove());
|
|
559
|
+
}
|
|
560
|
+
async participate(files, operation, undoInfo, token) {
|
|
561
|
+
const timeout = this.configurationService.getValue('files.participants.timeout');
|
|
562
|
+
if (typeof timeout !== 'number' || timeout <= 0) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
for (const participant of this.participants) {
|
|
566
|
+
try {
|
|
567
|
+
await participant.participate(files, operation, undoInfo, timeout, token);
|
|
568
|
+
}
|
|
569
|
+
catch (err) {
|
|
570
|
+
this.logService.warn(err);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
dispose() {
|
|
575
|
+
this.participants.clear();
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
WorkingCopyFileOperationParticipant = ( __decorate([
|
|
579
|
+
( __param(0, ILogService)),
|
|
580
|
+
( __param(1, IConfigurationService))
|
|
581
|
+
], WorkingCopyFileOperationParticipant));
|
|
582
|
+
let StoredFileWorkingCopySaveParticipant = class StoredFileWorkingCopySaveParticipant extends Disposable {
|
|
583
|
+
constructor(progressService, logService) {
|
|
584
|
+
super();
|
|
585
|
+
this.progressService = progressService;
|
|
586
|
+
this.logService = logService;
|
|
587
|
+
this.saveParticipants = [];
|
|
588
|
+
}
|
|
589
|
+
get length() { return this.saveParticipants.length; }
|
|
590
|
+
addSaveParticipant(participant) {
|
|
591
|
+
const remove = insert(this.saveParticipants, participant);
|
|
592
|
+
return toDisposable(() => remove());
|
|
593
|
+
}
|
|
594
|
+
participate(workingCopy, context, token) {
|
|
595
|
+
const cts = ( new CancellationTokenSource(token));
|
|
596
|
+
return this.progressService.withProgress({
|
|
597
|
+
title: ( localize('saveParticipants', "Saving '{0}'", workingCopy.name)),
|
|
598
|
+
location: 15 ,
|
|
599
|
+
cancellable: true,
|
|
600
|
+
delay: workingCopy.isDirty() ? 3000 : 5000
|
|
601
|
+
}, async (progress) => {
|
|
602
|
+
workingCopy.model?.pushStackElement();
|
|
603
|
+
for (const saveParticipant of this.saveParticipants) {
|
|
604
|
+
if (cts.token.isCancellationRequested || workingCopy.isDisposed()) {
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
try {
|
|
608
|
+
const promise = saveParticipant.participate(workingCopy, context, progress, cts.token);
|
|
609
|
+
await raceCancellation(promise, cts.token);
|
|
610
|
+
}
|
|
611
|
+
catch (err) {
|
|
612
|
+
this.logService.warn(err);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
workingCopy.model?.pushStackElement();
|
|
616
|
+
}, () => {
|
|
617
|
+
cts.dispose(true);
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
dispose() {
|
|
621
|
+
this.saveParticipants.splice(0, this.saveParticipants.length);
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
StoredFileWorkingCopySaveParticipant = ( __decorate([
|
|
625
|
+
( __param(0, IProgressService)),
|
|
626
|
+
( __param(1, ILogService))
|
|
627
|
+
], StoredFileWorkingCopySaveParticipant));
|
|
628
|
+
const IWorkingCopyFileService = ( createDecorator('workingCopyFileService'));
|
|
629
|
+
let WorkingCopyFileService = class WorkingCopyFileService extends Disposable {
|
|
630
|
+
constructor(fileService, workingCopyService, instantiationService, uriIdentityService) {
|
|
631
|
+
super();
|
|
632
|
+
this.fileService = fileService;
|
|
633
|
+
this.workingCopyService = workingCopyService;
|
|
634
|
+
this.instantiationService = instantiationService;
|
|
635
|
+
this.uriIdentityService = uriIdentityService;
|
|
636
|
+
this._onWillRunWorkingCopyFileOperation = this._register(( new AsyncEmitter()));
|
|
637
|
+
this.onWillRunWorkingCopyFileOperation = this._onWillRunWorkingCopyFileOperation.event;
|
|
638
|
+
this._onDidFailWorkingCopyFileOperation = this._register(( new AsyncEmitter()));
|
|
639
|
+
this.onDidFailWorkingCopyFileOperation = this._onDidFailWorkingCopyFileOperation.event;
|
|
640
|
+
this._onDidRunWorkingCopyFileOperation = this._register(( new AsyncEmitter()));
|
|
641
|
+
this.onDidRunWorkingCopyFileOperation = this._onDidRunWorkingCopyFileOperation.event;
|
|
642
|
+
this.correlationIds = 0;
|
|
643
|
+
this.fileOperationParticipants = this._register(this.instantiationService.createInstance(WorkingCopyFileOperationParticipant));
|
|
644
|
+
this.saveParticipants = this._register(this.instantiationService.createInstance(StoredFileWorkingCopySaveParticipant));
|
|
645
|
+
this.workingCopyProviders = [];
|
|
646
|
+
this._register(this.registerWorkingCopyProvider(resource => {
|
|
647
|
+
return this.workingCopyService.workingCopies.filter(workingCopy => {
|
|
648
|
+
if (this.fileService.hasProvider(resource)) {
|
|
649
|
+
return this.uriIdentityService.extUri.isEqualOrParent(workingCopy.resource, resource);
|
|
650
|
+
}
|
|
651
|
+
return this.uriIdentityService.extUri.isEqual(workingCopy.resource, resource);
|
|
652
|
+
});
|
|
653
|
+
}));
|
|
654
|
+
}
|
|
655
|
+
create(operations, token, undoInfo) {
|
|
656
|
+
return this.doCreateFileOrFolder(operations, true, token, undoInfo);
|
|
657
|
+
}
|
|
658
|
+
createFolder(operations, token, undoInfo) {
|
|
659
|
+
return this.doCreateFileOrFolder(operations, false, token, undoInfo);
|
|
660
|
+
}
|
|
661
|
+
async doCreateFileOrFolder(operations, isFile, token, undoInfo) {
|
|
662
|
+
if (operations.length === 0) {
|
|
663
|
+
return [];
|
|
664
|
+
}
|
|
665
|
+
if (isFile) {
|
|
666
|
+
const validateCreates = await Promises.settled(operations.map(operation => this.fileService.canCreateFile(operation.resource, { overwrite: operation.overwrite })));
|
|
667
|
+
const error = validateCreates.find(validateCreate => validateCreate instanceof Error);
|
|
668
|
+
if (error instanceof Error) {
|
|
669
|
+
throw error;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
const files = operations.map(operation => ({ target: operation.resource }));
|
|
673
|
+
await this.runFileOperationParticipants(files, 0 , undoInfo, token);
|
|
674
|
+
const event = { correlationId: this.correlationIds++, operation: 0 , files };
|
|
675
|
+
await this._onWillRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
676
|
+
let stats;
|
|
677
|
+
try {
|
|
678
|
+
if (isFile) {
|
|
679
|
+
stats = await Promises.settled(operations.map(operation => this.fileService.createFile(operation.resource, operation.contents, { overwrite: operation.overwrite })));
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
stats = await Promises.settled(operations.map(operation => this.fileService.createFolder(operation.resource)));
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
catch (error) {
|
|
686
|
+
await this._onDidFailWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
687
|
+
throw error;
|
|
688
|
+
}
|
|
689
|
+
await this._onDidRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
690
|
+
return stats;
|
|
691
|
+
}
|
|
692
|
+
async move(operations, token, undoInfo) {
|
|
693
|
+
return this.doMoveOrCopy(operations, true, token, undoInfo);
|
|
694
|
+
}
|
|
695
|
+
async copy(operations, token, undoInfo) {
|
|
696
|
+
return this.doMoveOrCopy(operations, false, token, undoInfo);
|
|
697
|
+
}
|
|
698
|
+
async doMoveOrCopy(operations, move, token, undoInfo) {
|
|
699
|
+
const stats = [];
|
|
700
|
+
for (const { file: { source, target }, overwrite } of operations) {
|
|
701
|
+
const validateMoveOrCopy = await (move ? this.fileService.canMove(source, target, overwrite) : this.fileService.canCopy(source, target, overwrite));
|
|
702
|
+
if (validateMoveOrCopy instanceof Error) {
|
|
703
|
+
throw validateMoveOrCopy;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
const files = operations.map(o => o.file);
|
|
707
|
+
await this.runFileOperationParticipants(files, move ? 2 : 3 , undoInfo, token);
|
|
708
|
+
const event = { correlationId: this.correlationIds++, operation: move ? 2 : 3 , files };
|
|
709
|
+
await this._onWillRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
710
|
+
try {
|
|
711
|
+
for (const { file: { source, target }, overwrite } of operations) {
|
|
712
|
+
if (!this.uriIdentityService.extUri.isEqual(source, target)) {
|
|
713
|
+
const dirtyWorkingCopies = (move ? [...this.getDirty(source), ...this.getDirty(target)] : this.getDirty(target));
|
|
714
|
+
await Promises.settled(dirtyWorkingCopies.map(dirtyWorkingCopy => dirtyWorkingCopy.revert({ soft: true })));
|
|
715
|
+
}
|
|
716
|
+
if (move) {
|
|
717
|
+
stats.push(await this.fileService.move(source, target, overwrite));
|
|
718
|
+
}
|
|
719
|
+
else {
|
|
720
|
+
stats.push(await this.fileService.copy(source, target, overwrite));
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
catch (error) {
|
|
725
|
+
await this._onDidFailWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
726
|
+
throw error;
|
|
727
|
+
}
|
|
728
|
+
await this._onDidRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
729
|
+
return stats;
|
|
730
|
+
}
|
|
731
|
+
async delete(operations, token, undoInfo) {
|
|
732
|
+
for (const operation of operations) {
|
|
733
|
+
const validateDelete = await this.fileService.canDelete(operation.resource, { recursive: operation.recursive, useTrash: operation.useTrash });
|
|
734
|
+
if (validateDelete instanceof Error) {
|
|
735
|
+
throw validateDelete;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
const files = operations.map(operation => ({ target: operation.resource }));
|
|
739
|
+
await this.runFileOperationParticipants(files, 1 , undoInfo, token);
|
|
740
|
+
const event = { correlationId: this.correlationIds++, operation: 1 , files };
|
|
741
|
+
await this._onWillRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
742
|
+
for (const operation of operations) {
|
|
743
|
+
const dirtyWorkingCopies = this.getDirty(operation.resource);
|
|
744
|
+
await Promises.settled(dirtyWorkingCopies.map(dirtyWorkingCopy => dirtyWorkingCopy.revert({ soft: true })));
|
|
745
|
+
}
|
|
746
|
+
try {
|
|
747
|
+
for (const operation of operations) {
|
|
748
|
+
await this.fileService.del(operation.resource, { recursive: operation.recursive, useTrash: operation.useTrash });
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
catch (error) {
|
|
752
|
+
await this._onDidFailWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
753
|
+
throw error;
|
|
754
|
+
}
|
|
755
|
+
await this._onDidRunWorkingCopyFileOperation.fireAsync(event, CancellationToken.None );
|
|
756
|
+
}
|
|
757
|
+
addFileOperationParticipant(participant) {
|
|
758
|
+
return this.fileOperationParticipants.addFileOperationParticipant(participant);
|
|
759
|
+
}
|
|
760
|
+
runFileOperationParticipants(files, operation, undoInfo, token) {
|
|
761
|
+
return this.fileOperationParticipants.participate(files, operation, undoInfo, token);
|
|
762
|
+
}
|
|
763
|
+
get hasSaveParticipants() { return this.saveParticipants.length > 0; }
|
|
764
|
+
addSaveParticipant(participant) {
|
|
765
|
+
return this.saveParticipants.addSaveParticipant(participant);
|
|
766
|
+
}
|
|
767
|
+
runSaveParticipants(workingCopy, context, token) {
|
|
768
|
+
return this.saveParticipants.participate(workingCopy, context, token);
|
|
769
|
+
}
|
|
770
|
+
registerWorkingCopyProvider(provider) {
|
|
771
|
+
const remove = insert(this.workingCopyProviders, provider);
|
|
772
|
+
return toDisposable(remove);
|
|
773
|
+
}
|
|
774
|
+
getDirty(resource) {
|
|
775
|
+
const dirtyWorkingCopies = ( new Set());
|
|
776
|
+
for (const provider of this.workingCopyProviders) {
|
|
777
|
+
for (const workingCopy of provider(resource)) {
|
|
778
|
+
if (workingCopy.isDirty()) {
|
|
779
|
+
dirtyWorkingCopies.add(workingCopy);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
return Array.from(dirtyWorkingCopies);
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
WorkingCopyFileService = ( __decorate([
|
|
787
|
+
( __param(0, IFileService)),
|
|
788
|
+
( __param(1, IWorkingCopyService)),
|
|
789
|
+
( __param(2, IInstantiationService)),
|
|
790
|
+
( __param(3, IUriIdentityService))
|
|
791
|
+
], WorkingCopyFileService));
|
|
792
|
+
function isVirtualResource(resource) {
|
|
793
|
+
return resource.scheme !== Schemas.file && resource.scheme !== Schemas.vscodeRemote;
|
|
794
|
+
}
|
|
795
|
+
function getVirtualWorkspaceLocation(workspace) {
|
|
796
|
+
if (workspace.folders.length) {
|
|
797
|
+
return workspace.folders.every(f => isVirtualResource(f.uri)) ? workspace.folders[0].uri : undefined;
|
|
798
|
+
}
|
|
799
|
+
else if (workspace.configuration && isVirtualResource(workspace.configuration)) {
|
|
800
|
+
return workspace.configuration;
|
|
801
|
+
}
|
|
802
|
+
return undefined;
|
|
803
|
+
}
|
|
804
|
+
function getVirtualWorkspaceScheme(workspace) {
|
|
805
|
+
return getVirtualWorkspaceLocation(workspace)?.scheme;
|
|
806
|
+
}
|
|
807
|
+
const IRemoteAgentService = ( createDecorator('remoteAgentService'));
|
|
808
|
+
const IPathService = ( createDecorator('pathService'));
|
|
809
|
+
let AbstractPathService = class AbstractPathService {
|
|
810
|
+
constructor(localUserHome, remoteAgentService, environmentService, contextService) {
|
|
811
|
+
this.localUserHome = localUserHome;
|
|
812
|
+
this.remoteAgentService = remoteAgentService;
|
|
813
|
+
this.environmentService = environmentService;
|
|
814
|
+
this.contextService = contextService;
|
|
815
|
+
this.resolveOS = (async () => {
|
|
816
|
+
const env = await this.remoteAgentService.getEnvironment();
|
|
817
|
+
return env?.os || OS;
|
|
818
|
+
})();
|
|
819
|
+
this.resolveUserHome = (async () => {
|
|
820
|
+
const env = await this.remoteAgentService.getEnvironment();
|
|
821
|
+
const userHome = this.maybeUnresolvedUserHome = env?.userHome ?? localUserHome;
|
|
822
|
+
return userHome;
|
|
823
|
+
})();
|
|
824
|
+
}
|
|
825
|
+
hasValidBasename(resource, arg2, basename) {
|
|
826
|
+
if (typeof arg2 === 'string' || typeof arg2 === 'undefined') {
|
|
827
|
+
return this.resolveOS.then(os => this.doHasValidBasename(resource, os, arg2));
|
|
828
|
+
}
|
|
829
|
+
return this.doHasValidBasename(resource, arg2, basename);
|
|
830
|
+
}
|
|
831
|
+
doHasValidBasename(resource, os, name) {
|
|
832
|
+
if (resource.scheme === Schemas.file || resource.scheme === Schemas.vscodeRemote) {
|
|
833
|
+
return isValidBasename(name ?? basename(resource), os === 1 );
|
|
834
|
+
}
|
|
835
|
+
return true;
|
|
836
|
+
}
|
|
837
|
+
get defaultUriScheme() {
|
|
838
|
+
return AbstractPathService.findDefaultUriScheme(this.environmentService, this.contextService);
|
|
839
|
+
}
|
|
840
|
+
static findDefaultUriScheme(environmentService, contextService) {
|
|
841
|
+
if (environmentService.remoteAuthority) {
|
|
842
|
+
return Schemas.vscodeRemote;
|
|
843
|
+
}
|
|
844
|
+
const virtualWorkspace = getVirtualWorkspaceScheme(contextService.getWorkspace());
|
|
845
|
+
if (virtualWorkspace) {
|
|
846
|
+
return virtualWorkspace;
|
|
847
|
+
}
|
|
848
|
+
const firstFolder = contextService.getWorkspace().folders[0];
|
|
849
|
+
if (firstFolder) {
|
|
850
|
+
return firstFolder.uri.scheme;
|
|
851
|
+
}
|
|
852
|
+
const configuration = contextService.getWorkspace().configuration;
|
|
853
|
+
if (configuration) {
|
|
854
|
+
return configuration.scheme;
|
|
855
|
+
}
|
|
856
|
+
return Schemas.file;
|
|
857
|
+
}
|
|
858
|
+
userHome(options) {
|
|
859
|
+
return options?.preferLocal ? this.localUserHome : this.resolveUserHome;
|
|
860
|
+
}
|
|
861
|
+
get resolvedUserHome() {
|
|
862
|
+
return this.maybeUnresolvedUserHome;
|
|
863
|
+
}
|
|
864
|
+
get path() {
|
|
865
|
+
return this.resolveOS.then(os => {
|
|
866
|
+
return os === 1 ?
|
|
867
|
+
win32 :
|
|
868
|
+
posix;
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
async fileURI(_path) {
|
|
872
|
+
let authority = '';
|
|
873
|
+
const os = await this.resolveOS;
|
|
874
|
+
if (os === 1 ) {
|
|
875
|
+
_path = _path.replace(/\\/g, '/');
|
|
876
|
+
}
|
|
877
|
+
if (_path[0] === '/' && _path[1] === '/') {
|
|
878
|
+
const idx = _path.indexOf('/', 2);
|
|
879
|
+
if (idx === -1) {
|
|
880
|
+
authority = _path.substring(2);
|
|
881
|
+
_path = '/';
|
|
882
|
+
}
|
|
883
|
+
else {
|
|
884
|
+
authority = _path.substring(2, idx);
|
|
885
|
+
_path = _path.substring(idx) || '/';
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
return ( URI.from({
|
|
889
|
+
scheme: Schemas.file,
|
|
890
|
+
authority,
|
|
891
|
+
path: _path,
|
|
892
|
+
query: '',
|
|
893
|
+
fragment: ''
|
|
894
|
+
}));
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
AbstractPathService = ( __decorate([
|
|
898
|
+
( __param(1, IRemoteAgentService)),
|
|
899
|
+
( __param(2, IWorkbenchEnvironmentService)),
|
|
900
|
+
( __param(3, IWorkspaceContextService))
|
|
901
|
+
], AbstractPathService));
|
|
902
|
+
const IPaneCompositePartService = ( createDecorator('paneCompositePartService'));
|
|
903
|
+
const IProductService = ( createDecorator('productService'));
|
|
271
904
|
const productSchemaId = 'vscode://schemas/vscode-product';
|
|
272
|
-
const ILanguageStatusService = (
|
|
273
|
-
const IHostService = (
|
|
274
|
-
const ISnippetsService = (
|
|
905
|
+
const ILanguageStatusService = ( createDecorator('ILanguageStatusService'));
|
|
906
|
+
const IHostService = ( createDecorator('hostService'));
|
|
907
|
+
const ISnippetsService = ( createDecorator('snippetService'));
|
|
275
908
|
let services;
|
|
276
909
|
var Services;
|
|
277
|
-
( (
|
|
910
|
+
(function (Services) {
|
|
278
911
|
Services.get = () => {
|
|
279
912
|
return services ?? {};
|
|
280
913
|
};
|
|
@@ -292,5 +925,5 @@ var Services;
|
|
|
292
925
|
};
|
|
293
926
|
}
|
|
294
927
|
Services.install = install;
|
|
295
|
-
})(Services || (Services = {}))
|
|
296
|
-
export { ACTIVE_GROUP as A,
|
|
928
|
+
})(Services || (Services = {}));
|
|
929
|
+
export { ACTIVE_GROUP as A, hasReadWriteCapability as B, CancellationTokenSource as C, hasFileReadStreamCapability as D, toFileSystemProviderErrorCode as E, FileType as F, etag as G, FileOperationEvent as H, ITextFileService as I, toFileOperationResult as J, ETAG_DISABLED as K, hasFileAtomicReadCapability as L, hasFileFolderCopyCapability as M, NotModifiedSinceFileOperationError as N, hasFileCloneCapability as O, FILES_ASSOCIATIONS_CONFIG as P, Services as S, FilePermission as a, FileSystemProviderErrorCode as b, SIDE_GROUP as c, IFileService as d, IWorkbenchEnvironmentService as e, IUriIdentityService as f, IWorkingCopyFileService as g, IPathService as h, IEditorService as i, IEditorGroupsService as j, IPaneCompositePartService as k, IProductService as l, markAsFileSystemProviderError as m, ILanguageStatusService as n, IHostService as o, FileOperationError as p, productSchemaId as q, refineServiceDecorator as r, IRemoteAgentService as s, ISnippetsService as t, isPreferredGroup as u, FileSystemProviderError as v, ensureFileSystemProviderError as w, createFileSystemProviderError as x, FileChangesEvent as y, hasOpenReadWriteCloseCapability as z };
|