@codingame/monaco-vscode-extension-editing-default-extension 1.85.1 → 1.85.3

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.
@@ -1,1999 +0,0 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ "use strict";
3
- /******/ var __webpack_modules__ = ([
4
- /* 0 */,
5
- /* 1 */
6
- /***/ ((module) => {
7
-
8
- module.exports = require("vscode");
9
-
10
- /***/ }),
11
- /* 2 */
12
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
13
-
14
-
15
- /*---------------------------------------------------------------------------------------------
16
- * Copyright (c) Microsoft Corporation. All rights reserved.
17
- * Licensed under the MIT License. See License.txt in the project root for license information.
18
- *--------------------------------------------------------------------------------------------*/
19
- Object.defineProperty(exports, "__esModule", ({ value: true }));
20
- exports.PackageDocument = void 0;
21
- const vscode = __webpack_require__(1);
22
- const jsonc_parser_1 = __webpack_require__(3);
23
- const constants_1 = __webpack_require__(8);
24
- class PackageDocument {
25
- constructor(document) {
26
- this.document = document;
27
- }
28
- provideCompletionItems(position, _token) {
29
- const location = (0, jsonc_parser_1.getLocation)(this.document.getText(), this.document.offsetAt(position));
30
- if (location.path.length >= 2 && location.path[1] === 'configurationDefaults') {
31
- return this.provideLanguageOverridesCompletionItems(location, position);
32
- }
33
- return undefined;
34
- }
35
- provideCodeActions(_range, context, _token) {
36
- const codeActions = [];
37
- for (const diagnostic of context.diagnostics) {
38
- if (diagnostic.message === constants_1.implicitActivationEvent || diagnostic.message === constants_1.redundantImplicitActivationEvent) {
39
- const codeAction = new vscode.CodeAction(vscode.l10n.t("Remove activation event"), vscode.CodeActionKind.QuickFix);
40
- codeAction.edit = new vscode.WorkspaceEdit();
41
- const rangeForCharAfter = diagnostic.range.with(diagnostic.range.end, diagnostic.range.end.translate(0, 1));
42
- if (this.document.getText(rangeForCharAfter) === ',') {
43
- codeAction.edit.delete(this.document.uri, diagnostic.range.with(undefined, diagnostic.range.end.translate(0, 1)));
44
- }
45
- else {
46
- codeAction.edit.delete(this.document.uri, diagnostic.range);
47
- }
48
- codeActions.push(codeAction);
49
- }
50
- }
51
- return codeActions;
52
- }
53
- provideLanguageOverridesCompletionItems(location, position) {
54
- let range = this.getReplaceRange(location, position);
55
- const text = this.document.getText(range);
56
- if (location.path.length === 2) {
57
- let snippet = '"[${1:language}]": {\n\t"$0"\n}';
58
- // Suggestion model word matching includes quotes,
59
- // hence exclude the starting quote from the snippet and the range
60
- // ending quote gets replaced
61
- if (text && text.startsWith('"')) {
62
- range = new vscode.Range(new vscode.Position(range.start.line, range.start.character + 1), range.end);
63
- snippet = snippet.substring(1);
64
- }
65
- return Promise.resolve([this.newSnippetCompletionItem({
66
- label: vscode.l10n.t("Language specific editor settings"),
67
- documentation: vscode.l10n.t("Override editor settings for language"),
68
- snippet,
69
- range
70
- })]);
71
- }
72
- if (location.path.length === 3 && location.previousNode && typeof location.previousNode.value === 'string' && location.previousNode.value.startsWith('[')) {
73
- // Suggestion model word matching includes starting quote and open sqaure bracket
74
- // Hence exclude them from the proposal range
75
- range = new vscode.Range(new vscode.Position(range.start.line, range.start.character + 2), range.end);
76
- return vscode.languages.getLanguages().then(languages => {
77
- return languages.map(l => {
78
- // Suggestion model word matching includes closed sqaure bracket and ending quote
79
- // Hence include them in the proposal to replace
80
- return this.newSimpleCompletionItem(l, range, '', l + ']"');
81
- });
82
- });
83
- }
84
- return Promise.resolve([]);
85
- }
86
- getReplaceRange(location, position) {
87
- const node = location.previousNode;
88
- if (node) {
89
- const nodeStart = this.document.positionAt(node.offset), nodeEnd = this.document.positionAt(node.offset + node.length);
90
- if (nodeStart.isBeforeOrEqual(position) && nodeEnd.isAfterOrEqual(position)) {
91
- return new vscode.Range(nodeStart, nodeEnd);
92
- }
93
- }
94
- return new vscode.Range(position, position);
95
- }
96
- newSimpleCompletionItem(text, range, description, insertText) {
97
- const item = new vscode.CompletionItem(text);
98
- item.kind = vscode.CompletionItemKind.Value;
99
- item.detail = description;
100
- item.insertText = insertText ? insertText : text;
101
- item.range = range;
102
- return item;
103
- }
104
- newSnippetCompletionItem(o) {
105
- const item = new vscode.CompletionItem(o.label);
106
- item.kind = vscode.CompletionItemKind.Value;
107
- item.documentation = o.documentation;
108
- item.insertText = new vscode.SnippetString(o.snippet);
109
- item.range = o.range;
110
- return item;
111
- }
112
- }
113
- exports.PackageDocument = PackageDocument;
114
-
115
-
116
- /***/ }),
117
- /* 3 */
118
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
119
-
120
- __webpack_require__.r(__webpack_exports__);
121
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
122
- /* harmony export */ "ParseErrorCode": () => (/* binding */ ParseErrorCode),
123
- /* harmony export */ "ScanError": () => (/* binding */ ScanError),
124
- /* harmony export */ "SyntaxKind": () => (/* binding */ SyntaxKind),
125
- /* harmony export */ "applyEdits": () => (/* binding */ applyEdits),
126
- /* harmony export */ "createScanner": () => (/* binding */ createScanner),
127
- /* harmony export */ "findNodeAtLocation": () => (/* binding */ findNodeAtLocation),
128
- /* harmony export */ "findNodeAtOffset": () => (/* binding */ findNodeAtOffset),
129
- /* harmony export */ "format": () => (/* binding */ format),
130
- /* harmony export */ "getLocation": () => (/* binding */ getLocation),
131
- /* harmony export */ "getNodePath": () => (/* binding */ getNodePath),
132
- /* harmony export */ "getNodeValue": () => (/* binding */ getNodeValue),
133
- /* harmony export */ "modify": () => (/* binding */ modify),
134
- /* harmony export */ "parse": () => (/* binding */ parse),
135
- /* harmony export */ "parseTree": () => (/* binding */ parseTree),
136
- /* harmony export */ "printParseErrorCode": () => (/* binding */ printParseErrorCode),
137
- /* harmony export */ "stripComments": () => (/* binding */ stripComments),
138
- /* harmony export */ "visit": () => (/* binding */ visit)
139
- /* harmony export */ });
140
- /* harmony import */ var _impl_format__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
141
- /* harmony import */ var _impl_edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
142
- /* harmony import */ var _impl_scanner__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
143
- /* harmony import */ var _impl_parser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7);
144
- /*---------------------------------------------------------------------------------------------
145
- * Copyright (c) Microsoft Corporation. All rights reserved.
146
- * Licensed under the MIT License. See License.txt in the project root for license information.
147
- *--------------------------------------------------------------------------------------------*/
148
-
149
-
150
-
151
-
152
-
153
- /**
154
- * Creates a JSON scanner on the given text.
155
- * If ignoreTrivia is set, whitespaces or comments are ignored.
156
- */
157
- const createScanner = _impl_scanner__WEBPACK_IMPORTED_MODULE_2__.createScanner;
158
- var ScanError;
159
- (function (ScanError) {
160
- ScanError[ScanError["None"] = 0] = "None";
161
- ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
162
- ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
163
- ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
164
- ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
165
- ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
166
- ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
167
- })(ScanError || (ScanError = {}));
168
- var SyntaxKind;
169
- (function (SyntaxKind) {
170
- SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
171
- SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
172
- SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
173
- SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
174
- SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
175
- SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
176
- SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
177
- SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
178
- SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
179
- SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
180
- SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
181
- SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
182
- SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
183
- SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
184
- SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
185
- SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
186
- SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
187
- })(SyntaxKind || (SyntaxKind = {}));
188
- /**
189
- * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
190
- */
191
- const getLocation = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getLocation;
192
- /**
193
- * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
194
- * Therefore, always check the errors list to find out if the input was valid.
195
- */
196
- const parse = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.parse;
197
- /**
198
- * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
199
- */
200
- const parseTree = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.parseTree;
201
- /**
202
- * Finds the node at the given path in a JSON DOM.
203
- */
204
- const findNodeAtLocation = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.findNodeAtLocation;
205
- /**
206
- * Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
207
- */
208
- const findNodeAtOffset = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.findNodeAtOffset;
209
- /**
210
- * Gets the JSON path of the given JSON DOM node
211
- */
212
- const getNodePath = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getNodePath;
213
- /**
214
- * Evaluates the JavaScript object of the given JSON DOM node
215
- */
216
- const getNodeValue = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getNodeValue;
217
- /**
218
- * Parses the given text and invokes the visitor functions for each object, array and literal reached.
219
- */
220
- const visit = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.visit;
221
- /**
222
- * Takes JSON with JavaScript-style comments and remove
223
- * them. Optionally replaces every none-newline character
224
- * of comments with a replaceCharacter
225
- */
226
- const stripComments = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.stripComments;
227
- var ParseErrorCode;
228
- (function (ParseErrorCode) {
229
- ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
230
- ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
231
- ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
232
- ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
233
- ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
234
- ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
235
- ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
236
- ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
237
- ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
238
- ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
239
- ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
240
- ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
241
- ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
242
- ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
243
- ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
244
- ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
245
- })(ParseErrorCode || (ParseErrorCode = {}));
246
- function printParseErrorCode(code) {
247
- switch (code) {
248
- case 1 /* ParseErrorCode.InvalidSymbol */: return 'InvalidSymbol';
249
- case 2 /* ParseErrorCode.InvalidNumberFormat */: return 'InvalidNumberFormat';
250
- case 3 /* ParseErrorCode.PropertyNameExpected */: return 'PropertyNameExpected';
251
- case 4 /* ParseErrorCode.ValueExpected */: return 'ValueExpected';
252
- case 5 /* ParseErrorCode.ColonExpected */: return 'ColonExpected';
253
- case 6 /* ParseErrorCode.CommaExpected */: return 'CommaExpected';
254
- case 7 /* ParseErrorCode.CloseBraceExpected */: return 'CloseBraceExpected';
255
- case 8 /* ParseErrorCode.CloseBracketExpected */: return 'CloseBracketExpected';
256
- case 9 /* ParseErrorCode.EndOfFileExpected */: return 'EndOfFileExpected';
257
- case 10 /* ParseErrorCode.InvalidCommentToken */: return 'InvalidCommentToken';
258
- case 11 /* ParseErrorCode.UnexpectedEndOfComment */: return 'UnexpectedEndOfComment';
259
- case 12 /* ParseErrorCode.UnexpectedEndOfString */: return 'UnexpectedEndOfString';
260
- case 13 /* ParseErrorCode.UnexpectedEndOfNumber */: return 'UnexpectedEndOfNumber';
261
- case 14 /* ParseErrorCode.InvalidUnicode */: return 'InvalidUnicode';
262
- case 15 /* ParseErrorCode.InvalidEscapeCharacter */: return 'InvalidEscapeCharacter';
263
- case 16 /* ParseErrorCode.InvalidCharacter */: return 'InvalidCharacter';
264
- }
265
- return '<unknown ParseErrorCode>';
266
- }
267
- /**
268
- * Computes the edit operations needed to format a JSON document.
269
- *
270
- * @param documentText The input text
271
- * @param range The range to format or `undefined` to format the full content
272
- * @param options The formatting options
273
- * @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.
274
- * To apply the edit operations to the input, use {@linkcode applyEdits}.
275
- */
276
- function format(documentText, range, options) {
277
- return _impl_format__WEBPACK_IMPORTED_MODULE_0__.format(documentText, range, options);
278
- }
279
- /**
280
- * Computes the edit operations needed to modify a value in the JSON document.
281
- *
282
- * @param documentText The input text
283
- * @param path The path of the value to change. The path represents either to the document root, a property or an array item.
284
- * If the path points to an non-existing property or item, it will be created.
285
- * @param value The new value for the specified property or item. If the value is undefined,
286
- * the property or item will be removed.
287
- * @param options Options
288
- * @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
289
- * To apply the edit operations to the input, use {@linkcode applyEdits}.
290
- */
291
- function modify(text, path, value, options) {
292
- return _impl_edit__WEBPACK_IMPORTED_MODULE_1__.setProperty(text, path, value, options);
293
- }
294
- /**
295
- * Applies edits to an input string.
296
- * @param text The input text
297
- * @param edits Edit operations following the format described in {@linkcode EditResult}.
298
- * @returns The text with the applied edits.
299
- * @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
300
- */
301
- function applyEdits(text, edits) {
302
- let sortedEdits = edits.slice(0).sort((a, b) => {
303
- const diff = a.offset - b.offset;
304
- if (diff === 0) {
305
- return a.length - b.length;
306
- }
307
- return diff;
308
- });
309
- let lastModifiedOffset = text.length;
310
- for (let i = sortedEdits.length - 1; i >= 0; i--) {
311
- let e = sortedEdits[i];
312
- if (e.offset + e.length <= lastModifiedOffset) {
313
- text = _impl_edit__WEBPACK_IMPORTED_MODULE_1__.applyEdit(text, e);
314
- }
315
- else {
316
- throw new Error('Overlapping edit');
317
- }
318
- lastModifiedOffset = e.offset;
319
- }
320
- return text;
321
- }
322
-
323
-
324
- /***/ }),
325
- /* 4 */
326
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
327
-
328
- __webpack_require__.r(__webpack_exports__);
329
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
330
- /* harmony export */ "format": () => (/* binding */ format),
331
- /* harmony export */ "isEOL": () => (/* binding */ isEOL)
332
- /* harmony export */ });
333
- /* harmony import */ var _scanner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
334
- /*---------------------------------------------------------------------------------------------
335
- * Copyright (c) Microsoft Corporation. All rights reserved.
336
- * Licensed under the MIT License. See License.txt in the project root for license information.
337
- *--------------------------------------------------------------------------------------------*/
338
-
339
-
340
- function format(documentText, range, options) {
341
- let initialIndentLevel;
342
- let formatText;
343
- let formatTextStart;
344
- let rangeStart;
345
- let rangeEnd;
346
- if (range) {
347
- rangeStart = range.offset;
348
- rangeEnd = rangeStart + range.length;
349
- formatTextStart = rangeStart;
350
- while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
351
- formatTextStart--;
352
- }
353
- let endOffset = rangeEnd;
354
- while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
355
- endOffset++;
356
- }
357
- formatText = documentText.substring(formatTextStart, endOffset);
358
- initialIndentLevel = computeIndentLevel(formatText, options);
359
- }
360
- else {
361
- formatText = documentText;
362
- initialIndentLevel = 0;
363
- formatTextStart = 0;
364
- rangeStart = 0;
365
- rangeEnd = documentText.length;
366
- }
367
- const eol = getEOL(options, documentText);
368
- let numberLineBreaks = 0;
369
- let indentLevel = 0;
370
- let indentValue;
371
- if (options.insertSpaces) {
372
- indentValue = repeat(' ', options.tabSize || 4);
373
- }
374
- else {
375
- indentValue = '\t';
376
- }
377
- let scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(formatText, false);
378
- let hasError = false;
379
- function newLinesAndIndent() {
380
- if (numberLineBreaks > 1) {
381
- return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
382
- }
383
- else {
384
- return eol + repeat(indentValue, initialIndentLevel + indentLevel);
385
- }
386
- }
387
- function scanNext() {
388
- let token = scanner.scan();
389
- numberLineBreaks = 0;
390
- while (token === 15 /* SyntaxKind.Trivia */ || token === 14 /* SyntaxKind.LineBreakTrivia */) {
391
- if (token === 14 /* SyntaxKind.LineBreakTrivia */ && options.keepLines) {
392
- numberLineBreaks += 1;
393
- }
394
- else if (token === 14 /* SyntaxKind.LineBreakTrivia */) {
395
- numberLineBreaks = 1;
396
- }
397
- token = scanner.scan();
398
- }
399
- hasError = token === 16 /* SyntaxKind.Unknown */ || scanner.getTokenError() !== 0 /* ScanError.None */;
400
- return token;
401
- }
402
- const editOperations = [];
403
- function addEdit(text, startOffset, endOffset) {
404
- if (!hasError && (!range || (startOffset < rangeEnd && endOffset > rangeStart)) && documentText.substring(startOffset, endOffset) !== text) {
405
- editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
406
- }
407
- }
408
- let firstToken = scanNext();
409
- if (options.keepLines && numberLineBreaks > 0) {
410
- addEdit(repeat(eol, numberLineBreaks), 0, 0);
411
- }
412
- if (firstToken !== 17 /* SyntaxKind.EOF */) {
413
- let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
414
- let initialIndent = repeat(indentValue, initialIndentLevel);
415
- addEdit(initialIndent, formatTextStart, firstTokenStart);
416
- }
417
- while (firstToken !== 17 /* SyntaxKind.EOF */) {
418
- let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
419
- let secondToken = scanNext();
420
- let replaceContent = '';
421
- let needsLineBreak = false;
422
- while (numberLineBreaks === 0 && (secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */)) {
423
- let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
424
- addEdit(' ', firstTokenEnd, commentTokenStart);
425
- firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
426
- needsLineBreak = secondToken === 12 /* SyntaxKind.LineCommentTrivia */;
427
- replaceContent = needsLineBreak ? newLinesAndIndent() : '';
428
- secondToken = scanNext();
429
- }
430
- if (secondToken === 2 /* SyntaxKind.CloseBraceToken */) {
431
- if (firstToken !== 1 /* SyntaxKind.OpenBraceToken */) {
432
- indentLevel--;
433
- }
434
- ;
435
- if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1 /* SyntaxKind.OpenBraceToken */) {
436
- replaceContent = newLinesAndIndent();
437
- }
438
- else if (options.keepLines) {
439
- replaceContent = ' ';
440
- }
441
- }
442
- else if (secondToken === 4 /* SyntaxKind.CloseBracketToken */) {
443
- if (firstToken !== 3 /* SyntaxKind.OpenBracketToken */) {
444
- indentLevel--;
445
- }
446
- ;
447
- if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3 /* SyntaxKind.OpenBracketToken */) {
448
- replaceContent = newLinesAndIndent();
449
- }
450
- else if (options.keepLines) {
451
- replaceContent = ' ';
452
- }
453
- }
454
- else {
455
- switch (firstToken) {
456
- case 3 /* SyntaxKind.OpenBracketToken */:
457
- case 1 /* SyntaxKind.OpenBraceToken */:
458
- indentLevel++;
459
- if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
460
- replaceContent = newLinesAndIndent();
461
- }
462
- else {
463
- replaceContent = ' ';
464
- }
465
- break;
466
- case 5 /* SyntaxKind.CommaToken */:
467
- if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
468
- replaceContent = newLinesAndIndent();
469
- }
470
- else {
471
- replaceContent = ' ';
472
- }
473
- break;
474
- case 12 /* SyntaxKind.LineCommentTrivia */:
475
- replaceContent = newLinesAndIndent();
476
- break;
477
- case 13 /* SyntaxKind.BlockCommentTrivia */:
478
- if (numberLineBreaks > 0) {
479
- replaceContent = newLinesAndIndent();
480
- }
481
- else if (!needsLineBreak) {
482
- replaceContent = ' ';
483
- }
484
- break;
485
- case 6 /* SyntaxKind.ColonToken */:
486
- if (options.keepLines && numberLineBreaks > 0) {
487
- replaceContent = newLinesAndIndent();
488
- }
489
- else if (!needsLineBreak) {
490
- replaceContent = ' ';
491
- }
492
- break;
493
- case 10 /* SyntaxKind.StringLiteral */:
494
- if (options.keepLines && numberLineBreaks > 0) {
495
- replaceContent = newLinesAndIndent();
496
- }
497
- else if (secondToken === 6 /* SyntaxKind.ColonToken */ && !needsLineBreak) {
498
- replaceContent = '';
499
- }
500
- break;
501
- case 7 /* SyntaxKind.NullKeyword */:
502
- case 8 /* SyntaxKind.TrueKeyword */:
503
- case 9 /* SyntaxKind.FalseKeyword */:
504
- case 11 /* SyntaxKind.NumericLiteral */:
505
- case 2 /* SyntaxKind.CloseBraceToken */:
506
- case 4 /* SyntaxKind.CloseBracketToken */:
507
- if (options.keepLines && numberLineBreaks > 0) {
508
- replaceContent = newLinesAndIndent();
509
- }
510
- else {
511
- if ((secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */) && !needsLineBreak) {
512
- replaceContent = ' ';
513
- }
514
- else if (secondToken !== 5 /* SyntaxKind.CommaToken */ && secondToken !== 17 /* SyntaxKind.EOF */) {
515
- hasError = true;
516
- }
517
- }
518
- break;
519
- case 16 /* SyntaxKind.Unknown */:
520
- hasError = true;
521
- break;
522
- }
523
- if (numberLineBreaks > 0 && (secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */)) {
524
- replaceContent = newLinesAndIndent();
525
- }
526
- }
527
- if (secondToken === 17 /* SyntaxKind.EOF */) {
528
- if (options.keepLines && numberLineBreaks > 0) {
529
- replaceContent = newLinesAndIndent();
530
- }
531
- else {
532
- replaceContent = options.insertFinalNewline ? eol : '';
533
- }
534
- }
535
- const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
536
- addEdit(replaceContent, firstTokenEnd, secondTokenStart);
537
- firstToken = secondToken;
538
- }
539
- return editOperations;
540
- }
541
- function repeat(s, count) {
542
- let result = '';
543
- for (let i = 0; i < count; i++) {
544
- result += s;
545
- }
546
- return result;
547
- }
548
- function computeIndentLevel(content, options) {
549
- let i = 0;
550
- let nChars = 0;
551
- const tabSize = options.tabSize || 4;
552
- while (i < content.length) {
553
- let ch = content.charAt(i);
554
- if (ch === ' ') {
555
- nChars++;
556
- }
557
- else if (ch === '\t') {
558
- nChars += tabSize;
559
- }
560
- else {
561
- break;
562
- }
563
- i++;
564
- }
565
- return Math.floor(nChars / tabSize);
566
- }
567
- function getEOL(options, text) {
568
- for (let i = 0; i < text.length; i++) {
569
- const ch = text.charAt(i);
570
- if (ch === '\r') {
571
- if (i + 1 < text.length && text.charAt(i + 1) === '\n') {
572
- return '\r\n';
573
- }
574
- return '\r';
575
- }
576
- else if (ch === '\n') {
577
- return '\n';
578
- }
579
- }
580
- return (options && options.eol) || '\n';
581
- }
582
- function isEOL(text, offset) {
583
- return '\r\n'.indexOf(text.charAt(offset)) !== -1;
584
- }
585
-
586
-
587
- /***/ }),
588
- /* 5 */
589
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
590
-
591
- __webpack_require__.r(__webpack_exports__);
592
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
593
- /* harmony export */ "createScanner": () => (/* binding */ createScanner)
594
- /* harmony export */ });
595
- /*---------------------------------------------------------------------------------------------
596
- * Copyright (c) Microsoft Corporation. All rights reserved.
597
- * Licensed under the MIT License. See License.txt in the project root for license information.
598
- *--------------------------------------------------------------------------------------------*/
599
-
600
- /**
601
- * Creates a JSON scanner on the given text.
602
- * If ignoreTrivia is set, whitespaces or comments are ignored.
603
- */
604
- function createScanner(text, ignoreTrivia = false) {
605
- const len = text.length;
606
- let pos = 0, value = '', tokenOffset = 0, token = 16 /* SyntaxKind.Unknown */, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0 /* ScanError.None */;
607
- function scanHexDigits(count, exact) {
608
- let digits = 0;
609
- let value = 0;
610
- while (digits < count || !exact) {
611
- let ch = text.charCodeAt(pos);
612
- if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) {
613
- value = value * 16 + ch - 48 /* CharacterCodes._0 */;
614
- }
615
- else if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) {
616
- value = value * 16 + ch - 65 /* CharacterCodes.A */ + 10;
617
- }
618
- else if (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */) {
619
- value = value * 16 + ch - 97 /* CharacterCodes.a */ + 10;
620
- }
621
- else {
622
- break;
623
- }
624
- pos++;
625
- digits++;
626
- }
627
- if (digits < count) {
628
- value = -1;
629
- }
630
- return value;
631
- }
632
- function setPosition(newPosition) {
633
- pos = newPosition;
634
- value = '';
635
- tokenOffset = 0;
636
- token = 16 /* SyntaxKind.Unknown */;
637
- scanError = 0 /* ScanError.None */;
638
- }
639
- function scanNumber() {
640
- let start = pos;
641
- if (text.charCodeAt(pos) === 48 /* CharacterCodes._0 */) {
642
- pos++;
643
- }
644
- else {
645
- pos++;
646
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
647
- pos++;
648
- }
649
- }
650
- if (pos < text.length && text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) {
651
- pos++;
652
- if (pos < text.length && isDigit(text.charCodeAt(pos))) {
653
- pos++;
654
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
655
- pos++;
656
- }
657
- }
658
- else {
659
- scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
660
- return text.substring(start, pos);
661
- }
662
- }
663
- let end = pos;
664
- if (pos < text.length && (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */)) {
665
- pos++;
666
- if (pos < text.length && text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) {
667
- pos++;
668
- }
669
- if (pos < text.length && isDigit(text.charCodeAt(pos))) {
670
- pos++;
671
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
672
- pos++;
673
- }
674
- end = pos;
675
- }
676
- else {
677
- scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
678
- }
679
- }
680
- return text.substring(start, end);
681
- }
682
- function scanString() {
683
- let result = '', start = pos;
684
- while (true) {
685
- if (pos >= len) {
686
- result += text.substring(start, pos);
687
- scanError = 2 /* ScanError.UnexpectedEndOfString */;
688
- break;
689
- }
690
- const ch = text.charCodeAt(pos);
691
- if (ch === 34 /* CharacterCodes.doubleQuote */) {
692
- result += text.substring(start, pos);
693
- pos++;
694
- break;
695
- }
696
- if (ch === 92 /* CharacterCodes.backslash */) {
697
- result += text.substring(start, pos);
698
- pos++;
699
- if (pos >= len) {
700
- scanError = 2 /* ScanError.UnexpectedEndOfString */;
701
- break;
702
- }
703
- const ch2 = text.charCodeAt(pos++);
704
- switch (ch2) {
705
- case 34 /* CharacterCodes.doubleQuote */:
706
- result += '\"';
707
- break;
708
- case 92 /* CharacterCodes.backslash */:
709
- result += '\\';
710
- break;
711
- case 47 /* CharacterCodes.slash */:
712
- result += '/';
713
- break;
714
- case 98 /* CharacterCodes.b */:
715
- result += '\b';
716
- break;
717
- case 102 /* CharacterCodes.f */:
718
- result += '\f';
719
- break;
720
- case 110 /* CharacterCodes.n */:
721
- result += '\n';
722
- break;
723
- case 114 /* CharacterCodes.r */:
724
- result += '\r';
725
- break;
726
- case 116 /* CharacterCodes.t */:
727
- result += '\t';
728
- break;
729
- case 117 /* CharacterCodes.u */:
730
- const ch3 = scanHexDigits(4, true);
731
- if (ch3 >= 0) {
732
- result += String.fromCharCode(ch3);
733
- }
734
- else {
735
- scanError = 4 /* ScanError.InvalidUnicode */;
736
- }
737
- break;
738
- default:
739
- scanError = 5 /* ScanError.InvalidEscapeCharacter */;
740
- }
741
- start = pos;
742
- continue;
743
- }
744
- if (ch >= 0 && ch <= 0x1f) {
745
- if (isLineBreak(ch)) {
746
- result += text.substring(start, pos);
747
- scanError = 2 /* ScanError.UnexpectedEndOfString */;
748
- break;
749
- }
750
- else {
751
- scanError = 6 /* ScanError.InvalidCharacter */;
752
- // mark as error but continue with string
753
- }
754
- }
755
- pos++;
756
- }
757
- return result;
758
- }
759
- function scanNext() {
760
- value = '';
761
- scanError = 0 /* ScanError.None */;
762
- tokenOffset = pos;
763
- lineStartOffset = lineNumber;
764
- prevTokenLineStartOffset = tokenLineStartOffset;
765
- if (pos >= len) {
766
- // at the end
767
- tokenOffset = len;
768
- return token = 17 /* SyntaxKind.EOF */;
769
- }
770
- let code = text.charCodeAt(pos);
771
- // trivia: whitespace
772
- if (isWhiteSpace(code)) {
773
- do {
774
- pos++;
775
- value += String.fromCharCode(code);
776
- code = text.charCodeAt(pos);
777
- } while (isWhiteSpace(code));
778
- return token = 15 /* SyntaxKind.Trivia */;
779
- }
780
- // trivia: newlines
781
- if (isLineBreak(code)) {
782
- pos++;
783
- value += String.fromCharCode(code);
784
- if (code === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
785
- pos++;
786
- value += '\n';
787
- }
788
- lineNumber++;
789
- tokenLineStartOffset = pos;
790
- return token = 14 /* SyntaxKind.LineBreakTrivia */;
791
- }
792
- switch (code) {
793
- // tokens: []{}:,
794
- case 123 /* CharacterCodes.openBrace */:
795
- pos++;
796
- return token = 1 /* SyntaxKind.OpenBraceToken */;
797
- case 125 /* CharacterCodes.closeBrace */:
798
- pos++;
799
- return token = 2 /* SyntaxKind.CloseBraceToken */;
800
- case 91 /* CharacterCodes.openBracket */:
801
- pos++;
802
- return token = 3 /* SyntaxKind.OpenBracketToken */;
803
- case 93 /* CharacterCodes.closeBracket */:
804
- pos++;
805
- return token = 4 /* SyntaxKind.CloseBracketToken */;
806
- case 58 /* CharacterCodes.colon */:
807
- pos++;
808
- return token = 6 /* SyntaxKind.ColonToken */;
809
- case 44 /* CharacterCodes.comma */:
810
- pos++;
811
- return token = 5 /* SyntaxKind.CommaToken */;
812
- // strings
813
- case 34 /* CharacterCodes.doubleQuote */:
814
- pos++;
815
- value = scanString();
816
- return token = 10 /* SyntaxKind.StringLiteral */;
817
- // comments
818
- case 47 /* CharacterCodes.slash */:
819
- const start = pos - 1;
820
- // Single-line comment
821
- if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
822
- pos += 2;
823
- while (pos < len) {
824
- if (isLineBreak(text.charCodeAt(pos))) {
825
- break;
826
- }
827
- pos++;
828
- }
829
- value = text.substring(start, pos);
830
- return token = 12 /* SyntaxKind.LineCommentTrivia */;
831
- }
832
- // Multi-line comment
833
- if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
834
- pos += 2;
835
- const safeLength = len - 1; // For lookahead.
836
- let commentClosed = false;
837
- while (pos < safeLength) {
838
- const ch = text.charCodeAt(pos);
839
- if (ch === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
840
- pos += 2;
841
- commentClosed = true;
842
- break;
843
- }
844
- pos++;
845
- if (isLineBreak(ch)) {
846
- if (ch === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
847
- pos++;
848
- }
849
- lineNumber++;
850
- tokenLineStartOffset = pos;
851
- }
852
- }
853
- if (!commentClosed) {
854
- pos++;
855
- scanError = 1 /* ScanError.UnexpectedEndOfComment */;
856
- }
857
- value = text.substring(start, pos);
858
- return token = 13 /* SyntaxKind.BlockCommentTrivia */;
859
- }
860
- // just a single slash
861
- value += String.fromCharCode(code);
862
- pos++;
863
- return token = 16 /* SyntaxKind.Unknown */;
864
- // numbers
865
- case 45 /* CharacterCodes.minus */:
866
- value += String.fromCharCode(code);
867
- pos++;
868
- if (pos === len || !isDigit(text.charCodeAt(pos))) {
869
- return token = 16 /* SyntaxKind.Unknown */;
870
- }
871
- // found a minus, followed by a number so
872
- // we fall through to proceed with scanning
873
- // numbers
874
- case 48 /* CharacterCodes._0 */:
875
- case 49 /* CharacterCodes._1 */:
876
- case 50 /* CharacterCodes._2 */:
877
- case 51 /* CharacterCodes._3 */:
878
- case 52 /* CharacterCodes._4 */:
879
- case 53 /* CharacterCodes._5 */:
880
- case 54 /* CharacterCodes._6 */:
881
- case 55 /* CharacterCodes._7 */:
882
- case 56 /* CharacterCodes._8 */:
883
- case 57 /* CharacterCodes._9 */:
884
- value += scanNumber();
885
- return token = 11 /* SyntaxKind.NumericLiteral */;
886
- // literals and unknown symbols
887
- default:
888
- // is a literal? Read the full word.
889
- while (pos < len && isUnknownContentCharacter(code)) {
890
- pos++;
891
- code = text.charCodeAt(pos);
892
- }
893
- if (tokenOffset !== pos) {
894
- value = text.substring(tokenOffset, pos);
895
- // keywords: true, false, null
896
- switch (value) {
897
- case 'true': return token = 8 /* SyntaxKind.TrueKeyword */;
898
- case 'false': return token = 9 /* SyntaxKind.FalseKeyword */;
899
- case 'null': return token = 7 /* SyntaxKind.NullKeyword */;
900
- }
901
- return token = 16 /* SyntaxKind.Unknown */;
902
- }
903
- // some
904
- value += String.fromCharCode(code);
905
- pos++;
906
- return token = 16 /* SyntaxKind.Unknown */;
907
- }
908
- }
909
- function isUnknownContentCharacter(code) {
910
- if (isWhiteSpace(code) || isLineBreak(code)) {
911
- return false;
912
- }
913
- switch (code) {
914
- case 125 /* CharacterCodes.closeBrace */:
915
- case 93 /* CharacterCodes.closeBracket */:
916
- case 123 /* CharacterCodes.openBrace */:
917
- case 91 /* CharacterCodes.openBracket */:
918
- case 34 /* CharacterCodes.doubleQuote */:
919
- case 58 /* CharacterCodes.colon */:
920
- case 44 /* CharacterCodes.comma */:
921
- case 47 /* CharacterCodes.slash */:
922
- return false;
923
- }
924
- return true;
925
- }
926
- function scanNextNonTrivia() {
927
- let result;
928
- do {
929
- result = scanNext();
930
- } while (result >= 12 /* SyntaxKind.LineCommentTrivia */ && result <= 15 /* SyntaxKind.Trivia */);
931
- return result;
932
- }
933
- return {
934
- setPosition: setPosition,
935
- getPosition: () => pos,
936
- scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
937
- getToken: () => token,
938
- getTokenValue: () => value,
939
- getTokenOffset: () => tokenOffset,
940
- getTokenLength: () => pos - tokenOffset,
941
- getTokenStartLine: () => lineStartOffset,
942
- getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
943
- getTokenError: () => scanError,
944
- };
945
- }
946
- function isWhiteSpace(ch) {
947
- return ch === 32 /* CharacterCodes.space */ || ch === 9 /* CharacterCodes.tab */;
948
- }
949
- function isLineBreak(ch) {
950
- return ch === 10 /* CharacterCodes.lineFeed */ || ch === 13 /* CharacterCodes.carriageReturn */;
951
- }
952
- function isDigit(ch) {
953
- return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */;
954
- }
955
- var CharacterCodes;
956
- (function (CharacterCodes) {
957
- CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
958
- CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
959
- CharacterCodes[CharacterCodes["space"] = 32] = "space";
960
- CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
961
- CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
962
- CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
963
- CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
964
- CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
965
- CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
966
- CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
967
- CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
968
- CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
969
- CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
970
- CharacterCodes[CharacterCodes["a"] = 97] = "a";
971
- CharacterCodes[CharacterCodes["b"] = 98] = "b";
972
- CharacterCodes[CharacterCodes["c"] = 99] = "c";
973
- CharacterCodes[CharacterCodes["d"] = 100] = "d";
974
- CharacterCodes[CharacterCodes["e"] = 101] = "e";
975
- CharacterCodes[CharacterCodes["f"] = 102] = "f";
976
- CharacterCodes[CharacterCodes["g"] = 103] = "g";
977
- CharacterCodes[CharacterCodes["h"] = 104] = "h";
978
- CharacterCodes[CharacterCodes["i"] = 105] = "i";
979
- CharacterCodes[CharacterCodes["j"] = 106] = "j";
980
- CharacterCodes[CharacterCodes["k"] = 107] = "k";
981
- CharacterCodes[CharacterCodes["l"] = 108] = "l";
982
- CharacterCodes[CharacterCodes["m"] = 109] = "m";
983
- CharacterCodes[CharacterCodes["n"] = 110] = "n";
984
- CharacterCodes[CharacterCodes["o"] = 111] = "o";
985
- CharacterCodes[CharacterCodes["p"] = 112] = "p";
986
- CharacterCodes[CharacterCodes["q"] = 113] = "q";
987
- CharacterCodes[CharacterCodes["r"] = 114] = "r";
988
- CharacterCodes[CharacterCodes["s"] = 115] = "s";
989
- CharacterCodes[CharacterCodes["t"] = 116] = "t";
990
- CharacterCodes[CharacterCodes["u"] = 117] = "u";
991
- CharacterCodes[CharacterCodes["v"] = 118] = "v";
992
- CharacterCodes[CharacterCodes["w"] = 119] = "w";
993
- CharacterCodes[CharacterCodes["x"] = 120] = "x";
994
- CharacterCodes[CharacterCodes["y"] = 121] = "y";
995
- CharacterCodes[CharacterCodes["z"] = 122] = "z";
996
- CharacterCodes[CharacterCodes["A"] = 65] = "A";
997
- CharacterCodes[CharacterCodes["B"] = 66] = "B";
998
- CharacterCodes[CharacterCodes["C"] = 67] = "C";
999
- CharacterCodes[CharacterCodes["D"] = 68] = "D";
1000
- CharacterCodes[CharacterCodes["E"] = 69] = "E";
1001
- CharacterCodes[CharacterCodes["F"] = 70] = "F";
1002
- CharacterCodes[CharacterCodes["G"] = 71] = "G";
1003
- CharacterCodes[CharacterCodes["H"] = 72] = "H";
1004
- CharacterCodes[CharacterCodes["I"] = 73] = "I";
1005
- CharacterCodes[CharacterCodes["J"] = 74] = "J";
1006
- CharacterCodes[CharacterCodes["K"] = 75] = "K";
1007
- CharacterCodes[CharacterCodes["L"] = 76] = "L";
1008
- CharacterCodes[CharacterCodes["M"] = 77] = "M";
1009
- CharacterCodes[CharacterCodes["N"] = 78] = "N";
1010
- CharacterCodes[CharacterCodes["O"] = 79] = "O";
1011
- CharacterCodes[CharacterCodes["P"] = 80] = "P";
1012
- CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
1013
- CharacterCodes[CharacterCodes["R"] = 82] = "R";
1014
- CharacterCodes[CharacterCodes["S"] = 83] = "S";
1015
- CharacterCodes[CharacterCodes["T"] = 84] = "T";
1016
- CharacterCodes[CharacterCodes["U"] = 85] = "U";
1017
- CharacterCodes[CharacterCodes["V"] = 86] = "V";
1018
- CharacterCodes[CharacterCodes["W"] = 87] = "W";
1019
- CharacterCodes[CharacterCodes["X"] = 88] = "X";
1020
- CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
1021
- CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
1022
- CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
1023
- CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
1024
- CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
1025
- CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
1026
- CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
1027
- CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
1028
- CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
1029
- CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
1030
- CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
1031
- CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
1032
- CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
1033
- CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
1034
- CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
1035
- CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
1036
- CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
1037
- })(CharacterCodes || (CharacterCodes = {}));
1038
-
1039
-
1040
- /***/ }),
1041
- /* 6 */
1042
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1043
-
1044
- __webpack_require__.r(__webpack_exports__);
1045
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1046
- /* harmony export */ "applyEdit": () => (/* binding */ applyEdit),
1047
- /* harmony export */ "isWS": () => (/* binding */ isWS),
1048
- /* harmony export */ "removeProperty": () => (/* binding */ removeProperty),
1049
- /* harmony export */ "setProperty": () => (/* binding */ setProperty)
1050
- /* harmony export */ });
1051
- /* harmony import */ var _format__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
1052
- /* harmony import */ var _parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
1053
- /*---------------------------------------------------------------------------------------------
1054
- * Copyright (c) Microsoft Corporation. All rights reserved.
1055
- * Licensed under the MIT License. See License.txt in the project root for license information.
1056
- *--------------------------------------------------------------------------------------------*/
1057
-
1058
-
1059
-
1060
- function removeProperty(text, path, options) {
1061
- return setProperty(text, path, void 0, options);
1062
- }
1063
- function setProperty(text, originalPath, value, options) {
1064
- const path = originalPath.slice();
1065
- const errors = [];
1066
- const root = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.parseTree)(text, errors);
1067
- let parent = void 0;
1068
- let lastSegment = void 0;
1069
- while (path.length > 0) {
1070
- lastSegment = path.pop();
1071
- parent = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.findNodeAtLocation)(root, path);
1072
- if (parent === void 0 && value !== void 0) {
1073
- if (typeof lastSegment === 'string') {
1074
- value = { [lastSegment]: value };
1075
- }
1076
- else {
1077
- value = [value];
1078
- }
1079
- }
1080
- else {
1081
- break;
1082
- }
1083
- }
1084
- if (!parent) {
1085
- // empty document
1086
- if (value === void 0) { // delete
1087
- throw new Error('Can not delete in empty document');
1088
- }
1089
- return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
1090
- }
1091
- else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {
1092
- const existing = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.findNodeAtLocation)(parent, [lastSegment]);
1093
- if (existing !== void 0) {
1094
- if (value === void 0) { // delete
1095
- if (!existing.parent) {
1096
- throw new Error('Malformed AST');
1097
- }
1098
- const propertyIndex = parent.children.indexOf(existing.parent);
1099
- let removeBegin;
1100
- let removeEnd = existing.parent.offset + existing.parent.length;
1101
- if (propertyIndex > 0) {
1102
- // remove the comma of the previous node
1103
- let previous = parent.children[propertyIndex - 1];
1104
- removeBegin = previous.offset + previous.length;
1105
- }
1106
- else {
1107
- removeBegin = parent.offset + 1;
1108
- if (parent.children.length > 1) {
1109
- // remove the comma of the next node
1110
- let next = parent.children[1];
1111
- removeEnd = next.offset;
1112
- }
1113
- }
1114
- return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: '' }, options);
1115
- }
1116
- else {
1117
- // set value of existing property
1118
- return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
1119
- }
1120
- }
1121
- else {
1122
- if (value === void 0) { // delete
1123
- return []; // property does not exist, nothing to do
1124
- }
1125
- const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
1126
- const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map(p => p.children[0].value)) : parent.children.length;
1127
- let edit;
1128
- if (index > 0) {
1129
- let previous = parent.children[index - 1];
1130
- edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
1131
- }
1132
- else if (parent.children.length === 0) {
1133
- edit = { offset: parent.offset + 1, length: 0, content: newProperty };
1134
- }
1135
- else {
1136
- edit = { offset: parent.offset + 1, length: 0, content: newProperty + ',' };
1137
- }
1138
- return withFormatting(text, edit, options);
1139
- }
1140
- }
1141
- else if (parent.type === 'array' && typeof lastSegment === 'number' && Array.isArray(parent.children)) {
1142
- const insertIndex = lastSegment;
1143
- if (insertIndex === -1) {
1144
- // Insert
1145
- const newProperty = `${JSON.stringify(value)}`;
1146
- let edit;
1147
- if (parent.children.length === 0) {
1148
- edit = { offset: parent.offset + 1, length: 0, content: newProperty };
1149
- }
1150
- else {
1151
- const previous = parent.children[parent.children.length - 1];
1152
- edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
1153
- }
1154
- return withFormatting(text, edit, options);
1155
- }
1156
- else if (value === void 0 && parent.children.length >= 0) {
1157
- // Removal
1158
- const removalIndex = lastSegment;
1159
- const toRemove = parent.children[removalIndex];
1160
- let edit;
1161
- if (parent.children.length === 1) {
1162
- // only item
1163
- edit = { offset: parent.offset + 1, length: parent.length - 2, content: '' };
1164
- }
1165
- else if (parent.children.length - 1 === removalIndex) {
1166
- // last item
1167
- let previous = parent.children[removalIndex - 1];
1168
- let offset = previous.offset + previous.length;
1169
- let parentEndOffset = parent.offset + parent.length;
1170
- edit = { offset, length: parentEndOffset - 2 - offset, content: '' };
1171
- }
1172
- else {
1173
- edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: '' };
1174
- }
1175
- return withFormatting(text, edit, options);
1176
- }
1177
- else if (value !== void 0) {
1178
- let edit;
1179
- const newProperty = `${JSON.stringify(value)}`;
1180
- if (!options.isArrayInsertion && parent.children.length > lastSegment) {
1181
- const toModify = parent.children[lastSegment];
1182
- edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
1183
- }
1184
- else if (parent.children.length === 0 || lastSegment === 0) {
1185
- edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + ',' };
1186
- }
1187
- else {
1188
- const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
1189
- const previous = parent.children[index - 1];
1190
- edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
1191
- }
1192
- return withFormatting(text, edit, options);
1193
- }
1194
- else {
1195
- throw new Error(`Can not ${value === void 0 ? 'remove' : (options.isArrayInsertion ? 'insert' : 'modify')} Array index ${insertIndex} as length is not sufficient`);
1196
- }
1197
- }
1198
- else {
1199
- throw new Error(`Can not add ${typeof lastSegment !== 'number' ? 'index' : 'property'} to parent of type ${parent.type}`);
1200
- }
1201
- }
1202
- function withFormatting(text, edit, options) {
1203
- if (!options.formattingOptions) {
1204
- return [edit];
1205
- }
1206
- // apply the edit
1207
- let newText = applyEdit(text, edit);
1208
- // format the new text
1209
- let begin = edit.offset;
1210
- let end = edit.offset + edit.content.length;
1211
- if (edit.length === 0 || edit.content.length === 0) { // insert or remove
1212
- while (begin > 0 && !(0,_format__WEBPACK_IMPORTED_MODULE_0__.isEOL)(newText, begin - 1)) {
1213
- begin--;
1214
- }
1215
- while (end < newText.length && !(0,_format__WEBPACK_IMPORTED_MODULE_0__.isEOL)(newText, end)) {
1216
- end++;
1217
- }
1218
- }
1219
- const edits = (0,_format__WEBPACK_IMPORTED_MODULE_0__.format)(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
1220
- // apply the formatting edits and track the begin and end offsets of the changes
1221
- for (let i = edits.length - 1; i >= 0; i--) {
1222
- const edit = edits[i];
1223
- newText = applyEdit(newText, edit);
1224
- begin = Math.min(begin, edit.offset);
1225
- end = Math.max(end, edit.offset + edit.length);
1226
- end += edit.content.length - edit.length;
1227
- }
1228
- // create a single edit with all changes
1229
- const editLength = text.length - (newText.length - end) - begin;
1230
- return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
1231
- }
1232
- function applyEdit(text, edit) {
1233
- return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
1234
- }
1235
- function isWS(text, offset) {
1236
- return '\r\n \t'.indexOf(text.charAt(offset)) !== -1;
1237
- }
1238
-
1239
-
1240
- /***/ }),
1241
- /* 7 */
1242
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1243
-
1244
- __webpack_require__.r(__webpack_exports__);
1245
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1246
- /* harmony export */ "contains": () => (/* binding */ contains),
1247
- /* harmony export */ "findNodeAtLocation": () => (/* binding */ findNodeAtLocation),
1248
- /* harmony export */ "findNodeAtOffset": () => (/* binding */ findNodeAtOffset),
1249
- /* harmony export */ "getLocation": () => (/* binding */ getLocation),
1250
- /* harmony export */ "getNodePath": () => (/* binding */ getNodePath),
1251
- /* harmony export */ "getNodeType": () => (/* binding */ getNodeType),
1252
- /* harmony export */ "getNodeValue": () => (/* binding */ getNodeValue),
1253
- /* harmony export */ "parse": () => (/* binding */ parse),
1254
- /* harmony export */ "parseTree": () => (/* binding */ parseTree),
1255
- /* harmony export */ "stripComments": () => (/* binding */ stripComments),
1256
- /* harmony export */ "visit": () => (/* binding */ visit)
1257
- /* harmony export */ });
1258
- /* harmony import */ var _scanner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
1259
- /*---------------------------------------------------------------------------------------------
1260
- * Copyright (c) Microsoft Corporation. All rights reserved.
1261
- * Licensed under the MIT License. See License.txt in the project root for license information.
1262
- *--------------------------------------------------------------------------------------------*/
1263
-
1264
-
1265
- var ParseOptions;
1266
- (function (ParseOptions) {
1267
- ParseOptions.DEFAULT = {
1268
- allowTrailingComma: false
1269
- };
1270
- })(ParseOptions || (ParseOptions = {}));
1271
- /**
1272
- * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
1273
- */
1274
- function getLocation(text, position) {
1275
- const segments = []; // strings or numbers
1276
- const earlyReturnException = new Object();
1277
- let previousNode = undefined;
1278
- const previousNodeInst = {
1279
- value: {},
1280
- offset: 0,
1281
- length: 0,
1282
- type: 'object',
1283
- parent: undefined
1284
- };
1285
- let isAtPropertyKey = false;
1286
- function setPreviousNode(value, offset, length, type) {
1287
- previousNodeInst.value = value;
1288
- previousNodeInst.offset = offset;
1289
- previousNodeInst.length = length;
1290
- previousNodeInst.type = type;
1291
- previousNodeInst.colonOffset = undefined;
1292
- previousNode = previousNodeInst;
1293
- }
1294
- try {
1295
- visit(text, {
1296
- onObjectBegin: (offset, length) => {
1297
- if (position <= offset) {
1298
- throw earlyReturnException;
1299
- }
1300
- previousNode = undefined;
1301
- isAtPropertyKey = position > offset;
1302
- segments.push(''); // push a placeholder (will be replaced)
1303
- },
1304
- onObjectProperty: (name, offset, length) => {
1305
- if (position < offset) {
1306
- throw earlyReturnException;
1307
- }
1308
- setPreviousNode(name, offset, length, 'property');
1309
- segments[segments.length - 1] = name;
1310
- if (position <= offset + length) {
1311
- throw earlyReturnException;
1312
- }
1313
- },
1314
- onObjectEnd: (offset, length) => {
1315
- if (position <= offset) {
1316
- throw earlyReturnException;
1317
- }
1318
- previousNode = undefined;
1319
- segments.pop();
1320
- },
1321
- onArrayBegin: (offset, length) => {
1322
- if (position <= offset) {
1323
- throw earlyReturnException;
1324
- }
1325
- previousNode = undefined;
1326
- segments.push(0);
1327
- },
1328
- onArrayEnd: (offset, length) => {
1329
- if (position <= offset) {
1330
- throw earlyReturnException;
1331
- }
1332
- previousNode = undefined;
1333
- segments.pop();
1334
- },
1335
- onLiteralValue: (value, offset, length) => {
1336
- if (position < offset) {
1337
- throw earlyReturnException;
1338
- }
1339
- setPreviousNode(value, offset, length, getNodeType(value));
1340
- if (position <= offset + length) {
1341
- throw earlyReturnException;
1342
- }
1343
- },
1344
- onSeparator: (sep, offset, length) => {
1345
- if (position <= offset) {
1346
- throw earlyReturnException;
1347
- }
1348
- if (sep === ':' && previousNode && previousNode.type === 'property') {
1349
- previousNode.colonOffset = offset;
1350
- isAtPropertyKey = false;
1351
- previousNode = undefined;
1352
- }
1353
- else if (sep === ',') {
1354
- const last = segments[segments.length - 1];
1355
- if (typeof last === 'number') {
1356
- segments[segments.length - 1] = last + 1;
1357
- }
1358
- else {
1359
- isAtPropertyKey = true;
1360
- segments[segments.length - 1] = '';
1361
- }
1362
- previousNode = undefined;
1363
- }
1364
- }
1365
- });
1366
- }
1367
- catch (e) {
1368
- if (e !== earlyReturnException) {
1369
- throw e;
1370
- }
1371
- }
1372
- return {
1373
- path: segments,
1374
- previousNode,
1375
- isAtPropertyKey,
1376
- matches: (pattern) => {
1377
- let k = 0;
1378
- for (let i = 0; k < pattern.length && i < segments.length; i++) {
1379
- if (pattern[k] === segments[i] || pattern[k] === '*') {
1380
- k++;
1381
- }
1382
- else if (pattern[k] !== '**') {
1383
- return false;
1384
- }
1385
- }
1386
- return k === pattern.length;
1387
- }
1388
- };
1389
- }
1390
- /**
1391
- * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
1392
- * Therefore always check the errors list to find out if the input was valid.
1393
- */
1394
- function parse(text, errors = [], options = ParseOptions.DEFAULT) {
1395
- let currentProperty = null;
1396
- let currentParent = [];
1397
- const previousParents = [];
1398
- function onValue(value) {
1399
- if (Array.isArray(currentParent)) {
1400
- currentParent.push(value);
1401
- }
1402
- else if (currentProperty !== null) {
1403
- currentParent[currentProperty] = value;
1404
- }
1405
- }
1406
- const visitor = {
1407
- onObjectBegin: () => {
1408
- const object = {};
1409
- onValue(object);
1410
- previousParents.push(currentParent);
1411
- currentParent = object;
1412
- currentProperty = null;
1413
- },
1414
- onObjectProperty: (name) => {
1415
- currentProperty = name;
1416
- },
1417
- onObjectEnd: () => {
1418
- currentParent = previousParents.pop();
1419
- },
1420
- onArrayBegin: () => {
1421
- const array = [];
1422
- onValue(array);
1423
- previousParents.push(currentParent);
1424
- currentParent = array;
1425
- currentProperty = null;
1426
- },
1427
- onArrayEnd: () => {
1428
- currentParent = previousParents.pop();
1429
- },
1430
- onLiteralValue: onValue,
1431
- onError: (error, offset, length) => {
1432
- errors.push({ error, offset, length });
1433
- }
1434
- };
1435
- visit(text, visitor, options);
1436
- return currentParent[0];
1437
- }
1438
- /**
1439
- * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
1440
- */
1441
- function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
1442
- let currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root
1443
- function ensurePropertyComplete(endOffset) {
1444
- if (currentParent.type === 'property') {
1445
- currentParent.length = endOffset - currentParent.offset;
1446
- currentParent = currentParent.parent;
1447
- }
1448
- }
1449
- function onValue(valueNode) {
1450
- currentParent.children.push(valueNode);
1451
- return valueNode;
1452
- }
1453
- const visitor = {
1454
- onObjectBegin: (offset) => {
1455
- currentParent = onValue({ type: 'object', offset, length: -1, parent: currentParent, children: [] });
1456
- },
1457
- onObjectProperty: (name, offset, length) => {
1458
- currentParent = onValue({ type: 'property', offset, length: -1, parent: currentParent, children: [] });
1459
- currentParent.children.push({ type: 'string', value: name, offset, length, parent: currentParent });
1460
- },
1461
- onObjectEnd: (offset, length) => {
1462
- ensurePropertyComplete(offset + length); // in case of a missing value for a property: make sure property is complete
1463
- currentParent.length = offset + length - currentParent.offset;
1464
- currentParent = currentParent.parent;
1465
- ensurePropertyComplete(offset + length);
1466
- },
1467
- onArrayBegin: (offset, length) => {
1468
- currentParent = onValue({ type: 'array', offset, length: -1, parent: currentParent, children: [] });
1469
- },
1470
- onArrayEnd: (offset, length) => {
1471
- currentParent.length = offset + length - currentParent.offset;
1472
- currentParent = currentParent.parent;
1473
- ensurePropertyComplete(offset + length);
1474
- },
1475
- onLiteralValue: (value, offset, length) => {
1476
- onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
1477
- ensurePropertyComplete(offset + length);
1478
- },
1479
- onSeparator: (sep, offset, length) => {
1480
- if (currentParent.type === 'property') {
1481
- if (sep === ':') {
1482
- currentParent.colonOffset = offset;
1483
- }
1484
- else if (sep === ',') {
1485
- ensurePropertyComplete(offset);
1486
- }
1487
- }
1488
- },
1489
- onError: (error, offset, length) => {
1490
- errors.push({ error, offset, length });
1491
- }
1492
- };
1493
- visit(text, visitor, options);
1494
- const result = currentParent.children[0];
1495
- if (result) {
1496
- delete result.parent;
1497
- }
1498
- return result;
1499
- }
1500
- /**
1501
- * Finds the node at the given path in a JSON DOM.
1502
- */
1503
- function findNodeAtLocation(root, path) {
1504
- if (!root) {
1505
- return undefined;
1506
- }
1507
- let node = root;
1508
- for (let segment of path) {
1509
- if (typeof segment === 'string') {
1510
- if (node.type !== 'object' || !Array.isArray(node.children)) {
1511
- return undefined;
1512
- }
1513
- let found = false;
1514
- for (const propertyNode of node.children) {
1515
- if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
1516
- node = propertyNode.children[1];
1517
- found = true;
1518
- break;
1519
- }
1520
- }
1521
- if (!found) {
1522
- return undefined;
1523
- }
1524
- }
1525
- else {
1526
- const index = segment;
1527
- if (node.type !== 'array' || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
1528
- return undefined;
1529
- }
1530
- node = node.children[index];
1531
- }
1532
- }
1533
- return node;
1534
- }
1535
- /**
1536
- * Gets the JSON path of the given JSON DOM node
1537
- */
1538
- function getNodePath(node) {
1539
- if (!node.parent || !node.parent.children) {
1540
- return [];
1541
- }
1542
- const path = getNodePath(node.parent);
1543
- if (node.parent.type === 'property') {
1544
- const key = node.parent.children[0].value;
1545
- path.push(key);
1546
- }
1547
- else if (node.parent.type === 'array') {
1548
- const index = node.parent.children.indexOf(node);
1549
- if (index !== -1) {
1550
- path.push(index);
1551
- }
1552
- }
1553
- return path;
1554
- }
1555
- /**
1556
- * Evaluates the JavaScript object of the given JSON DOM node
1557
- */
1558
- function getNodeValue(node) {
1559
- switch (node.type) {
1560
- case 'array':
1561
- return node.children.map(getNodeValue);
1562
- case 'object':
1563
- const obj = Object.create(null);
1564
- for (let prop of node.children) {
1565
- const valueNode = prop.children[1];
1566
- if (valueNode) {
1567
- obj[prop.children[0].value] = getNodeValue(valueNode);
1568
- }
1569
- }
1570
- return obj;
1571
- case 'null':
1572
- case 'string':
1573
- case 'number':
1574
- case 'boolean':
1575
- return node.value;
1576
- default:
1577
- return undefined;
1578
- }
1579
- }
1580
- function contains(node, offset, includeRightBound = false) {
1581
- return (offset >= node.offset && offset < (node.offset + node.length)) || includeRightBound && (offset === (node.offset + node.length));
1582
- }
1583
- /**
1584
- * Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
1585
- */
1586
- function findNodeAtOffset(node, offset, includeRightBound = false) {
1587
- if (contains(node, offset, includeRightBound)) {
1588
- const children = node.children;
1589
- if (Array.isArray(children)) {
1590
- for (let i = 0; i < children.length && children[i].offset <= offset; i++) {
1591
- const item = findNodeAtOffset(children[i], offset, includeRightBound);
1592
- if (item) {
1593
- return item;
1594
- }
1595
- }
1596
- }
1597
- return node;
1598
- }
1599
- return undefined;
1600
- }
1601
- /**
1602
- * Parses the given text and invokes the visitor functions for each object, array and literal reached.
1603
- */
1604
- function visit(text, visitor, options = ParseOptions.DEFAULT) {
1605
- const _scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(text, false);
1606
- // Important: Only pass copies of this to visitor functions to prevent accidental modification, and
1607
- // to not affect visitor functions which stored a reference to a previous JSONPath
1608
- const _jsonPath = [];
1609
- function toNoArgVisit(visitFunction) {
1610
- return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
1611
- }
1612
- function toNoArgVisitWithPath(visitFunction) {
1613
- return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
1614
- }
1615
- function toOneArgVisit(visitFunction) {
1616
- return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
1617
- }
1618
- function toOneArgVisitWithPath(visitFunction) {
1619
- return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
1620
- }
1621
- const onObjectBegin = toNoArgVisitWithPath(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisitWithPath(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
1622
- const disallowComments = options && options.disallowComments;
1623
- const allowTrailingComma = options && options.allowTrailingComma;
1624
- function scanNext() {
1625
- while (true) {
1626
- const token = _scanner.scan();
1627
- switch (_scanner.getTokenError()) {
1628
- case 4 /* ScanError.InvalidUnicode */:
1629
- handleError(14 /* ParseErrorCode.InvalidUnicode */);
1630
- break;
1631
- case 5 /* ScanError.InvalidEscapeCharacter */:
1632
- handleError(15 /* ParseErrorCode.InvalidEscapeCharacter */);
1633
- break;
1634
- case 3 /* ScanError.UnexpectedEndOfNumber */:
1635
- handleError(13 /* ParseErrorCode.UnexpectedEndOfNumber */);
1636
- break;
1637
- case 1 /* ScanError.UnexpectedEndOfComment */:
1638
- if (!disallowComments) {
1639
- handleError(11 /* ParseErrorCode.UnexpectedEndOfComment */);
1640
- }
1641
- break;
1642
- case 2 /* ScanError.UnexpectedEndOfString */:
1643
- handleError(12 /* ParseErrorCode.UnexpectedEndOfString */);
1644
- break;
1645
- case 6 /* ScanError.InvalidCharacter */:
1646
- handleError(16 /* ParseErrorCode.InvalidCharacter */);
1647
- break;
1648
- }
1649
- switch (token) {
1650
- case 12 /* SyntaxKind.LineCommentTrivia */:
1651
- case 13 /* SyntaxKind.BlockCommentTrivia */:
1652
- if (disallowComments) {
1653
- handleError(10 /* ParseErrorCode.InvalidCommentToken */);
1654
- }
1655
- else {
1656
- onComment();
1657
- }
1658
- break;
1659
- case 16 /* SyntaxKind.Unknown */:
1660
- handleError(1 /* ParseErrorCode.InvalidSymbol */);
1661
- break;
1662
- case 15 /* SyntaxKind.Trivia */:
1663
- case 14 /* SyntaxKind.LineBreakTrivia */:
1664
- break;
1665
- default:
1666
- return token;
1667
- }
1668
- }
1669
- }
1670
- function handleError(error, skipUntilAfter = [], skipUntil = []) {
1671
- onError(error);
1672
- if (skipUntilAfter.length + skipUntil.length > 0) {
1673
- let token = _scanner.getToken();
1674
- while (token !== 17 /* SyntaxKind.EOF */) {
1675
- if (skipUntilAfter.indexOf(token) !== -1) {
1676
- scanNext();
1677
- break;
1678
- }
1679
- else if (skipUntil.indexOf(token) !== -1) {
1680
- break;
1681
- }
1682
- token = scanNext();
1683
- }
1684
- }
1685
- }
1686
- function parseString(isValue) {
1687
- const value = _scanner.getTokenValue();
1688
- if (isValue) {
1689
- onLiteralValue(value);
1690
- }
1691
- else {
1692
- onObjectProperty(value);
1693
- // add property name afterwards
1694
- _jsonPath.push(value);
1695
- }
1696
- scanNext();
1697
- return true;
1698
- }
1699
- function parseLiteral() {
1700
- switch (_scanner.getToken()) {
1701
- case 11 /* SyntaxKind.NumericLiteral */:
1702
- const tokenValue = _scanner.getTokenValue();
1703
- let value = Number(tokenValue);
1704
- if (isNaN(value)) {
1705
- handleError(2 /* ParseErrorCode.InvalidNumberFormat */);
1706
- value = 0;
1707
- }
1708
- onLiteralValue(value);
1709
- break;
1710
- case 7 /* SyntaxKind.NullKeyword */:
1711
- onLiteralValue(null);
1712
- break;
1713
- case 8 /* SyntaxKind.TrueKeyword */:
1714
- onLiteralValue(true);
1715
- break;
1716
- case 9 /* SyntaxKind.FalseKeyword */:
1717
- onLiteralValue(false);
1718
- break;
1719
- default:
1720
- return false;
1721
- }
1722
- scanNext();
1723
- return true;
1724
- }
1725
- function parseProperty() {
1726
- if (_scanner.getToken() !== 10 /* SyntaxKind.StringLiteral */) {
1727
- handleError(3 /* ParseErrorCode.PropertyNameExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
1728
- return false;
1729
- }
1730
- parseString(false);
1731
- if (_scanner.getToken() === 6 /* SyntaxKind.ColonToken */) {
1732
- onSeparator(':');
1733
- scanNext(); // consume colon
1734
- if (!parseValue()) {
1735
- handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
1736
- }
1737
- }
1738
- else {
1739
- handleError(5 /* ParseErrorCode.ColonExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
1740
- }
1741
- _jsonPath.pop(); // remove processed property name
1742
- return true;
1743
- }
1744
- function parseObject() {
1745
- onObjectBegin();
1746
- scanNext(); // consume open brace
1747
- let needsComma = false;
1748
- while (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
1749
- if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
1750
- if (!needsComma) {
1751
- handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
1752
- }
1753
- onSeparator(',');
1754
- scanNext(); // consume comma
1755
- if (_scanner.getToken() === 2 /* SyntaxKind.CloseBraceToken */ && allowTrailingComma) {
1756
- break;
1757
- }
1758
- }
1759
- else if (needsComma) {
1760
- handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
1761
- }
1762
- if (!parseProperty()) {
1763
- handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
1764
- }
1765
- needsComma = true;
1766
- }
1767
- onObjectEnd();
1768
- if (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */) {
1769
- handleError(7 /* ParseErrorCode.CloseBraceExpected */, [2 /* SyntaxKind.CloseBraceToken */], []);
1770
- }
1771
- else {
1772
- scanNext(); // consume close brace
1773
- }
1774
- return true;
1775
- }
1776
- function parseArray() {
1777
- onArrayBegin();
1778
- scanNext(); // consume open bracket
1779
- let isFirstElement = true;
1780
- let needsComma = false;
1781
- while (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
1782
- if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
1783
- if (!needsComma) {
1784
- handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
1785
- }
1786
- onSeparator(',');
1787
- scanNext(); // consume comma
1788
- if (_scanner.getToken() === 4 /* SyntaxKind.CloseBracketToken */ && allowTrailingComma) {
1789
- break;
1790
- }
1791
- }
1792
- else if (needsComma) {
1793
- handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
1794
- }
1795
- if (isFirstElement) {
1796
- _jsonPath.push(0);
1797
- isFirstElement = false;
1798
- }
1799
- else {
1800
- _jsonPath[_jsonPath.length - 1]++;
1801
- }
1802
- if (!parseValue()) {
1803
- handleError(4 /* ParseErrorCode.ValueExpected */, [], [4 /* SyntaxKind.CloseBracketToken */, 5 /* SyntaxKind.CommaToken */]);
1804
- }
1805
- needsComma = true;
1806
- }
1807
- onArrayEnd();
1808
- if (!isFirstElement) {
1809
- _jsonPath.pop(); // remove array index
1810
- }
1811
- if (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */) {
1812
- handleError(8 /* ParseErrorCode.CloseBracketExpected */, [4 /* SyntaxKind.CloseBracketToken */], []);
1813
- }
1814
- else {
1815
- scanNext(); // consume close bracket
1816
- }
1817
- return true;
1818
- }
1819
- function parseValue() {
1820
- switch (_scanner.getToken()) {
1821
- case 3 /* SyntaxKind.OpenBracketToken */:
1822
- return parseArray();
1823
- case 1 /* SyntaxKind.OpenBraceToken */:
1824
- return parseObject();
1825
- case 10 /* SyntaxKind.StringLiteral */:
1826
- return parseString(true);
1827
- default:
1828
- return parseLiteral();
1829
- }
1830
- }
1831
- scanNext();
1832
- if (_scanner.getToken() === 17 /* SyntaxKind.EOF */) {
1833
- if (options.allowEmptyContent) {
1834
- return true;
1835
- }
1836
- handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
1837
- return false;
1838
- }
1839
- if (!parseValue()) {
1840
- handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
1841
- return false;
1842
- }
1843
- if (_scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
1844
- handleError(9 /* ParseErrorCode.EndOfFileExpected */, [], []);
1845
- }
1846
- return true;
1847
- }
1848
- /**
1849
- * Takes JSON with JavaScript-style comments and remove
1850
- * them. Optionally replaces every none-newline character
1851
- * of comments with a replaceCharacter
1852
- */
1853
- function stripComments(text, replaceCh) {
1854
- let _scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(text), parts = [], kind, offset = 0, pos;
1855
- do {
1856
- pos = _scanner.getPosition();
1857
- kind = _scanner.scan();
1858
- switch (kind) {
1859
- case 12 /* SyntaxKind.LineCommentTrivia */:
1860
- case 13 /* SyntaxKind.BlockCommentTrivia */:
1861
- case 17 /* SyntaxKind.EOF */:
1862
- if (offset !== pos) {
1863
- parts.push(text.substring(offset, pos));
1864
- }
1865
- if (replaceCh !== undefined) {
1866
- parts.push(_scanner.getTokenValue().replace(/[^\r\n]/g, replaceCh));
1867
- }
1868
- offset = _scanner.getPosition();
1869
- break;
1870
- }
1871
- } while (kind !== 17 /* SyntaxKind.EOF */);
1872
- return parts.join('');
1873
- }
1874
- function getNodeType(value) {
1875
- switch (typeof value) {
1876
- case 'boolean': return 'boolean';
1877
- case 'number': return 'number';
1878
- case 'string': return 'string';
1879
- case 'object': {
1880
- if (!value) {
1881
- return 'null';
1882
- }
1883
- else if (Array.isArray(value)) {
1884
- return 'array';
1885
- }
1886
- return 'object';
1887
- }
1888
- default: return 'null';
1889
- }
1890
- }
1891
-
1892
-
1893
- /***/ }),
1894
- /* 8 */
1895
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1896
-
1897
-
1898
- /*---------------------------------------------------------------------------------------------
1899
- * Copyright (c) Microsoft Corporation. All rights reserved.
1900
- * Licensed under the MIT License. See License.txt in the project root for license information.
1901
- *--------------------------------------------------------------------------------------------*/
1902
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1903
- exports.redundantImplicitActivationEvent = exports.implicitActivationEvent = void 0;
1904
- const vscode_1 = __webpack_require__(1);
1905
- exports.implicitActivationEvent = vscode_1.l10n.t("This activation event cannot be explicitly listed by your extension.");
1906
- exports.redundantImplicitActivationEvent = vscode_1.l10n.t("This activation event can be removed as VS Code generates these automatically from your package.json contribution declarations.");
1907
-
1908
-
1909
- /***/ })
1910
- /******/ ]);
1911
- /************************************************************************/
1912
- /******/ // The module cache
1913
- /******/ var __webpack_module_cache__ = {};
1914
- /******/
1915
- /******/ // The require function
1916
- /******/ function __webpack_require__(moduleId) {
1917
- /******/ // Check if module is in cache
1918
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
1919
- /******/ if (cachedModule !== undefined) {
1920
- /******/ return cachedModule.exports;
1921
- /******/ }
1922
- /******/ // Create a new module (and put it into the cache)
1923
- /******/ var module = __webpack_module_cache__[moduleId] = {
1924
- /******/ // no module.id needed
1925
- /******/ // no module.loaded needed
1926
- /******/ exports: {}
1927
- /******/ };
1928
- /******/
1929
- /******/ // Execute the module function
1930
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1931
- /******/
1932
- /******/ // Return the exports of the module
1933
- /******/ return module.exports;
1934
- /******/ }
1935
- /******/
1936
- /************************************************************************/
1937
- /******/ /* webpack/runtime/define property getters */
1938
- /******/ (() => {
1939
- /******/ // define getter functions for harmony exports
1940
- /******/ __webpack_require__.d = (exports, definition) => {
1941
- /******/ for(var key in definition) {
1942
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1943
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1944
- /******/ }
1945
- /******/ }
1946
- /******/ };
1947
- /******/ })();
1948
- /******/
1949
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
1950
- /******/ (() => {
1951
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
1952
- /******/ })();
1953
- /******/
1954
- /******/ /* webpack/runtime/make namespace object */
1955
- /******/ (() => {
1956
- /******/ // define __esModule on exports
1957
- /******/ __webpack_require__.r = (exports) => {
1958
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1959
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1960
- /******/ }
1961
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
1962
- /******/ };
1963
- /******/ })();
1964
- /******/
1965
- /************************************************************************/
1966
- var __webpack_exports__ = {};
1967
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
1968
- (() => {
1969
- var exports = __webpack_exports__;
1970
-
1971
- /*---------------------------------------------------------------------------------------------
1972
- * Copyright (c) Microsoft Corporation. All rights reserved.
1973
- * Licensed under the MIT License. See License.txt in the project root for license information.
1974
- *--------------------------------------------------------------------------------------------*/
1975
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1976
- exports.activate = void 0;
1977
- const vscode = __webpack_require__(1);
1978
- const packageDocumentHelper_1 = __webpack_require__(2);
1979
- function activate(context) {
1980
- //package.json suggestions
1981
- context.subscriptions.push(registerPackageDocumentCompletions());
1982
- }
1983
- exports.activate = activate;
1984
- function registerPackageDocumentCompletions() {
1985
- return vscode.languages.registerCompletionItemProvider({ language: 'json', pattern: '**/package.json' }, {
1986
- provideCompletionItems(document, position, token) {
1987
- return new packageDocumentHelper_1.PackageDocument(document).provideCompletionItems(position, token);
1988
- }
1989
- });
1990
- }
1991
-
1992
- })();
1993
-
1994
- var __webpack_export_target__ = exports;
1995
- for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
1996
- if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
1997
- /******/ })()
1998
- ;
1999
- //# sourceMappingURL=extensionEditingBrowserMain.js.map