@codingame/monaco-vscode-rollup-vsix-plugin 5.3.0 → 6.0.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/package.json +2 -2
- package/rollup-vsix-plugin.js +156 -156
- package/vscode-dts/vscode.proposed.attributableCoverage.d.ts +28 -0
- package/vscode-dts/vscode.proposed.chatParticipantAdditions.d.ts +90 -97
- package/vscode-dts/vscode.proposed.chatParticipantPrivate.d.ts +76 -0
- package/vscode-dts/vscode.proposed.chatProvider.d.ts +24 -7
- package/vscode-dts/vscode.proposed.chatVariableResolver.d.ts +82 -2
- package/vscode-dts/vscode.proposed.defaultChatParticipant.d.ts +0 -5
- package/vscode-dts/vscode.proposed.editorHoverVerbosityLevel.d.ts +2 -2
- package/vscode-dts/vscode.proposed.embeddings.d.ts +33 -0
- package/vscode-dts/vscode.proposed.interactive.d.ts +2 -110
- package/vscode-dts/vscode.proposed.languageModelSystem.d.ts +17 -0
- package/vscode-dts/vscode.proposed.resolvers.d.ts +2 -1
- package/vscode-dts/vscode.proposed.speech.d.ts +26 -6
- package/vscode-dts/vscode.proposed.testObserver.d.ts +9 -0
- package/vscode-dts/vscode.proposed.chatParticipant.d.ts +0 -458
- package/vscode-dts/vscode.proposed.debugFocus.d.ts +0 -66
- package/vscode-dts/vscode.proposed.languageModels.d.ts +0 -291
- package/vscode-dts/vscode.proposed.testPreserveFocus.d.ts +0 -28
package/rollup-vsix-plugin.js
CHANGED
|
@@ -79,21 +79,21 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
79
79
|
const len = text.length;
|
|
80
80
|
let value = '';
|
|
81
81
|
let tokenOffset = 0;
|
|
82
|
-
let token =
|
|
83
|
-
let scanError =
|
|
82
|
+
let token = SyntaxKind.Unknown;
|
|
83
|
+
let scanError = ScanError.None;
|
|
84
84
|
function scanHexDigits(count) {
|
|
85
85
|
let digits = 0;
|
|
86
86
|
let hexValue = 0;
|
|
87
87
|
while (digits < count) {
|
|
88
88
|
const ch = text.charCodeAt(pos);
|
|
89
|
-
if (ch >=
|
|
90
|
-
hexValue = hexValue * 16 + ch -
|
|
89
|
+
if (ch >= CharacterCodes._0 && ch <= CharacterCodes._9) {
|
|
90
|
+
hexValue = hexValue * 16 + ch - CharacterCodes._0;
|
|
91
91
|
}
|
|
92
|
-
else if (ch >=
|
|
93
|
-
hexValue = hexValue * 16 + ch -
|
|
92
|
+
else if (ch >= CharacterCodes.A && ch <= CharacterCodes.F) {
|
|
93
|
+
hexValue = hexValue * 16 + ch - CharacterCodes.A + 10;
|
|
94
94
|
}
|
|
95
|
-
else if (ch >=
|
|
96
|
-
hexValue = hexValue * 16 + ch -
|
|
95
|
+
else if (ch >= CharacterCodes.a && ch <= CharacterCodes.f) {
|
|
96
|
+
hexValue = hexValue * 16 + ch - CharacterCodes.a + 10;
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
99
|
break;
|
|
@@ -110,12 +110,12 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
110
110
|
pos = newPosition;
|
|
111
111
|
value = '';
|
|
112
112
|
tokenOffset = 0;
|
|
113
|
-
token =
|
|
114
|
-
scanError =
|
|
113
|
+
token = SyntaxKind.Unknown;
|
|
114
|
+
scanError = ScanError.None;
|
|
115
115
|
}
|
|
116
116
|
function scanNumber() {
|
|
117
117
|
const start = pos;
|
|
118
|
-
if (text.charCodeAt(pos) ===
|
|
118
|
+
if (text.charCodeAt(pos) === CharacterCodes._0) {
|
|
119
119
|
pos++;
|
|
120
120
|
}
|
|
121
121
|
else {
|
|
@@ -124,7 +124,7 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
124
124
|
pos++;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
if (pos < text.length && text.charCodeAt(pos) ===
|
|
127
|
+
if (pos < text.length && text.charCodeAt(pos) === CharacterCodes.dot) {
|
|
128
128
|
pos++;
|
|
129
129
|
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
130
130
|
pos++;
|
|
@@ -133,14 +133,14 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
else {
|
|
136
|
-
scanError =
|
|
136
|
+
scanError = ScanError.UnexpectedEndOfNumber;
|
|
137
137
|
return text.substring(start, pos);
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
let end = pos;
|
|
141
|
-
if (pos < text.length && (text.charCodeAt(pos) ===
|
|
141
|
+
if (pos < text.length && (text.charCodeAt(pos) === CharacterCodes.E || text.charCodeAt(pos) === CharacterCodes.e)) {
|
|
142
142
|
pos++;
|
|
143
|
-
if (pos < text.length && text.charCodeAt(pos) ===
|
|
143
|
+
if (pos < text.length && text.charCodeAt(pos) === CharacterCodes.plus || text.charCodeAt(pos) === CharacterCodes.minus) {
|
|
144
144
|
pos++;
|
|
145
145
|
}
|
|
146
146
|
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
@@ -151,7 +151,7 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
151
151
|
end = pos;
|
|
152
152
|
}
|
|
153
153
|
else {
|
|
154
|
-
scanError =
|
|
154
|
+
scanError = ScanError.UnexpectedEndOfNumber;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
return text.substring(start, end);
|
|
@@ -161,60 +161,60 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
161
161
|
while (true) {
|
|
162
162
|
if (pos >= len) {
|
|
163
163
|
result += text.substring(start, pos);
|
|
164
|
-
scanError =
|
|
164
|
+
scanError = ScanError.UnexpectedEndOfString;
|
|
165
165
|
break;
|
|
166
166
|
}
|
|
167
167
|
const ch = text.charCodeAt(pos);
|
|
168
|
-
if (ch ===
|
|
168
|
+
if (ch === CharacterCodes.doubleQuote) {
|
|
169
169
|
result += text.substring(start, pos);
|
|
170
170
|
pos++;
|
|
171
171
|
break;
|
|
172
172
|
}
|
|
173
|
-
if (ch ===
|
|
173
|
+
if (ch === CharacterCodes.backslash) {
|
|
174
174
|
result += text.substring(start, pos);
|
|
175
175
|
pos++;
|
|
176
176
|
if (pos >= len) {
|
|
177
|
-
scanError =
|
|
177
|
+
scanError = ScanError.UnexpectedEndOfString;
|
|
178
178
|
break;
|
|
179
179
|
}
|
|
180
180
|
const ch2 = text.charCodeAt(pos++);
|
|
181
181
|
switch (ch2) {
|
|
182
|
-
case
|
|
182
|
+
case CharacterCodes.doubleQuote:
|
|
183
183
|
result += '\"';
|
|
184
184
|
break;
|
|
185
|
-
case
|
|
185
|
+
case CharacterCodes.backslash:
|
|
186
186
|
result += '\\';
|
|
187
187
|
break;
|
|
188
|
-
case
|
|
188
|
+
case CharacterCodes.slash:
|
|
189
189
|
result += '/';
|
|
190
190
|
break;
|
|
191
|
-
case
|
|
191
|
+
case CharacterCodes.b:
|
|
192
192
|
result += '\b';
|
|
193
193
|
break;
|
|
194
|
-
case
|
|
194
|
+
case CharacterCodes.f:
|
|
195
195
|
result += '\f';
|
|
196
196
|
break;
|
|
197
|
-
case
|
|
197
|
+
case CharacterCodes.n:
|
|
198
198
|
result += '\n';
|
|
199
199
|
break;
|
|
200
|
-
case
|
|
200
|
+
case CharacterCodes.r:
|
|
201
201
|
result += '\r';
|
|
202
202
|
break;
|
|
203
|
-
case
|
|
203
|
+
case CharacterCodes.t:
|
|
204
204
|
result += '\t';
|
|
205
205
|
break;
|
|
206
|
-
case
|
|
206
|
+
case CharacterCodes.u: {
|
|
207
207
|
const ch3 = scanHexDigits(4);
|
|
208
208
|
if (ch3 >= 0) {
|
|
209
209
|
result += String.fromCharCode(ch3);
|
|
210
210
|
}
|
|
211
211
|
else {
|
|
212
|
-
scanError =
|
|
212
|
+
scanError = ScanError.InvalidUnicode;
|
|
213
213
|
}
|
|
214
214
|
break;
|
|
215
215
|
}
|
|
216
216
|
default:
|
|
217
|
-
scanError =
|
|
217
|
+
scanError = ScanError.InvalidEscapeCharacter;
|
|
218
218
|
}
|
|
219
219
|
start = pos;
|
|
220
220
|
continue;
|
|
@@ -222,11 +222,11 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
222
222
|
if (ch >= 0 && ch <= 0x1F) {
|
|
223
223
|
if (isLineBreak(ch)) {
|
|
224
224
|
result += text.substring(start, pos);
|
|
225
|
-
scanError =
|
|
225
|
+
scanError = ScanError.UnexpectedEndOfString;
|
|
226
226
|
break;
|
|
227
227
|
}
|
|
228
228
|
else {
|
|
229
|
-
scanError =
|
|
229
|
+
scanError = ScanError.InvalidCharacter;
|
|
230
230
|
// mark as error but continue with string
|
|
231
231
|
}
|
|
232
232
|
}
|
|
@@ -236,12 +236,12 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
236
236
|
}
|
|
237
237
|
function scanNext() {
|
|
238
238
|
value = '';
|
|
239
|
-
scanError =
|
|
239
|
+
scanError = ScanError.None;
|
|
240
240
|
tokenOffset = pos;
|
|
241
241
|
if (pos >= len) {
|
|
242
242
|
// at the end
|
|
243
243
|
tokenOffset = len;
|
|
244
|
-
return token =
|
|
244
|
+
return token = SyntaxKind.EOF;
|
|
245
245
|
}
|
|
246
246
|
let code = text.charCodeAt(pos);
|
|
247
247
|
// trivia: whitespace
|
|
@@ -251,48 +251,48 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
251
251
|
value += String.fromCharCode(code);
|
|
252
252
|
code = text.charCodeAt(pos);
|
|
253
253
|
} while (isWhitespace(code));
|
|
254
|
-
return token =
|
|
254
|
+
return token = SyntaxKind.Trivia;
|
|
255
255
|
}
|
|
256
256
|
// trivia: newlines
|
|
257
257
|
if (isLineBreak(code)) {
|
|
258
258
|
pos++;
|
|
259
259
|
value += String.fromCharCode(code);
|
|
260
|
-
if (code ===
|
|
260
|
+
if (code === CharacterCodes.carriageReturn && text.charCodeAt(pos) === CharacterCodes.lineFeed) {
|
|
261
261
|
pos++;
|
|
262
262
|
value += '\n';
|
|
263
263
|
}
|
|
264
|
-
return token =
|
|
264
|
+
return token = SyntaxKind.LineBreakTrivia;
|
|
265
265
|
}
|
|
266
266
|
switch (code) {
|
|
267
267
|
// tokens: []{}:,
|
|
268
|
-
case
|
|
268
|
+
case CharacterCodes.openBrace:
|
|
269
269
|
pos++;
|
|
270
|
-
return token =
|
|
271
|
-
case
|
|
270
|
+
return token = SyntaxKind.OpenBraceToken;
|
|
271
|
+
case CharacterCodes.closeBrace:
|
|
272
272
|
pos++;
|
|
273
|
-
return token =
|
|
274
|
-
case
|
|
273
|
+
return token = SyntaxKind.CloseBraceToken;
|
|
274
|
+
case CharacterCodes.openBracket:
|
|
275
275
|
pos++;
|
|
276
|
-
return token =
|
|
277
|
-
case
|
|
276
|
+
return token = SyntaxKind.OpenBracketToken;
|
|
277
|
+
case CharacterCodes.closeBracket:
|
|
278
278
|
pos++;
|
|
279
|
-
return token =
|
|
280
|
-
case
|
|
279
|
+
return token = SyntaxKind.CloseBracketToken;
|
|
280
|
+
case CharacterCodes.colon:
|
|
281
281
|
pos++;
|
|
282
|
-
return token =
|
|
283
|
-
case
|
|
282
|
+
return token = SyntaxKind.ColonToken;
|
|
283
|
+
case CharacterCodes.comma:
|
|
284
284
|
pos++;
|
|
285
|
-
return token =
|
|
285
|
+
return token = SyntaxKind.CommaToken;
|
|
286
286
|
// strings
|
|
287
|
-
case
|
|
287
|
+
case CharacterCodes.doubleQuote:
|
|
288
288
|
pos++;
|
|
289
289
|
value = scanString();
|
|
290
|
-
return token =
|
|
290
|
+
return token = SyntaxKind.StringLiteral;
|
|
291
291
|
// comments
|
|
292
|
-
case
|
|
292
|
+
case CharacterCodes.slash: {
|
|
293
293
|
const start = pos - 1;
|
|
294
294
|
// Single-line comment
|
|
295
|
-
if (text.charCodeAt(pos + 1) ===
|
|
295
|
+
if (text.charCodeAt(pos + 1) === CharacterCodes.slash) {
|
|
296
296
|
pos += 2;
|
|
297
297
|
while (pos < len) {
|
|
298
298
|
if (isLineBreak(text.charCodeAt(pos))) {
|
|
@@ -301,16 +301,16 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
301
301
|
pos++;
|
|
302
302
|
}
|
|
303
303
|
value = text.substring(start, pos);
|
|
304
|
-
return token =
|
|
304
|
+
return token = SyntaxKind.LineCommentTrivia;
|
|
305
305
|
}
|
|
306
306
|
// Multi-line comment
|
|
307
|
-
if (text.charCodeAt(pos + 1) ===
|
|
307
|
+
if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) {
|
|
308
308
|
pos += 2;
|
|
309
309
|
const safeLength = len - 1; // For lookahead.
|
|
310
310
|
let commentClosed = false;
|
|
311
311
|
while (pos < safeLength) {
|
|
312
312
|
const ch = text.charCodeAt(pos);
|
|
313
|
-
if (ch ===
|
|
313
|
+
if (ch === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) {
|
|
314
314
|
pos += 2;
|
|
315
315
|
commentClosed = true;
|
|
316
316
|
break;
|
|
@@ -319,38 +319,38 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
319
319
|
}
|
|
320
320
|
if (!commentClosed) {
|
|
321
321
|
pos++;
|
|
322
|
-
scanError =
|
|
322
|
+
scanError = ScanError.UnexpectedEndOfComment;
|
|
323
323
|
}
|
|
324
324
|
value = text.substring(start, pos);
|
|
325
|
-
return token =
|
|
325
|
+
return token = SyntaxKind.BlockCommentTrivia;
|
|
326
326
|
}
|
|
327
327
|
// just a single slash
|
|
328
328
|
value += String.fromCharCode(code);
|
|
329
329
|
pos++;
|
|
330
|
-
return token =
|
|
330
|
+
return token = SyntaxKind.Unknown;
|
|
331
331
|
}
|
|
332
332
|
// numbers
|
|
333
|
-
case
|
|
333
|
+
case CharacterCodes.minus:
|
|
334
334
|
value += String.fromCharCode(code);
|
|
335
335
|
pos++;
|
|
336
336
|
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
337
|
-
return token =
|
|
337
|
+
return token = SyntaxKind.Unknown;
|
|
338
338
|
}
|
|
339
339
|
// found a minus, followed by a number so
|
|
340
340
|
// we fall through to proceed with scanning
|
|
341
341
|
// numbers
|
|
342
|
-
case
|
|
343
|
-
case
|
|
344
|
-
case
|
|
345
|
-
case
|
|
346
|
-
case
|
|
347
|
-
case
|
|
348
|
-
case
|
|
349
|
-
case
|
|
350
|
-
case
|
|
351
|
-
case
|
|
342
|
+
case CharacterCodes._0:
|
|
343
|
+
case CharacterCodes._1:
|
|
344
|
+
case CharacterCodes._2:
|
|
345
|
+
case CharacterCodes._3:
|
|
346
|
+
case CharacterCodes._4:
|
|
347
|
+
case CharacterCodes._5:
|
|
348
|
+
case CharacterCodes._6:
|
|
349
|
+
case CharacterCodes._7:
|
|
350
|
+
case CharacterCodes._8:
|
|
351
|
+
case CharacterCodes._9:
|
|
352
352
|
value += scanNumber();
|
|
353
|
-
return token =
|
|
353
|
+
return token = SyntaxKind.NumericLiteral;
|
|
354
354
|
// literals and unknown symbols
|
|
355
355
|
default:
|
|
356
356
|
// is a literal? Read the full word.
|
|
@@ -362,16 +362,16 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
362
362
|
value = text.substring(tokenOffset, pos);
|
|
363
363
|
// keywords: true, false, null
|
|
364
364
|
switch (value) {
|
|
365
|
-
case 'true': return token =
|
|
366
|
-
case 'false': return token =
|
|
367
|
-
case 'null': return token =
|
|
365
|
+
case 'true': return token = SyntaxKind.TrueKeyword;
|
|
366
|
+
case 'false': return token = SyntaxKind.FalseKeyword;
|
|
367
|
+
case 'null': return token = SyntaxKind.NullKeyword;
|
|
368
368
|
}
|
|
369
|
-
return token =
|
|
369
|
+
return token = SyntaxKind.Unknown;
|
|
370
370
|
}
|
|
371
371
|
// some
|
|
372
372
|
value += String.fromCharCode(code);
|
|
373
373
|
pos++;
|
|
374
|
-
return token =
|
|
374
|
+
return token = SyntaxKind.Unknown;
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
function isUnknownContentCharacter(code) {
|
|
@@ -379,14 +379,14 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
379
379
|
return false;
|
|
380
380
|
}
|
|
381
381
|
switch (code) {
|
|
382
|
-
case
|
|
383
|
-
case
|
|
384
|
-
case
|
|
385
|
-
case
|
|
386
|
-
case
|
|
387
|
-
case
|
|
388
|
-
case
|
|
389
|
-
case
|
|
382
|
+
case CharacterCodes.closeBrace:
|
|
383
|
+
case CharacterCodes.closeBracket:
|
|
384
|
+
case CharacterCodes.openBrace:
|
|
385
|
+
case CharacterCodes.openBracket:
|
|
386
|
+
case CharacterCodes.doubleQuote:
|
|
387
|
+
case CharacterCodes.colon:
|
|
388
|
+
case CharacterCodes.comma:
|
|
389
|
+
case CharacterCodes.slash:
|
|
390
390
|
return false;
|
|
391
391
|
}
|
|
392
392
|
return true;
|
|
@@ -395,7 +395,7 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
395
395
|
let result;
|
|
396
396
|
do {
|
|
397
397
|
result = scanNext();
|
|
398
|
-
} while (result >=
|
|
398
|
+
} while (result >= SyntaxKind.LineCommentTrivia && result <= SyntaxKind.Trivia);
|
|
399
399
|
return result;
|
|
400
400
|
}
|
|
401
401
|
return {
|
|
@@ -410,15 +410,15 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
410
410
|
};
|
|
411
411
|
}
|
|
412
412
|
function isWhitespace(ch) {
|
|
413
|
-
return ch ===
|
|
414
|
-
ch ===
|
|
415
|
-
ch ===
|
|
413
|
+
return ch === CharacterCodes.space || ch === CharacterCodes.tab || ch === CharacterCodes.verticalTab || ch === CharacterCodes.formFeed ||
|
|
414
|
+
ch === CharacterCodes.nonBreakingSpace || ch === CharacterCodes.ogham || ch >= CharacterCodes.enQuad && ch <= CharacterCodes.zeroWidthSpace ||
|
|
415
|
+
ch === CharacterCodes.narrowNoBreakSpace || ch === CharacterCodes.mathematicalSpace || ch === CharacterCodes.ideographicSpace || ch === CharacterCodes.byteOrderMark;
|
|
416
416
|
}
|
|
417
417
|
function isLineBreak(ch) {
|
|
418
|
-
return ch ===
|
|
418
|
+
return ch === CharacterCodes.lineFeed || ch === CharacterCodes.carriageReturn || ch === CharacterCodes.lineSeparator || ch === CharacterCodes.paragraphSeparator;
|
|
419
419
|
}
|
|
420
420
|
function isDigit(ch) {
|
|
421
|
-
return ch >=
|
|
421
|
+
return ch >= CharacterCodes._0 && ch <= CharacterCodes._9;
|
|
422
422
|
}
|
|
423
423
|
var CharacterCodes;
|
|
424
424
|
(function (CharacterCodes) {
|
|
@@ -614,42 +614,42 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
614
614
|
while (true) {
|
|
615
615
|
const token = _scanner.scan();
|
|
616
616
|
switch (_scanner.getTokenError()) {
|
|
617
|
-
case
|
|
618
|
-
handleError(
|
|
617
|
+
case ScanError.InvalidUnicode:
|
|
618
|
+
handleError(ParseErrorCode.InvalidUnicode);
|
|
619
619
|
break;
|
|
620
|
-
case
|
|
621
|
-
handleError(
|
|
620
|
+
case ScanError.InvalidEscapeCharacter:
|
|
621
|
+
handleError(ParseErrorCode.InvalidEscapeCharacter);
|
|
622
622
|
break;
|
|
623
|
-
case
|
|
624
|
-
handleError(
|
|
623
|
+
case ScanError.UnexpectedEndOfNumber:
|
|
624
|
+
handleError(ParseErrorCode.UnexpectedEndOfNumber);
|
|
625
625
|
break;
|
|
626
|
-
case
|
|
626
|
+
case ScanError.UnexpectedEndOfComment:
|
|
627
627
|
if (!disallowComments) {
|
|
628
|
-
handleError(
|
|
628
|
+
handleError(ParseErrorCode.UnexpectedEndOfComment);
|
|
629
629
|
}
|
|
630
630
|
break;
|
|
631
|
-
case
|
|
632
|
-
handleError(
|
|
631
|
+
case ScanError.UnexpectedEndOfString:
|
|
632
|
+
handleError(ParseErrorCode.UnexpectedEndOfString);
|
|
633
633
|
break;
|
|
634
|
-
case
|
|
635
|
-
handleError(
|
|
634
|
+
case ScanError.InvalidCharacter:
|
|
635
|
+
handleError(ParseErrorCode.InvalidCharacter);
|
|
636
636
|
break;
|
|
637
637
|
}
|
|
638
638
|
switch (token) {
|
|
639
|
-
case
|
|
640
|
-
case
|
|
639
|
+
case SyntaxKind.LineCommentTrivia:
|
|
640
|
+
case SyntaxKind.BlockCommentTrivia:
|
|
641
641
|
if (disallowComments) {
|
|
642
|
-
handleError(
|
|
642
|
+
handleError(ParseErrorCode.InvalidCommentToken);
|
|
643
643
|
}
|
|
644
644
|
else {
|
|
645
645
|
onComment();
|
|
646
646
|
}
|
|
647
647
|
break;
|
|
648
|
-
case
|
|
649
|
-
handleError(
|
|
648
|
+
case SyntaxKind.Unknown:
|
|
649
|
+
handleError(ParseErrorCode.InvalidSymbol);
|
|
650
650
|
break;
|
|
651
|
-
case
|
|
652
|
-
case
|
|
651
|
+
case SyntaxKind.Trivia:
|
|
652
|
+
case SyntaxKind.LineBreakTrivia:
|
|
653
653
|
break;
|
|
654
654
|
default:
|
|
655
655
|
return token;
|
|
@@ -660,7 +660,7 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
660
660
|
onError(error);
|
|
661
661
|
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
662
662
|
let token = _scanner.getToken();
|
|
663
|
-
while (token !==
|
|
663
|
+
while (token !== SyntaxKind.EOF) {
|
|
664
664
|
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
665
665
|
scanNext();
|
|
666
666
|
break;
|
|
@@ -685,28 +685,28 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
685
685
|
}
|
|
686
686
|
function parseLiteral() {
|
|
687
687
|
switch (_scanner.getToken()) {
|
|
688
|
-
case
|
|
688
|
+
case SyntaxKind.NumericLiteral: {
|
|
689
689
|
let value = 0;
|
|
690
690
|
try {
|
|
691
691
|
value = JSON.parse(_scanner.getTokenValue());
|
|
692
692
|
if (typeof value !== 'number') {
|
|
693
|
-
handleError(
|
|
693
|
+
handleError(ParseErrorCode.InvalidNumberFormat);
|
|
694
694
|
value = 0;
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
697
|
catch (e) {
|
|
698
|
-
handleError(
|
|
698
|
+
handleError(ParseErrorCode.InvalidNumberFormat);
|
|
699
699
|
}
|
|
700
700
|
onLiteralValue(value);
|
|
701
701
|
break;
|
|
702
702
|
}
|
|
703
|
-
case
|
|
703
|
+
case SyntaxKind.NullKeyword:
|
|
704
704
|
onLiteralValue(null);
|
|
705
705
|
break;
|
|
706
|
-
case
|
|
706
|
+
case SyntaxKind.TrueKeyword:
|
|
707
707
|
onLiteralValue(true);
|
|
708
708
|
break;
|
|
709
|
-
case
|
|
709
|
+
case SyntaxKind.FalseKeyword:
|
|
710
710
|
onLiteralValue(false);
|
|
711
711
|
break;
|
|
712
712
|
default:
|
|
@@ -716,20 +716,20 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
716
716
|
return true;
|
|
717
717
|
}
|
|
718
718
|
function parseProperty() {
|
|
719
|
-
if (_scanner.getToken() !==
|
|
720
|
-
handleError(
|
|
719
|
+
if (_scanner.getToken() !== SyntaxKind.StringLiteral) {
|
|
720
|
+
handleError(ParseErrorCode.PropertyNameExpected, [], [SyntaxKind.CloseBraceToken, SyntaxKind.CommaToken]);
|
|
721
721
|
return false;
|
|
722
722
|
}
|
|
723
723
|
parseString(false);
|
|
724
|
-
if (_scanner.getToken() ===
|
|
724
|
+
if (_scanner.getToken() === SyntaxKind.ColonToken) {
|
|
725
725
|
onSeparator(':');
|
|
726
726
|
scanNext(); // consume colon
|
|
727
727
|
if (!parseValue()) {
|
|
728
|
-
handleError(
|
|
728
|
+
handleError(ParseErrorCode.ValueExpected, [], [SyntaxKind.CloseBraceToken, SyntaxKind.CommaToken]);
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
731
|
else {
|
|
732
|
-
handleError(
|
|
732
|
+
handleError(ParseErrorCode.ColonExpected, [], [SyntaxKind.CloseBraceToken, SyntaxKind.CommaToken]);
|
|
733
733
|
}
|
|
734
734
|
return true;
|
|
735
735
|
}
|
|
@@ -737,28 +737,28 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
737
737
|
onObjectBegin();
|
|
738
738
|
scanNext(); // consume open brace
|
|
739
739
|
let needsComma = false;
|
|
740
|
-
while (_scanner.getToken() !==
|
|
741
|
-
if (_scanner.getToken() ===
|
|
740
|
+
while (_scanner.getToken() !== SyntaxKind.CloseBraceToken && _scanner.getToken() !== SyntaxKind.EOF) {
|
|
741
|
+
if (_scanner.getToken() === SyntaxKind.CommaToken) {
|
|
742
742
|
if (!needsComma) {
|
|
743
|
-
handleError(
|
|
743
|
+
handleError(ParseErrorCode.ValueExpected, [], []);
|
|
744
744
|
}
|
|
745
745
|
onSeparator(',');
|
|
746
746
|
scanNext(); // consume comma
|
|
747
|
-
if (_scanner.getToken() ===
|
|
747
|
+
if (_scanner.getToken() === SyntaxKind.CloseBraceToken && allowTrailingComma) {
|
|
748
748
|
break;
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
751
|
else if (needsComma) {
|
|
752
|
-
handleError(
|
|
752
|
+
handleError(ParseErrorCode.CommaExpected, [], []);
|
|
753
753
|
}
|
|
754
754
|
if (!parseProperty()) {
|
|
755
|
-
handleError(
|
|
755
|
+
handleError(ParseErrorCode.ValueExpected, [], [SyntaxKind.CloseBraceToken, SyntaxKind.CommaToken]);
|
|
756
756
|
}
|
|
757
757
|
needsComma = true;
|
|
758
758
|
}
|
|
759
759
|
onObjectEnd();
|
|
760
|
-
if (_scanner.getToken() !==
|
|
761
|
-
handleError(
|
|
760
|
+
if (_scanner.getToken() !== SyntaxKind.CloseBraceToken) {
|
|
761
|
+
handleError(ParseErrorCode.CloseBraceExpected, [SyntaxKind.CloseBraceToken], []);
|
|
762
762
|
}
|
|
763
763
|
else {
|
|
764
764
|
scanNext(); // consume close brace
|
|
@@ -769,28 +769,28 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
769
769
|
onArrayBegin();
|
|
770
770
|
scanNext(); // consume open bracket
|
|
771
771
|
let needsComma = false;
|
|
772
|
-
while (_scanner.getToken() !==
|
|
773
|
-
if (_scanner.getToken() ===
|
|
772
|
+
while (_scanner.getToken() !== SyntaxKind.CloseBracketToken && _scanner.getToken() !== SyntaxKind.EOF) {
|
|
773
|
+
if (_scanner.getToken() === SyntaxKind.CommaToken) {
|
|
774
774
|
if (!needsComma) {
|
|
775
|
-
handleError(
|
|
775
|
+
handleError(ParseErrorCode.ValueExpected, [], []);
|
|
776
776
|
}
|
|
777
777
|
onSeparator(',');
|
|
778
778
|
scanNext(); // consume comma
|
|
779
|
-
if (_scanner.getToken() ===
|
|
779
|
+
if (_scanner.getToken() === SyntaxKind.CloseBracketToken && allowTrailingComma) {
|
|
780
780
|
break;
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
783
|
else if (needsComma) {
|
|
784
|
-
handleError(
|
|
784
|
+
handleError(ParseErrorCode.CommaExpected, [], []);
|
|
785
785
|
}
|
|
786
786
|
if (!parseValue()) {
|
|
787
|
-
handleError(
|
|
787
|
+
handleError(ParseErrorCode.ValueExpected, [], [SyntaxKind.CloseBracketToken, SyntaxKind.CommaToken]);
|
|
788
788
|
}
|
|
789
789
|
needsComma = true;
|
|
790
790
|
}
|
|
791
791
|
onArrayEnd();
|
|
792
|
-
if (_scanner.getToken() !==
|
|
793
|
-
handleError(
|
|
792
|
+
if (_scanner.getToken() !== SyntaxKind.CloseBracketToken) {
|
|
793
|
+
handleError(ParseErrorCode.CloseBracketExpected, [SyntaxKind.CloseBracketToken], []);
|
|
794
794
|
}
|
|
795
795
|
else {
|
|
796
796
|
scanNext(); // consume close bracket
|
|
@@ -799,30 +799,30 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
799
799
|
}
|
|
800
800
|
function parseValue() {
|
|
801
801
|
switch (_scanner.getToken()) {
|
|
802
|
-
case
|
|
802
|
+
case SyntaxKind.OpenBracketToken:
|
|
803
803
|
return parseArray();
|
|
804
|
-
case
|
|
804
|
+
case SyntaxKind.OpenBraceToken:
|
|
805
805
|
return parseObject();
|
|
806
|
-
case
|
|
806
|
+
case SyntaxKind.StringLiteral:
|
|
807
807
|
return parseString(true);
|
|
808
808
|
default:
|
|
809
809
|
return parseLiteral();
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
scanNext();
|
|
813
|
-
if (_scanner.getToken() ===
|
|
813
|
+
if (_scanner.getToken() === SyntaxKind.EOF) {
|
|
814
814
|
if (options.allowEmptyContent) {
|
|
815
815
|
return true;
|
|
816
816
|
}
|
|
817
|
-
handleError(
|
|
817
|
+
handleError(ParseErrorCode.ValueExpected, [], []);
|
|
818
818
|
return false;
|
|
819
819
|
}
|
|
820
820
|
if (!parseValue()) {
|
|
821
|
-
handleError(
|
|
821
|
+
handleError(ParseErrorCode.ValueExpected, [], []);
|
|
822
822
|
return false;
|
|
823
823
|
}
|
|
824
|
-
if (_scanner.getToken() !==
|
|
825
|
-
handleError(
|
|
824
|
+
if (_scanner.getToken() !== SyntaxKind.EOF) {
|
|
825
|
+
handleError(ParseErrorCode.EndOfFileExpected, [], []);
|
|
826
826
|
}
|
|
827
827
|
return true;
|
|
828
828
|
}
|
|
@@ -871,15 +871,15 @@ function localizeWithPath(path, data, defaultMessage, ...args) {
|
|
|
871
871
|
const _moduleId = "vs/base/common/jsonErrorMessages";
|
|
872
872
|
function getParseErrorMessage(errorCode) {
|
|
873
873
|
switch (errorCode) {
|
|
874
|
-
case
|
|
875
|
-
case
|
|
876
|
-
case
|
|
877
|
-
case
|
|
878
|
-
case
|
|
879
|
-
case
|
|
880
|
-
case
|
|
881
|
-
case
|
|
882
|
-
case
|
|
874
|
+
case ParseErrorCode.InvalidSymbol: return localizeWithPath(_moduleId, 'error.invalidSymbol', 'Invalid symbol');
|
|
875
|
+
case ParseErrorCode.InvalidNumberFormat: return localizeWithPath(_moduleId, 'error.invalidNumberFormat', 'Invalid number format');
|
|
876
|
+
case ParseErrorCode.PropertyNameExpected: return localizeWithPath(_moduleId, 'error.propertyNameExpected', 'Property name expected');
|
|
877
|
+
case ParseErrorCode.ValueExpected: return localizeWithPath(_moduleId, 'error.valueExpected', 'Value expected');
|
|
878
|
+
case ParseErrorCode.ColonExpected: return localizeWithPath(_moduleId, 'error.colonExpected', 'Colon expected');
|
|
879
|
+
case ParseErrorCode.CommaExpected: return localizeWithPath(_moduleId, 'error.commaExpected', 'Comma expected');
|
|
880
|
+
case ParseErrorCode.CloseBraceExpected: return localizeWithPath(_moduleId, 'error.closeBraceExpected', 'Closing brace expected');
|
|
881
|
+
case ParseErrorCode.CloseBracketExpected: return localizeWithPath(_moduleId, 'error.closeBracketExpected', 'Closing bracket expected');
|
|
882
|
+
case ParseErrorCode.EndOfFileExpected: return localizeWithPath(_moduleId, 'error.endOfFileExpected', 'End of file expected');
|
|
883
883
|
default:
|
|
884
884
|
return '';
|
|
885
885
|
}
|