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