@codingame/monaco-vscode-api 1.69.5 → 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 +140 -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 +5227 -5877
- package/dist/modelEditor.js +69 -68
- package/dist/monaco.js +14 -13
- package/dist/notifications.js +268 -337
- package/dist/polyfill.js +5348 -0
- package/dist/services.js +2 -2
- package/dist/services2.js +646 -140
- 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 +7 -1
package/dist/snippets.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { p as parse, w as getNodeType } from './polyfill.js';
|
|
2
|
+
import { j as IUserDataProfileService, b as ILifecycleService, E as ExtensionsRegistry, m as ExtensionMessageCollector } from './missing-services.js';
|
|
3
|
+
import { t as ISnippetsService, d as IFileService, I as ITextFileService, S as Services } from './services2.js';
|
|
4
|
+
import { b as __decorate, d as __param } from './contextkey.js';
|
|
4
5
|
import * as monacoSuggest from 'monaco-editor/esm/vs/editor/contrib/suggest/browser/suggest.js';
|
|
5
|
-
import { extname
|
|
6
|
+
import { extname, basename } from 'monaco-editor/esm/vs/base/common/path.js';
|
|
6
7
|
import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
|
|
7
|
-
import {
|
|
8
|
+
import { relativePath, isEqualOrParent, extname as extname$1, basename as basename$1, joinPath } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
8
9
|
import { IdleValue } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
9
10
|
import { isObject } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
10
11
|
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
@@ -12,7 +13,7 @@ import { SnippetParser, Placeholder, Variable, Text } from 'monaco-editor/esm/vs
|
|
|
12
13
|
import { tail, insertInto } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
13
14
|
import { KnownSnippetVariableNames } from 'monaco-editor/esm/vs/editor/contrib/snippet/browser/snippetVariables.js';
|
|
14
15
|
import { l as languagesExtPoint } from './languageService.js';
|
|
15
|
-
import {
|
|
16
|
+
import { bk as Range, D as DEFAULT_EXTENSION } from './extHost.js';
|
|
16
17
|
import { CommandsRegistry } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
|
|
17
18
|
import { getWordAtText } from 'monaco-editor/esm/vs/editor/common/core/wordHelper.js';
|
|
18
19
|
import { isPatternInWord } from 'monaco-editor/esm/vs/base/common/filters.js';
|
|
@@ -30,7 +31,7 @@ import { IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspac
|
|
|
30
31
|
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
31
32
|
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
32
33
|
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
33
|
-
import { g as getExtensionPoint,
|
|
34
|
+
import { g as getExtensionPoint, o as onServicesInitialized, c as consoleExtensionMessageHandler } from './tools.js';
|
|
34
35
|
import { g as getServiceOverride$1 } from './workspaceContext.js';
|
|
35
36
|
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
36
37
|
function setSnippetSuggestSupport (support) {
|
|
@@ -47,8 +48,8 @@ class SnippetBodyInsights {
|
|
|
47
48
|
this.usesClipboardVariable = false;
|
|
48
49
|
this.usesSelectionVariable = false;
|
|
49
50
|
this.codeSnippet = body;
|
|
50
|
-
const textmateSnippet = (
|
|
51
|
-
const placeholders = (
|
|
51
|
+
const textmateSnippet = ( new SnippetParser()).parse(body, false);
|
|
52
|
+
const placeholders = ( new Map());
|
|
52
53
|
let placeholderMax = 0;
|
|
53
54
|
for (const placeholder of textmateSnippet.placeholders) {
|
|
54
55
|
placeholderMax = Math.max(placeholderMax, placeholder.index);
|
|
@@ -67,7 +68,7 @@ class SnippetBodyInsights {
|
|
|
67
68
|
if (marker.children.length === 0 && !KnownSnippetVariableNames[marker.name]) {
|
|
68
69
|
const index = placeholders.has(marker.name) ? placeholders.get(marker.name) : ++placeholderMax;
|
|
69
70
|
placeholders.set(marker.name, index);
|
|
70
|
-
const synthetic = (
|
|
71
|
+
const synthetic = ( new Placeholder(index)).appendChild(( new Text(marker.name)));
|
|
71
72
|
textmateSnippet.replace(marker, [synthetic]);
|
|
72
73
|
this.isBogous = true;
|
|
73
74
|
}
|
|
@@ -103,7 +104,7 @@ class Snippet {
|
|
|
103
104
|
this.snippetIdentifier = snippetIdentifier;
|
|
104
105
|
this.extensionId = extensionId;
|
|
105
106
|
this.prefixLow = prefix.toLowerCase();
|
|
106
|
-
this._bodyInsights = (
|
|
107
|
+
this._bodyInsights = ( new IdleValue(() => ( new SnippetBodyInsights(this.body))));
|
|
107
108
|
}
|
|
108
109
|
get codeSnippet() {
|
|
109
110
|
return this._bodyInsights.value.codeSnippet;
|
|
@@ -133,7 +134,7 @@ class SnippetFile {
|
|
|
133
134
|
this._fileService = _fileService;
|
|
134
135
|
this._extensionResourceLoaderService = _extensionResourceLoaderService;
|
|
135
136
|
this.data = [];
|
|
136
|
-
this.isGlobalSnippets = extname
|
|
137
|
+
this.isGlobalSnippets = extname(location.path) === '.code-snippets';
|
|
137
138
|
this.isUserSnippets = !this._extension;
|
|
138
139
|
}
|
|
139
140
|
select(selector, bucket) {
|
|
@@ -145,7 +146,7 @@ class SnippetFile {
|
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
_filepathSelect(selector, bucket) {
|
|
148
|
-
if (selector + '.json' === basename
|
|
149
|
+
if (selector + '.json' === basename(this.location.path)) {
|
|
149
150
|
bucket.push(...this.data);
|
|
150
151
|
}
|
|
151
152
|
}
|
|
@@ -175,9 +176,7 @@ class SnippetFile {
|
|
|
175
176
|
}
|
|
176
177
|
else {
|
|
177
178
|
const content = await this._fileService.readFile(this.location);
|
|
178
|
-
return (
|
|
179
|
-
(content.value.toString())
|
|
180
|
-
);
|
|
179
|
+
return ( content.value.toString());
|
|
181
180
|
}
|
|
182
181
|
}
|
|
183
182
|
load() {
|
|
@@ -234,18 +233,18 @@ class SnippetFile {
|
|
|
234
233
|
source = this._extension.displayName || this._extension.name;
|
|
235
234
|
}
|
|
236
235
|
else if (this.source === 2 ) {
|
|
237
|
-
source = (
|
|
236
|
+
source = ( localize('source.workspaceSnippetGlobal', "Workspace Snippet"));
|
|
238
237
|
}
|
|
239
238
|
else {
|
|
240
239
|
if (this.isGlobalSnippets) {
|
|
241
|
-
source = (
|
|
240
|
+
source = ( localize('source.userSnippetGlobal', "Global User Snippet"));
|
|
242
241
|
}
|
|
243
242
|
else {
|
|
244
|
-
source = (
|
|
243
|
+
source = ( localize('source.userSnippet', "User Snippet"));
|
|
245
244
|
}
|
|
246
245
|
}
|
|
247
246
|
for (const _prefix of Array.isArray(prefix) ? prefix : Iterable.single(prefix)) {
|
|
248
|
-
bucket.push((
|
|
247
|
+
bucket.push(( new Snippet(
|
|
249
248
|
Boolean(isFileTemplate),
|
|
250
249
|
scopes,
|
|
251
250
|
name,
|
|
@@ -254,9 +253,9 @@ class SnippetFile {
|
|
|
254
253
|
body,
|
|
255
254
|
source,
|
|
256
255
|
this.source,
|
|
257
|
-
this._extension ? `${relativePath(this._extension.extensionLocation, this.location)}/${name}` : `${basename
|
|
256
|
+
this._extension ? `${relativePath(this._extension.extensionLocation, this.location)}/${name}` : `${basename(this.location.path)}/${name}`,
|
|
258
257
|
this._extension?.identifier
|
|
259
|
-
)))
|
|
258
|
+
)));
|
|
260
259
|
}
|
|
261
260
|
}
|
|
262
261
|
}
|
|
@@ -272,12 +271,12 @@ class SnippetCompletion {
|
|
|
272
271
|
constructor(snippet, range) {
|
|
273
272
|
this.snippet = snippet;
|
|
274
273
|
this.label = { label: snippet.prefix, description: snippet.name };
|
|
275
|
-
this.detail = (
|
|
274
|
+
this.detail = ( localize(
|
|
276
275
|
'detail.snippet',
|
|
277
276
|
"{0} ({1})",
|
|
278
277
|
snippet.description || snippet.name,
|
|
279
278
|
snippet.source
|
|
280
|
-
))
|
|
279
|
+
));
|
|
281
280
|
this.insertText = snippet.codeSnippet;
|
|
282
281
|
this.extensionId = snippet.extensionId;
|
|
283
282
|
this.range = range;
|
|
@@ -287,7 +286,7 @@ class SnippetCompletion {
|
|
|
287
286
|
this.command = { id: markSnippetAsUsed, title: '', arguments: [snippet] };
|
|
288
287
|
}
|
|
289
288
|
resolve() {
|
|
290
|
-
this.documentation = (
|
|
289
|
+
this.documentation = ( new MarkdownString()).appendCodeblock('', ( new SnippetParser()).text(this.snippet.codeSnippet));
|
|
291
290
|
return this;
|
|
292
291
|
}
|
|
293
292
|
static compareByLabel(a, b) {
|
|
@@ -302,10 +301,10 @@ let SnippetCompletionProvider = class SnippetCompletionProvider {
|
|
|
302
301
|
this._debugDisplayName = 'snippetCompletions';
|
|
303
302
|
}
|
|
304
303
|
async provideCompletionItems(model, position, context) {
|
|
305
|
-
const sw = (
|
|
304
|
+
const sw = ( new StopWatch(true));
|
|
306
305
|
const languageId = this._getLanguageIdAtPosition(model, position);
|
|
307
306
|
const languageConfig = this._languageConfigurationService.getLanguageConfiguration(languageId);
|
|
308
|
-
const snippets = (
|
|
307
|
+
const snippets = ( new Set(await this._snippets.getSnippets(languageId)));
|
|
309
308
|
const lineContentLow = model.getLineContent(position.lineNumber).toLowerCase();
|
|
310
309
|
const wordUntil = model.getWordUntilPosition(position).word.toLowerCase();
|
|
311
310
|
const suggestions = [];
|
|
@@ -340,9 +339,9 @@ let SnippetCompletionProvider = class SnippetCompletionProvider {
|
|
|
340
339
|
endColumn++;
|
|
341
340
|
}
|
|
342
341
|
}
|
|
343
|
-
const replace = Range
|
|
342
|
+
const replace = Range.fromPositions(startPosition, { lineNumber: position.lineNumber, column: endColumn });
|
|
344
343
|
const insert = replace.setEndPosition(position.lineNumber, position.column);
|
|
345
|
-
suggestions.push((
|
|
344
|
+
suggestions.push(( new SnippetCompletion(snippet, { replace, insert })));
|
|
346
345
|
snippets.delete(snippet);
|
|
347
346
|
break;
|
|
348
347
|
}
|
|
@@ -351,9 +350,9 @@ let SnippetCompletionProvider = class SnippetCompletionProvider {
|
|
|
351
350
|
const endsInWhitespace = /\s/.test(lineContentLow[position.column - 2]);
|
|
352
351
|
if (endsInWhitespace || !lineContentLow ) {
|
|
353
352
|
for (const snippet of snippets) {
|
|
354
|
-
const insert = Range
|
|
353
|
+
const insert = Range.fromPositions(position);
|
|
355
354
|
const replace = lineContentLow.indexOf(snippet.prefixLow, columnOffset) === columnOffset ? insert.setEndPosition(position.lineNumber, position.column + snippet.prefixLow.length) : insert;
|
|
356
|
-
suggestions.push((
|
|
355
|
+
suggestions.push(( new SnippetCompletion(snippet, { replace, insert })));
|
|
357
356
|
}
|
|
358
357
|
}
|
|
359
358
|
}
|
|
@@ -362,20 +361,20 @@ let SnippetCompletionProvider = class SnippetCompletionProvider {
|
|
|
362
361
|
const item = suggestions[i];
|
|
363
362
|
let to = i + 1;
|
|
364
363
|
for (; to < suggestions.length && item.label === suggestions[to].label; to++) {
|
|
365
|
-
suggestions[to].label.label = (
|
|
364
|
+
suggestions[to].label.label = ( localize(
|
|
366
365
|
'snippetSuggest.longLabel',
|
|
367
366
|
"{0}, {1}",
|
|
368
367
|
suggestions[to].label.label,
|
|
369
368
|
suggestions[to].snippet.name
|
|
370
|
-
))
|
|
369
|
+
));
|
|
371
370
|
}
|
|
372
371
|
if (to > i + 1) {
|
|
373
|
-
suggestions[i].label.label = (
|
|
372
|
+
suggestions[i].label.label = ( localize(
|
|
374
373
|
'snippetSuggest.longLabel',
|
|
375
374
|
"{0}, {1}",
|
|
376
375
|
suggestions[i].label.label,
|
|
377
376
|
suggestions[i].snippet.name
|
|
378
|
-
))
|
|
377
|
+
));
|
|
379
378
|
i = to;
|
|
380
379
|
}
|
|
381
380
|
}
|
|
@@ -396,51 +395,51 @@ let SnippetCompletionProvider = class SnippetCompletionProvider {
|
|
|
396
395
|
return languageId;
|
|
397
396
|
}
|
|
398
397
|
};
|
|
399
|
-
SnippetCompletionProvider = (
|
|
400
|
-
(
|
|
401
|
-
(
|
|
402
|
-
(
|
|
403
|
-
], SnippetCompletionProvider))
|
|
398
|
+
SnippetCompletionProvider = ( __decorate([
|
|
399
|
+
( __param(0, ILanguageService)),
|
|
400
|
+
( __param(1, ISnippetsService)),
|
|
401
|
+
( __param(2, ILanguageConfigurationService))
|
|
402
|
+
], SnippetCompletionProvider));
|
|
404
403
|
var snippetExt;
|
|
405
|
-
( (
|
|
404
|
+
( (function(snippetExt) {
|
|
406
405
|
function toValidSnippet(extension, snippet, languageService) {
|
|
407
406
|
if (isFalsyOrWhitespace(snippet.path)) {
|
|
408
|
-
extension.collector.error((
|
|
407
|
+
extension.collector.error(( localize(
|
|
409
408
|
'invalid.path.0',
|
|
410
409
|
"Expected string in `contributes.{0}.path`. Provided value: {1}",
|
|
411
410
|
extension.description.name,
|
|
412
411
|
String(snippet.path)
|
|
413
|
-
)))
|
|
412
|
+
)));
|
|
414
413
|
return null;
|
|
415
414
|
}
|
|
416
415
|
if (isFalsyOrWhitespace(snippet.language) && !snippet.path.endsWith('.code-snippets')) {
|
|
417
|
-
extension.collector.error((
|
|
416
|
+
extension.collector.error(( localize(
|
|
418
417
|
'invalid.language.0',
|
|
419
418
|
"When omitting the language, the value of `contributes.{0}.path` must be a `.code-snippets`-file. Provided value: {1}",
|
|
420
419
|
extension.description.name,
|
|
421
420
|
String(snippet.path)
|
|
422
|
-
)))
|
|
421
|
+
)));
|
|
423
422
|
return null;
|
|
424
423
|
}
|
|
425
424
|
if (!isFalsyOrWhitespace(snippet.language) && !languageService.isRegisteredLanguageId(snippet.language)) {
|
|
426
|
-
extension.collector.error((
|
|
425
|
+
extension.collector.error(( localize(
|
|
427
426
|
'invalid.language',
|
|
428
427
|
"Unknown language in `contributes.{0}.language`. Provided value: {1}",
|
|
429
428
|
extension.description.name,
|
|
430
429
|
String(snippet.language)
|
|
431
|
-
)))
|
|
430
|
+
)));
|
|
432
431
|
return null;
|
|
433
432
|
}
|
|
434
433
|
const extensionLocation = extension.description.extensionLocation;
|
|
435
434
|
const snippetLocation = joinPath(extensionLocation, snippet.path);
|
|
436
435
|
if (!isEqualOrParent(snippetLocation, extensionLocation)) {
|
|
437
|
-
extension.collector.error((
|
|
436
|
+
extension.collector.error(( localize(
|
|
438
437
|
'invalid.path.1',
|
|
439
438
|
"Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.",
|
|
440
439
|
extension.description.name,
|
|
441
440
|
snippetLocation.path,
|
|
442
441
|
extensionLocation.path
|
|
443
|
-
)))
|
|
442
|
+
)));
|
|
444
443
|
return null;
|
|
445
444
|
}
|
|
446
445
|
return {
|
|
@@ -450,7 +449,7 @@ var snippetExt;
|
|
|
450
449
|
}
|
|
451
450
|
snippetExt.toValidSnippet = toValidSnippet;
|
|
452
451
|
snippetExt.snippetsContribution = {
|
|
453
|
-
description: (
|
|
452
|
+
description: ( localize('vscode.extension.contributes.snippets', 'Contributes snippets.')),
|
|
454
453
|
type: 'array',
|
|
455
454
|
defaultSnippets: [{ body: [{ language: '', path: '' }] }],
|
|
456
455
|
items: {
|
|
@@ -458,28 +457,28 @@ var snippetExt;
|
|
|
458
457
|
defaultSnippets: [{ body: { language: '${1:id}', path: './snippets/${2:id}.json.' } }],
|
|
459
458
|
properties: {
|
|
460
459
|
language: {
|
|
461
|
-
description: (
|
|
460
|
+
description: ( localize(
|
|
462
461
|
'vscode.extension.contributes.snippets-language',
|
|
463
462
|
'Language identifier for which this snippet is contributed to.'
|
|
464
|
-
))
|
|
463
|
+
)),
|
|
465
464
|
type: 'string'
|
|
466
465
|
},
|
|
467
466
|
path: {
|
|
468
|
-
description: (
|
|
467
|
+
description: ( localize(
|
|
469
468
|
'vscode.extension.contributes.snippets-path',
|
|
470
469
|
'Path of the snippets file. The path is relative to the extension folder and typically starts with \'./snippets/\'.'
|
|
471
|
-
))
|
|
470
|
+
)),
|
|
472
471
|
type: 'string'
|
|
473
472
|
}
|
|
474
473
|
}
|
|
475
474
|
}
|
|
476
475
|
};
|
|
477
|
-
snippetExt.point = (
|
|
476
|
+
snippetExt.point = ( ExtensionsRegistry.registerExtensionPoint({
|
|
478
477
|
extensionPoint: 'snippets',
|
|
479
478
|
deps: [languagesExtPoint],
|
|
480
479
|
jsonSchema: snippetExt.snippetsContribution
|
|
481
|
-
}))
|
|
482
|
-
})(snippetExt || (snippetExt = {})))
|
|
480
|
+
}));
|
|
481
|
+
})(snippetExt || (snippetExt = {})));
|
|
483
482
|
function watch(service, resource, callback) {
|
|
484
483
|
return combinedDisposable(service.watch(resource), service.onDidFilesChange(e => {
|
|
485
484
|
if (e.affects(resource)) {
|
|
@@ -496,7 +495,7 @@ let SnippetEnablement = class SnippetEnablement {
|
|
|
496
495
|
data = JSON.parse(raw);
|
|
497
496
|
}
|
|
498
497
|
catch { }
|
|
499
|
-
this._ignored = isStringArray(data) ? (
|
|
498
|
+
this._ignored = isStringArray(data) ? ( new Set(data)) : ( new Set());
|
|
500
499
|
}
|
|
501
500
|
isIgnored(id) {
|
|
502
501
|
return this._ignored.has(id);
|
|
@@ -517,9 +516,9 @@ let SnippetEnablement = class SnippetEnablement {
|
|
|
517
516
|
}
|
|
518
517
|
};
|
|
519
518
|
SnippetEnablement._key = 'snippets.ignoredSnippets';
|
|
520
|
-
SnippetEnablement = (
|
|
521
|
-
(
|
|
522
|
-
], SnippetEnablement))
|
|
519
|
+
SnippetEnablement = ( __decorate([
|
|
520
|
+
( __param(0, IStorageService))
|
|
521
|
+
], SnippetEnablement));
|
|
523
522
|
let SnippetUsageTimestamps = class SnippetUsageTimestamps {
|
|
524
523
|
constructor(_storageService) {
|
|
525
524
|
this._storageService = _storageService;
|
|
@@ -531,7 +530,7 @@ let SnippetUsageTimestamps = class SnippetUsageTimestamps {
|
|
|
531
530
|
catch {
|
|
532
531
|
data = [];
|
|
533
532
|
}
|
|
534
|
-
this._usages = Array.isArray(data) ? (
|
|
533
|
+
this._usages = Array.isArray(data) ? ( new Map(data)) : ( new Map());
|
|
535
534
|
}
|
|
536
535
|
getUsageTimestamp(id) {
|
|
537
536
|
return this._usages.get(id);
|
|
@@ -544,9 +543,9 @@ let SnippetUsageTimestamps = class SnippetUsageTimestamps {
|
|
|
544
543
|
}
|
|
545
544
|
};
|
|
546
545
|
SnippetUsageTimestamps._key = 'snippets.usageTimestamps';
|
|
547
|
-
SnippetUsageTimestamps = (
|
|
548
|
-
(
|
|
549
|
-
], SnippetUsageTimestamps))
|
|
546
|
+
SnippetUsageTimestamps = ( __decorate([
|
|
547
|
+
( __param(0, IStorageService))
|
|
548
|
+
], SnippetUsageTimestamps));
|
|
550
549
|
let SnippetsService = class SnippetsService {
|
|
551
550
|
constructor(_environmentService, _userDataProfileService, _contextService, _languageService, _logService, _fileService, _textfileService, _extensionResourceLoaderService, lifecycleService, instantiationService, languageConfigurationService) {
|
|
552
551
|
this._environmentService = _environmentService;
|
|
@@ -557,15 +556,15 @@ let SnippetsService = class SnippetsService {
|
|
|
557
556
|
this._fileService = _fileService;
|
|
558
557
|
this._textfileService = _textfileService;
|
|
559
558
|
this._extensionResourceLoaderService = _extensionResourceLoaderService;
|
|
560
|
-
this._disposables = (
|
|
559
|
+
this._disposables = ( new DisposableStore());
|
|
561
560
|
this._pendingWork = [];
|
|
562
|
-
this._files = (
|
|
561
|
+
this._files = ( new ResourceMap());
|
|
563
562
|
this._pendingWork.push(Promise.resolve(lifecycleService.when(3 ).then(() => {
|
|
564
563
|
this._initExtensionSnippets();
|
|
565
564
|
this._initUserSnippets();
|
|
566
565
|
this._initWorkspaceSnippets();
|
|
567
566
|
})));
|
|
568
|
-
setSnippetSuggestSupport((
|
|
567
|
+
setSnippetSuggestSupport(( new SnippetCompletionProvider(this._languageService, this, languageConfigurationService)));
|
|
569
568
|
this._enablement = instantiationService.createInstance(SnippetEnablement);
|
|
570
569
|
this._usageTimestamps = instantiationService.createInstance(SnippetUsageTimestamps);
|
|
571
570
|
}
|
|
@@ -588,9 +587,7 @@ let SnippetsService = class SnippetsService {
|
|
|
588
587
|
}
|
|
589
588
|
async getSnippetFiles() {
|
|
590
589
|
await this._joinSnippets();
|
|
591
|
-
return (
|
|
592
|
-
(this._files.values())
|
|
593
|
-
);
|
|
590
|
+
return ( this._files.values());
|
|
594
591
|
}
|
|
595
592
|
async getSnippets(languageId, opts) {
|
|
596
593
|
await this._joinSnippets();
|
|
@@ -598,18 +595,18 @@ let SnippetsService = class SnippetsService {
|
|
|
598
595
|
const promises = [];
|
|
599
596
|
if (languageId) {
|
|
600
597
|
if (this._languageService.isRegisteredLanguageId(languageId)) {
|
|
601
|
-
for (const file of (
|
|
598
|
+
for (const file of ( this._files.values())) {
|
|
602
599
|
promises.push(file.load()
|
|
603
600
|
.then(file => file.select(languageId, result))
|
|
604
|
-
.catch(err => this._logService.error(err, (
|
|
601
|
+
.catch(err => this._logService.error(err, ( file.location.toString()))));
|
|
605
602
|
}
|
|
606
603
|
}
|
|
607
604
|
}
|
|
608
605
|
else {
|
|
609
|
-
for (const file of (
|
|
606
|
+
for (const file of ( this._files.values())) {
|
|
610
607
|
promises.push(file.load()
|
|
611
608
|
.then(file => insertInto(result, result.length, file.data))
|
|
612
|
-
.catch(err => this._logService.error(err, (
|
|
609
|
+
.catch(err => this._logService.error(err, ( file.location.toString()))));
|
|
613
610
|
}
|
|
614
611
|
}
|
|
615
612
|
await Promise.all(promises);
|
|
@@ -618,7 +615,7 @@ let SnippetsService = class SnippetsService {
|
|
|
618
615
|
getSnippetsSync(languageId, opts) {
|
|
619
616
|
const result = [];
|
|
620
617
|
if (this._languageService.isRegisteredLanguageId(languageId)) {
|
|
621
|
-
for (const file of (
|
|
618
|
+
for (const file of ( this._files.values())) {
|
|
622
619
|
file.load().catch(_err => { });
|
|
623
620
|
file.select(languageId, result);
|
|
624
621
|
}
|
|
@@ -698,30 +695,26 @@ let SnippetsService = class SnippetsService {
|
|
|
698
695
|
}
|
|
699
696
|
}
|
|
700
697
|
else {
|
|
701
|
-
const file = (
|
|
698
|
+
const file = ( new SnippetFile(
|
|
702
699
|
3 ,
|
|
703
700
|
validContribution.location,
|
|
704
701
|
validContribution.language ? [validContribution.language] : undefined,
|
|
705
702
|
extension.description,
|
|
706
703
|
this._fileService,
|
|
707
704
|
this._extensionResourceLoaderService
|
|
708
|
-
))
|
|
705
|
+
));
|
|
709
706
|
this._files.set(file.location, file);
|
|
710
707
|
if (this._environmentService.isExtensionDevelopment) {
|
|
711
708
|
file.load().then(file => {
|
|
712
709
|
if (file.data.some(snippet => snippet.isBogous)) {
|
|
713
|
-
extension.collector.warn((
|
|
710
|
+
extension.collector.warn(( localize(
|
|
714
711
|
'badVariableUse',
|
|
715
712
|
"One or more snippets from the extension '{0}' very likely confuse snippet-variables and snippet-placeholders (see https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax for more details)",
|
|
716
713
|
extension.description.name
|
|
717
|
-
)))
|
|
714
|
+
)));
|
|
718
715
|
}
|
|
719
716
|
}, err => {
|
|
720
|
-
extension.collector.warn((
|
|
721
|
-
'badFile',
|
|
722
|
-
"The snippet file \"{0}\" could not be read.",
|
|
723
|
-
(file.location.toString())
|
|
724
|
-
))));
|
|
717
|
+
extension.collector.warn(( localize('badFile', "The snippet file \"{0}\" could not be read.", ( file.location.toString()))));
|
|
725
718
|
});
|
|
726
719
|
}
|
|
727
720
|
}
|
|
@@ -730,7 +723,7 @@ let SnippetsService = class SnippetsService {
|
|
|
730
723
|
});
|
|
731
724
|
}
|
|
732
725
|
_initWorkspaceSnippets() {
|
|
733
|
-
const disposables = (
|
|
726
|
+
const disposables = ( new DisposableStore());
|
|
734
727
|
const updateWorkspaceSnippets = () => {
|
|
735
728
|
disposables.clear();
|
|
736
729
|
this._pendingWork.push(this._initWorkspaceFolderSnippets(this._contextService.getWorkspace(), disposables));
|
|
@@ -758,7 +751,7 @@ let SnippetsService = class SnippetsService {
|
|
|
758
751
|
await Promise.all(promises);
|
|
759
752
|
}
|
|
760
753
|
async _initUserSnippets() {
|
|
761
|
-
const disposables = (
|
|
754
|
+
const disposables = ( new DisposableStore());
|
|
762
755
|
const updateUserSnippets = async () => {
|
|
763
756
|
disposables.clear();
|
|
764
757
|
const userSnippetsFolder = this._userDataProfileService.currentProfile.snippetsHome;
|
|
@@ -775,7 +768,7 @@ let SnippetsService = class SnippetsService {
|
|
|
775
768
|
await updateUserSnippets();
|
|
776
769
|
}
|
|
777
770
|
_initFolderSnippets(source, folder, bucket) {
|
|
778
|
-
const disposables = (
|
|
771
|
+
const disposables = ( new DisposableStore());
|
|
779
772
|
const addFolderSnippets = async () => {
|
|
780
773
|
disposables.clear();
|
|
781
774
|
if (!(await this._fileService.exists(folder))) {
|
|
@@ -788,7 +781,7 @@ let SnippetsService = class SnippetsService {
|
|
|
788
781
|
}
|
|
789
782
|
}
|
|
790
783
|
catch (err) {
|
|
791
|
-
this._logService.error(`Failed snippets from folder '${(
|
|
784
|
+
this._logService.error(`Failed snippets from folder '${( folder.toString())}'`, err);
|
|
792
785
|
}
|
|
793
786
|
};
|
|
794
787
|
bucket.add(this._textfileService.files.onDidSave(e => {
|
|
@@ -801,46 +794,46 @@ let SnippetsService = class SnippetsService {
|
|
|
801
794
|
return addFolderSnippets();
|
|
802
795
|
}
|
|
803
796
|
_addSnippetFile(uri, source) {
|
|
804
|
-
const ext = extname(uri);
|
|
797
|
+
const ext = extname$1(uri);
|
|
805
798
|
if (source === 1 && ext === '.json') {
|
|
806
|
-
const langName = basename(uri).replace(/\.json/, '');
|
|
807
|
-
this._files.set(uri, (
|
|
799
|
+
const langName = basename$1(uri).replace(/\.json/, '');
|
|
800
|
+
this._files.set(uri, ( new SnippetFile(
|
|
808
801
|
source,
|
|
809
802
|
uri,
|
|
810
803
|
[langName],
|
|
811
804
|
undefined,
|
|
812
805
|
this._fileService,
|
|
813
806
|
this._extensionResourceLoaderService
|
|
814
|
-
)))
|
|
807
|
+
)));
|
|
815
808
|
}
|
|
816
809
|
else if (ext === '.code-snippets') {
|
|
817
|
-
this._files.set(uri, (
|
|
810
|
+
this._files.set(uri, ( new SnippetFile(
|
|
818
811
|
source,
|
|
819
812
|
uri,
|
|
820
813
|
undefined,
|
|
821
814
|
undefined,
|
|
822
815
|
this._fileService,
|
|
823
816
|
this._extensionResourceLoaderService
|
|
824
|
-
)))
|
|
817
|
+
)));
|
|
825
818
|
}
|
|
826
819
|
return {
|
|
827
820
|
dispose: () => this._files.delete(uri)
|
|
828
821
|
};
|
|
829
822
|
}
|
|
830
823
|
};
|
|
831
|
-
SnippetsService = (
|
|
832
|
-
(
|
|
833
|
-
(
|
|
834
|
-
(
|
|
835
|
-
(
|
|
836
|
-
(
|
|
837
|
-
(
|
|
838
|
-
(
|
|
839
|
-
(
|
|
840
|
-
(
|
|
841
|
-
(
|
|
842
|
-
(
|
|
843
|
-
], SnippetsService))
|
|
824
|
+
SnippetsService = ( __decorate([
|
|
825
|
+
( __param(0, IEnvironmentService)),
|
|
826
|
+
( __param(1, IUserDataProfileService)),
|
|
827
|
+
( __param(2, IWorkspaceContextService)),
|
|
828
|
+
( __param(3, ILanguageService)),
|
|
829
|
+
( __param(4, ILogService)),
|
|
830
|
+
( __param(5, IFileService)),
|
|
831
|
+
( __param(6, ITextFileService)),
|
|
832
|
+
( __param(7, IExtensionResourceLoaderService)),
|
|
833
|
+
( __param(8, ILifecycleService)),
|
|
834
|
+
( __param(9, IInstantiationService)),
|
|
835
|
+
( __param(10, ILanguageConfigurationService))
|
|
836
|
+
], SnippetsService));
|
|
844
837
|
const snippetExtensionPoint = getExtensionPoint('snippets');
|
|
845
838
|
function setSnippets(snippets, getContent, extension = Services.get().extension ?? DEFAULT_EXTENSION) {
|
|
846
839
|
snippetExtensionPoint.acceptUsers([{
|
|
@@ -859,7 +852,7 @@ function getServiceOverride() {
|
|
|
859
852
|
onServicesInitialized(initialize);
|
|
860
853
|
return {
|
|
861
854
|
...getServiceOverride$1(),
|
|
862
|
-
[
|
|
855
|
+
[ISnippetsService.toString()]: new SyncDescriptor(SnippetsService)
|
|
863
856
|
};
|
|
864
857
|
}
|
|
865
858
|
export { getServiceOverride as default, setSnippets };
|