@codingame/monaco-vscode-api 1.76.1 → 1.76.3-next.0

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 (59) hide show
  1. package/README.md +2 -1
  2. package/dist/api.js +3 -860
  3. package/dist/{extHost.js → api2.js} +16555 -13467
  4. package/dist/async.js +107 -2
  5. package/dist/audioCue.js +105 -103
  6. package/dist/button.js +1 -1
  7. package/dist/cancellation.js +3 -0
  8. package/dist/configuration.js +7 -344
  9. package/dist/configuration2.js +339 -0
  10. package/dist/configurationRegistry.js +441 -0
  11. package/dist/contextkeys.js +211 -0
  12. package/dist/debug.d.ts +22 -0
  13. package/dist/debug.js +15842 -0
  14. package/dist/dialogs.js +855 -9
  15. package/dist/extensionResourceLoader.js +96 -0
  16. package/dist/extensions.d.ts +491 -0
  17. package/dist/extensions.js +70 -0
  18. package/dist/{tools.js → extensionsRegistry.js} +2 -30
  19. package/dist/files.js +1407 -334
  20. package/dist/iconv.js +43 -0
  21. package/dist/injection.js +1 -1
  22. package/dist/jschardet.js +7 -0
  23. package/dist/keybindings.d.ts +1 -485
  24. package/dist/keybindings.js +666 -679
  25. package/dist/labels.js +14 -0
  26. package/dist/languageConfiguration.d.ts +1 -2
  27. package/dist/languageConfiguration.js +9 -16
  28. package/dist/languageService.js +112 -8
  29. package/dist/languages.d.ts +1 -473
  30. package/dist/languages.js +2 -12
  31. package/dist/layout.js +4 -3
  32. package/dist/layoutService.js +1 -1
  33. package/dist/missing-services.js +4710 -74
  34. package/dist/modelEditor.d.ts +324 -2
  35. package/dist/modelEditor.js +15 -228
  36. package/dist/monaco.js +7 -72
  37. package/dist/notifications.js +75 -232
  38. package/dist/polyfill.js +10715 -2459
  39. package/dist/resources.js +197 -0
  40. package/dist/services.d.ts +924 -3
  41. package/dist/services.js +1 -2
  42. package/dist/services2.js +2436 -18
  43. package/dist/snippets.d.ts +1 -473
  44. package/dist/snippets.js +8 -867
  45. package/dist/snippetsService.js +868 -0
  46. package/dist/textFileEditorModel.js +2985 -0
  47. package/dist/textmate.d.ts +3 -475
  48. package/dist/textmate.js +19 -29
  49. package/dist/theme.d.ts +1 -3
  50. package/dist/theme.js +24 -70
  51. package/dist/tokenClassification.d.ts +1 -475
  52. package/dist/tokenClassification.js +11 -37
  53. package/dist/tokenClassificationRegistry.js +8 -4
  54. package/dist/variableResolver.js +1711 -0
  55. package/dist/workbenchThemeService.js +1 -1
  56. package/dist/workspaceContext.js +1 -3
  57. package/package.json +27 -12
  58. package/dist/contextkey.js +0 -419
  59. package/dist/dialog.web.contribution.js +0 -945
@@ -0,0 +1,1711 @@
1
+ import { R as Range } from './polyfill.js';
2
+ import { cwd, env, platform } from 'monaco-editor/esm/vs/base/common/process.js';
3
+ import { equalsIgnoreCase } from 'monaco-editor/esm/vs/base/common/strings.js';
4
+ import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
5
+ import { coalesce } from 'monaco-editor/esm/vs/base/common/arrays.js';
6
+ import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
7
+ import { deepClone } from 'monaco-editor/esm/vs/base/common/objects.js';
8
+ import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
9
+ import { cn as replaceAsync, co as VariableKind, cp as VariableError } from './missing-services.js';
10
+ import { isWindows, isMacintosh, isLinux } from 'monaco-editor/esm/vs/base/common/platform.js';
11
+ import { isString, isObject, isUndefinedOrNull } from 'monaco-editor/esm/vs/base/common/types.js';
12
+ import { sep, basename, dirname, extname, relative } from 'monaco-editor/esm/vs/base/common/path.js';
13
+ import { localize } from 'monaco-editor/esm/vs/nls.js';
14
+ import { normalizeDriveLetter } from 'monaco-editor/esm/vs/base/common/labels.js';
15
+ const CHAR_UPPERCASE_A = 65;
16
+ const CHAR_LOWERCASE_A = 97;
17
+ const CHAR_UPPERCASE_Z = 90;
18
+ const CHAR_LOWERCASE_Z = 122;
19
+ const CHAR_DOT = 46;
20
+ const CHAR_FORWARD_SLASH = 47;
21
+ const CHAR_BACKWARD_SLASH = 92;
22
+ const CHAR_COLON = 58;
23
+ const CHAR_QUESTION_MARK = 63;
24
+ class ErrorInvalidArgType extends Error {
25
+ constructor(name, expected, actual) {
26
+ let determiner;
27
+ if (typeof expected === 'string' && expected.indexOf('not ') === 0) {
28
+ determiner = 'must not be';
29
+ expected = expected.replace(/^not /, '');
30
+ }
31
+ else {
32
+ determiner = 'must be';
33
+ }
34
+ const type = name.indexOf('.') !== -1 ? 'property' : 'argument';
35
+ let msg = `The "${name}" ${type} ${determiner} of type ${expected}`;
36
+ msg += `. Received type ${typeof actual}`;
37
+ super(msg);
38
+ this.code = 'ERR_INVALID_ARG_TYPE';
39
+ }
40
+ }
41
+ function validateObject(pathObject, name) {
42
+ if (pathObject === null || typeof pathObject !== 'object') {
43
+ throw new ErrorInvalidArgType(name, 'Object', pathObject);
44
+ }
45
+ }
46
+ function validateString(value, name) {
47
+ if (typeof value !== 'string') {
48
+ throw new ErrorInvalidArgType(name, 'string', value);
49
+ }
50
+ }
51
+ const platformIsWin32 = (platform === 'win32');
52
+ function isPathSeparator(code) {
53
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
54
+ }
55
+ function isPosixPathSeparator(code) {
56
+ return code === CHAR_FORWARD_SLASH;
57
+ }
58
+ function isWindowsDeviceRoot(code) {
59
+ return (code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z) ||
60
+ (code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z);
61
+ }
62
+ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
63
+ let res = '';
64
+ let lastSegmentLength = 0;
65
+ let lastSlash = -1;
66
+ let dots = 0;
67
+ let code = 0;
68
+ for (let i = 0; i <= path.length; ++i) {
69
+ if (i < path.length) {
70
+ code = path.charCodeAt(i);
71
+ }
72
+ else if (isPathSeparator(code)) {
73
+ break;
74
+ }
75
+ else {
76
+ code = CHAR_FORWARD_SLASH;
77
+ }
78
+ if (isPathSeparator(code)) {
79
+ if (lastSlash === i - 1 || dots === 1) ;
80
+ else if (dots === 2) {
81
+ if (res.length < 2 || lastSegmentLength !== 2 ||
82
+ res.charCodeAt(res.length - 1) !== CHAR_DOT ||
83
+ res.charCodeAt(res.length - 2) !== CHAR_DOT) {
84
+ if (res.length > 2) {
85
+ const lastSlashIndex = res.lastIndexOf(separator);
86
+ if (lastSlashIndex === -1) {
87
+ res = '';
88
+ lastSegmentLength = 0;
89
+ }
90
+ else {
91
+ res = res.slice(0, lastSlashIndex);
92
+ lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
93
+ }
94
+ lastSlash = i;
95
+ dots = 0;
96
+ continue;
97
+ }
98
+ else if (res.length !== 0) {
99
+ res = '';
100
+ lastSegmentLength = 0;
101
+ lastSlash = i;
102
+ dots = 0;
103
+ continue;
104
+ }
105
+ }
106
+ if (allowAboveRoot) {
107
+ res += res.length > 0 ? `${separator}..` : '..';
108
+ lastSegmentLength = 2;
109
+ }
110
+ }
111
+ else {
112
+ if (res.length > 0) {
113
+ res += `${separator}${path.slice(lastSlash + 1, i)}`;
114
+ }
115
+ else {
116
+ res = path.slice(lastSlash + 1, i);
117
+ }
118
+ lastSegmentLength = i - lastSlash - 1;
119
+ }
120
+ lastSlash = i;
121
+ dots = 0;
122
+ }
123
+ else if (code === CHAR_DOT && dots !== -1) {
124
+ ++dots;
125
+ }
126
+ else {
127
+ dots = -1;
128
+ }
129
+ }
130
+ return res;
131
+ }
132
+ function _format(sep, pathObject) {
133
+ validateObject(pathObject, 'pathObject');
134
+ const dir = pathObject.dir || pathObject.root;
135
+ const base = pathObject.base ||
136
+ `${pathObject.name || ''}${pathObject.ext || ''}`;
137
+ if (!dir) {
138
+ return base;
139
+ }
140
+ return dir === pathObject.root ? `${dir}${base}` : `${dir}${sep}${base}`;
141
+ }
142
+ const win32 = {
143
+ resolve(...pathSegments) {
144
+ let resolvedDevice = '';
145
+ let resolvedTail = '';
146
+ let resolvedAbsolute = false;
147
+ for (let i = pathSegments.length - 1; i >= -1; i--) {
148
+ let path;
149
+ if (i >= 0) {
150
+ path = pathSegments[i];
151
+ validateString(path, 'path');
152
+ if (path.length === 0) {
153
+ continue;
154
+ }
155
+ }
156
+ else if (resolvedDevice.length === 0) {
157
+ path = cwd();
158
+ }
159
+ else {
160
+ path = env[`=${resolvedDevice}`] || cwd();
161
+ if (path === undefined ||
162
+ (path.slice(0, 2).toLowerCase() !== resolvedDevice.toLowerCase() &&
163
+ path.charCodeAt(2) === CHAR_BACKWARD_SLASH)) {
164
+ path = `${resolvedDevice}\\`;
165
+ }
166
+ }
167
+ const len = path.length;
168
+ let rootEnd = 0;
169
+ let device = '';
170
+ let isAbsolute = false;
171
+ const code = path.charCodeAt(0);
172
+ if (len === 1) {
173
+ if (isPathSeparator(code)) {
174
+ rootEnd = 1;
175
+ isAbsolute = true;
176
+ }
177
+ }
178
+ else if (isPathSeparator(code)) {
179
+ isAbsolute = true;
180
+ if (isPathSeparator(path.charCodeAt(1))) {
181
+ let j = 2;
182
+ let last = j;
183
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
184
+ j++;
185
+ }
186
+ if (j < len && j !== last) {
187
+ const firstPart = path.slice(last, j);
188
+ last = j;
189
+ while (j < len && isPathSeparator(path.charCodeAt(j))) {
190
+ j++;
191
+ }
192
+ if (j < len && j !== last) {
193
+ last = j;
194
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
195
+ j++;
196
+ }
197
+ if (j === len || j !== last) {
198
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
199
+ rootEnd = j;
200
+ }
201
+ }
202
+ }
203
+ }
204
+ else {
205
+ rootEnd = 1;
206
+ }
207
+ }
208
+ else if (isWindowsDeviceRoot(code) &&
209
+ path.charCodeAt(1) === CHAR_COLON) {
210
+ device = path.slice(0, 2);
211
+ rootEnd = 2;
212
+ if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
213
+ isAbsolute = true;
214
+ rootEnd = 3;
215
+ }
216
+ }
217
+ if (device.length > 0) {
218
+ if (resolvedDevice.length > 0) {
219
+ if (device.toLowerCase() !== resolvedDevice.toLowerCase()) {
220
+ continue;
221
+ }
222
+ }
223
+ else {
224
+ resolvedDevice = device;
225
+ }
226
+ }
227
+ if (resolvedAbsolute) {
228
+ if (resolvedDevice.length > 0) {
229
+ break;
230
+ }
231
+ }
232
+ else {
233
+ resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
234
+ resolvedAbsolute = isAbsolute;
235
+ if (isAbsolute && resolvedDevice.length > 0) {
236
+ break;
237
+ }
238
+ }
239
+ }
240
+ resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, '\\', isPathSeparator);
241
+ return resolvedAbsolute ?
242
+ `${resolvedDevice}\\${resolvedTail}` :
243
+ `${resolvedDevice}${resolvedTail}` || '.';
244
+ },
245
+ normalize(path) {
246
+ validateString(path, 'path');
247
+ const len = path.length;
248
+ if (len === 0) {
249
+ return '.';
250
+ }
251
+ let rootEnd = 0;
252
+ let device;
253
+ let isAbsolute = false;
254
+ const code = path.charCodeAt(0);
255
+ if (len === 1) {
256
+ return isPosixPathSeparator(code) ? '\\' : path;
257
+ }
258
+ if (isPathSeparator(code)) {
259
+ isAbsolute = true;
260
+ if (isPathSeparator(path.charCodeAt(1))) {
261
+ let j = 2;
262
+ let last = j;
263
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
264
+ j++;
265
+ }
266
+ if (j < len && j !== last) {
267
+ const firstPart = path.slice(last, j);
268
+ last = j;
269
+ while (j < len && isPathSeparator(path.charCodeAt(j))) {
270
+ j++;
271
+ }
272
+ if (j < len && j !== last) {
273
+ last = j;
274
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
275
+ j++;
276
+ }
277
+ if (j === len) {
278
+ return `\\\\${firstPart}\\${path.slice(last)}\\`;
279
+ }
280
+ if (j !== last) {
281
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
282
+ rootEnd = j;
283
+ }
284
+ }
285
+ }
286
+ }
287
+ else {
288
+ rootEnd = 1;
289
+ }
290
+ }
291
+ else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
292
+ device = path.slice(0, 2);
293
+ rootEnd = 2;
294
+ if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
295
+ isAbsolute = true;
296
+ rootEnd = 3;
297
+ }
298
+ }
299
+ let tail = rootEnd < len ?
300
+ normalizeString(path.slice(rootEnd), !isAbsolute, '\\', isPathSeparator) :
301
+ '';
302
+ if (tail.length === 0 && !isAbsolute) {
303
+ tail = '.';
304
+ }
305
+ if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {
306
+ tail += '\\';
307
+ }
308
+ if (device === undefined) {
309
+ return isAbsolute ? `\\${tail}` : tail;
310
+ }
311
+ return isAbsolute ? `${device}\\${tail}` : `${device}${tail}`;
312
+ },
313
+ isAbsolute(path) {
314
+ validateString(path, 'path');
315
+ const len = path.length;
316
+ if (len === 0) {
317
+ return false;
318
+ }
319
+ const code = path.charCodeAt(0);
320
+ return isPathSeparator(code) ||
321
+ (len > 2 &&
322
+ isWindowsDeviceRoot(code) &&
323
+ path.charCodeAt(1) === CHAR_COLON &&
324
+ isPathSeparator(path.charCodeAt(2)));
325
+ },
326
+ join(...paths) {
327
+ if (paths.length === 0) {
328
+ return '.';
329
+ }
330
+ let joined;
331
+ let firstPart;
332
+ for (let i = 0; i < paths.length; ++i) {
333
+ const arg = paths[i];
334
+ validateString(arg, 'path');
335
+ if (arg.length > 0) {
336
+ if (joined === undefined) {
337
+ joined = firstPart = arg;
338
+ }
339
+ else {
340
+ joined += `\\${arg}`;
341
+ }
342
+ }
343
+ }
344
+ if (joined === undefined) {
345
+ return '.';
346
+ }
347
+ let needsReplace = true;
348
+ let slashCount = 0;
349
+ if (typeof firstPart === 'string' && isPathSeparator(firstPart.charCodeAt(0))) {
350
+ ++slashCount;
351
+ const firstLen = firstPart.length;
352
+ if (firstLen > 1 && isPathSeparator(firstPart.charCodeAt(1))) {
353
+ ++slashCount;
354
+ if (firstLen > 2) {
355
+ if (isPathSeparator(firstPart.charCodeAt(2))) {
356
+ ++slashCount;
357
+ }
358
+ else {
359
+ needsReplace = false;
360
+ }
361
+ }
362
+ }
363
+ }
364
+ if (needsReplace) {
365
+ while (slashCount < joined.length &&
366
+ isPathSeparator(joined.charCodeAt(slashCount))) {
367
+ slashCount++;
368
+ }
369
+ if (slashCount >= 2) {
370
+ joined = `\\${joined.slice(slashCount)}`;
371
+ }
372
+ }
373
+ return win32.normalize(joined);
374
+ },
375
+ relative(from, to) {
376
+ validateString(from, 'from');
377
+ validateString(to, 'to');
378
+ if (from === to) {
379
+ return '';
380
+ }
381
+ const fromOrig = win32.resolve(from);
382
+ const toOrig = win32.resolve(to);
383
+ if (fromOrig === toOrig) {
384
+ return '';
385
+ }
386
+ from = fromOrig.toLowerCase();
387
+ to = toOrig.toLowerCase();
388
+ if (from === to) {
389
+ return '';
390
+ }
391
+ let fromStart = 0;
392
+ while (fromStart < from.length &&
393
+ from.charCodeAt(fromStart) === CHAR_BACKWARD_SLASH) {
394
+ fromStart++;
395
+ }
396
+ let fromEnd = from.length;
397
+ while (fromEnd - 1 > fromStart &&
398
+ from.charCodeAt(fromEnd - 1) === CHAR_BACKWARD_SLASH) {
399
+ fromEnd--;
400
+ }
401
+ const fromLen = fromEnd - fromStart;
402
+ let toStart = 0;
403
+ while (toStart < to.length &&
404
+ to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
405
+ toStart++;
406
+ }
407
+ let toEnd = to.length;
408
+ while (toEnd - 1 > toStart &&
409
+ to.charCodeAt(toEnd - 1) === CHAR_BACKWARD_SLASH) {
410
+ toEnd--;
411
+ }
412
+ const toLen = toEnd - toStart;
413
+ const length = fromLen < toLen ? fromLen : toLen;
414
+ let lastCommonSep = -1;
415
+ let i = 0;
416
+ for (; i < length; i++) {
417
+ const fromCode = from.charCodeAt(fromStart + i);
418
+ if (fromCode !== to.charCodeAt(toStart + i)) {
419
+ break;
420
+ }
421
+ else if (fromCode === CHAR_BACKWARD_SLASH) {
422
+ lastCommonSep = i;
423
+ }
424
+ }
425
+ if (i !== length) {
426
+ if (lastCommonSep === -1) {
427
+ return toOrig;
428
+ }
429
+ }
430
+ else {
431
+ if (toLen > length) {
432
+ if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
433
+ return toOrig.slice(toStart + i + 1);
434
+ }
435
+ if (i === 2) {
436
+ return toOrig.slice(toStart + i);
437
+ }
438
+ }
439
+ if (fromLen > length) {
440
+ if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
441
+ lastCommonSep = i;
442
+ }
443
+ else if (i === 2) {
444
+ lastCommonSep = 3;
445
+ }
446
+ }
447
+ if (lastCommonSep === -1) {
448
+ lastCommonSep = 0;
449
+ }
450
+ }
451
+ let out = '';
452
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
453
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
454
+ out += out.length === 0 ? '..' : '\\..';
455
+ }
456
+ }
457
+ toStart += lastCommonSep;
458
+ if (out.length > 0) {
459
+ return `${out}${toOrig.slice(toStart, toEnd)}`;
460
+ }
461
+ if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
462
+ ++toStart;
463
+ }
464
+ return toOrig.slice(toStart, toEnd);
465
+ },
466
+ toNamespacedPath(path) {
467
+ if (typeof path !== 'string' || path.length === 0) {
468
+ return path;
469
+ }
470
+ const resolvedPath = win32.resolve(path);
471
+ if (resolvedPath.length <= 2) {
472
+ return path;
473
+ }
474
+ if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
475
+ if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
476
+ const code = resolvedPath.charCodeAt(2);
477
+ if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
478
+ return `\\\\?\\UNC\\${resolvedPath.slice(2)}`;
479
+ }
480
+ }
481
+ }
482
+ else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0)) &&
483
+ resolvedPath.charCodeAt(1) === CHAR_COLON &&
484
+ resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
485
+ return `\\\\?\\${resolvedPath}`;
486
+ }
487
+ return path;
488
+ },
489
+ dirname(path) {
490
+ validateString(path, 'path');
491
+ const len = path.length;
492
+ if (len === 0) {
493
+ return '.';
494
+ }
495
+ let rootEnd = -1;
496
+ let offset = 0;
497
+ const code = path.charCodeAt(0);
498
+ if (len === 1) {
499
+ return isPathSeparator(code) ? path : '.';
500
+ }
501
+ if (isPathSeparator(code)) {
502
+ rootEnd = offset = 1;
503
+ if (isPathSeparator(path.charCodeAt(1))) {
504
+ let j = 2;
505
+ let last = j;
506
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
507
+ j++;
508
+ }
509
+ if (j < len && j !== last) {
510
+ last = j;
511
+ while (j < len && isPathSeparator(path.charCodeAt(j))) {
512
+ j++;
513
+ }
514
+ if (j < len && j !== last) {
515
+ last = j;
516
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
517
+ j++;
518
+ }
519
+ if (j === len) {
520
+ return path;
521
+ }
522
+ if (j !== last) {
523
+ rootEnd = offset = j + 1;
524
+ }
525
+ }
526
+ }
527
+ }
528
+ }
529
+ else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
530
+ rootEnd = len > 2 && isPathSeparator(path.charCodeAt(2)) ? 3 : 2;
531
+ offset = rootEnd;
532
+ }
533
+ let end = -1;
534
+ let matchedSlash = true;
535
+ for (let i = len - 1; i >= offset; --i) {
536
+ if (isPathSeparator(path.charCodeAt(i))) {
537
+ if (!matchedSlash) {
538
+ end = i;
539
+ break;
540
+ }
541
+ }
542
+ else {
543
+ matchedSlash = false;
544
+ }
545
+ }
546
+ if (end === -1) {
547
+ if (rootEnd === -1) {
548
+ return '.';
549
+ }
550
+ end = rootEnd;
551
+ }
552
+ return path.slice(0, end);
553
+ },
554
+ basename(path, ext) {
555
+ if (ext !== undefined) {
556
+ validateString(ext, 'ext');
557
+ }
558
+ validateString(path, 'path');
559
+ let start = 0;
560
+ let end = -1;
561
+ let matchedSlash = true;
562
+ let i;
563
+ if (path.length >= 2 &&
564
+ isWindowsDeviceRoot(path.charCodeAt(0)) &&
565
+ path.charCodeAt(1) === CHAR_COLON) {
566
+ start = 2;
567
+ }
568
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
569
+ if (ext === path) {
570
+ return '';
571
+ }
572
+ let extIdx = ext.length - 1;
573
+ let firstNonSlashEnd = -1;
574
+ for (i = path.length - 1; i >= start; --i) {
575
+ const code = path.charCodeAt(i);
576
+ if (isPathSeparator(code)) {
577
+ if (!matchedSlash) {
578
+ start = i + 1;
579
+ break;
580
+ }
581
+ }
582
+ else {
583
+ if (firstNonSlashEnd === -1) {
584
+ matchedSlash = false;
585
+ firstNonSlashEnd = i + 1;
586
+ }
587
+ if (extIdx >= 0) {
588
+ if (code === ext.charCodeAt(extIdx)) {
589
+ if (--extIdx === -1) {
590
+ end = i;
591
+ }
592
+ }
593
+ else {
594
+ extIdx = -1;
595
+ end = firstNonSlashEnd;
596
+ }
597
+ }
598
+ }
599
+ }
600
+ if (start === end) {
601
+ end = firstNonSlashEnd;
602
+ }
603
+ else if (end === -1) {
604
+ end = path.length;
605
+ }
606
+ return path.slice(start, end);
607
+ }
608
+ for (i = path.length - 1; i >= start; --i) {
609
+ if (isPathSeparator(path.charCodeAt(i))) {
610
+ if (!matchedSlash) {
611
+ start = i + 1;
612
+ break;
613
+ }
614
+ }
615
+ else if (end === -1) {
616
+ matchedSlash = false;
617
+ end = i + 1;
618
+ }
619
+ }
620
+ if (end === -1) {
621
+ return '';
622
+ }
623
+ return path.slice(start, end);
624
+ },
625
+ extname(path) {
626
+ validateString(path, 'path');
627
+ let start = 0;
628
+ let startDot = -1;
629
+ let startPart = 0;
630
+ let end = -1;
631
+ let matchedSlash = true;
632
+ let preDotState = 0;
633
+ if (path.length >= 2 &&
634
+ path.charCodeAt(1) === CHAR_COLON &&
635
+ isWindowsDeviceRoot(path.charCodeAt(0))) {
636
+ start = startPart = 2;
637
+ }
638
+ for (let i = path.length - 1; i >= start; --i) {
639
+ const code = path.charCodeAt(i);
640
+ if (isPathSeparator(code)) {
641
+ if (!matchedSlash) {
642
+ startPart = i + 1;
643
+ break;
644
+ }
645
+ continue;
646
+ }
647
+ if (end === -1) {
648
+ matchedSlash = false;
649
+ end = i + 1;
650
+ }
651
+ if (code === CHAR_DOT) {
652
+ if (startDot === -1) {
653
+ startDot = i;
654
+ }
655
+ else if (preDotState !== 1) {
656
+ preDotState = 1;
657
+ }
658
+ }
659
+ else if (startDot !== -1) {
660
+ preDotState = -1;
661
+ }
662
+ }
663
+ if (startDot === -1 ||
664
+ end === -1 ||
665
+ preDotState === 0 ||
666
+ (preDotState === 1 &&
667
+ startDot === end - 1 &&
668
+ startDot === startPart + 1)) {
669
+ return '';
670
+ }
671
+ return path.slice(startDot, end);
672
+ },
673
+ format: _format.bind(null, '\\'),
674
+ parse(path) {
675
+ validateString(path, 'path');
676
+ const ret = { root: '', dir: '', base: '', ext: '', name: '' };
677
+ if (path.length === 0) {
678
+ return ret;
679
+ }
680
+ const len = path.length;
681
+ let rootEnd = 0;
682
+ let code = path.charCodeAt(0);
683
+ if (len === 1) {
684
+ if (isPathSeparator(code)) {
685
+ ret.root = ret.dir = path;
686
+ return ret;
687
+ }
688
+ ret.base = ret.name = path;
689
+ return ret;
690
+ }
691
+ if (isPathSeparator(code)) {
692
+ rootEnd = 1;
693
+ if (isPathSeparator(path.charCodeAt(1))) {
694
+ let j = 2;
695
+ let last = j;
696
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
697
+ j++;
698
+ }
699
+ if (j < len && j !== last) {
700
+ last = j;
701
+ while (j < len && isPathSeparator(path.charCodeAt(j))) {
702
+ j++;
703
+ }
704
+ if (j < len && j !== last) {
705
+ last = j;
706
+ while (j < len && !isPathSeparator(path.charCodeAt(j))) {
707
+ j++;
708
+ }
709
+ if (j === len) {
710
+ rootEnd = j;
711
+ }
712
+ else if (j !== last) {
713
+ rootEnd = j + 1;
714
+ }
715
+ }
716
+ }
717
+ }
718
+ }
719
+ else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
720
+ if (len <= 2) {
721
+ ret.root = ret.dir = path;
722
+ return ret;
723
+ }
724
+ rootEnd = 2;
725
+ if (isPathSeparator(path.charCodeAt(2))) {
726
+ if (len === 3) {
727
+ ret.root = ret.dir = path;
728
+ return ret;
729
+ }
730
+ rootEnd = 3;
731
+ }
732
+ }
733
+ if (rootEnd > 0) {
734
+ ret.root = path.slice(0, rootEnd);
735
+ }
736
+ let startDot = -1;
737
+ let startPart = rootEnd;
738
+ let end = -1;
739
+ let matchedSlash = true;
740
+ let i = path.length - 1;
741
+ let preDotState = 0;
742
+ for (; i >= rootEnd; --i) {
743
+ code = path.charCodeAt(i);
744
+ if (isPathSeparator(code)) {
745
+ if (!matchedSlash) {
746
+ startPart = i + 1;
747
+ break;
748
+ }
749
+ continue;
750
+ }
751
+ if (end === -1) {
752
+ matchedSlash = false;
753
+ end = i + 1;
754
+ }
755
+ if (code === CHAR_DOT) {
756
+ if (startDot === -1) {
757
+ startDot = i;
758
+ }
759
+ else if (preDotState !== 1) {
760
+ preDotState = 1;
761
+ }
762
+ }
763
+ else if (startDot !== -1) {
764
+ preDotState = -1;
765
+ }
766
+ }
767
+ if (end !== -1) {
768
+ if (startDot === -1 ||
769
+ preDotState === 0 ||
770
+ (preDotState === 1 &&
771
+ startDot === end - 1 &&
772
+ startDot === startPart + 1)) {
773
+ ret.base = ret.name = path.slice(startPart, end);
774
+ }
775
+ else {
776
+ ret.name = path.slice(startPart, startDot);
777
+ ret.base = path.slice(startPart, end);
778
+ ret.ext = path.slice(startDot, end);
779
+ }
780
+ }
781
+ if (startPart > 0 && startPart !== rootEnd) {
782
+ ret.dir = path.slice(0, startPart - 1);
783
+ }
784
+ else {
785
+ ret.dir = ret.root;
786
+ }
787
+ return ret;
788
+ },
789
+ sep: '\\',
790
+ delimiter: ';',
791
+ win32: null,
792
+ posix: null
793
+ };
794
+ const posixCwd = (() => {
795
+ if (platformIsWin32) {
796
+ const regexp = /\\/g;
797
+ return () => {
798
+ const cwd$1 = cwd().replace(regexp, '/');
799
+ return cwd$1.slice(cwd$1.indexOf('/'));
800
+ };
801
+ }
802
+ return () => cwd();
803
+ })();
804
+ const posix = {
805
+ resolve(...pathSegments) {
806
+ let resolvedPath = '';
807
+ let resolvedAbsolute = false;
808
+ for (let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
809
+ const path = i >= 0 ? pathSegments[i] : posixCwd();
810
+ validateString(path, 'path');
811
+ if (path.length === 0) {
812
+ continue;
813
+ }
814
+ resolvedPath = `${path}/${resolvedPath}`;
815
+ resolvedAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
816
+ }
817
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, '/', isPosixPathSeparator);
818
+ if (resolvedAbsolute) {
819
+ return `/${resolvedPath}`;
820
+ }
821
+ return resolvedPath.length > 0 ? resolvedPath : '.';
822
+ },
823
+ normalize(path) {
824
+ validateString(path, 'path');
825
+ if (path.length === 0) {
826
+ return '.';
827
+ }
828
+ const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
829
+ const trailingSeparator = path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH;
830
+ path = normalizeString(path, !isAbsolute, '/', isPosixPathSeparator);
831
+ if (path.length === 0) {
832
+ if (isAbsolute) {
833
+ return '/';
834
+ }
835
+ return trailingSeparator ? './' : '.';
836
+ }
837
+ if (trailingSeparator) {
838
+ path += '/';
839
+ }
840
+ return isAbsolute ? `/${path}` : path;
841
+ },
842
+ isAbsolute(path) {
843
+ validateString(path, 'path');
844
+ return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH;
845
+ },
846
+ join(...paths) {
847
+ if (paths.length === 0) {
848
+ return '.';
849
+ }
850
+ let joined;
851
+ for (let i = 0; i < paths.length; ++i) {
852
+ const arg = paths[i];
853
+ validateString(arg, 'path');
854
+ if (arg.length > 0) {
855
+ if (joined === undefined) {
856
+ joined = arg;
857
+ }
858
+ else {
859
+ joined += `/${arg}`;
860
+ }
861
+ }
862
+ }
863
+ if (joined === undefined) {
864
+ return '.';
865
+ }
866
+ return posix.normalize(joined);
867
+ },
868
+ relative(from, to) {
869
+ validateString(from, 'from');
870
+ validateString(to, 'to');
871
+ if (from === to) {
872
+ return '';
873
+ }
874
+ from = posix.resolve(from);
875
+ to = posix.resolve(to);
876
+ if (from === to) {
877
+ return '';
878
+ }
879
+ const fromStart = 1;
880
+ const fromEnd = from.length;
881
+ const fromLen = fromEnd - fromStart;
882
+ const toStart = 1;
883
+ const toLen = to.length - toStart;
884
+ const length = (fromLen < toLen ? fromLen : toLen);
885
+ let lastCommonSep = -1;
886
+ let i = 0;
887
+ for (; i < length; i++) {
888
+ const fromCode = from.charCodeAt(fromStart + i);
889
+ if (fromCode !== to.charCodeAt(toStart + i)) {
890
+ break;
891
+ }
892
+ else if (fromCode === CHAR_FORWARD_SLASH) {
893
+ lastCommonSep = i;
894
+ }
895
+ }
896
+ if (i === length) {
897
+ if (toLen > length) {
898
+ if (to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH) {
899
+ return to.slice(toStart + i + 1);
900
+ }
901
+ if (i === 0) {
902
+ return to.slice(toStart + i);
903
+ }
904
+ }
905
+ else if (fromLen > length) {
906
+ if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
907
+ lastCommonSep = i;
908
+ }
909
+ else if (i === 0) {
910
+ lastCommonSep = 0;
911
+ }
912
+ }
913
+ }
914
+ let out = '';
915
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
916
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
917
+ out += out.length === 0 ? '..' : '/..';
918
+ }
919
+ }
920
+ return `${out}${to.slice(toStart + lastCommonSep)}`;
921
+ },
922
+ toNamespacedPath(path) {
923
+ return path;
924
+ },
925
+ dirname(path) {
926
+ validateString(path, 'path');
927
+ if (path.length === 0) {
928
+ return '.';
929
+ }
930
+ const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
931
+ let end = -1;
932
+ let matchedSlash = true;
933
+ for (let i = path.length - 1; i >= 1; --i) {
934
+ if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
935
+ if (!matchedSlash) {
936
+ end = i;
937
+ break;
938
+ }
939
+ }
940
+ else {
941
+ matchedSlash = false;
942
+ }
943
+ }
944
+ if (end === -1) {
945
+ return hasRoot ? '/' : '.';
946
+ }
947
+ if (hasRoot && end === 1) {
948
+ return '//';
949
+ }
950
+ return path.slice(0, end);
951
+ },
952
+ basename(path, ext) {
953
+ if (ext !== undefined) {
954
+ validateString(ext, 'ext');
955
+ }
956
+ validateString(path, 'path');
957
+ let start = 0;
958
+ let end = -1;
959
+ let matchedSlash = true;
960
+ let i;
961
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
962
+ if (ext === path) {
963
+ return '';
964
+ }
965
+ let extIdx = ext.length - 1;
966
+ let firstNonSlashEnd = -1;
967
+ for (i = path.length - 1; i >= 0; --i) {
968
+ const code = path.charCodeAt(i);
969
+ if (code === CHAR_FORWARD_SLASH) {
970
+ if (!matchedSlash) {
971
+ start = i + 1;
972
+ break;
973
+ }
974
+ }
975
+ else {
976
+ if (firstNonSlashEnd === -1) {
977
+ matchedSlash = false;
978
+ firstNonSlashEnd = i + 1;
979
+ }
980
+ if (extIdx >= 0) {
981
+ if (code === ext.charCodeAt(extIdx)) {
982
+ if (--extIdx === -1) {
983
+ end = i;
984
+ }
985
+ }
986
+ else {
987
+ extIdx = -1;
988
+ end = firstNonSlashEnd;
989
+ }
990
+ }
991
+ }
992
+ }
993
+ if (start === end) {
994
+ end = firstNonSlashEnd;
995
+ }
996
+ else if (end === -1) {
997
+ end = path.length;
998
+ }
999
+ return path.slice(start, end);
1000
+ }
1001
+ for (i = path.length - 1; i >= 0; --i) {
1002
+ if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
1003
+ if (!matchedSlash) {
1004
+ start = i + 1;
1005
+ break;
1006
+ }
1007
+ }
1008
+ else if (end === -1) {
1009
+ matchedSlash = false;
1010
+ end = i + 1;
1011
+ }
1012
+ }
1013
+ if (end === -1) {
1014
+ return '';
1015
+ }
1016
+ return path.slice(start, end);
1017
+ },
1018
+ extname(path) {
1019
+ validateString(path, 'path');
1020
+ let startDot = -1;
1021
+ let startPart = 0;
1022
+ let end = -1;
1023
+ let matchedSlash = true;
1024
+ let preDotState = 0;
1025
+ for (let i = path.length - 1; i >= 0; --i) {
1026
+ const code = path.charCodeAt(i);
1027
+ if (code === CHAR_FORWARD_SLASH) {
1028
+ if (!matchedSlash) {
1029
+ startPart = i + 1;
1030
+ break;
1031
+ }
1032
+ continue;
1033
+ }
1034
+ if (end === -1) {
1035
+ matchedSlash = false;
1036
+ end = i + 1;
1037
+ }
1038
+ if (code === CHAR_DOT) {
1039
+ if (startDot === -1) {
1040
+ startDot = i;
1041
+ }
1042
+ else if (preDotState !== 1) {
1043
+ preDotState = 1;
1044
+ }
1045
+ }
1046
+ else if (startDot !== -1) {
1047
+ preDotState = -1;
1048
+ }
1049
+ }
1050
+ if (startDot === -1 ||
1051
+ end === -1 ||
1052
+ preDotState === 0 ||
1053
+ (preDotState === 1 &&
1054
+ startDot === end - 1 &&
1055
+ startDot === startPart + 1)) {
1056
+ return '';
1057
+ }
1058
+ return path.slice(startDot, end);
1059
+ },
1060
+ format: _format.bind(null, '/'),
1061
+ parse(path) {
1062
+ validateString(path, 'path');
1063
+ const ret = { root: '', dir: '', base: '', ext: '', name: '' };
1064
+ if (path.length === 0) {
1065
+ return ret;
1066
+ }
1067
+ const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
1068
+ let start;
1069
+ if (isAbsolute) {
1070
+ ret.root = '/';
1071
+ start = 1;
1072
+ }
1073
+ else {
1074
+ start = 0;
1075
+ }
1076
+ let startDot = -1;
1077
+ let startPart = 0;
1078
+ let end = -1;
1079
+ let matchedSlash = true;
1080
+ let i = path.length - 1;
1081
+ let preDotState = 0;
1082
+ for (; i >= start; --i) {
1083
+ const code = path.charCodeAt(i);
1084
+ if (code === CHAR_FORWARD_SLASH) {
1085
+ if (!matchedSlash) {
1086
+ startPart = i + 1;
1087
+ break;
1088
+ }
1089
+ continue;
1090
+ }
1091
+ if (end === -1) {
1092
+ matchedSlash = false;
1093
+ end = i + 1;
1094
+ }
1095
+ if (code === CHAR_DOT) {
1096
+ if (startDot === -1) {
1097
+ startDot = i;
1098
+ }
1099
+ else if (preDotState !== 1) {
1100
+ preDotState = 1;
1101
+ }
1102
+ }
1103
+ else if (startDot !== -1) {
1104
+ preDotState = -1;
1105
+ }
1106
+ }
1107
+ if (end !== -1) {
1108
+ const start = startPart === 0 && isAbsolute ? 1 : startPart;
1109
+ if (startDot === -1 ||
1110
+ preDotState === 0 ||
1111
+ (preDotState === 1 &&
1112
+ startDot === end - 1 &&
1113
+ startDot === startPart + 1)) {
1114
+ ret.base = ret.name = path.slice(start, end);
1115
+ }
1116
+ else {
1117
+ ret.name = path.slice(start, startDot);
1118
+ ret.base = path.slice(start, end);
1119
+ ret.ext = path.slice(startDot, end);
1120
+ }
1121
+ }
1122
+ if (startPart > 0) {
1123
+ ret.dir = path.slice(0, startPart - 1);
1124
+ }
1125
+ else if (isAbsolute) {
1126
+ ret.dir = '/';
1127
+ }
1128
+ return ret;
1129
+ },
1130
+ sep: '/',
1131
+ delimiter: ':',
1132
+ win32: null,
1133
+ posix: null
1134
+ };
1135
+ posix.win32 = win32.win32 = win32;
1136
+ posix.posix = win32.posix = posix;
1137
+ const isAbsolute = (platformIsWin32 ? win32.isAbsolute : posix.isAbsolute);
1138
+ const join = (platformIsWin32 ? win32.join : posix.join);
1139
+ const _formatPIIRegexp = /{([^}]+)}/g;
1140
+ function formatPII(value, excludePII, args) {
1141
+ return value.replace(_formatPIIRegexp, function (match, group) {
1142
+ if (excludePII && group.length > 0 && group[0] !== '_') {
1143
+ return match;
1144
+ }
1145
+ return args && args.hasOwnProperty(group) ?
1146
+ args[group] :
1147
+ match;
1148
+ });
1149
+ }
1150
+ function filterExceptionsFromTelemetry(data) {
1151
+ const output = {};
1152
+ for (const key of ( (Object.keys(data)))) {
1153
+ if (!key.startsWith('!')) {
1154
+ output[key] = data[key];
1155
+ }
1156
+ }
1157
+ return output;
1158
+ }
1159
+ function isSessionAttach(session) {
1160
+ return session.configuration.request === 'attach' && !getExtensionHostDebugSession(session) && (!session.parentSession || isSessionAttach(session.parentSession));
1161
+ }
1162
+ function getExtensionHostDebugSession(session) {
1163
+ let type = session.configuration.type;
1164
+ if (!type) {
1165
+ return;
1166
+ }
1167
+ if (type === 'vslsShare') {
1168
+ type = session.configuration.adapterProxy.configuration.type;
1169
+ }
1170
+ if (equalsIgnoreCase(type, 'extensionhost') || equalsIgnoreCase(type, 'pwa-extensionhost')) {
1171
+ return session;
1172
+ }
1173
+ return session.parentSession ? getExtensionHostDebugSession(session.parentSession) : undefined;
1174
+ }
1175
+ function isDebuggerMainContribution(dbg) {
1176
+ return dbg.type && (dbg.label || dbg.program || dbg.runtime);
1177
+ }
1178
+ function getExactExpressionStartAndEnd(lineContent, looseStart, looseEnd) {
1179
+ let matchingExpression = undefined;
1180
+ let startOffset = 0;
1181
+ const expression = /([^()\[\]{}<>\s+\-/%~#^;=|,`!]|\->)+/g;
1182
+ let result = null;
1183
+ while (result = expression.exec(lineContent)) {
1184
+ const start = result.index + 1;
1185
+ const end = start + result[0].length;
1186
+ if (start <= looseStart && end >= looseEnd) {
1187
+ matchingExpression = result[0];
1188
+ startOffset = start;
1189
+ break;
1190
+ }
1191
+ }
1192
+ if (matchingExpression) {
1193
+ const subExpression = /\w+/g;
1194
+ let subExpressionResult = null;
1195
+ while (subExpressionResult = subExpression.exec(matchingExpression)) {
1196
+ const subEnd = subExpressionResult.index + 1 + startOffset + subExpressionResult[0].length;
1197
+ if (subEnd >= looseEnd) {
1198
+ break;
1199
+ }
1200
+ }
1201
+ if (subExpressionResult) {
1202
+ matchingExpression = matchingExpression.substring(0, subExpression.lastIndex);
1203
+ }
1204
+ }
1205
+ return matchingExpression ?
1206
+ { start: startOffset, end: startOffset + matchingExpression.length - 1 } :
1207
+ { start: 0, end: 0 };
1208
+ }
1209
+ async function getEvaluatableExpressionAtPosition(languageFeaturesService, model, position, token) {
1210
+ if (languageFeaturesService.evaluatableExpressionProvider.has(model)) {
1211
+ const supports = languageFeaturesService.evaluatableExpressionProvider.ordered(model);
1212
+ const results = coalesce(await Promise.all(( (supports.map(async (support) => {
1213
+ try {
1214
+ return await support.provideEvaluatableExpression(model, position, token ?? CancellationToken.None);
1215
+ }
1216
+ catch (err) {
1217
+ return undefined;
1218
+ }
1219
+ })))));
1220
+ if (results.length > 0) {
1221
+ let matchingExpression = results[0].expression;
1222
+ const range = results[0].range;
1223
+ if (!matchingExpression) {
1224
+ const lineContent = model.getLineContent(position.lineNumber);
1225
+ matchingExpression = lineContent.substring(range.startColumn - 1, range.endColumn - 1);
1226
+ }
1227
+ return { range, matchingExpression };
1228
+ }
1229
+ }
1230
+ else {
1231
+ const lineContent = model.getLineContent(position.lineNumber);
1232
+ const { start, end } = getExactExpressionStartAndEnd(lineContent, position.column, position.column);
1233
+ const matchingExpression = lineContent.substring(start - 1, end);
1234
+ return {
1235
+ matchingExpression,
1236
+ range: ( (new Range(
1237
+ position.lineNumber,
1238
+ start,
1239
+ position.lineNumber,
1240
+ start + matchingExpression.length
1241
+ )))
1242
+ };
1243
+ }
1244
+ return null;
1245
+ }
1246
+ const _schemePattern = /^[a-zA-Z][a-zA-Z0-9\+\-\.]+:/;
1247
+ function isUri(s) {
1248
+ return !!(s && s.match(_schemePattern));
1249
+ }
1250
+ function stringToUri(source) {
1251
+ if (typeof source.path === 'string') {
1252
+ if (typeof source.sourceReference === 'number' && source.sourceReference > 0) ;
1253
+ else {
1254
+ if (isUri(source.path)) {
1255
+ return ( URI.parse(source.path));
1256
+ }
1257
+ else {
1258
+ if (isAbsolute(source.path)) {
1259
+ return URI.file(source.path);
1260
+ }
1261
+ }
1262
+ }
1263
+ }
1264
+ return source.path;
1265
+ }
1266
+ function uriToString(source) {
1267
+ if (typeof source.path === 'object') {
1268
+ const u = URI.revive(source.path);
1269
+ if (u) {
1270
+ if (u.scheme === Schemas.file) {
1271
+ return u.fsPath;
1272
+ }
1273
+ else {
1274
+ return (
1275
+ (u.toString())
1276
+ );
1277
+ }
1278
+ }
1279
+ }
1280
+ return source.path;
1281
+ }
1282
+ function convertToDAPaths(message, toUri) {
1283
+ const fixPath = toUri ? stringToUri : uriToString;
1284
+ const msg = deepClone(message);
1285
+ convertPaths(msg, (toDA, source) => {
1286
+ if (toDA && source) {
1287
+ source.path = fixPath(source);
1288
+ }
1289
+ });
1290
+ return msg;
1291
+ }
1292
+ function convertToVSCPaths(message, toUri) {
1293
+ const fixPath = toUri ? stringToUri : uriToString;
1294
+ const msg = deepClone(message);
1295
+ convertPaths(msg, (toDA, source) => {
1296
+ if (!toDA && source) {
1297
+ source.path = fixPath(source);
1298
+ }
1299
+ });
1300
+ return msg;
1301
+ }
1302
+ function convertPaths(msg, fixSourcePath) {
1303
+ switch (msg.type) {
1304
+ case 'event': {
1305
+ const event = msg;
1306
+ switch (event.event) {
1307
+ case 'output':
1308
+ fixSourcePath(false, event.body.source);
1309
+ break;
1310
+ case 'loadedSource':
1311
+ fixSourcePath(false, event.body.source);
1312
+ break;
1313
+ case 'breakpoint':
1314
+ fixSourcePath(false, event.body.breakpoint.source);
1315
+ break;
1316
+ }
1317
+ break;
1318
+ }
1319
+ case 'request': {
1320
+ const request = msg;
1321
+ switch (request.command) {
1322
+ case 'setBreakpoints':
1323
+ fixSourcePath(true, request.arguments.source);
1324
+ break;
1325
+ case 'breakpointLocations':
1326
+ fixSourcePath(true, request.arguments.source);
1327
+ break;
1328
+ case 'source':
1329
+ fixSourcePath(true, request.arguments.source);
1330
+ break;
1331
+ case 'gotoTargets':
1332
+ fixSourcePath(true, request.arguments.source);
1333
+ break;
1334
+ case 'launchVSCode':
1335
+ request.arguments.args.forEach((arg) => fixSourcePath(false, arg));
1336
+ break;
1337
+ }
1338
+ break;
1339
+ }
1340
+ case 'response': {
1341
+ const response = msg;
1342
+ if (response.success && response.body) {
1343
+ switch (response.command) {
1344
+ case 'stackTrace':
1345
+ response.body.stackFrames.forEach(frame => fixSourcePath(false, frame.source));
1346
+ break;
1347
+ case 'loadedSources':
1348
+ response.body.sources.forEach(source => fixSourcePath(false, source));
1349
+ break;
1350
+ case 'scopes':
1351
+ response.body.scopes.forEach(scope => fixSourcePath(false, scope.source));
1352
+ break;
1353
+ case 'setFunctionBreakpoints':
1354
+ response.body.breakpoints.forEach(bp => fixSourcePath(false, bp.source));
1355
+ break;
1356
+ case 'setBreakpoints':
1357
+ response.body.breakpoints.forEach(bp => fixSourcePath(false, bp.source));
1358
+ break;
1359
+ case 'disassemble':
1360
+ {
1361
+ const di = response;
1362
+ di.body?.instructions.forEach(di => fixSourcePath(false, di.location));
1363
+ }
1364
+ break;
1365
+ }
1366
+ }
1367
+ break;
1368
+ }
1369
+ }
1370
+ }
1371
+ function getVisibleAndSorted(array) {
1372
+ return array.filter(config => !config.presentation?.hidden).sort((first, second) => {
1373
+ if (!first.presentation) {
1374
+ if (!second.presentation) {
1375
+ return 0;
1376
+ }
1377
+ return 1;
1378
+ }
1379
+ if (!second.presentation) {
1380
+ return -1;
1381
+ }
1382
+ if (!first.presentation.group) {
1383
+ if (!second.presentation.group) {
1384
+ return compareOrders(first.presentation.order, second.presentation.order);
1385
+ }
1386
+ return 1;
1387
+ }
1388
+ if (!second.presentation.group) {
1389
+ return -1;
1390
+ }
1391
+ if (first.presentation.group !== second.presentation.group) {
1392
+ return first.presentation.group.localeCompare(second.presentation.group);
1393
+ }
1394
+ return compareOrders(first.presentation.order, second.presentation.order);
1395
+ });
1396
+ }
1397
+ function compareOrders(first, second) {
1398
+ if (typeof first !== 'number') {
1399
+ if (typeof second !== 'number') {
1400
+ return 0;
1401
+ }
1402
+ return 1;
1403
+ }
1404
+ if (typeof second !== 'number') {
1405
+ return -1;
1406
+ }
1407
+ return first - second;
1408
+ }
1409
+ async function saveAllBeforeDebugStart(configurationService, editorService) {
1410
+ const saveBeforeStartConfig = configurationService.getValue('debug.saveBeforeStart', { overrideIdentifier: editorService.activeTextEditorLanguageId });
1411
+ if (saveBeforeStartConfig !== 'none') {
1412
+ await editorService.saveAll();
1413
+ if (saveBeforeStartConfig === 'allEditorsInActiveGroup') {
1414
+ const activeEditor = editorService.activeEditorPane;
1415
+ if (activeEditor && activeEditor.input.resource?.scheme === Schemas.untitled) {
1416
+ await editorService.save({ editor: activeEditor.input, groupId: activeEditor.group.id });
1417
+ }
1418
+ }
1419
+ }
1420
+ await configurationService.reloadConfiguration();
1421
+ }
1422
+ class AbstractVariableResolverService {
1423
+ constructor(_context, _labelService, _userHomePromise, _envVariablesPromise) {
1424
+ this._contributedVariables = ( (new Map()));
1425
+ this._context = _context;
1426
+ this._labelService = _labelService;
1427
+ this._userHomePromise = _userHomePromise;
1428
+ if (_envVariablesPromise) {
1429
+ this._envVariablesPromise = _envVariablesPromise.then(envVariables => {
1430
+ return this.prepareEnv(envVariables);
1431
+ });
1432
+ }
1433
+ }
1434
+ prepareEnv(envVariables) {
1435
+ if (isWindows) {
1436
+ const ev = Object.create(null);
1437
+ ( (Object.keys(envVariables))).forEach(key => {
1438
+ ev[key.toLowerCase()] = envVariables[key];
1439
+ });
1440
+ return ev;
1441
+ }
1442
+ return envVariables;
1443
+ }
1444
+ resolveWithEnvironment(environment, root, value) {
1445
+ return this.recursiveResolve({ env: this.prepareEnv(environment), userHome: undefined }, root ? root.uri : undefined, value);
1446
+ }
1447
+ async resolveAsync(root, value) {
1448
+ const environment = {
1449
+ env: await this._envVariablesPromise,
1450
+ userHome: await this._userHomePromise
1451
+ };
1452
+ return this.recursiveResolve(environment, root ? root.uri : undefined, value);
1453
+ }
1454
+ async resolveAnyBase(workspaceFolder, config, commandValueMapping, resolvedVariables) {
1455
+ const result = deepClone(config);
1456
+ if (isWindows && result.windows) {
1457
+ ( (Object.keys(result.windows))).forEach(key => result[key] = result.windows[key]);
1458
+ }
1459
+ else if (isMacintosh && result.osx) {
1460
+ ( (Object.keys(result.osx))).forEach(key => result[key] = result.osx[key]);
1461
+ }
1462
+ else if (isLinux && result.linux) {
1463
+ ( (Object.keys(result.linux))).forEach(key => result[key] = result.linux[key]);
1464
+ }
1465
+ delete result.windows;
1466
+ delete result.osx;
1467
+ delete result.linux;
1468
+ const environmentPromises = {
1469
+ env: await this._envVariablesPromise,
1470
+ userHome: await this._userHomePromise
1471
+ };
1472
+ return this.recursiveResolve(environmentPromises, workspaceFolder ? workspaceFolder.uri : undefined, result, commandValueMapping, resolvedVariables);
1473
+ }
1474
+ async resolveAnyAsync(workspaceFolder, config, commandValueMapping) {
1475
+ return this.resolveAnyBase(workspaceFolder, config, commandValueMapping);
1476
+ }
1477
+ async resolveAnyMap(workspaceFolder, config, commandValueMapping) {
1478
+ const resolvedVariables = ( (new Map()));
1479
+ const newConfig = await this.resolveAnyBase(workspaceFolder, config, commandValueMapping, resolvedVariables);
1480
+ return { newConfig, resolvedVariables };
1481
+ }
1482
+ resolveWithInteractionReplace(folder, config, section, variables) {
1483
+ throw new Error('resolveWithInteractionReplace not implemented.');
1484
+ }
1485
+ resolveWithInteraction(folder, config, section, variables) {
1486
+ throw new Error('resolveWithInteraction not implemented.');
1487
+ }
1488
+ contributeVariable(variable, resolution) {
1489
+ if (this._contributedVariables.has(variable)) {
1490
+ throw new Error('Variable ' + variable + ' is contributed twice.');
1491
+ }
1492
+ else {
1493
+ this._contributedVariables.set(variable, resolution);
1494
+ }
1495
+ }
1496
+ async recursiveResolve(environment, folderUri, value, commandValueMapping, resolvedVariables) {
1497
+ if (isString(value)) {
1498
+ return this.resolveString(environment, folderUri, value, commandValueMapping, resolvedVariables);
1499
+ }
1500
+ else if (Array.isArray(value)) {
1501
+ return Promise.all(( (value.map(
1502
+ s => this.recursiveResolve(environment, folderUri, s, commandValueMapping, resolvedVariables)
1503
+ ))));
1504
+ }
1505
+ else if (isObject(value)) {
1506
+ const result = Object.create(null);
1507
+ const replaced = await Promise.all(( (( (Object.keys(value))).map(async (key) => {
1508
+ const replaced = await this.resolveString(environment, folderUri, key, commandValueMapping, resolvedVariables);
1509
+ return [replaced, await this.recursiveResolve(environment, folderUri, value[key], commandValueMapping, resolvedVariables)];
1510
+ }))));
1511
+ for (const [key, value] of replaced) {
1512
+ result[key] = value;
1513
+ }
1514
+ return result;
1515
+ }
1516
+ return value;
1517
+ }
1518
+ resolveString(environment, folderUri, value, commandValueMapping, resolvedVariables) {
1519
+ return replaceAsync(value, AbstractVariableResolverService.VARIABLE_REGEXP, async (match, variable) => {
1520
+ if (variable.includes(AbstractVariableResolverService.VARIABLE_LHS)) {
1521
+ return match;
1522
+ }
1523
+ let resolvedValue = await this.evaluateSingleVariable(environment, match, variable, folderUri, commandValueMapping);
1524
+ resolvedVariables?.set(variable, resolvedValue);
1525
+ if ((resolvedValue !== match) && isString(resolvedValue) && resolvedValue.match(AbstractVariableResolverService.VARIABLE_REGEXP)) {
1526
+ resolvedValue = await this.resolveString(environment, folderUri, resolvedValue, commandValueMapping, resolvedVariables);
1527
+ }
1528
+ return resolvedValue;
1529
+ });
1530
+ }
1531
+ fsPath(displayUri) {
1532
+ return this._labelService ? this._labelService.getUriLabel(displayUri, { noPrefix: true }) : displayUri.fsPath;
1533
+ }
1534
+ async evaluateSingleVariable(environment, match, variable, folderUri, commandValueMapping) {
1535
+ let argument;
1536
+ const parts = variable.split(':');
1537
+ if (parts.length > 1) {
1538
+ variable = parts[0];
1539
+ argument = parts[1];
1540
+ }
1541
+ const getFilePath = (variableKind) => {
1542
+ const filePath = this._context.getFilePath();
1543
+ if (filePath) {
1544
+ return normalizeDriveLetter(filePath);
1545
+ }
1546
+ throw new VariableError(variableKind, (localize('canNotResolveFile', "Variable {0} can not be resolved. Please open an editor.", match)));
1547
+ };
1548
+ const getFolderPathForFile = (variableKind) => {
1549
+ const filePath = getFilePath(variableKind);
1550
+ if (this._context.getWorkspaceFolderPathForFile) {
1551
+ const folderPath = this._context.getWorkspaceFolderPathForFile();
1552
+ if (folderPath) {
1553
+ return normalizeDriveLetter(folderPath);
1554
+ }
1555
+ }
1556
+ throw new VariableError(variableKind, localize('canNotResolveFolderForFile', "Variable {0}: can not find workspace folder of '{1}'.", match, basename(filePath)));
1557
+ };
1558
+ const getFolderUri = (variableKind) => {
1559
+ if (argument) {
1560
+ const folder = this._context.getFolderUri(argument);
1561
+ if (folder) {
1562
+ return folder;
1563
+ }
1564
+ throw new VariableError(variableKind, localize('canNotFindFolder', "Variable {0} can not be resolved. No such folder '{1}'.", match, argument));
1565
+ }
1566
+ if (folderUri) {
1567
+ return folderUri;
1568
+ }
1569
+ if (this._context.getWorkspaceFolderCount() > 1) {
1570
+ throw new VariableError(variableKind, localize('canNotResolveWorkspaceFolderMultiRoot', "Variable {0} can not be resolved in a multi folder workspace. Scope this variable using ':' and a workspace folder name.", match));
1571
+ }
1572
+ throw new VariableError(variableKind, localize('canNotResolveWorkspaceFolder', "Variable {0} can not be resolved. Please open a folder.", match));
1573
+ };
1574
+ switch (variable) {
1575
+ case 'env':
1576
+ if (argument) {
1577
+ if (environment.env) {
1578
+ const env = environment.env[isWindows ? argument.toLowerCase() : argument];
1579
+ if (isString(env)) {
1580
+ return env;
1581
+ }
1582
+ }
1583
+ return '';
1584
+ }
1585
+ throw new VariableError(VariableKind.Env, localize('missingEnvVarName', "Variable {0} can not be resolved because no environment variable name is given.", match));
1586
+ case 'config':
1587
+ if (argument) {
1588
+ const config = this._context.getConfigurationValue(folderUri, argument);
1589
+ if (isUndefinedOrNull(config)) {
1590
+ throw new VariableError(VariableKind.Config, localize('configNotFound', "Variable {0} can not be resolved because setting '{1}' not found.", match, argument));
1591
+ }
1592
+ if (isObject(config)) {
1593
+ throw new VariableError(VariableKind.Config, localize('configNoString', "Variable {0} can not be resolved because '{1}' is a structured value.", match, argument));
1594
+ }
1595
+ return config;
1596
+ }
1597
+ throw new VariableError(VariableKind.Config, localize('missingConfigName', "Variable {0} can not be resolved because no settings name is given.", match));
1598
+ case 'command':
1599
+ return this.resolveFromMap(VariableKind.Command, match, argument, commandValueMapping, 'command');
1600
+ case 'input':
1601
+ return this.resolveFromMap(VariableKind.Input, match, argument, commandValueMapping, 'input');
1602
+ case 'extensionInstallFolder':
1603
+ if (argument) {
1604
+ const ext = await this._context.getExtension(argument);
1605
+ if (!ext) {
1606
+ throw new VariableError(VariableKind.ExtensionInstallFolder, localize('extensionNotInstalled', "Variable {0} can not be resolved because the extension {1} is not installed.", match, argument));
1607
+ }
1608
+ return this.fsPath(ext.extensionLocation);
1609
+ }
1610
+ throw new VariableError(VariableKind.ExtensionInstallFolder, localize('missingExtensionName', "Variable {0} can not be resolved because no extension name is given.", match));
1611
+ default: {
1612
+ switch (variable) {
1613
+ case 'workspaceRoot':
1614
+ case 'workspaceFolder':
1615
+ return normalizeDriveLetter(this.fsPath(getFolderUri(VariableKind.WorkspaceFolder)));
1616
+ case 'cwd':
1617
+ return ((folderUri || argument) ? normalizeDriveLetter(this.fsPath(getFolderUri(VariableKind.Cwd))) : cwd());
1618
+ case 'workspaceRootFolderName':
1619
+ case 'workspaceFolderBasename':
1620
+ return normalizeDriveLetter(basename(this.fsPath(getFolderUri(VariableKind.WorkspaceFolderBasename))));
1621
+ case 'userHome': {
1622
+ if (environment.userHome) {
1623
+ return environment.userHome;
1624
+ }
1625
+ throw new VariableError(VariableKind.UserHome, localize('canNotResolveUserHome', "Variable {0} can not be resolved. UserHome path is not defined", match));
1626
+ }
1627
+ case 'lineNumber': {
1628
+ const lineNumber = this._context.getLineNumber();
1629
+ if (lineNumber) {
1630
+ return lineNumber;
1631
+ }
1632
+ throw new VariableError(VariableKind.LineNumber, localize('canNotResolveLineNumber', "Variable {0} can not be resolved. Make sure to have a line selected in the active editor.", match));
1633
+ }
1634
+ case 'selectedText': {
1635
+ const selectedText = this._context.getSelectedText();
1636
+ if (selectedText) {
1637
+ return selectedText;
1638
+ }
1639
+ throw new VariableError(VariableKind.SelectedText, localize('canNotResolveSelectedText', "Variable {0} can not be resolved. Make sure to have some text selected in the active editor.", match));
1640
+ }
1641
+ case 'file':
1642
+ return getFilePath(VariableKind.File);
1643
+ case 'fileWorkspaceFolder':
1644
+ return getFolderPathForFile(VariableKind.FileWorkspaceFolder);
1645
+ case 'relativeFile':
1646
+ if (folderUri || argument) {
1647
+ return relative(this.fsPath(getFolderUri(VariableKind.RelativeFile)), getFilePath(VariableKind.RelativeFile));
1648
+ }
1649
+ return getFilePath(VariableKind.RelativeFile);
1650
+ case 'relativeFileDirname': {
1651
+ const dirname$1 = dirname(getFilePath(VariableKind.RelativeFileDirname));
1652
+ if (folderUri || argument) {
1653
+ const relative$1 = relative(this.fsPath(getFolderUri(VariableKind.RelativeFileDirname)), dirname$1);
1654
+ return relative$1.length === 0 ? '.' : relative$1;
1655
+ }
1656
+ return dirname$1;
1657
+ }
1658
+ case 'fileDirname':
1659
+ return dirname(getFilePath(VariableKind.FileDirname));
1660
+ case 'fileExtname':
1661
+ return extname(getFilePath(VariableKind.FileExtname));
1662
+ case 'fileBasename':
1663
+ return basename(getFilePath(VariableKind.FileBasename));
1664
+ case 'fileBasenameNoExtension': {
1665
+ const basename$1 = basename(getFilePath(VariableKind.FileBasenameNoExtension));
1666
+ return (basename$1.slice(0, basename$1.length - extname(basename$1).length));
1667
+ }
1668
+ case 'fileDirnameBasename':
1669
+ return basename(dirname(getFilePath(VariableKind.FileDirnameBasename)));
1670
+ case 'execPath': {
1671
+ const ep = this._context.getExecPath();
1672
+ if (ep) {
1673
+ return ep;
1674
+ }
1675
+ return match;
1676
+ }
1677
+ case 'execInstallFolder': {
1678
+ const ar = this._context.getAppRoot();
1679
+ if (ar) {
1680
+ return ar;
1681
+ }
1682
+ return match;
1683
+ }
1684
+ case 'pathSeparator':
1685
+ return sep;
1686
+ default:
1687
+ try {
1688
+ const key = argument ? `${variable}:${argument}` : variable;
1689
+ return this.resolveFromMap(VariableKind.Unknown, match, key, commandValueMapping, undefined);
1690
+ }
1691
+ catch (error) {
1692
+ return match;
1693
+ }
1694
+ }
1695
+ }
1696
+ }
1697
+ }
1698
+ resolveFromMap(variableKind, match, argument, commandValueMapping, prefix) {
1699
+ if (argument && commandValueMapping) {
1700
+ const v = (prefix === undefined) ? commandValueMapping[argument] : commandValueMapping[prefix + ':' + argument];
1701
+ if (typeof v === 'string') {
1702
+ return v;
1703
+ }
1704
+ throw new VariableError(variableKind, localize('noValueForCommand', "Variable {0} can not be resolved because the command has no value.", match));
1705
+ }
1706
+ return match;
1707
+ }
1708
+ }
1709
+ AbstractVariableResolverService.VARIABLE_LHS = '${';
1710
+ AbstractVariableResolverService.VARIABLE_REGEXP = /\$\{(.*?)\}/g;
1711
+ export { AbstractVariableResolverService as A, convertToDAPaths as a, isSessionAttach as b, convertToVSCPaths as c, isAbsolute as d, getVisibleAndSorted as e, filterExceptionsFromTelemetry as f, getExtensionHostDebugSession as g, getEvaluatableExpressionAtPosition as h, isDebuggerMainContribution as i, join as j, isUri as k, formatPII as l, saveAllBeforeDebugStart as s };