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