@codingame/monaco-vscode-api 1.69.7 → 1.69.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +8 -7
- package/dist/configuration.js +384 -73
- package/dist/contextkey.js +13 -1
- package/dist/dialogs.js +13 -12
- package/dist/extHost.js +2063 -1396
- package/dist/files.js +100 -105
- package/dist/keybindings.js +358 -307
- package/dist/languageConfiguration.js +5 -4
- package/dist/languageService.js +3 -3
- package/dist/languages.js +4 -3
- package/dist/layout.js +294 -311
- package/dist/messages.js +2 -0
- package/dist/missing-services.js +5304 -5954
- package/dist/modelEditor.js +69 -68
- package/dist/monaco.js +14 -13
- package/dist/notifications.js +268 -337
- package/dist/polyfill.js +446 -913
- package/dist/services.js +1 -1
- package/dist/services2.js +659 -26
- package/dist/snippets.js +102 -109
- package/dist/textmate.js +82 -89
- package/dist/theme.js +396 -407
- package/dist/tokenClassification.js +4 -3
- package/dist/tokenClassificationRegistry.js +78 -84
- package/dist/tools.js +2 -1
- package/dist/workbenchThemeService.js +1 -1
- package/dist/workspaceContext.js +2 -1
- package/package.json +1 -1
package/dist/polyfill.js
CHANGED
|
@@ -45,12 +45,6 @@ import { SnippetParser } from 'monaco-editor/esm/vs/editor/contrib/snippet/brows
|
|
|
45
45
|
import { QuickInputController } from 'monaco-editor/esm/vs/base/parts/quickinput/browser/quickInput.js';
|
|
46
46
|
import { getSingletonServiceDescriptors } from 'monaco-editor/esm/vs/platform/instantiation/common/extensions.js';
|
|
47
47
|
import { ILabelService } from 'monaco-editor/esm/vs/platform/label/common/label.js';
|
|
48
|
-
|
|
49
|
-
/*---------------------------------------------------------------------------------------------
|
|
50
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
51
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
52
|
-
*--------------------------------------------------------------------------------------------*/
|
|
53
|
-
// Avoid circular dependency on EventEmitter by implementing a subset of the interface.
|
|
54
48
|
class ErrorHandler {
|
|
55
49
|
constructor() {
|
|
56
50
|
this.listeners = [];
|
|
@@ -90,18 +84,17 @@ class ErrorHandler {
|
|
|
90
84
|
this.unexpectedErrorHandler(e);
|
|
91
85
|
this.emit(e);
|
|
92
86
|
}
|
|
93
|
-
// For external errors, we don't want the listeners to be called
|
|
94
87
|
onUnexpectedExternalError(e) {
|
|
95
88
|
this.unexpectedErrorHandler(e);
|
|
96
89
|
}
|
|
97
90
|
}
|
|
98
91
|
function readonly(name) {
|
|
99
92
|
return name
|
|
100
|
-
? (
|
|
101
|
-
: (
|
|
93
|
+
? ( new Error(`readonly property '${name} cannot be changed'`))
|
|
94
|
+
: ( new Error('readonly property cannot be changed'));
|
|
102
95
|
}
|
|
103
96
|
function disposed(what) {
|
|
104
|
-
const result = (
|
|
97
|
+
const result = ( new Error(`${what} has been disposed`));
|
|
105
98
|
result.name = 'DISPOSED';
|
|
106
99
|
return result;
|
|
107
100
|
}
|
|
@@ -125,9 +118,6 @@ class NotImplementedError extends Error {
|
|
|
125
118
|
}
|
|
126
119
|
}
|
|
127
120
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Error that when thrown won't be logged in telemetry as an unhandled error.
|
|
130
|
-
*/
|
|
131
121
|
class ErrorNoTelemetry extends Error {
|
|
132
122
|
constructor(msg) {
|
|
133
123
|
super(msg);
|
|
@@ -137,7 +127,7 @@ class ErrorNoTelemetry extends Error {
|
|
|
137
127
|
if (err instanceof ErrorNoTelemetry) {
|
|
138
128
|
return err;
|
|
139
129
|
}
|
|
140
|
-
const result = (
|
|
130
|
+
const result = ( new ErrorNoTelemetry());
|
|
141
131
|
result.message = err.message;
|
|
142
132
|
result.stack = err.stack;
|
|
143
133
|
return result;
|
|
@@ -146,11 +136,6 @@ class ErrorNoTelemetry extends Error {
|
|
|
146
136
|
return err.name === 'ErrorNoTelemetry';
|
|
147
137
|
}
|
|
148
138
|
}
|
|
149
|
-
|
|
150
|
-
/*---------------------------------------------------------------------------------------------
|
|
151
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
152
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
153
|
-
*--------------------------------------------------------------------------------------------*/
|
|
154
139
|
function isReadableStream(obj) {
|
|
155
140
|
const candidate = obj;
|
|
156
141
|
if (!candidate) {
|
|
@@ -166,7 +151,7 @@ function isReadableBufferedStream(obj) {
|
|
|
166
151
|
return isReadableStream(candidate.stream) && Array.isArray(candidate.buffer) && typeof candidate.ended === 'boolean';
|
|
167
152
|
}
|
|
168
153
|
function newWriteableStream(reducer, options) {
|
|
169
|
-
return (
|
|
154
|
+
return ( new WriteableStreamImpl(reducer, options));
|
|
170
155
|
}
|
|
171
156
|
class WriteableStreamImpl {
|
|
172
157
|
constructor(reducer, options) {
|
|
@@ -200,7 +185,6 @@ class WriteableStreamImpl {
|
|
|
200
185
|
}
|
|
201
186
|
if (!this.state.flowing) {
|
|
202
187
|
this.state.flowing = true;
|
|
203
|
-
// emit buffered events
|
|
204
188
|
this.flowData();
|
|
205
189
|
this.flowErrors();
|
|
206
190
|
this.flowEnd();
|
|
@@ -210,16 +194,13 @@ class WriteableStreamImpl {
|
|
|
210
194
|
if (this.state.destroyed) {
|
|
211
195
|
return;
|
|
212
196
|
}
|
|
213
|
-
// flowing: directly send the data to listeners
|
|
214
197
|
if (this.state.flowing) {
|
|
215
198
|
this.emitData(data);
|
|
216
199
|
}
|
|
217
|
-
// not yet flowing: buffer data until flowing
|
|
218
200
|
else {
|
|
219
201
|
this.buffer.data.push(data);
|
|
220
|
-
// highWaterMark: if configured, signal back when buffer reached limits
|
|
221
202
|
if (typeof this.options?.highWaterMark === 'number' && this.buffer.data.length > this.options.highWaterMark) {
|
|
222
|
-
return (
|
|
203
|
+
return ( new Promise(resolve => this.pendingWritePromises.push(resolve)));
|
|
223
204
|
}
|
|
224
205
|
}
|
|
225
206
|
}
|
|
@@ -227,11 +208,9 @@ class WriteableStreamImpl {
|
|
|
227
208
|
if (this.state.destroyed) {
|
|
228
209
|
return;
|
|
229
210
|
}
|
|
230
|
-
// flowing: directly send the error to listeners
|
|
231
211
|
if (this.state.flowing) {
|
|
232
212
|
this.emitError(error);
|
|
233
213
|
}
|
|
234
|
-
// not yet flowing: buffer errors until flowing
|
|
235
214
|
else {
|
|
236
215
|
this.buffer.error.push(error);
|
|
237
216
|
}
|
|
@@ -240,33 +219,30 @@ class WriteableStreamImpl {
|
|
|
240
219
|
if (this.state.destroyed) {
|
|
241
220
|
return;
|
|
242
221
|
}
|
|
243
|
-
// end with data if provided
|
|
244
222
|
if (typeof result !== 'undefined') {
|
|
245
223
|
this.write(result);
|
|
246
224
|
}
|
|
247
|
-
// flowing: send end event to listeners
|
|
248
225
|
if (this.state.flowing) {
|
|
249
226
|
this.emitEnd();
|
|
250
227
|
this.destroy();
|
|
251
228
|
}
|
|
252
|
-
// not yet flowing: remember state
|
|
253
229
|
else {
|
|
254
230
|
this.state.ended = true;
|
|
255
231
|
}
|
|
256
232
|
}
|
|
257
233
|
emitData(data) {
|
|
258
|
-
this.listeners.data.slice(0).forEach(listener => listener(data));
|
|
234
|
+
this.listeners.data.slice(0).forEach(listener => listener(data));
|
|
259
235
|
}
|
|
260
236
|
emitError(error) {
|
|
261
237
|
if (this.listeners.error.length === 0) {
|
|
262
|
-
onUnexpectedError(error);
|
|
238
|
+
onUnexpectedError(error);
|
|
263
239
|
}
|
|
264
240
|
else {
|
|
265
|
-
this.listeners.error.slice(0).forEach(listener => listener(error));
|
|
241
|
+
this.listeners.error.slice(0).forEach(listener => listener(error));
|
|
266
242
|
}
|
|
267
243
|
}
|
|
268
244
|
emitEnd() {
|
|
269
|
-
this.listeners.end.slice(0).forEach(listener => listener());
|
|
245
|
+
this.listeners.end.slice(0).forEach(listener => listener());
|
|
270
246
|
}
|
|
271
247
|
on(event, callback) {
|
|
272
248
|
if (this.state.destroyed) {
|
|
@@ -275,24 +251,16 @@ class WriteableStreamImpl {
|
|
|
275
251
|
switch (event) {
|
|
276
252
|
case 'data':
|
|
277
253
|
this.listeners.data.push(callback);
|
|
278
|
-
// switch into flowing mode as soon as the first 'data'
|
|
279
|
-
// listener is added and we are not yet in flowing mode
|
|
280
254
|
this.resume();
|
|
281
255
|
break;
|
|
282
256
|
case 'end':
|
|
283
257
|
this.listeners.end.push(callback);
|
|
284
|
-
// emit 'end' event directly if we are flowing
|
|
285
|
-
// and the end has already been reached
|
|
286
|
-
//
|
|
287
|
-
// finish() when it went through
|
|
288
258
|
if (this.state.flowing && this.flowEnd()) {
|
|
289
259
|
this.destroy();
|
|
290
260
|
}
|
|
291
261
|
break;
|
|
292
262
|
case 'error':
|
|
293
263
|
this.listeners.error.push(callback);
|
|
294
|
-
// emit buffered 'error' events unless done already
|
|
295
|
-
// now that we know that we have at least one listener
|
|
296
264
|
if (this.state.flowing) {
|
|
297
265
|
this.flowErrors();
|
|
298
266
|
}
|
|
@@ -327,7 +295,6 @@ class WriteableStreamImpl {
|
|
|
327
295
|
const fullDataBuffer = this.reducer(this.buffer.data);
|
|
328
296
|
this.emitData(fullDataBuffer);
|
|
329
297
|
this.buffer.data.length = 0;
|
|
330
|
-
// When the buffer is empty, resolve all pending writers
|
|
331
298
|
const pendingWritePromises = [...this.pendingWritePromises];
|
|
332
299
|
this.pendingWritePromises.length = 0;
|
|
333
300
|
pendingWritePromises.forEach(pendingWritePromise => pendingWritePromise());
|
|
@@ -361,9 +328,6 @@ class WriteableStreamImpl {
|
|
|
361
328
|
}
|
|
362
329
|
}
|
|
363
330
|
}
|
|
364
|
-
/**
|
|
365
|
-
* Helper to fully read a T readable into a T.
|
|
366
|
-
*/
|
|
367
331
|
function consumeReadable(readable, reducer) {
|
|
368
332
|
const chunks = [];
|
|
369
333
|
let chunk;
|
|
@@ -372,47 +336,31 @@ function consumeReadable(readable, reducer) {
|
|
|
372
336
|
}
|
|
373
337
|
return reducer(chunks);
|
|
374
338
|
}
|
|
375
|
-
/**
|
|
376
|
-
* Helper to read a T readable up to a maximum of chunks. If the limit is
|
|
377
|
-
* reached, will return a readable instead to ensure all data can still
|
|
378
|
-
* be read.
|
|
379
|
-
*/
|
|
380
339
|
function peekReadable(readable, reducer, maxChunks) {
|
|
381
340
|
const chunks = [];
|
|
382
341
|
let chunk = undefined;
|
|
383
342
|
while ((chunk = readable.read()) !== null && chunks.length < maxChunks) {
|
|
384
343
|
chunks.push(chunk);
|
|
385
344
|
}
|
|
386
|
-
// If the last chunk is null, it means we reached the end of
|
|
387
|
-
// the readable and return all the data at once
|
|
388
345
|
if (chunk === null && chunks.length > 0) {
|
|
389
346
|
return reducer(chunks);
|
|
390
347
|
}
|
|
391
|
-
// Otherwise, we still have a chunk, it means we reached the maxChunks
|
|
392
|
-
// value and as such we return a new Readable that first returns
|
|
393
|
-
// the existing read chunks and then continues with reading from
|
|
394
|
-
// the underlying readable.
|
|
395
348
|
return {
|
|
396
349
|
read: () => {
|
|
397
|
-
// First consume chunks from our array
|
|
398
350
|
if (chunks.length > 0) {
|
|
399
351
|
return chunks.shift();
|
|
400
352
|
}
|
|
401
|
-
// Then ensure to return our last read chunk
|
|
402
353
|
if (typeof chunk !== 'undefined') {
|
|
403
354
|
const lastReadChunk = chunk;
|
|
404
|
-
// explicitly use undefined here to indicate that we consumed
|
|
405
|
-
// the chunk, which could have either been null or valued.
|
|
406
355
|
chunk = undefined;
|
|
407
356
|
return lastReadChunk;
|
|
408
357
|
}
|
|
409
|
-
// Finally delegate back to the Readable
|
|
410
358
|
return readable.read();
|
|
411
359
|
}
|
|
412
360
|
};
|
|
413
361
|
}
|
|
414
362
|
function consumeStream(stream, reducer) {
|
|
415
|
-
return (
|
|
363
|
+
return ( new Promise((resolve, reject) => {
|
|
416
364
|
const chunks = [];
|
|
417
365
|
listenStream(stream, {
|
|
418
366
|
onData: chunk => {
|
|
@@ -439,9 +387,6 @@ function consumeStream(stream, reducer) {
|
|
|
439
387
|
});
|
|
440
388
|
}));
|
|
441
389
|
}
|
|
442
|
-
/**
|
|
443
|
-
* Helper to listen to all events of a T stream in proper order.
|
|
444
|
-
*/
|
|
445
390
|
function listenStream(stream, listener) {
|
|
446
391
|
let destroyed = false;
|
|
447
392
|
stream.on('error', error => {
|
|
@@ -454,9 +399,6 @@ function listenStream(stream, listener) {
|
|
|
454
399
|
listener.onEnd();
|
|
455
400
|
}
|
|
456
401
|
});
|
|
457
|
-
// Adding the `data` listener will turn the stream
|
|
458
|
-
// into flowing mode. As such it is important to
|
|
459
|
-
// add this listener last (DO NOT CHANGE!)
|
|
460
402
|
stream.on('data', data => {
|
|
461
403
|
if (!destroyed) {
|
|
462
404
|
listener.onData(data);
|
|
@@ -464,33 +406,21 @@ function listenStream(stream, listener) {
|
|
|
464
406
|
});
|
|
465
407
|
return toDisposable(() => destroyed = true);
|
|
466
408
|
}
|
|
467
|
-
/**
|
|
468
|
-
* Helper to peek up to `maxChunks` into a stream. The return type signals if
|
|
469
|
-
* the stream has ended or not. If not, caller needs to add a `data` listener
|
|
470
|
-
* to continue reading.
|
|
471
|
-
*/
|
|
472
409
|
function peekStream(stream, maxChunks) {
|
|
473
|
-
return (
|
|
474
|
-
const streamListeners = (
|
|
410
|
+
return ( new Promise((resolve, reject) => {
|
|
411
|
+
const streamListeners = ( new DisposableStore());
|
|
475
412
|
const buffer = [];
|
|
476
|
-
// Data Listener
|
|
477
413
|
const dataListener = (chunk) => {
|
|
478
|
-
// Add to buffer
|
|
479
414
|
buffer.push(chunk);
|
|
480
|
-
// We reached maxChunks and thus need to return
|
|
481
415
|
if (buffer.length > maxChunks) {
|
|
482
|
-
// Dispose any listeners and ensure to pause the
|
|
483
|
-
// stream so that it can be consumed again by caller
|
|
484
416
|
streamListeners.dispose();
|
|
485
417
|
stream.pause();
|
|
486
418
|
return resolve({ stream, buffer, ended: false });
|
|
487
419
|
}
|
|
488
420
|
};
|
|
489
|
-
// Error Listener
|
|
490
421
|
const errorListener = (error) => {
|
|
491
422
|
return reject(error);
|
|
492
423
|
};
|
|
493
|
-
// End Listener
|
|
494
424
|
const endListener = () => {
|
|
495
425
|
return resolve({ stream, buffer, ended: true });
|
|
496
426
|
};
|
|
@@ -498,16 +428,10 @@ function peekStream(stream, maxChunks) {
|
|
|
498
428
|
stream.on('error', errorListener);
|
|
499
429
|
streamListeners.add(toDisposable(() => stream.removeListener('end', endListener)));
|
|
500
430
|
stream.on('end', endListener);
|
|
501
|
-
// Important: leave the `data` listener last because
|
|
502
|
-
// this can turn the stream into flowing mode and we
|
|
503
|
-
// want `error` events to be received as well.
|
|
504
431
|
streamListeners.add(toDisposable(() => stream.removeListener('data', dataListener)));
|
|
505
432
|
stream.on('data', dataListener);
|
|
506
433
|
}));
|
|
507
434
|
}
|
|
508
|
-
/**
|
|
509
|
-
* Helper to convert a T into a Readable<T>.
|
|
510
|
-
*/
|
|
511
435
|
function toReadable(t) {
|
|
512
436
|
let consumed = false;
|
|
513
437
|
return {
|
|
@@ -520,9 +444,6 @@ function toReadable(t) {
|
|
|
520
444
|
}
|
|
521
445
|
};
|
|
522
446
|
}
|
|
523
|
-
/**
|
|
524
|
-
* Helper to transform a readable stream into another stream.
|
|
525
|
-
*/
|
|
526
447
|
function transform(stream, transformer, reducer) {
|
|
527
448
|
const target = newWriteableStream(reducer);
|
|
528
449
|
listenStream(stream, {
|
|
@@ -532,11 +453,6 @@ function transform(stream, transformer, reducer) {
|
|
|
532
453
|
});
|
|
533
454
|
return target;
|
|
534
455
|
}
|
|
535
|
-
|
|
536
|
-
/*---------------------------------------------------------------------------------------------
|
|
537
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
538
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
539
|
-
*--------------------------------------------------------------------------------------------*/
|
|
540
456
|
const hasBuffer = (typeof Buffer !== 'undefined');
|
|
541
457
|
let textEncoder;
|
|
542
458
|
let textDecoder;
|
|
@@ -545,51 +461,32 @@ class VSBuffer {
|
|
|
545
461
|
this.buffer = buffer;
|
|
546
462
|
this.byteLength = this.buffer.byteLength;
|
|
547
463
|
}
|
|
548
|
-
/**
|
|
549
|
-
* When running in a nodejs context, the backing store for the returned `VSBuffer` instance
|
|
550
|
-
* might use a nodejs Buffer allocated from node's Buffer pool, which is not transferrable.
|
|
551
|
-
*/
|
|
552
464
|
static alloc(byteLength) {
|
|
553
465
|
if (hasBuffer) {
|
|
554
|
-
return (
|
|
466
|
+
return ( new VSBuffer(Buffer.allocUnsafe(byteLength)));
|
|
555
467
|
}
|
|
556
468
|
else {
|
|
557
|
-
return (
|
|
469
|
+
return ( new VSBuffer(( new Uint8Array(byteLength))));
|
|
558
470
|
}
|
|
559
471
|
}
|
|
560
|
-
/**
|
|
561
|
-
* When running in a nodejs context, if `actual` is not a nodejs Buffer, the backing store for
|
|
562
|
-
* the returned `VSBuffer` instance might use a nodejs Buffer allocated from node's Buffer pool,
|
|
563
|
-
* which is not transferrable.
|
|
564
|
-
*/
|
|
565
472
|
static wrap(actual) {
|
|
566
473
|
if (hasBuffer && !(Buffer.isBuffer(actual))) {
|
|
567
|
-
// https://nodejs.org/dist/latest-v10.x/docs/api/buffer.html#buffer_class_method_buffer_from_arraybuffer_byteoffset_length
|
|
568
|
-
// Create a zero-copy Buffer wrapper around the ArrayBuffer pointed to by the Uint8Array
|
|
569
474
|
actual = Buffer.from(actual.buffer, actual.byteOffset, actual.byteLength);
|
|
570
475
|
}
|
|
571
|
-
return (
|
|
476
|
+
return ( new VSBuffer(actual));
|
|
572
477
|
}
|
|
573
|
-
/**
|
|
574
|
-
* When running in a nodejs context, the backing store for the returned `VSBuffer` instance
|
|
575
|
-
* might use a nodejs Buffer allocated from node's Buffer pool, which is not transferrable.
|
|
576
|
-
*/
|
|
577
478
|
static fromString(source, options) {
|
|
578
479
|
const dontUseNodeBuffer = options?.dontUseNodeBuffer || false;
|
|
579
480
|
if (!dontUseNodeBuffer && hasBuffer) {
|
|
580
|
-
return (
|
|
481
|
+
return ( new VSBuffer(Buffer.from(source)));
|
|
581
482
|
}
|
|
582
483
|
else {
|
|
583
484
|
if (!textEncoder) {
|
|
584
|
-
textEncoder = (
|
|
485
|
+
textEncoder = ( new TextEncoder());
|
|
585
486
|
}
|
|
586
|
-
return (
|
|
487
|
+
return ( new VSBuffer(textEncoder.encode(source)));
|
|
587
488
|
}
|
|
588
489
|
}
|
|
589
|
-
/**
|
|
590
|
-
* When running in a nodejs context, the backing store for the returned `VSBuffer` instance
|
|
591
|
-
* might use a nodejs Buffer allocated from node's Buffer pool, which is not transferrable.
|
|
592
|
-
*/
|
|
593
490
|
static fromByteArray(source) {
|
|
594
491
|
const result = VSBuffer.alloc(source.length);
|
|
595
492
|
for (let i = 0, len = source.length; i < len; i++) {
|
|
@@ -597,10 +494,6 @@ class VSBuffer {
|
|
|
597
494
|
}
|
|
598
495
|
return result;
|
|
599
496
|
}
|
|
600
|
-
/**
|
|
601
|
-
* When running in a nodejs context, the backing store for the returned `VSBuffer` instance
|
|
602
|
-
* might use a nodejs Buffer allocated from node's Buffer pool, which is not transferrable.
|
|
603
|
-
*/
|
|
604
497
|
static concat(buffers, totalLength) {
|
|
605
498
|
if (typeof totalLength === 'undefined') {
|
|
606
499
|
totalLength = 0;
|
|
@@ -617,10 +510,6 @@ class VSBuffer {
|
|
|
617
510
|
}
|
|
618
511
|
return ret;
|
|
619
512
|
}
|
|
620
|
-
/**
|
|
621
|
-
* When running in a nodejs context, the backing store for the returned `VSBuffer` instance
|
|
622
|
-
* might use a nodejs Buffer allocated from node's Buffer pool, which is not transferrable.
|
|
623
|
-
*/
|
|
624
513
|
clone() {
|
|
625
514
|
const result = VSBuffer.alloc(this.byteLength);
|
|
626
515
|
result.set(this);
|
|
@@ -628,20 +517,17 @@ class VSBuffer {
|
|
|
628
517
|
}
|
|
629
518
|
toString() {
|
|
630
519
|
if (hasBuffer) {
|
|
631
|
-
return (
|
|
520
|
+
return ( this.buffer.toString());
|
|
632
521
|
}
|
|
633
522
|
else {
|
|
634
523
|
if (!textDecoder) {
|
|
635
|
-
textDecoder = (
|
|
524
|
+
textDecoder = ( new TextDecoder());
|
|
636
525
|
}
|
|
637
526
|
return textDecoder.decode(this.buffer);
|
|
638
527
|
}
|
|
639
528
|
}
|
|
640
529
|
slice(start, end) {
|
|
641
|
-
|
|
642
|
-
// creates shallow copy and NodeBuffer#slice doesn't. The use of subarray
|
|
643
|
-
// ensures the same, performance, behaviour.
|
|
644
|
-
return (/*#__PURE__*/ new VSBuffer(this.buffer.subarray(start, end)));
|
|
530
|
+
return ( new VSBuffer(this.buffer.subarray(start, end)));
|
|
645
531
|
}
|
|
646
532
|
set(array, offset) {
|
|
647
533
|
if (array instanceof VSBuffer) {
|
|
@@ -651,10 +537,10 @@ class VSBuffer {
|
|
|
651
537
|
this.buffer.set(array, offset);
|
|
652
538
|
}
|
|
653
539
|
else if (array instanceof ArrayBuffer) {
|
|
654
|
-
this.buffer.set((
|
|
540
|
+
this.buffer.set(( new Uint8Array(array)), offset);
|
|
655
541
|
}
|
|
656
542
|
else if (ArrayBuffer.isView(array)) {
|
|
657
|
-
this.buffer.set((
|
|
543
|
+
this.buffer.set(( new Uint8Array(array.buffer, array.byteOffset, array.byteLength)), offset);
|
|
658
544
|
}
|
|
659
545
|
else {
|
|
660
546
|
throw new Error(`Unknown argument 'array'`);
|
|
@@ -729,35 +615,22 @@ async function bufferedStreamToBuffer(bufferedStream) {
|
|
|
729
615
|
return VSBuffer.concat(bufferedStream.buffer);
|
|
730
616
|
}
|
|
731
617
|
return VSBuffer.concat([
|
|
732
|
-
// Include already read chunks...
|
|
733
618
|
...bufferedStream.buffer,
|
|
734
|
-
// ...and all additional chunks
|
|
735
619
|
await streamToBuffer(bufferedStream.stream)
|
|
736
620
|
]);
|
|
737
621
|
}
|
|
738
622
|
function newWriteableBufferStream(options) {
|
|
739
623
|
return newWriteableStream(chunks => VSBuffer.concat(chunks), options);
|
|
740
624
|
}
|
|
741
|
-
|
|
742
625
|
const Emitter = monaco.Emitter;
|
|
743
|
-
|
|
744
|
-
/*---------------------------------------------------------------------------------------------
|
|
745
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
746
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
747
|
-
*--------------------------------------------------------------------------------------------*/
|
|
748
|
-
// static theming participant
|
|
749
626
|
const Extensions$1 = {
|
|
750
627
|
ThemingContribution: 'base.contributions.theming'
|
|
751
628
|
};
|
|
752
|
-
/**
|
|
753
|
-
* Utility base class for all themable components.
|
|
754
|
-
*/
|
|
755
629
|
class Themable extends Disposable {
|
|
756
630
|
constructor(themeService) {
|
|
757
631
|
super();
|
|
758
632
|
this.themeService = themeService;
|
|
759
633
|
this.theme = themeService.getColorTheme();
|
|
760
|
-
// Hook up to theme changes
|
|
761
634
|
this._register(this.themeService.onDidColorThemeChange(theme => this.onThemeChange(theme)));
|
|
762
635
|
}
|
|
763
636
|
onThemeChange(theme) {
|
|
@@ -765,40 +638,26 @@ class Themable extends Disposable {
|
|
|
765
638
|
this.updateStyles();
|
|
766
639
|
}
|
|
767
640
|
updateStyles() {
|
|
768
|
-
// Subclasses to override
|
|
769
641
|
}
|
|
770
642
|
getColor(id, modify) {
|
|
771
643
|
let color = this.theme.getColor(id);
|
|
772
644
|
if (color && modify) {
|
|
773
645
|
color = modify(color, this.theme);
|
|
774
646
|
}
|
|
775
|
-
return color ? (
|
|
647
|
+
return color ? ( color.toString()) : null;
|
|
776
648
|
}
|
|
777
649
|
}
|
|
778
|
-
|
|
779
|
-
/*---------------------------------------------------------------------------------------------
|
|
780
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
781
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
782
|
-
*--------------------------------------------------------------------------------------------*/
|
|
783
650
|
const Extensions = {
|
|
784
651
|
JSONContribution: 'base.contributions.json'
|
|
785
652
|
};
|
|
786
|
-
|
|
787
|
-
/*---------------------------------------------------------------------------------------------
|
|
788
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
789
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
790
|
-
*--------------------------------------------------------------------------------------------*/
|
|
791
653
|
const CSS_DONE = 'done';
|
|
792
654
|
const CSS_ACTIVE = 'active';
|
|
793
655
|
const CSS_INFINITE = 'infinite';
|
|
794
656
|
const CSS_INFINITE_LONG_RUNNING = 'infinite-long-running';
|
|
795
657
|
const CSS_DISCRETE = 'discrete';
|
|
796
658
|
const defaultOpts = {
|
|
797
|
-
progressBarBackground: (
|
|
659
|
+
progressBarBackground: ( Color$1.fromHex('#0E70C0'))
|
|
798
660
|
};
|
|
799
|
-
/**
|
|
800
|
-
* A progress bar with support for infinite or discrete progress.
|
|
801
|
-
*/
|
|
802
661
|
class ProgressBar extends Disposable {
|
|
803
662
|
constructor(container, options) {
|
|
804
663
|
super();
|
|
@@ -806,8 +665,8 @@ class ProgressBar extends Disposable {
|
|
|
806
665
|
mixin(this.options, defaultOpts, false);
|
|
807
666
|
this.workedVal = 0;
|
|
808
667
|
this.progressBarBackground = this.options.progressBarBackground;
|
|
809
|
-
this.showDelayedScheduler = this._register((
|
|
810
|
-
this.longRunningScheduler = this._register((
|
|
668
|
+
this.showDelayedScheduler = this._register(( new RunOnceScheduler(() => show(this.element), 0)));
|
|
669
|
+
this.longRunningScheduler = this._register(( new RunOnceScheduler(
|
|
811
670
|
() => this.infiniteLongRunning(),
|
|
812
671
|
ProgressBar.LONG_RUNNING_INFINITE_THRESHOLD
|
|
813
672
|
)));
|
|
@@ -832,21 +691,14 @@ class ProgressBar extends Disposable {
|
|
|
832
691
|
this.totalWork = undefined;
|
|
833
692
|
this.longRunningScheduler.cancel();
|
|
834
693
|
}
|
|
835
|
-
/**
|
|
836
|
-
* Indicates to the progress bar that all work is done.
|
|
837
|
-
*/
|
|
838
694
|
done() {
|
|
839
695
|
return this.doDone(true);
|
|
840
696
|
}
|
|
841
|
-
/**
|
|
842
|
-
* Stops the progressbar from showing any progress instantly without fading out.
|
|
843
|
-
*/
|
|
844
697
|
stop() {
|
|
845
698
|
return this.doDone(false);
|
|
846
699
|
}
|
|
847
700
|
doDone(delayed) {
|
|
848
701
|
this.element.classList.add(CSS_DONE);
|
|
849
|
-
// discrete: let it grow to 100% width and hide afterwards
|
|
850
702
|
if (!this.element.classList.contains(CSS_INFINITE)) {
|
|
851
703
|
this.bit.style.width = 'inherit';
|
|
852
704
|
if (delayed) {
|
|
@@ -856,7 +708,6 @@ class ProgressBar extends Disposable {
|
|
|
856
708
|
this.off();
|
|
857
709
|
}
|
|
858
710
|
}
|
|
859
|
-
// infinite: let it fade out and hide afterwards
|
|
860
711
|
else {
|
|
861
712
|
this.bit.style.opacity = '0';
|
|
862
713
|
if (delayed) {
|
|
@@ -868,9 +719,6 @@ class ProgressBar extends Disposable {
|
|
|
868
719
|
}
|
|
869
720
|
return this;
|
|
870
721
|
}
|
|
871
|
-
/**
|
|
872
|
-
* Use this mode to indicate progress that has no total number of work units.
|
|
873
|
-
*/
|
|
874
722
|
infinite() {
|
|
875
723
|
this.bit.style.width = '2%';
|
|
876
724
|
this.bit.style.opacity = '1';
|
|
@@ -882,32 +730,19 @@ class ProgressBar extends Disposable {
|
|
|
882
730
|
infiniteLongRunning() {
|
|
883
731
|
this.element.classList.add(CSS_INFINITE_LONG_RUNNING);
|
|
884
732
|
}
|
|
885
|
-
/**
|
|
886
|
-
* Tells the progress bar the total number of work. Use in combination with workedVal() to let
|
|
887
|
-
* the progress bar show the actual progress based on the work that is done.
|
|
888
|
-
*/
|
|
889
733
|
total(value) {
|
|
890
734
|
this.workedVal = 0;
|
|
891
735
|
this.totalWork = value;
|
|
892
|
-
this.element.setAttribute('aria-valuemax', (
|
|
736
|
+
this.element.setAttribute('aria-valuemax', ( value.toString()));
|
|
893
737
|
return this;
|
|
894
738
|
}
|
|
895
|
-
/**
|
|
896
|
-
* Finds out if this progress bar is configured with total work
|
|
897
|
-
*/
|
|
898
739
|
hasTotal() {
|
|
899
740
|
return isNumber(this.totalWork);
|
|
900
741
|
}
|
|
901
|
-
/**
|
|
902
|
-
* Tells the progress bar that an increment of work has been completed.
|
|
903
|
-
*/
|
|
904
742
|
worked(value) {
|
|
905
743
|
value = Math.max(1, Number(value));
|
|
906
744
|
return this.doSetWorked(this.workedVal + value);
|
|
907
745
|
}
|
|
908
|
-
/**
|
|
909
|
-
* Tells the progress bar the total amount of work that has been completed.
|
|
910
|
-
*/
|
|
911
746
|
setWorked(value) {
|
|
912
747
|
value = Math.max(1, Number(value));
|
|
913
748
|
return this.doSetWorked(value);
|
|
@@ -918,7 +753,7 @@ class ProgressBar extends Disposable {
|
|
|
918
753
|
this.workedVal = Math.min(totalWork, this.workedVal);
|
|
919
754
|
this.element.classList.remove(CSS_INFINITE, CSS_INFINITE_LONG_RUNNING, CSS_DONE);
|
|
920
755
|
this.element.classList.add(CSS_ACTIVE, CSS_DISCRETE);
|
|
921
|
-
this.element.setAttribute('aria-valuenow', (
|
|
756
|
+
this.element.setAttribute('aria-valuenow', ( value.toString()));
|
|
922
757
|
this.bit.style.width = 100 * (this.workedVal / (totalWork)) + '%';
|
|
923
758
|
return this;
|
|
924
759
|
}
|
|
@@ -944,37 +779,24 @@ class ProgressBar extends Disposable {
|
|
|
944
779
|
}
|
|
945
780
|
applyStyles() {
|
|
946
781
|
if (this.bit) {
|
|
947
|
-
const background = this.progressBarBackground ? (
|
|
782
|
+
const background = this.progressBarBackground ? ( this.progressBarBackground.toString()) : '';
|
|
948
783
|
this.bit.style.backgroundColor = background;
|
|
949
784
|
}
|
|
950
785
|
}
|
|
951
786
|
}
|
|
952
|
-
/**
|
|
953
|
-
* After a certain time of showing the progress bar, switch
|
|
954
|
-
* to long-running mode and throttle animations to reduce
|
|
955
|
-
* the pressure on the GPU process.
|
|
956
|
-
*
|
|
957
|
-
* https://github.com/microsoft/vscode/issues/97900
|
|
958
|
-
* https://github.com/microsoft/vscode/issues/138396
|
|
959
|
-
*/
|
|
960
787
|
ProgressBar.LONG_RUNNING_INFINITE_THRESHOLD = 10000;
|
|
961
|
-
|
|
962
|
-
/*---------------------------------------------------------------------------------------------
|
|
963
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
964
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
965
|
-
*--------------------------------------------------------------------------------------------*/
|
|
966
788
|
class LanguageService extends Disposable {
|
|
967
789
|
constructor(warnOnOverwrite = false) {
|
|
968
790
|
super();
|
|
969
|
-
this._onDidEncounterLanguage = this._register((
|
|
791
|
+
this._onDidEncounterLanguage = this._register(( new Emitter()));
|
|
970
792
|
this.onDidEncounterLanguage = this._onDidEncounterLanguage.event;
|
|
971
|
-
this._onDidChange = this._register((
|
|
972
|
-
{ leakWarningThreshold: 200
|
|
793
|
+
this._onDidChange = this._register(( new Emitter(
|
|
794
|
+
{ leakWarningThreshold: 200 }
|
|
973
795
|
)));
|
|
974
796
|
this.onDidChange = this._onDidChange.event;
|
|
975
797
|
LanguageService.instanceCount++;
|
|
976
|
-
this._encounteredLanguages = (
|
|
977
|
-
this._registry = this._register((
|
|
798
|
+
this._encounteredLanguages = ( new Set());
|
|
799
|
+
this._registry = this._register(( new LanguagesRegistry$1(true, warnOnOverwrite)));
|
|
978
800
|
this.languageIdCodec = this._registry.languageIdCodec;
|
|
979
801
|
this._register(this._registry.onDidChange(() => this._onDidChange.fire()));
|
|
980
802
|
}
|
|
@@ -1023,32 +845,29 @@ class LanguageService extends Disposable {
|
|
|
1023
845
|
return firstOrDefault(languageIds, null);
|
|
1024
846
|
}
|
|
1025
847
|
createById(languageId) {
|
|
1026
|
-
return (
|
|
848
|
+
return ( new LanguageSelection(this.onDidChange, () => {
|
|
1027
849
|
return this._createAndGetLanguageIdentifier(languageId);
|
|
1028
850
|
}));
|
|
1029
851
|
}
|
|
1030
852
|
createByMimeType(mimeType) {
|
|
1031
|
-
return (
|
|
853
|
+
return ( new LanguageSelection(this.onDidChange, () => {
|
|
1032
854
|
const languageId = this.getLanguageIdByMimeType(mimeType);
|
|
1033
855
|
return this._createAndGetLanguageIdentifier(languageId);
|
|
1034
856
|
}));
|
|
1035
857
|
}
|
|
1036
858
|
createByFilepathOrFirstLine(resource, firstLine) {
|
|
1037
|
-
return (
|
|
859
|
+
return ( new LanguageSelection(this.onDidChange, () => {
|
|
1038
860
|
const languageId = this.guessLanguageIdByFilepathOrFirstLine(resource, firstLine);
|
|
1039
861
|
return this._createAndGetLanguageIdentifier(languageId);
|
|
1040
862
|
}));
|
|
1041
863
|
}
|
|
1042
864
|
_createAndGetLanguageIdentifier(languageId) {
|
|
1043
865
|
if (!languageId || !this.isRegisteredLanguageId(languageId)) {
|
|
1044
|
-
// Fall back to plain text if language is unknown
|
|
1045
866
|
languageId = PLAINTEXT_LANGUAGE_ID;
|
|
1046
867
|
}
|
|
1047
868
|
if (!this._encounteredLanguages.has(languageId)) {
|
|
1048
869
|
this._encounteredLanguages.add(languageId);
|
|
1049
|
-
// Ensure tokenizers are created
|
|
1050
870
|
TokenizationRegistry.getOrCreate(languageId);
|
|
1051
|
-
// Fire event
|
|
1052
871
|
this._onDidEncounterLanguage.fire(languageId);
|
|
1053
872
|
}
|
|
1054
873
|
return languageId;
|
|
@@ -1078,7 +897,7 @@ class LanguageSelection {
|
|
|
1078
897
|
this._listener = this._onDidChangeLanguages(() => this._evaluate());
|
|
1079
898
|
}
|
|
1080
899
|
if (!this._emitter) {
|
|
1081
|
-
this._emitter = (
|
|
900
|
+
this._emitter = ( new Emitter({
|
|
1082
901
|
onLastListenerRemove: () => {
|
|
1083
902
|
this._dispose();
|
|
1084
903
|
}
|
|
@@ -1089,48 +908,38 @@ class LanguageSelection {
|
|
|
1089
908
|
_evaluate() {
|
|
1090
909
|
const languageId = this._selector();
|
|
1091
910
|
if (languageId === this.languageId) {
|
|
1092
|
-
// no change
|
|
1093
911
|
return;
|
|
1094
912
|
}
|
|
1095
913
|
this.languageId = languageId;
|
|
1096
914
|
this._emitter?.fire(this.languageId);
|
|
1097
915
|
}
|
|
1098
916
|
}
|
|
1099
|
-
|
|
1100
|
-
/*---------------------------------------------------------------------------------------------
|
|
1101
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1102
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
1103
|
-
*--------------------------------------------------------------------------------------------*/
|
|
1104
917
|
var ParseOptions;
|
|
1105
|
-
(
|
|
918
|
+
( (function(ParseOptions) {
|
|
1106
919
|
ParseOptions.DEFAULT = {
|
|
1107
920
|
allowTrailingComma: true
|
|
1108
921
|
};
|
|
1109
922
|
})(ParseOptions || (ParseOptions = {})));
|
|
1110
|
-
/**
|
|
1111
|
-
* Creates a JSON scanner on the given text.
|
|
1112
|
-
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
|
1113
|
-
*/
|
|
1114
923
|
function createScanner(text, ignoreTrivia = false) {
|
|
1115
924
|
let pos = 0;
|
|
1116
925
|
const len = text.length;
|
|
1117
926
|
let value = '';
|
|
1118
927
|
let tokenOffset = 0;
|
|
1119
|
-
let token = 16
|
|
1120
|
-
let scanError = 0
|
|
928
|
+
let token = 16 ;
|
|
929
|
+
let scanError = 0 ;
|
|
1121
930
|
function scanHexDigits(count) {
|
|
1122
931
|
let digits = 0;
|
|
1123
932
|
let hexValue = 0;
|
|
1124
933
|
while (digits < count) {
|
|
1125
934
|
const ch = text.charCodeAt(pos);
|
|
1126
|
-
if (ch >= 48
|
|
1127
|
-
hexValue = hexValue * 16 + ch - 48
|
|
935
|
+
if (ch >= 48 && ch <= 57 ) {
|
|
936
|
+
hexValue = hexValue * 16 + ch - 48 ;
|
|
1128
937
|
}
|
|
1129
|
-
else if (ch >= 65
|
|
1130
|
-
hexValue = hexValue * 16 + ch - 65
|
|
938
|
+
else if (ch >= 65 && ch <= 70 ) {
|
|
939
|
+
hexValue = hexValue * 16 + ch - 65 + 10;
|
|
1131
940
|
}
|
|
1132
|
-
else if (ch >= 97
|
|
1133
|
-
hexValue = hexValue * 16 + ch - 97
|
|
941
|
+
else if (ch >= 97 && ch <= 102 ) {
|
|
942
|
+
hexValue = hexValue * 16 + ch - 97 + 10;
|
|
1134
943
|
}
|
|
1135
944
|
else {
|
|
1136
945
|
break;
|
|
@@ -1147,12 +956,12 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1147
956
|
pos = newPosition;
|
|
1148
957
|
value = '';
|
|
1149
958
|
tokenOffset = 0;
|
|
1150
|
-
token = 16
|
|
1151
|
-
scanError = 0
|
|
959
|
+
token = 16 ;
|
|
960
|
+
scanError = 0 ;
|
|
1152
961
|
}
|
|
1153
962
|
function scanNumber() {
|
|
1154
963
|
const start = pos;
|
|
1155
|
-
if (text.charCodeAt(pos) === 48
|
|
964
|
+
if (text.charCodeAt(pos) === 48 ) {
|
|
1156
965
|
pos++;
|
|
1157
966
|
}
|
|
1158
967
|
else {
|
|
@@ -1161,7 +970,7 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1161
970
|
pos++;
|
|
1162
971
|
}
|
|
1163
972
|
}
|
|
1164
|
-
if (pos < text.length && text.charCodeAt(pos) === 46
|
|
973
|
+
if (pos < text.length && text.charCodeAt(pos) === 46 ) {
|
|
1165
974
|
pos++;
|
|
1166
975
|
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
1167
976
|
pos++;
|
|
@@ -1170,14 +979,14 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1170
979
|
}
|
|
1171
980
|
}
|
|
1172
981
|
else {
|
|
1173
|
-
scanError = 3
|
|
982
|
+
scanError = 3 ;
|
|
1174
983
|
return text.substring(start, pos);
|
|
1175
984
|
}
|
|
1176
985
|
}
|
|
1177
986
|
let end = pos;
|
|
1178
|
-
if (pos < text.length && ((text.charCodeAt(pos) === 69
|
|
987
|
+
if (pos < text.length && ((text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) )) {
|
|
1179
988
|
pos++;
|
|
1180
|
-
if (pos < text.length && text.charCodeAt(pos) === 43
|
|
989
|
+
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45 ) {
|
|
1181
990
|
pos++;
|
|
1182
991
|
}
|
|
1183
992
|
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
@@ -1188,7 +997,7 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1188
997
|
end = pos;
|
|
1189
998
|
}
|
|
1190
999
|
else {
|
|
1191
|
-
scanError = 3
|
|
1000
|
+
scanError = 3 ;
|
|
1192
1001
|
}
|
|
1193
1002
|
}
|
|
1194
1003
|
return text.substring(start, end);
|
|
@@ -1198,60 +1007,60 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1198
1007
|
while (true) {
|
|
1199
1008
|
if (pos >= len) {
|
|
1200
1009
|
result += text.substring(start, pos);
|
|
1201
|
-
scanError = 2
|
|
1010
|
+
scanError = 2 ;
|
|
1202
1011
|
break;
|
|
1203
1012
|
}
|
|
1204
1013
|
const ch = text.charCodeAt(pos);
|
|
1205
|
-
if (ch === 34
|
|
1014
|
+
if (ch === 34 ) {
|
|
1206
1015
|
result += text.substring(start, pos);
|
|
1207
1016
|
pos++;
|
|
1208
1017
|
break;
|
|
1209
1018
|
}
|
|
1210
|
-
if (ch === 92
|
|
1019
|
+
if (ch === 92 ) {
|
|
1211
1020
|
result += text.substring(start, pos);
|
|
1212
1021
|
pos++;
|
|
1213
1022
|
if (pos >= len) {
|
|
1214
|
-
scanError = 2
|
|
1023
|
+
scanError = 2 ;
|
|
1215
1024
|
break;
|
|
1216
1025
|
}
|
|
1217
1026
|
const ch2 = text.charCodeAt(pos++);
|
|
1218
1027
|
switch (ch2) {
|
|
1219
|
-
case 34
|
|
1028
|
+
case 34 :
|
|
1220
1029
|
result += '\"';
|
|
1221
1030
|
break;
|
|
1222
|
-
case 92
|
|
1031
|
+
case 92 :
|
|
1223
1032
|
result += '\\';
|
|
1224
1033
|
break;
|
|
1225
|
-
case 47
|
|
1034
|
+
case 47 :
|
|
1226
1035
|
result += '/';
|
|
1227
1036
|
break;
|
|
1228
|
-
case 98
|
|
1037
|
+
case 98 :
|
|
1229
1038
|
result += '\b';
|
|
1230
1039
|
break;
|
|
1231
|
-
case 102
|
|
1040
|
+
case 102 :
|
|
1232
1041
|
result += '\f';
|
|
1233
1042
|
break;
|
|
1234
|
-
case 110
|
|
1043
|
+
case 110 :
|
|
1235
1044
|
result += '\n';
|
|
1236
1045
|
break;
|
|
1237
|
-
case 114
|
|
1046
|
+
case 114 :
|
|
1238
1047
|
result += '\r';
|
|
1239
1048
|
break;
|
|
1240
|
-
case 116
|
|
1049
|
+
case 116 :
|
|
1241
1050
|
result += '\t';
|
|
1242
1051
|
break;
|
|
1243
|
-
case 117
|
|
1052
|
+
case 117 : {
|
|
1244
1053
|
const ch3 = scanHexDigits(4);
|
|
1245
1054
|
if (ch3 >= 0) {
|
|
1246
1055
|
result += String.fromCharCode(ch3);
|
|
1247
1056
|
}
|
|
1248
1057
|
else {
|
|
1249
|
-
scanError = 4
|
|
1058
|
+
scanError = 4 ;
|
|
1250
1059
|
}
|
|
1251
1060
|
break;
|
|
1252
1061
|
}
|
|
1253
1062
|
default:
|
|
1254
|
-
scanError = 5
|
|
1063
|
+
scanError = 5 ;
|
|
1255
1064
|
}
|
|
1256
1065
|
start = pos;
|
|
1257
1066
|
continue;
|
|
@@ -1259,12 +1068,11 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1259
1068
|
if (ch >= 0 && ch <= 0x1F) {
|
|
1260
1069
|
if (isLineBreak(ch)) {
|
|
1261
1070
|
result += text.substring(start, pos);
|
|
1262
|
-
scanError = 2
|
|
1071
|
+
scanError = 2 ;
|
|
1263
1072
|
break;
|
|
1264
1073
|
}
|
|
1265
1074
|
else {
|
|
1266
|
-
scanError = 6
|
|
1267
|
-
// mark as error but continue with string
|
|
1075
|
+
scanError = 6 ;
|
|
1268
1076
|
}
|
|
1269
1077
|
}
|
|
1270
1078
|
pos++;
|
|
@@ -1273,63 +1081,56 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1273
1081
|
}
|
|
1274
1082
|
function scanNext() {
|
|
1275
1083
|
value = '';
|
|
1276
|
-
scanError = 0
|
|
1084
|
+
scanError = 0 ;
|
|
1277
1085
|
tokenOffset = pos;
|
|
1278
1086
|
if (pos >= len) {
|
|
1279
|
-
// at the end
|
|
1280
1087
|
tokenOffset = len;
|
|
1281
|
-
return token = 17
|
|
1088
|
+
return token = 17 ;
|
|
1282
1089
|
}
|
|
1283
1090
|
let code = text.charCodeAt(pos);
|
|
1284
|
-
// trivia: whitespace
|
|
1285
1091
|
if (isWhitespace(code)) {
|
|
1286
1092
|
do {
|
|
1287
1093
|
pos++;
|
|
1288
1094
|
value += String.fromCharCode(code);
|
|
1289
1095
|
code = text.charCodeAt(pos);
|
|
1290
1096
|
} while (isWhitespace(code));
|
|
1291
|
-
return token = 15
|
|
1097
|
+
return token = 15 ;
|
|
1292
1098
|
}
|
|
1293
|
-
// trivia: newlines
|
|
1294
1099
|
if (isLineBreak(code)) {
|
|
1295
1100
|
pos++;
|
|
1296
1101
|
value += String.fromCharCode(code);
|
|
1297
|
-
if (code === 13
|
|
1102
|
+
if (code === 13 && text.charCodeAt(pos) === 10 ) {
|
|
1298
1103
|
pos++;
|
|
1299
1104
|
value += '\n';
|
|
1300
1105
|
}
|
|
1301
|
-
return token = 14
|
|
1106
|
+
return token = 14 ;
|
|
1302
1107
|
}
|
|
1303
1108
|
switch (code) {
|
|
1304
|
-
|
|
1305
|
-
case 123 /* CharacterCodes.openBrace */:
|
|
1109
|
+
case 123 :
|
|
1306
1110
|
pos++;
|
|
1307
|
-
return token = 1
|
|
1308
|
-
case 125
|
|
1111
|
+
return token = 1 ;
|
|
1112
|
+
case 125 :
|
|
1309
1113
|
pos++;
|
|
1310
|
-
return token = 2
|
|
1311
|
-
case 91
|
|
1114
|
+
return token = 2 ;
|
|
1115
|
+
case 91 :
|
|
1312
1116
|
pos++;
|
|
1313
|
-
return token = 3
|
|
1314
|
-
case 93
|
|
1117
|
+
return token = 3 ;
|
|
1118
|
+
case 93 :
|
|
1315
1119
|
pos++;
|
|
1316
|
-
return token = 4
|
|
1317
|
-
case 58
|
|
1120
|
+
return token = 4 ;
|
|
1121
|
+
case 58 :
|
|
1318
1122
|
pos++;
|
|
1319
|
-
return token = 6
|
|
1320
|
-
case 44
|
|
1123
|
+
return token = 6 ;
|
|
1124
|
+
case 44 :
|
|
1321
1125
|
pos++;
|
|
1322
|
-
return token = 5
|
|
1323
|
-
|
|
1324
|
-
case 34 /* CharacterCodes.doubleQuote */:
|
|
1126
|
+
return token = 5 ;
|
|
1127
|
+
case 34 :
|
|
1325
1128
|
pos++;
|
|
1326
1129
|
value = scanString();
|
|
1327
|
-
return token = 10
|
|
1328
|
-
|
|
1329
|
-
case 47 /* CharacterCodes.slash */: {
|
|
1130
|
+
return token = 10 ;
|
|
1131
|
+
case 47 : {
|
|
1330
1132
|
const start = pos - 1;
|
|
1331
|
-
|
|
1332
|
-
if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
|
|
1133
|
+
if (text.charCodeAt(pos + 1) === 47 ) {
|
|
1333
1134
|
pos += 2;
|
|
1334
1135
|
while (pos < len) {
|
|
1335
1136
|
if (isLineBreak(text.charCodeAt(pos))) {
|
|
@@ -1338,16 +1139,15 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1338
1139
|
pos++;
|
|
1339
1140
|
}
|
|
1340
1141
|
value = text.substring(start, pos);
|
|
1341
|
-
return token = 12
|
|
1142
|
+
return token = 12 ;
|
|
1342
1143
|
}
|
|
1343
|
-
|
|
1344
|
-
if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
|
|
1144
|
+
if (text.charCodeAt(pos + 1) === 42 ) {
|
|
1345
1145
|
pos += 2;
|
|
1346
|
-
const safeLength = len - 1;
|
|
1146
|
+
const safeLength = len - 1;
|
|
1347
1147
|
let commentClosed = false;
|
|
1348
1148
|
while (pos < safeLength) {
|
|
1349
1149
|
const ch = text.charCodeAt(pos);
|
|
1350
|
-
if (ch === 42
|
|
1150
|
+
if (ch === 42 && text.charCodeAt(pos + 1) === 47 ) {
|
|
1351
1151
|
pos += 2;
|
|
1352
1152
|
commentClosed = true;
|
|
1353
1153
|
break;
|
|
@@ -1356,59 +1156,50 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1356
1156
|
}
|
|
1357
1157
|
if (!commentClosed) {
|
|
1358
1158
|
pos++;
|
|
1359
|
-
scanError = 1
|
|
1159
|
+
scanError = 1 ;
|
|
1360
1160
|
}
|
|
1361
1161
|
value = text.substring(start, pos);
|
|
1362
|
-
return token = 13
|
|
1162
|
+
return token = 13 ;
|
|
1363
1163
|
}
|
|
1364
|
-
// just a single slash
|
|
1365
1164
|
value += String.fromCharCode(code);
|
|
1366
1165
|
pos++;
|
|
1367
|
-
return token = 16
|
|
1166
|
+
return token = 16 ;
|
|
1368
1167
|
}
|
|
1369
|
-
|
|
1370
|
-
case 45 /* CharacterCodes.minus */:
|
|
1168
|
+
case 45 :
|
|
1371
1169
|
value += String.fromCharCode(code);
|
|
1372
1170
|
pos++;
|
|
1373
1171
|
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
1374
|
-
return token = 16
|
|
1172
|
+
return token = 16 ;
|
|
1375
1173
|
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
case
|
|
1380
|
-
case
|
|
1381
|
-
case
|
|
1382
|
-
case
|
|
1383
|
-
case
|
|
1384
|
-
case
|
|
1385
|
-
case
|
|
1386
|
-
case 55 /* CharacterCodes._7 */:
|
|
1387
|
-
case 56 /* CharacterCodes._8 */:
|
|
1388
|
-
case 57 /* CharacterCodes._9 */:
|
|
1174
|
+
case 48 :
|
|
1175
|
+
case 49 :
|
|
1176
|
+
case 50 :
|
|
1177
|
+
case 51 :
|
|
1178
|
+
case 52 :
|
|
1179
|
+
case 53 :
|
|
1180
|
+
case 54 :
|
|
1181
|
+
case 55 :
|
|
1182
|
+
case 56 :
|
|
1183
|
+
case 57 :
|
|
1389
1184
|
value += scanNumber();
|
|
1390
|
-
return token = 11
|
|
1391
|
-
// literals and unknown symbols
|
|
1185
|
+
return token = 11 ;
|
|
1392
1186
|
default:
|
|
1393
|
-
// is a literal? Read the full word.
|
|
1394
1187
|
while (pos < len && isUnknownContentCharacter(code)) {
|
|
1395
1188
|
pos++;
|
|
1396
1189
|
code = text.charCodeAt(pos);
|
|
1397
1190
|
}
|
|
1398
1191
|
if (tokenOffset !== pos) {
|
|
1399
1192
|
value = text.substring(tokenOffset, pos);
|
|
1400
|
-
// keywords: true, false, null
|
|
1401
1193
|
switch (value) {
|
|
1402
|
-
case 'true': return token = 8
|
|
1403
|
-
case 'false': return token = 9
|
|
1404
|
-
case 'null': return token = 7
|
|
1194
|
+
case 'true': return token = 8 ;
|
|
1195
|
+
case 'false': return token = 9 ;
|
|
1196
|
+
case 'null': return token = 7 ;
|
|
1405
1197
|
}
|
|
1406
|
-
return token = 16
|
|
1198
|
+
return token = 16 ;
|
|
1407
1199
|
}
|
|
1408
|
-
// some
|
|
1409
1200
|
value += String.fromCharCode(code);
|
|
1410
1201
|
pos++;
|
|
1411
|
-
return token = 16
|
|
1202
|
+
return token = 16 ;
|
|
1412
1203
|
}
|
|
1413
1204
|
}
|
|
1414
1205
|
function isUnknownContentCharacter(code) {
|
|
@@ -1416,14 +1207,14 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1416
1207
|
return false;
|
|
1417
1208
|
}
|
|
1418
1209
|
switch (code) {
|
|
1419
|
-
case 125
|
|
1420
|
-
case 93
|
|
1421
|
-
case 123
|
|
1422
|
-
case 91
|
|
1423
|
-
case 34
|
|
1424
|
-
case 58
|
|
1425
|
-
case 44
|
|
1426
|
-
case 47
|
|
1210
|
+
case 125 :
|
|
1211
|
+
case 93 :
|
|
1212
|
+
case 123 :
|
|
1213
|
+
case 91 :
|
|
1214
|
+
case 34 :
|
|
1215
|
+
case 58 :
|
|
1216
|
+
case 44 :
|
|
1217
|
+
case 47 :
|
|
1427
1218
|
return false;
|
|
1428
1219
|
}
|
|
1429
1220
|
return true;
|
|
@@ -1432,7 +1223,7 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1432
1223
|
let result;
|
|
1433
1224
|
do {
|
|
1434
1225
|
result = scanNext();
|
|
1435
|
-
} while (result >= 12
|
|
1226
|
+
} while (result >= 12 && result <= 15 );
|
|
1436
1227
|
return result;
|
|
1437
1228
|
}
|
|
1438
1229
|
return {
|
|
@@ -1447,20 +1238,16 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1447
1238
|
};
|
|
1448
1239
|
}
|
|
1449
1240
|
function isWhitespace(ch) {
|
|
1450
|
-
return ch === 32
|
|
1451
|
-
ch === 160
|
|
1452
|
-
ch === 8239
|
|
1241
|
+
return ch === 32 || ch === 9 || ch === 11 || ch === 12 ||
|
|
1242
|
+
ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 ||
|
|
1243
|
+
ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279 ;
|
|
1453
1244
|
}
|
|
1454
1245
|
function isLineBreak(ch) {
|
|
1455
|
-
return ch === 10
|
|
1246
|
+
return ch === 10 || ch === 13 || ch === 8232 || ch === 8233 ;
|
|
1456
1247
|
}
|
|
1457
1248
|
function isDigit(ch) {
|
|
1458
|
-
return ch >= 48
|
|
1249
|
+
return ch >= 48 && ch <= 57 ;
|
|
1459
1250
|
}
|
|
1460
|
-
/**
|
|
1461
|
-
* 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.
|
|
1462
|
-
* Therefore always check the errors list to find out if the input was valid.
|
|
1463
|
-
*/
|
|
1464
1251
|
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
1465
1252
|
let currentProperty = null;
|
|
1466
1253
|
let currentParent = [];
|
|
@@ -1505,11 +1292,8 @@ function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
|
1505
1292
|
visit(text, visitor, options);
|
|
1506
1293
|
return currentParent[0];
|
|
1507
1294
|
}
|
|
1508
|
-
/**
|
|
1509
|
-
* 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.
|
|
1510
|
-
*/
|
|
1511
1295
|
function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
1512
|
-
let currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined };
|
|
1296
|
+
let currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined };
|
|
1513
1297
|
function ensurePropertyComplete(endOffset) {
|
|
1514
1298
|
if (currentParent.type === 'property') {
|
|
1515
1299
|
currentParent.length = endOffset - currentParent.offset;
|
|
@@ -1566,9 +1350,6 @@ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
|
1566
1350
|
}
|
|
1567
1351
|
return result;
|
|
1568
1352
|
}
|
|
1569
|
-
/**
|
|
1570
|
-
* Finds the node at the given path in a JSON DOM.
|
|
1571
|
-
*/
|
|
1572
1353
|
function findNodeAtLocation(root, path) {
|
|
1573
1354
|
if (!root) {
|
|
1574
1355
|
return undefined;
|
|
@@ -1601,9 +1382,6 @@ function findNodeAtLocation(root, path) {
|
|
|
1601
1382
|
}
|
|
1602
1383
|
return node;
|
|
1603
1384
|
}
|
|
1604
|
-
/**
|
|
1605
|
-
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
|
1606
|
-
*/
|
|
1607
1385
|
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
1608
1386
|
const _scanner = createScanner(text, false);
|
|
1609
1387
|
function toNoArgVisit(visitFunction) {
|
|
@@ -1619,42 +1397,42 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
1619
1397
|
while (true) {
|
|
1620
1398
|
const token = _scanner.scan();
|
|
1621
1399
|
switch (_scanner.getTokenError()) {
|
|
1622
|
-
case 4
|
|
1623
|
-
handleError(14
|
|
1400
|
+
case 4 :
|
|
1401
|
+
handleError(14 );
|
|
1624
1402
|
break;
|
|
1625
|
-
case 5
|
|
1626
|
-
handleError(15
|
|
1403
|
+
case 5 :
|
|
1404
|
+
handleError(15 );
|
|
1627
1405
|
break;
|
|
1628
|
-
case 3
|
|
1629
|
-
handleError(13
|
|
1406
|
+
case 3 :
|
|
1407
|
+
handleError(13 );
|
|
1630
1408
|
break;
|
|
1631
|
-
case 1
|
|
1409
|
+
case 1 :
|
|
1632
1410
|
if (!disallowComments) {
|
|
1633
|
-
handleError(11
|
|
1411
|
+
handleError(11 );
|
|
1634
1412
|
}
|
|
1635
1413
|
break;
|
|
1636
|
-
case 2
|
|
1637
|
-
handleError(12
|
|
1414
|
+
case 2 :
|
|
1415
|
+
handleError(12 );
|
|
1638
1416
|
break;
|
|
1639
|
-
case 6
|
|
1640
|
-
handleError(16
|
|
1417
|
+
case 6 :
|
|
1418
|
+
handleError(16 );
|
|
1641
1419
|
break;
|
|
1642
1420
|
}
|
|
1643
1421
|
switch (token) {
|
|
1644
|
-
case 12
|
|
1645
|
-
case 13
|
|
1422
|
+
case 12 :
|
|
1423
|
+
case 13 :
|
|
1646
1424
|
if (disallowComments) {
|
|
1647
|
-
handleError(10
|
|
1425
|
+
handleError(10 );
|
|
1648
1426
|
}
|
|
1649
1427
|
else {
|
|
1650
1428
|
onComment();
|
|
1651
1429
|
}
|
|
1652
1430
|
break;
|
|
1653
|
-
case 16
|
|
1654
|
-
handleError(1
|
|
1431
|
+
case 16 :
|
|
1432
|
+
handleError(1 );
|
|
1655
1433
|
break;
|
|
1656
|
-
case 15
|
|
1657
|
-
case 14
|
|
1434
|
+
case 15 :
|
|
1435
|
+
case 14 :
|
|
1658
1436
|
break;
|
|
1659
1437
|
default:
|
|
1660
1438
|
return token;
|
|
@@ -1665,7 +1443,7 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
1665
1443
|
onError(error);
|
|
1666
1444
|
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
1667
1445
|
let token = _scanner.getToken();
|
|
1668
|
-
while (token !== 17
|
|
1446
|
+
while (token !== 17 ) {
|
|
1669
1447
|
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
1670
1448
|
scanNext();
|
|
1671
1449
|
break;
|
|
@@ -1690,28 +1468,28 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
1690
1468
|
}
|
|
1691
1469
|
function parseLiteral() {
|
|
1692
1470
|
switch (_scanner.getToken()) {
|
|
1693
|
-
case 11
|
|
1471
|
+
case 11 : {
|
|
1694
1472
|
let value = 0;
|
|
1695
1473
|
try {
|
|
1696
1474
|
value = JSON.parse(_scanner.getTokenValue());
|
|
1697
1475
|
if (typeof value !== 'number') {
|
|
1698
|
-
handleError(2
|
|
1476
|
+
handleError(2 );
|
|
1699
1477
|
value = 0;
|
|
1700
1478
|
}
|
|
1701
1479
|
}
|
|
1702
1480
|
catch (e) {
|
|
1703
|
-
handleError(2
|
|
1481
|
+
handleError(2 );
|
|
1704
1482
|
}
|
|
1705
1483
|
onLiteralValue(value);
|
|
1706
1484
|
break;
|
|
1707
1485
|
}
|
|
1708
|
-
case 7
|
|
1486
|
+
case 7 :
|
|
1709
1487
|
onLiteralValue(null);
|
|
1710
1488
|
break;
|
|
1711
|
-
case 8
|
|
1489
|
+
case 8 :
|
|
1712
1490
|
onLiteralValue(true);
|
|
1713
1491
|
break;
|
|
1714
|
-
case 9
|
|
1492
|
+
case 9 :
|
|
1715
1493
|
onLiteralValue(false);
|
|
1716
1494
|
break;
|
|
1717
1495
|
default:
|
|
@@ -1721,113 +1499,113 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
1721
1499
|
return true;
|
|
1722
1500
|
}
|
|
1723
1501
|
function parseProperty() {
|
|
1724
|
-
if (_scanner.getToken() !== 10
|
|
1725
|
-
handleError(3
|
|
1502
|
+
if (_scanner.getToken() !== 10 ) {
|
|
1503
|
+
handleError(3 , [], [2 , 5 ]);
|
|
1726
1504
|
return false;
|
|
1727
1505
|
}
|
|
1728
1506
|
parseString(false);
|
|
1729
|
-
if (_scanner.getToken() === 6
|
|
1507
|
+
if (_scanner.getToken() === 6 ) {
|
|
1730
1508
|
onSeparator(':');
|
|
1731
|
-
scanNext();
|
|
1509
|
+
scanNext();
|
|
1732
1510
|
if (!parseValue()) {
|
|
1733
|
-
handleError(4
|
|
1511
|
+
handleError(4 , [], [2 , 5 ]);
|
|
1734
1512
|
}
|
|
1735
1513
|
}
|
|
1736
1514
|
else {
|
|
1737
|
-
handleError(5
|
|
1515
|
+
handleError(5 , [], [2 , 5 ]);
|
|
1738
1516
|
}
|
|
1739
1517
|
return true;
|
|
1740
1518
|
}
|
|
1741
1519
|
function parseObject() {
|
|
1742
1520
|
onObjectBegin();
|
|
1743
|
-
scanNext();
|
|
1521
|
+
scanNext();
|
|
1744
1522
|
let needsComma = false;
|
|
1745
|
-
while (_scanner.getToken() !== 2
|
|
1746
|
-
if (_scanner.getToken() === 5
|
|
1523
|
+
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17 ) {
|
|
1524
|
+
if (_scanner.getToken() === 5 ) {
|
|
1747
1525
|
if (!needsComma) {
|
|
1748
|
-
handleError(4
|
|
1526
|
+
handleError(4 , [], []);
|
|
1749
1527
|
}
|
|
1750
1528
|
onSeparator(',');
|
|
1751
|
-
scanNext();
|
|
1752
|
-
if (_scanner.getToken() === 2
|
|
1529
|
+
scanNext();
|
|
1530
|
+
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
1753
1531
|
break;
|
|
1754
1532
|
}
|
|
1755
1533
|
}
|
|
1756
1534
|
else if (needsComma) {
|
|
1757
|
-
handleError(6
|
|
1535
|
+
handleError(6 , [], []);
|
|
1758
1536
|
}
|
|
1759
1537
|
if (!parseProperty()) {
|
|
1760
|
-
handleError(4
|
|
1538
|
+
handleError(4 , [], [2 , 5 ]);
|
|
1761
1539
|
}
|
|
1762
1540
|
needsComma = true;
|
|
1763
1541
|
}
|
|
1764
1542
|
onObjectEnd();
|
|
1765
|
-
if (_scanner.getToken() !== 2
|
|
1766
|
-
handleError(7
|
|
1543
|
+
if (_scanner.getToken() !== 2 ) {
|
|
1544
|
+
handleError(7 , [2 ], []);
|
|
1767
1545
|
}
|
|
1768
1546
|
else {
|
|
1769
|
-
scanNext();
|
|
1547
|
+
scanNext();
|
|
1770
1548
|
}
|
|
1771
1549
|
return true;
|
|
1772
1550
|
}
|
|
1773
1551
|
function parseArray() {
|
|
1774
1552
|
onArrayBegin();
|
|
1775
|
-
scanNext();
|
|
1553
|
+
scanNext();
|
|
1776
1554
|
let needsComma = false;
|
|
1777
|
-
while (_scanner.getToken() !== 4
|
|
1778
|
-
if (_scanner.getToken() === 5
|
|
1555
|
+
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17 ) {
|
|
1556
|
+
if (_scanner.getToken() === 5 ) {
|
|
1779
1557
|
if (!needsComma) {
|
|
1780
|
-
handleError(4
|
|
1558
|
+
handleError(4 , [], []);
|
|
1781
1559
|
}
|
|
1782
1560
|
onSeparator(',');
|
|
1783
|
-
scanNext();
|
|
1784
|
-
if (_scanner.getToken() === 4
|
|
1561
|
+
scanNext();
|
|
1562
|
+
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
1785
1563
|
break;
|
|
1786
1564
|
}
|
|
1787
1565
|
}
|
|
1788
1566
|
else if (needsComma) {
|
|
1789
|
-
handleError(6
|
|
1567
|
+
handleError(6 , [], []);
|
|
1790
1568
|
}
|
|
1791
1569
|
if (!parseValue()) {
|
|
1792
|
-
handleError(4
|
|
1570
|
+
handleError(4 , [], [4 , 5 ]);
|
|
1793
1571
|
}
|
|
1794
1572
|
needsComma = true;
|
|
1795
1573
|
}
|
|
1796
1574
|
onArrayEnd();
|
|
1797
|
-
if (_scanner.getToken() !== 4
|
|
1798
|
-
handleError(8
|
|
1575
|
+
if (_scanner.getToken() !== 4 ) {
|
|
1576
|
+
handleError(8 , [4 ], []);
|
|
1799
1577
|
}
|
|
1800
1578
|
else {
|
|
1801
|
-
scanNext();
|
|
1579
|
+
scanNext();
|
|
1802
1580
|
}
|
|
1803
1581
|
return true;
|
|
1804
1582
|
}
|
|
1805
1583
|
function parseValue() {
|
|
1806
1584
|
switch (_scanner.getToken()) {
|
|
1807
|
-
case 3
|
|
1585
|
+
case 3 :
|
|
1808
1586
|
return parseArray();
|
|
1809
|
-
case 1
|
|
1587
|
+
case 1 :
|
|
1810
1588
|
return parseObject();
|
|
1811
|
-
case 10
|
|
1589
|
+
case 10 :
|
|
1812
1590
|
return parseString(true);
|
|
1813
1591
|
default:
|
|
1814
1592
|
return parseLiteral();
|
|
1815
1593
|
}
|
|
1816
1594
|
}
|
|
1817
1595
|
scanNext();
|
|
1818
|
-
if (_scanner.getToken() === 17
|
|
1596
|
+
if (_scanner.getToken() === 17 ) {
|
|
1819
1597
|
if (options.allowEmptyContent) {
|
|
1820
1598
|
return true;
|
|
1821
1599
|
}
|
|
1822
|
-
handleError(4
|
|
1600
|
+
handleError(4 , [], []);
|
|
1823
1601
|
return false;
|
|
1824
1602
|
}
|
|
1825
1603
|
if (!parseValue()) {
|
|
1826
|
-
handleError(4
|
|
1604
|
+
handleError(4 , [], []);
|
|
1827
1605
|
return false;
|
|
1828
1606
|
}
|
|
1829
|
-
if (_scanner.getToken() !== 17
|
|
1830
|
-
handleError(9
|
|
1607
|
+
if (_scanner.getToken() !== 17 ) {
|
|
1608
|
+
handleError(9 , [], []);
|
|
1831
1609
|
}
|
|
1832
1610
|
return true;
|
|
1833
1611
|
}
|
|
@@ -1848,11 +1626,6 @@ function getNodeType(value) {
|
|
|
1848
1626
|
default: return 'null';
|
|
1849
1627
|
}
|
|
1850
1628
|
}
|
|
1851
|
-
|
|
1852
|
-
/*---------------------------------------------------------------------------------------------
|
|
1853
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1854
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
1855
|
-
*--------------------------------------------------------------------------------------------*/
|
|
1856
1629
|
var _a$1, _b$1;
|
|
1857
1630
|
class StringIterator {
|
|
1858
1631
|
constructor() {
|
|
@@ -1894,12 +1667,11 @@ class ConfigKeysIterator {
|
|
|
1894
1667
|
return this._to < this._value.length;
|
|
1895
1668
|
}
|
|
1896
1669
|
next() {
|
|
1897
|
-
// this._data = key.split(/[\\/]/).filter(s => !!s);
|
|
1898
1670
|
this._from = this._to;
|
|
1899
1671
|
let justSeps = true;
|
|
1900
1672
|
for (; this._to < this._value.length; this._to++) {
|
|
1901
1673
|
const ch = this._value.charCodeAt(this._to);
|
|
1902
|
-
if (ch === 46
|
|
1674
|
+
if (ch === 46 ) {
|
|
1903
1675
|
if (justSeps) {
|
|
1904
1676
|
this._from++;
|
|
1905
1677
|
}
|
|
@@ -1934,7 +1706,7 @@ class PathIterator {
|
|
|
1934
1706
|
this._valueLen = key.length;
|
|
1935
1707
|
for (let pos = key.length - 1; pos >= 0; pos--, this._valueLen--) {
|
|
1936
1708
|
const ch = this._value.charCodeAt(pos);
|
|
1937
|
-
if (!((ch === 47
|
|
1709
|
+
if (!((ch === 47 || this._splitOnBackslash && ch === 92) )) {
|
|
1938
1710
|
break;
|
|
1939
1711
|
}
|
|
1940
1712
|
}
|
|
@@ -1944,12 +1716,11 @@ class PathIterator {
|
|
|
1944
1716
|
return this._to < this._valueLen;
|
|
1945
1717
|
}
|
|
1946
1718
|
next() {
|
|
1947
|
-
// this._data = key.split(/[\\/]/).filter(s => !!s);
|
|
1948
1719
|
this._from = this._to;
|
|
1949
1720
|
let justSeps = true;
|
|
1950
1721
|
for (; this._to < this._valueLen; this._to++) {
|
|
1951
1722
|
const ch = this._value.charCodeAt(this._to);
|
|
1952
|
-
if (ch === 47
|
|
1723
|
+
if (ch === 47 || this._splitOnBackslash && ch === 92 ) {
|
|
1953
1724
|
if (justSeps) {
|
|
1954
1725
|
this._from++;
|
|
1955
1726
|
}
|
|
@@ -1983,31 +1754,31 @@ class UriIterator {
|
|
|
1983
1754
|
this._value = key;
|
|
1984
1755
|
this._states = [];
|
|
1985
1756
|
if (this._value.scheme) {
|
|
1986
|
-
this._states.push(1
|
|
1757
|
+
this._states.push(1 );
|
|
1987
1758
|
}
|
|
1988
1759
|
if (this._value.authority) {
|
|
1989
|
-
this._states.push(2
|
|
1760
|
+
this._states.push(2 );
|
|
1990
1761
|
}
|
|
1991
1762
|
if (this._value.path) {
|
|
1992
|
-
this._pathIterator = (
|
|
1763
|
+
this._pathIterator = ( new PathIterator(false, !this._ignorePathCasing(key)));
|
|
1993
1764
|
this._pathIterator.reset(key.path);
|
|
1994
1765
|
if (this._pathIterator.value()) {
|
|
1995
|
-
this._states.push(3
|
|
1766
|
+
this._states.push(3 );
|
|
1996
1767
|
}
|
|
1997
1768
|
}
|
|
1998
1769
|
if (!this._ignoreQueryAndFragment(key)) {
|
|
1999
1770
|
if (this._value.query) {
|
|
2000
|
-
this._states.push(4
|
|
1771
|
+
this._states.push(4 );
|
|
2001
1772
|
}
|
|
2002
1773
|
if (this._value.fragment) {
|
|
2003
|
-
this._states.push(5
|
|
1774
|
+
this._states.push(5 );
|
|
2004
1775
|
}
|
|
2005
1776
|
}
|
|
2006
1777
|
this._stateIdx = 0;
|
|
2007
1778
|
return this;
|
|
2008
1779
|
}
|
|
2009
1780
|
next() {
|
|
2010
|
-
if (this._states[this._stateIdx] === 3
|
|
1781
|
+
if (this._states[this._stateIdx] === 3 && this._pathIterator.hasNext()) {
|
|
2011
1782
|
this._pathIterator.next();
|
|
2012
1783
|
}
|
|
2013
1784
|
else {
|
|
@@ -2016,41 +1787,41 @@ class UriIterator {
|
|
|
2016
1787
|
return this;
|
|
2017
1788
|
}
|
|
2018
1789
|
hasNext() {
|
|
2019
|
-
return (this._states[this._stateIdx] === 3
|
|
1790
|
+
return (this._states[this._stateIdx] === 3 && this._pathIterator.hasNext())
|
|
2020
1791
|
|| this._stateIdx < this._states.length - 1;
|
|
2021
1792
|
}
|
|
2022
1793
|
cmp(a) {
|
|
2023
|
-
if (this._states[this._stateIdx] === 1
|
|
1794
|
+
if (this._states[this._stateIdx] === 1 ) {
|
|
2024
1795
|
return compareIgnoreCase(a, this._value.scheme);
|
|
2025
1796
|
}
|
|
2026
|
-
else if (this._states[this._stateIdx] === 2
|
|
1797
|
+
else if (this._states[this._stateIdx] === 2 ) {
|
|
2027
1798
|
return compareIgnoreCase(a, this._value.authority);
|
|
2028
1799
|
}
|
|
2029
|
-
else if (this._states[this._stateIdx] === 3
|
|
1800
|
+
else if (this._states[this._stateIdx] === 3 ) {
|
|
2030
1801
|
return this._pathIterator.cmp(a);
|
|
2031
1802
|
}
|
|
2032
|
-
else if (this._states[this._stateIdx] === 4
|
|
1803
|
+
else if (this._states[this._stateIdx] === 4 ) {
|
|
2033
1804
|
return compare$1(a, this._value.query);
|
|
2034
1805
|
}
|
|
2035
|
-
else if (this._states[this._stateIdx] === 5
|
|
1806
|
+
else if (this._states[this._stateIdx] === 5 ) {
|
|
2036
1807
|
return compare$1(a, this._value.fragment);
|
|
2037
1808
|
}
|
|
2038
1809
|
throw new Error();
|
|
2039
1810
|
}
|
|
2040
1811
|
value() {
|
|
2041
|
-
if (this._states[this._stateIdx] === 1
|
|
1812
|
+
if (this._states[this._stateIdx] === 1 ) {
|
|
2042
1813
|
return this._value.scheme;
|
|
2043
1814
|
}
|
|
2044
|
-
else if (this._states[this._stateIdx] === 2
|
|
1815
|
+
else if (this._states[this._stateIdx] === 2 ) {
|
|
2045
1816
|
return this._value.authority;
|
|
2046
1817
|
}
|
|
2047
|
-
else if (this._states[this._stateIdx] === 3
|
|
1818
|
+
else if (this._states[this._stateIdx] === 3 ) {
|
|
2048
1819
|
return this._pathIterator.value();
|
|
2049
1820
|
}
|
|
2050
|
-
else if (this._states[this._stateIdx] === 4
|
|
1821
|
+
else if (this._states[this._stateIdx] === 4 ) {
|
|
2051
1822
|
return this._value.query;
|
|
2052
1823
|
}
|
|
2053
|
-
else if (this._states[this._stateIdx] === 5
|
|
1824
|
+
else if (this._states[this._stateIdx] === 5 ) {
|
|
2054
1825
|
return this._value.fragment;
|
|
2055
1826
|
}
|
|
2056
1827
|
throw new Error();
|
|
@@ -2097,16 +1868,16 @@ class TernarySearchTree {
|
|
|
2097
1868
|
this._iter = segments;
|
|
2098
1869
|
}
|
|
2099
1870
|
static forUris(ignorePathCasing = () => false, ignoreQueryAndFragment = () => false) {
|
|
2100
|
-
return (
|
|
1871
|
+
return ( new TernarySearchTree(( new UriIterator(ignorePathCasing, ignoreQueryAndFragment))));
|
|
2101
1872
|
}
|
|
2102
1873
|
static forPaths(ignorePathCasing = false) {
|
|
2103
|
-
return (
|
|
1874
|
+
return ( new TernarySearchTree(( new PathIterator(undefined, !ignorePathCasing))));
|
|
2104
1875
|
}
|
|
2105
1876
|
static forStrings() {
|
|
2106
|
-
return (
|
|
1877
|
+
return ( new TernarySearchTree(( new StringIterator())));
|
|
2107
1878
|
}
|
|
2108
1879
|
static forConfigKeys() {
|
|
2109
|
-
return (
|
|
1880
|
+
return ( new TernarySearchTree(( new ConfigKeysIterator())));
|
|
2110
1881
|
}
|
|
2111
1882
|
clear() {
|
|
2112
1883
|
this._root = undefined;
|
|
@@ -2131,90 +1902,78 @@ class TernarySearchTree {
|
|
|
2131
1902
|
const iter = this._iter.reset(key);
|
|
2132
1903
|
let node;
|
|
2133
1904
|
if (!this._root) {
|
|
2134
|
-
this._root = (
|
|
1905
|
+
this._root = ( new TernarySearchTreeNode());
|
|
2135
1906
|
this._root.segment = iter.value();
|
|
2136
1907
|
}
|
|
2137
1908
|
const stack = [];
|
|
2138
|
-
// find insert_node
|
|
2139
1909
|
node = this._root;
|
|
2140
1910
|
while (true) {
|
|
2141
1911
|
const val = iter.cmp(node.segment);
|
|
2142
1912
|
if (val > 0) {
|
|
2143
|
-
// left
|
|
2144
1913
|
if (!node.left) {
|
|
2145
|
-
node.left = (
|
|
1914
|
+
node.left = ( new TernarySearchTreeNode());
|
|
2146
1915
|
node.left.segment = iter.value();
|
|
2147
1916
|
}
|
|
2148
|
-
stack.push([-1
|
|
1917
|
+
stack.push([-1 , node]);
|
|
2149
1918
|
node = node.left;
|
|
2150
1919
|
}
|
|
2151
1920
|
else if (val < 0) {
|
|
2152
|
-
// right
|
|
2153
1921
|
if (!node.right) {
|
|
2154
|
-
node.right = (
|
|
1922
|
+
node.right = ( new TernarySearchTreeNode());
|
|
2155
1923
|
node.right.segment = iter.value();
|
|
2156
1924
|
}
|
|
2157
|
-
stack.push([1
|
|
1925
|
+
stack.push([1 , node]);
|
|
2158
1926
|
node = node.right;
|
|
2159
1927
|
}
|
|
2160
1928
|
else if (iter.hasNext()) {
|
|
2161
|
-
// mid
|
|
2162
1929
|
iter.next();
|
|
2163
1930
|
if (!node.mid) {
|
|
2164
|
-
node.mid = (
|
|
1931
|
+
node.mid = ( new TernarySearchTreeNode());
|
|
2165
1932
|
node.mid.segment = iter.value();
|
|
2166
1933
|
}
|
|
2167
|
-
stack.push([0
|
|
1934
|
+
stack.push([0 , node]);
|
|
2168
1935
|
node = node.mid;
|
|
2169
1936
|
}
|
|
2170
1937
|
else {
|
|
2171
1938
|
break;
|
|
2172
1939
|
}
|
|
2173
1940
|
}
|
|
2174
|
-
// set value
|
|
2175
1941
|
const oldElement = node.value;
|
|
2176
1942
|
node.value = element;
|
|
2177
1943
|
node.key = key;
|
|
2178
|
-
// balance
|
|
2179
1944
|
for (let i = stack.length - 1; i >= 0; i--) {
|
|
2180
1945
|
const node = stack[i][1];
|
|
2181
1946
|
node.updateHeight();
|
|
2182
1947
|
const bf = node.balanceFactor();
|
|
2183
1948
|
if (bf < -1 || bf > 1) {
|
|
2184
|
-
// needs rotate
|
|
2185
1949
|
const d1 = stack[i][0];
|
|
2186
1950
|
const d2 = stack[i + 1][0];
|
|
2187
|
-
if (d1 === 1
|
|
2188
|
-
//right, right -> rotate left
|
|
1951
|
+
if (d1 === 1 && d2 === 1 ) {
|
|
2189
1952
|
stack[i][1] = node.rotateLeft();
|
|
2190
1953
|
}
|
|
2191
|
-
else if (d1 === -1
|
|
2192
|
-
// left, left -> rotate right
|
|
1954
|
+
else if (d1 === -1 && d2 === -1 ) {
|
|
2193
1955
|
stack[i][1] = node.rotateRight();
|
|
2194
1956
|
}
|
|
2195
|
-
else if (d1 === 1
|
|
2196
|
-
// right, left -> double rotate right, left
|
|
1957
|
+
else if (d1 === 1 && d2 === -1 ) {
|
|
2197
1958
|
node.right = stack[i + 1][1] = stack[i + 1][1].rotateRight();
|
|
2198
1959
|
stack[i][1] = node.rotateLeft();
|
|
2199
1960
|
}
|
|
2200
|
-
else if (d1 === -1
|
|
2201
|
-
// left, right -> double rotate left, right
|
|
1961
|
+
else if (d1 === -1 && d2 === 1 ) {
|
|
2202
1962
|
node.left = stack[i + 1][1] = stack[i + 1][1].rotateLeft();
|
|
2203
1963
|
stack[i][1] = node.rotateRight();
|
|
2204
1964
|
}
|
|
2205
1965
|
else {
|
|
2206
1966
|
throw new Error();
|
|
2207
1967
|
}
|
|
2208
|
-
// patch path to parent
|
|
2209
1968
|
if (i > 0) {
|
|
2210
1969
|
switch (stack[i - 1][0]) {
|
|
2211
|
-
case -1
|
|
1970
|
+
case -1 :
|
|
2212
1971
|
stack[i - 1][1].left = stack[i][1];
|
|
2213
1972
|
break;
|
|
2214
|
-
case 1
|
|
1973
|
+
case 1 :
|
|
2215
1974
|
stack[i - 1][1].right = stack[i][1];
|
|
2216
1975
|
break;
|
|
2217
|
-
case 0
|
|
1976
|
+
case 0 :
|
|
2218
1977
|
stack[i - 1][1].mid = stack[i][1];
|
|
2219
1978
|
break;
|
|
2220
1979
|
}
|
|
@@ -2235,15 +1994,12 @@ class TernarySearchTree {
|
|
|
2235
1994
|
while (node) {
|
|
2236
1995
|
const val = iter.cmp(node.segment);
|
|
2237
1996
|
if (val > 0) {
|
|
2238
|
-
// left
|
|
2239
1997
|
node = node.left;
|
|
2240
1998
|
}
|
|
2241
1999
|
else if (val < 0) {
|
|
2242
|
-
// right
|
|
2243
2000
|
node = node.right;
|
|
2244
2001
|
}
|
|
2245
2002
|
else if (iter.hasNext()) {
|
|
2246
|
-
// mid
|
|
2247
2003
|
iter.next();
|
|
2248
2004
|
node = node.mid;
|
|
2249
2005
|
}
|
|
@@ -2267,23 +2023,19 @@ class TernarySearchTree {
|
|
|
2267
2023
|
const iter = this._iter.reset(key);
|
|
2268
2024
|
const stack = [];
|
|
2269
2025
|
let node = this._root;
|
|
2270
|
-
// find node
|
|
2271
2026
|
while (node) {
|
|
2272
2027
|
const val = iter.cmp(node.segment);
|
|
2273
2028
|
if (val > 0) {
|
|
2274
|
-
|
|
2275
|
-
stack.push([-1 /* Dir.Left */, node]);
|
|
2029
|
+
stack.push([-1 , node]);
|
|
2276
2030
|
node = node.left;
|
|
2277
2031
|
}
|
|
2278
2032
|
else if (val < 0) {
|
|
2279
|
-
|
|
2280
|
-
stack.push([1 /* Dir.Right */, node]);
|
|
2033
|
+
stack.push([1 , node]);
|
|
2281
2034
|
node = node.right;
|
|
2282
2035
|
}
|
|
2283
2036
|
else if (iter.hasNext()) {
|
|
2284
|
-
// mid
|
|
2285
2037
|
iter.next();
|
|
2286
|
-
stack.push([0
|
|
2038
|
+
stack.push([0 , node]);
|
|
2287
2039
|
node = node.mid;
|
|
2288
2040
|
}
|
|
2289
2041
|
else {
|
|
@@ -2291,25 +2043,20 @@ class TernarySearchTree {
|
|
|
2291
2043
|
}
|
|
2292
2044
|
}
|
|
2293
2045
|
if (!node) {
|
|
2294
|
-
// node not found
|
|
2295
2046
|
return;
|
|
2296
2047
|
}
|
|
2297
2048
|
if (superStr) {
|
|
2298
|
-
// removing children, reset height
|
|
2299
2049
|
node.left = undefined;
|
|
2300
2050
|
node.mid = undefined;
|
|
2301
2051
|
node.right = undefined;
|
|
2302
2052
|
node.height = 1;
|
|
2303
2053
|
}
|
|
2304
2054
|
else {
|
|
2305
|
-
// removing element
|
|
2306
2055
|
node.key = undefined;
|
|
2307
2056
|
node.value = undefined;
|
|
2308
2057
|
}
|
|
2309
|
-
// BST node removal
|
|
2310
2058
|
if (!node.mid && !node.value) {
|
|
2311
2059
|
if (node.left && node.right) {
|
|
2312
|
-
// full node
|
|
2313
2060
|
const min = this._min(node.right);
|
|
2314
2061
|
const { key, value, segment } = min;
|
|
2315
2062
|
this._delete(min.key, false);
|
|
@@ -2318,18 +2065,17 @@ class TernarySearchTree {
|
|
|
2318
2065
|
node.segment = segment;
|
|
2319
2066
|
}
|
|
2320
2067
|
else {
|
|
2321
|
-
// empty or half empty
|
|
2322
2068
|
const newChild = node.left ?? node.right;
|
|
2323
2069
|
if (stack.length > 0) {
|
|
2324
2070
|
const [dir, parent] = stack[stack.length - 1];
|
|
2325
2071
|
switch (dir) {
|
|
2326
|
-
case -1
|
|
2072
|
+
case -1 :
|
|
2327
2073
|
parent.left = newChild;
|
|
2328
2074
|
break;
|
|
2329
|
-
case 0
|
|
2075
|
+
case 0 :
|
|
2330
2076
|
parent.mid = newChild;
|
|
2331
2077
|
break;
|
|
2332
|
-
case 1
|
|
2078
|
+
case 1 :
|
|
2333
2079
|
parent.right = newChild;
|
|
2334
2080
|
break;
|
|
2335
2081
|
}
|
|
@@ -2339,45 +2085,37 @@ class TernarySearchTree {
|
|
|
2339
2085
|
}
|
|
2340
2086
|
}
|
|
2341
2087
|
}
|
|
2342
|
-
// AVL balance
|
|
2343
2088
|
for (let i = stack.length - 1; i >= 0; i--) {
|
|
2344
2089
|
const node = stack[i][1];
|
|
2345
2090
|
node.updateHeight();
|
|
2346
2091
|
const bf = node.balanceFactor();
|
|
2347
2092
|
if (bf > 1) {
|
|
2348
|
-
// right heavy
|
|
2349
2093
|
if (node.right.balanceFactor() >= 0) {
|
|
2350
|
-
// right, right -> rotate left
|
|
2351
2094
|
stack[i][1] = node.rotateLeft();
|
|
2352
2095
|
}
|
|
2353
2096
|
else {
|
|
2354
|
-
// right, left -> double rotate
|
|
2355
2097
|
node.right = node.right.rotateRight();
|
|
2356
2098
|
stack[i][1] = node.rotateLeft();
|
|
2357
2099
|
}
|
|
2358
2100
|
}
|
|
2359
2101
|
else if (bf < -1) {
|
|
2360
|
-
// left heavy
|
|
2361
2102
|
if (node.left.balanceFactor() <= 0) {
|
|
2362
|
-
// left, left -> rotate right
|
|
2363
2103
|
stack[i][1] = node.rotateRight();
|
|
2364
2104
|
}
|
|
2365
2105
|
else {
|
|
2366
|
-
// left, right -> double rotate
|
|
2367
2106
|
node.left = node.left.rotateLeft();
|
|
2368
2107
|
stack[i][1] = node.rotateRight();
|
|
2369
2108
|
}
|
|
2370
2109
|
}
|
|
2371
|
-
// patch path to parent
|
|
2372
2110
|
if (i > 0) {
|
|
2373
2111
|
switch (stack[i - 1][0]) {
|
|
2374
|
-
case -1
|
|
2112
|
+
case -1 :
|
|
2375
2113
|
stack[i - 1][1].left = stack[i][1];
|
|
2376
2114
|
break;
|
|
2377
|
-
case 1
|
|
2115
|
+
case 1 :
|
|
2378
2116
|
stack[i - 1][1].right = stack[i][1];
|
|
2379
2117
|
break;
|
|
2380
|
-
case 0
|
|
2118
|
+
case 0 :
|
|
2381
2119
|
stack[i - 1][1].mid = stack[i][1];
|
|
2382
2120
|
break;
|
|
2383
2121
|
}
|
|
@@ -2400,15 +2138,12 @@ class TernarySearchTree {
|
|
|
2400
2138
|
while (node) {
|
|
2401
2139
|
const val = iter.cmp(node.segment);
|
|
2402
2140
|
if (val > 0) {
|
|
2403
|
-
// left
|
|
2404
2141
|
node = node.left;
|
|
2405
2142
|
}
|
|
2406
2143
|
else if (val < 0) {
|
|
2407
|
-
// right
|
|
2408
2144
|
node = node.right;
|
|
2409
2145
|
}
|
|
2410
2146
|
else if (iter.hasNext()) {
|
|
2411
|
-
// mid
|
|
2412
2147
|
iter.next();
|
|
2413
2148
|
candidate = node.value || candidate;
|
|
2414
2149
|
node = node.mid;
|
|
@@ -2425,20 +2160,16 @@ class TernarySearchTree {
|
|
|
2425
2160
|
while (node) {
|
|
2426
2161
|
const val = iter.cmp(node.segment);
|
|
2427
2162
|
if (val > 0) {
|
|
2428
|
-
// left
|
|
2429
2163
|
node = node.left;
|
|
2430
2164
|
}
|
|
2431
2165
|
else if (val < 0) {
|
|
2432
|
-
// right
|
|
2433
2166
|
node = node.right;
|
|
2434
2167
|
}
|
|
2435
2168
|
else if (iter.hasNext()) {
|
|
2436
|
-
// mid
|
|
2437
2169
|
iter.next();
|
|
2438
2170
|
node = node.mid;
|
|
2439
2171
|
}
|
|
2440
2172
|
else {
|
|
2441
|
-
// collect
|
|
2442
2173
|
if (!node.mid) {
|
|
2443
2174
|
return undefined;
|
|
2444
2175
|
}
|
|
@@ -2463,7 +2194,6 @@ class TernarySearchTree {
|
|
|
2463
2194
|
return result[Symbol.iterator]();
|
|
2464
2195
|
}
|
|
2465
2196
|
_dfsEntries(node, bucket) {
|
|
2466
|
-
// DFS
|
|
2467
2197
|
if (!node) {
|
|
2468
2198
|
return;
|
|
2469
2199
|
}
|
|
@@ -2480,7 +2210,6 @@ class TernarySearchTree {
|
|
|
2480
2210
|
this._dfsEntries(node.right, bucket);
|
|
2481
2211
|
}
|
|
2482
2212
|
}
|
|
2483
|
-
// for debug/testing
|
|
2484
2213
|
_isBalanced() {
|
|
2485
2214
|
const nodeIsBalanced = (node) => {
|
|
2486
2215
|
if (!node) {
|
|
@@ -2505,16 +2234,16 @@ class ResourceMap {
|
|
|
2505
2234
|
constructor(mapOrKeyFn, toKey) {
|
|
2506
2235
|
this[_a$1] = 'ResourceMap';
|
|
2507
2236
|
if (mapOrKeyFn instanceof ResourceMap) {
|
|
2508
|
-
this.map = (
|
|
2237
|
+
this.map = ( new Map(mapOrKeyFn.map));
|
|
2509
2238
|
this.toKey = toKey ?? ResourceMap.defaultToKey;
|
|
2510
2239
|
}
|
|
2511
2240
|
else {
|
|
2512
|
-
this.map = (
|
|
2241
|
+
this.map = ( new Map());
|
|
2513
2242
|
this.toKey = mapOrKeyFn ?? ResourceMap.defaultToKey;
|
|
2514
2243
|
}
|
|
2515
2244
|
}
|
|
2516
2245
|
set(resource, value) {
|
|
2517
|
-
this.map.set(this.toKey(resource), (
|
|
2246
|
+
this.map.set(this.toKey(resource), ( new ResourceMapEntry(resource, value)));
|
|
2518
2247
|
return this;
|
|
2519
2248
|
}
|
|
2520
2249
|
get(resource) {
|
|
@@ -2541,17 +2270,17 @@ class ResourceMap {
|
|
|
2541
2270
|
}
|
|
2542
2271
|
}
|
|
2543
2272
|
*values() {
|
|
2544
|
-
for (const entry of (
|
|
2273
|
+
for (const entry of ( this.map.values())) {
|
|
2545
2274
|
yield entry.value;
|
|
2546
2275
|
}
|
|
2547
2276
|
}
|
|
2548
2277
|
*keys() {
|
|
2549
|
-
for (const entry of (
|
|
2278
|
+
for (const entry of ( this.map.values())) {
|
|
2550
2279
|
yield entry.uri;
|
|
2551
2280
|
}
|
|
2552
2281
|
}
|
|
2553
2282
|
*entries() {
|
|
2554
|
-
for (const entry of (
|
|
2283
|
+
for (const entry of ( this.map.values())) {
|
|
2555
2284
|
yield [entry.uri, entry.value];
|
|
2556
2285
|
}
|
|
2557
2286
|
}
|
|
@@ -2561,15 +2290,15 @@ class ResourceMap {
|
|
|
2561
2290
|
}
|
|
2562
2291
|
}
|
|
2563
2292
|
}
|
|
2564
|
-
ResourceMap.defaultToKey = (resource) => (
|
|
2293
|
+
ResourceMap.defaultToKey = (resource) => ( resource.toString());
|
|
2565
2294
|
class ResourceSet {
|
|
2566
2295
|
constructor(entriesOrKey, toKey) {
|
|
2567
2296
|
this[_b$1] = 'ResourceSet';
|
|
2568
2297
|
if (!entriesOrKey || typeof entriesOrKey === 'function') {
|
|
2569
|
-
this._map = (
|
|
2298
|
+
this._map = ( new ResourceMap(entriesOrKey));
|
|
2570
2299
|
}
|
|
2571
2300
|
else {
|
|
2572
|
-
this._map = (
|
|
2301
|
+
this._map = ( new ResourceMap(toKey));
|
|
2573
2302
|
entriesOrKey.forEach(this.add, this);
|
|
2574
2303
|
}
|
|
2575
2304
|
}
|
|
@@ -2596,27 +2325,22 @@ class ResourceSet {
|
|
|
2596
2325
|
return this._map.entries();
|
|
2597
2326
|
}
|
|
2598
2327
|
keys() {
|
|
2599
|
-
return (
|
|
2328
|
+
return ( this._map.keys());
|
|
2600
2329
|
}
|
|
2601
2330
|
values() {
|
|
2602
|
-
return (
|
|
2331
|
+
return ( this._map.keys());
|
|
2603
2332
|
}
|
|
2604
2333
|
[(_b$1 = Symbol.toStringTag, Symbol.iterator)]() {
|
|
2605
|
-
return (
|
|
2334
|
+
return ( this.keys());
|
|
2606
2335
|
}
|
|
2607
2336
|
}
|
|
2608
|
-
|
|
2609
|
-
/*---------------------------------------------------------------------------------------------
|
|
2610
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2611
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
2612
|
-
*--------------------------------------------------------------------------------------------*/
|
|
2613
2337
|
class ConfigurationModel {
|
|
2614
2338
|
constructor(_contents = {}, _keys = [], _overrides = []) {
|
|
2615
2339
|
this._contents = _contents;
|
|
2616
2340
|
this._keys = _keys;
|
|
2617
2341
|
this._overrides = _overrides;
|
|
2618
2342
|
this.frozen = false;
|
|
2619
|
-
this.overrideConfigurations = (
|
|
2343
|
+
this.overrideConfigurations = ( new Map());
|
|
2620
2344
|
}
|
|
2621
2345
|
get contents() {
|
|
2622
2346
|
return this.checkAndFreeze(this._contents);
|
|
@@ -2628,7 +2352,7 @@ class ConfigurationModel {
|
|
|
2628
2352
|
return this.checkAndFreeze(this._keys);
|
|
2629
2353
|
}
|
|
2630
2354
|
isEmpty() {
|
|
2631
|
-
return this._keys.length === 0 && (
|
|
2355
|
+
return this._keys.length === 0 && ( Object.keys(this._contents)).length === 0 && this._overrides.length === 0;
|
|
2632
2356
|
}
|
|
2633
2357
|
isFrozen() {
|
|
2634
2358
|
return this.frozen;
|
|
@@ -2692,14 +2416,14 @@ class ConfigurationModel {
|
|
|
2692
2416
|
}
|
|
2693
2417
|
}
|
|
2694
2418
|
}
|
|
2695
|
-
return (
|
|
2419
|
+
return ( new ConfigurationModel(contents, keys, overrides));
|
|
2696
2420
|
}
|
|
2697
2421
|
freeze() {
|
|
2698
2422
|
this.frozen = true;
|
|
2699
2423
|
return this;
|
|
2700
2424
|
}
|
|
2701
2425
|
clone() {
|
|
2702
|
-
return (
|
|
2426
|
+
return ( new ConfigurationModel(
|
|
2703
2427
|
deepClone(this.contents),
|
|
2704
2428
|
[...this.keys],
|
|
2705
2429
|
deepClone(this.overrides)
|
|
@@ -2707,17 +2431,14 @@ class ConfigurationModel {
|
|
|
2707
2431
|
}
|
|
2708
2432
|
createOverrideConfigurationModel(identifier) {
|
|
2709
2433
|
const overrideContents = this.getContentsForOverrideIdentifer(identifier);
|
|
2710
|
-
if (!overrideContents || typeof overrideContents !== 'object' || !(
|
|
2711
|
-
// If there are no valid overrides, return self
|
|
2434
|
+
if (!overrideContents || typeof overrideContents !== 'object' || !( Object.keys(overrideContents)).length) {
|
|
2712
2435
|
return this;
|
|
2713
2436
|
}
|
|
2714
2437
|
const contents = {};
|
|
2715
|
-
for (const key of distinct([...(
|
|
2438
|
+
for (const key of distinct([...( Object.keys(this.contents)), ...( Object.keys(overrideContents))])) {
|
|
2716
2439
|
let contentsForKey = this.contents[key];
|
|
2717
2440
|
const overrideContentsForKey = overrideContents[key];
|
|
2718
|
-
// If there are override contents for the key, clone and merge otherwise use base contents
|
|
2719
2441
|
if (overrideContentsForKey) {
|
|
2720
|
-
// Clone and merge only if base contents and override contents are of type object otherwise just override
|
|
2721
2442
|
if (typeof contentsForKey === 'object' && typeof overrideContentsForKey === 'object') {
|
|
2722
2443
|
contentsForKey = deepClone(contentsForKey);
|
|
2723
2444
|
this.mergeContents(contentsForKey, overrideContentsForKey);
|
|
@@ -2728,10 +2449,10 @@ class ConfigurationModel {
|
|
|
2728
2449
|
}
|
|
2729
2450
|
contents[key] = contentsForKey;
|
|
2730
2451
|
}
|
|
2731
|
-
return (
|
|
2452
|
+
return ( new ConfigurationModel(contents, this.keys, this.overrides));
|
|
2732
2453
|
}
|
|
2733
2454
|
mergeContents(source, target) {
|
|
2734
|
-
for (const key of (
|
|
2455
|
+
for (const key of ( Object.keys(target))) {
|
|
2735
2456
|
if (key in source) {
|
|
2736
2457
|
if (isObject(source[key]) && isObject(target[key])) {
|
|
2737
2458
|
this.mergeContents(source[key], target[key]);
|
|
@@ -2768,7 +2489,6 @@ class ConfigurationModel {
|
|
|
2768
2489
|
mergeContents(override.contents);
|
|
2769
2490
|
}
|
|
2770
2491
|
}
|
|
2771
|
-
// Merge contents of the identifier only at the end to take precedence.
|
|
2772
2492
|
mergeContents(contentsForIdentifierOnly);
|
|
2773
2493
|
return contents;
|
|
2774
2494
|
}
|
|
@@ -2779,7 +2499,6 @@ class ConfigurationModel {
|
|
|
2779
2499
|
keys: this.keys
|
|
2780
2500
|
};
|
|
2781
2501
|
}
|
|
2782
|
-
// Update methods
|
|
2783
2502
|
setValue(key, value) {
|
|
2784
2503
|
this.addKey(key);
|
|
2785
2504
|
addToValueTree(this.contents, key, value, e => { throw new Error(e); });
|
|
@@ -2816,7 +2535,7 @@ class ConfigurationModelParser {
|
|
|
2816
2535
|
this._parseErrors = [];
|
|
2817
2536
|
}
|
|
2818
2537
|
get configurationModel() {
|
|
2819
|
-
return this._configurationModel || (
|
|
2538
|
+
return this._configurationModel || ( new ConfigurationModel());
|
|
2820
2539
|
}
|
|
2821
2540
|
get restrictedConfigurations() {
|
|
2822
2541
|
return this._restrictedConfigurations;
|
|
@@ -2838,7 +2557,7 @@ class ConfigurationModelParser {
|
|
|
2838
2557
|
parseRaw(raw, options) {
|
|
2839
2558
|
this._raw = raw;
|
|
2840
2559
|
const { contents, keys, overrides, restricted } = this.doParseRaw(raw, options);
|
|
2841
|
-
this._configurationModel = (
|
|
2560
|
+
this._configurationModel = ( new ConfigurationModel(contents, keys, overrides));
|
|
2842
2561
|
this._restrictedConfigurations = restricted || [];
|
|
2843
2562
|
}
|
|
2844
2563
|
doParseContent(content) {
|
|
@@ -2895,11 +2614,11 @@ class ConfigurationModelParser {
|
|
|
2895
2614
|
return raw;
|
|
2896
2615
|
}
|
|
2897
2616
|
doParseRaw(raw, options) {
|
|
2898
|
-
const configurationProperties = (
|
|
2617
|
+
const configurationProperties = ( Registry.as(Extensions$2.Configuration)).getConfigurationProperties();
|
|
2899
2618
|
const filtered = this.filter(raw, configurationProperties, true, options);
|
|
2900
2619
|
raw = filtered.raw;
|
|
2901
2620
|
const contents = toValuesTree(raw, message => console.error(`Conflict in settings file ${this._name}: ${message}`));
|
|
2902
|
-
const keys = (
|
|
2621
|
+
const keys = ( Object.keys(raw));
|
|
2903
2622
|
const overrides = this.toOverrides(raw, message => console.error(`Conflict in settings file ${this._name}: ${message}`));
|
|
2904
2623
|
return { contents, keys, overrides, restricted: filtered.restricted };
|
|
2905
2624
|
}
|
|
@@ -2917,11 +2636,10 @@ class ConfigurationModelParser {
|
|
|
2917
2636
|
}
|
|
2918
2637
|
else {
|
|
2919
2638
|
const propertySchema = configurationProperties[key];
|
|
2920
|
-
const scope = propertySchema ? typeof propertySchema.scope !== 'undefined' ? propertySchema.scope : 3
|
|
2639
|
+
const scope = propertySchema ? typeof propertySchema.scope !== 'undefined' ? propertySchema.scope : 3 : undefined;
|
|
2921
2640
|
if (propertySchema?.restricted) {
|
|
2922
2641
|
restricted.push(key);
|
|
2923
2642
|
}
|
|
2924
|
-
// Load unregistered configurations always.
|
|
2925
2643
|
if (scope === undefined || options.scopes === undefined || options.scopes.includes(scope)) {
|
|
2926
2644
|
if (!(options.skipRestricted && propertySchema?.restricted)) {
|
|
2927
2645
|
raw[key] = properties[key];
|
|
@@ -2933,7 +2651,7 @@ class ConfigurationModelParser {
|
|
|
2933
2651
|
}
|
|
2934
2652
|
toOverrides(raw, conflictReporter) {
|
|
2935
2653
|
const overrides = [];
|
|
2936
|
-
for (const key of (
|
|
2654
|
+
for (const key of ( Object.keys(raw))) {
|
|
2937
2655
|
if (OVERRIDE_PROPERTY_REGEX.test(key)) {
|
|
2938
2656
|
const overrideRaw = {};
|
|
2939
2657
|
for (const keyInOverrideRaw in raw[key]) {
|
|
@@ -2941,7 +2659,7 @@ class ConfigurationModelParser {
|
|
|
2941
2659
|
}
|
|
2942
2660
|
overrides.push({
|
|
2943
2661
|
identifiers: overrideIdentifiersFromKey(key),
|
|
2944
|
-
keys: (
|
|
2662
|
+
keys: ( Object.keys(overrideRaw)),
|
|
2945
2663
|
contents: toValuesTree(overrideRaw, conflictReporter)
|
|
2946
2664
|
});
|
|
2947
2665
|
}
|
|
@@ -2955,23 +2673,22 @@ class UserSettings extends Disposable {
|
|
|
2955
2673
|
this.userSettingsResource = userSettingsResource;
|
|
2956
2674
|
this.scopes = scopes;
|
|
2957
2675
|
this.fileService = fileService;
|
|
2958
|
-
this._onDidChange = this._register((
|
|
2676
|
+
this._onDidChange = this._register(( new Emitter()));
|
|
2959
2677
|
this.onDidChange = this._onDidChange.event;
|
|
2960
|
-
this.parser = (
|
|
2678
|
+
this.parser = ( new ConfigurationModelParser(( this.userSettingsResource.toString())));
|
|
2961
2679
|
this.parseOptions = { scopes: this.scopes };
|
|
2962
2680
|
this._register(this.fileService.watch(extUri.dirname(this.userSettingsResource)));
|
|
2963
|
-
// Also listen to the resource incase the resource is a symlink - https://github.com/microsoft/vscode/issues/118134
|
|
2964
2681
|
this._register(this.fileService.watch(this.userSettingsResource));
|
|
2965
|
-
this._register(Event.any(Event.filter(this.fileService.onDidFilesChange, e => e.contains(this.userSettingsResource)), Event.filter(this.fileService.onDidRunOperation, e => (e.isOperation(0
|
|
2682
|
+
this._register(Event.any(Event.filter(this.fileService.onDidFilesChange, e => e.contains(this.userSettingsResource)), Event.filter(this.fileService.onDidRunOperation, e => (e.isOperation(0 ) || e.isOperation(3 ) || e.isOperation(1 ) || e.isOperation(4 )) && extUri.isEqual(e.resource, userSettingsResource)))(() => this._onDidChange.fire()));
|
|
2966
2683
|
}
|
|
2967
2684
|
async loadConfiguration() {
|
|
2968
2685
|
try {
|
|
2969
2686
|
const content = await this.fileService.readFile(this.userSettingsResource);
|
|
2970
|
-
this.parser.parse((
|
|
2687
|
+
this.parser.parse(( content.value.toString()) || '{}', this.parseOptions);
|
|
2971
2688
|
return this.parser.configurationModel;
|
|
2972
2689
|
}
|
|
2973
2690
|
catch (e) {
|
|
2974
|
-
return (
|
|
2691
|
+
return ( new ConfigurationModel());
|
|
2975
2692
|
}
|
|
2976
2693
|
}
|
|
2977
2694
|
reparse() {
|
|
@@ -2983,7 +2700,7 @@ class UserSettings extends Disposable {
|
|
|
2983
2700
|
}
|
|
2984
2701
|
}
|
|
2985
2702
|
class Configuration {
|
|
2986
|
-
constructor(_defaultConfiguration, _policyConfiguration, _applicationConfiguration, _localUserConfiguration, _remoteUserConfiguration = (
|
|
2703
|
+
constructor(_defaultConfiguration, _policyConfiguration, _applicationConfiguration, _localUserConfiguration, _remoteUserConfiguration = ( new ConfigurationModel()), _workspaceConfiguration = ( new ConfigurationModel()), _folderConfigurations = ( new ResourceMap$1()), _memoryConfiguration = ( new ConfigurationModel()), _memoryConfigurationByResource = ( new ResourceMap$1()), _freeze = true) {
|
|
2987
2704
|
this._defaultConfiguration = _defaultConfiguration;
|
|
2988
2705
|
this._policyConfiguration = _policyConfiguration;
|
|
2989
2706
|
this._applicationConfiguration = _applicationConfiguration;
|
|
@@ -2995,7 +2712,7 @@ class Configuration {
|
|
|
2995
2712
|
this._memoryConfigurationByResource = _memoryConfigurationByResource;
|
|
2996
2713
|
this._freeze = _freeze;
|
|
2997
2714
|
this._workspaceConsolidatedConfiguration = null;
|
|
2998
|
-
this._foldersConsolidatedConfigurations = (
|
|
2715
|
+
this._foldersConsolidatedConfigurations = ( new ResourceMap$1());
|
|
2999
2716
|
this._userConfiguration = null;
|
|
3000
2717
|
}
|
|
3001
2718
|
getValue(section, overrides, workspace) {
|
|
@@ -3007,7 +2724,7 @@ class Configuration {
|
|
|
3007
2724
|
if (overrides.resource) {
|
|
3008
2725
|
memoryConfiguration = this._memoryConfigurationByResource.get(overrides.resource);
|
|
3009
2726
|
if (!memoryConfiguration) {
|
|
3010
|
-
memoryConfiguration = (
|
|
2727
|
+
memoryConfiguration = ( new ConfigurationModel());
|
|
3011
2728
|
this._memoryConfigurationByResource.set(overrides.resource, memoryConfiguration);
|
|
3012
2729
|
}
|
|
3013
2730
|
}
|
|
@@ -3034,7 +2751,7 @@ class Configuration {
|
|
|
3034
2751
|
const userValue = overrides.overrideIdentifier ? this.userConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.userConfiguration.freeze().getValue(key);
|
|
3035
2752
|
const userLocalValue = overrides.overrideIdentifier ? this.localUserConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.localUserConfiguration.freeze().getValue(key);
|
|
3036
2753
|
const userRemoteValue = overrides.overrideIdentifier ? this.remoteUserConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.remoteUserConfiguration.freeze().getValue(key);
|
|
3037
|
-
const workspaceValue = workspace ? overrides.overrideIdentifier ? this._workspaceConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this._workspaceConfiguration.freeze().getValue(key) : undefined;
|
|
2754
|
+
const workspaceValue = workspace ? overrides.overrideIdentifier ? this._workspaceConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this._workspaceConfiguration.freeze().getValue(key) : undefined;
|
|
3038
2755
|
const workspaceFolderValue = folderConfigurationModel ? overrides.overrideIdentifier ? folderConfigurationModel.freeze().override(overrides.overrideIdentifier).getValue(key) : folderConfigurationModel.freeze().getValue(key) : undefined;
|
|
3039
2756
|
const memoryValue = overrides.overrideIdentifier ? memoryConfigurationModel.override(overrides.overrideIdentifier).getValue(key) : memoryConfigurationModel.getValue(key);
|
|
3040
2757
|
const value = consolidateConfigurationModel.getValue(key);
|
|
@@ -3302,7 +3019,7 @@ class Configuration {
|
|
|
3302
3019
|
overrides: this._workspaceConfiguration.overrides,
|
|
3303
3020
|
keys: this._workspaceConfiguration.keys
|
|
3304
3021
|
},
|
|
3305
|
-
folders: [...(
|
|
3022
|
+
folders: [...( this._folderConfigurations.keys())].reduce((result, folder) => {
|
|
3306
3023
|
const { contents, overrides, keys } = this._folderConfigurations.get(folder);
|
|
3307
3024
|
result.push([folder, { contents, overrides, keys }]);
|
|
3308
3025
|
return result;
|
|
@@ -3310,28 +3027,28 @@ class Configuration {
|
|
|
3310
3027
|
};
|
|
3311
3028
|
}
|
|
3312
3029
|
allKeys() {
|
|
3313
|
-
const keys = (
|
|
3030
|
+
const keys = ( new Set());
|
|
3314
3031
|
this._defaultConfiguration.freeze().keys.forEach(key => keys.add(key));
|
|
3315
3032
|
this.userConfiguration.freeze().keys.forEach(key => keys.add(key));
|
|
3316
3033
|
this._workspaceConfiguration.freeze().keys.forEach(key => keys.add(key));
|
|
3317
3034
|
this._folderConfigurations.forEach(folderConfiguraiton => folderConfiguraiton.freeze().keys.forEach(key => keys.add(key)));
|
|
3318
|
-
return [...(
|
|
3035
|
+
return [...( keys.values())];
|
|
3319
3036
|
}
|
|
3320
3037
|
allOverrideIdentifiers() {
|
|
3321
|
-
const keys = (
|
|
3038
|
+
const keys = ( new Set());
|
|
3322
3039
|
this._defaultConfiguration.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key));
|
|
3323
3040
|
this.userConfiguration.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key));
|
|
3324
3041
|
this._workspaceConfiguration.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key));
|
|
3325
3042
|
this._folderConfigurations.forEach(folderConfiguraiton => folderConfiguraiton.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key)));
|
|
3326
|
-
return [...(
|
|
3043
|
+
return [...( keys.values())];
|
|
3327
3044
|
}
|
|
3328
3045
|
getAllKeysForOverrideIdentifier(overrideIdentifier) {
|
|
3329
|
-
const keys = (
|
|
3046
|
+
const keys = ( new Set());
|
|
3330
3047
|
this._defaultConfiguration.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key));
|
|
3331
3048
|
this.userConfiguration.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key));
|
|
3332
3049
|
this._workspaceConfiguration.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key));
|
|
3333
3050
|
this._folderConfigurations.forEach(folderConfiguraiton => folderConfiguraiton.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key)));
|
|
3334
|
-
return [...(
|
|
3051
|
+
return [...( keys.values())];
|
|
3335
3052
|
}
|
|
3336
3053
|
static parse(data) {
|
|
3337
3054
|
const defaultConfiguration = this.parseConfigurationModel(data.defaults);
|
|
@@ -3342,22 +3059,22 @@ class Configuration {
|
|
|
3342
3059
|
const folders = data.folders.reduce((result, value) => {
|
|
3343
3060
|
result.set(URI.revive(value[0]), this.parseConfigurationModel(value[1]));
|
|
3344
3061
|
return result;
|
|
3345
|
-
}, (
|
|
3346
|
-
return (
|
|
3062
|
+
}, ( new ResourceMap$1()));
|
|
3063
|
+
return ( new Configuration(
|
|
3347
3064
|
defaultConfiguration,
|
|
3348
3065
|
policyConfiguration,
|
|
3349
3066
|
applicationConfiguration,
|
|
3350
3067
|
userConfiguration,
|
|
3351
|
-
(
|
|
3068
|
+
( new ConfigurationModel()),
|
|
3352
3069
|
workspaceConfiguration,
|
|
3353
3070
|
folders,
|
|
3354
|
-
(
|
|
3355
|
-
(
|
|
3071
|
+
( new ConfigurationModel()),
|
|
3072
|
+
( new ResourceMap$1()),
|
|
3356
3073
|
false
|
|
3357
3074
|
));
|
|
3358
3075
|
}
|
|
3359
3076
|
static parseConfigurationModel(model) {
|
|
3360
|
-
return (
|
|
3077
|
+
return ( new ConfigurationModel(model.contents, model.keys, model.overrides)).freeze();
|
|
3361
3078
|
}
|
|
3362
3079
|
}
|
|
3363
3080
|
function compare(from, to) {
|
|
@@ -3408,24 +3125,12 @@ function compareConfigurationContents(to, from) {
|
|
|
3408
3125
|
}
|
|
3409
3126
|
return { added, removed, updated };
|
|
3410
3127
|
}
|
|
3411
|
-
|
|
3412
|
-
/*---------------------------------------------------------------------------------------------
|
|
3413
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3414
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
3415
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3416
3128
|
function isWorkspaceIdentifier(obj) {
|
|
3417
3129
|
const workspaceIdentifier = obj;
|
|
3418
3130
|
return typeof workspaceIdentifier?.id === 'string' && URI.isUri(workspaceIdentifier.configPath);
|
|
3419
3131
|
}
|
|
3420
3132
|
class WorkspaceFolder {
|
|
3421
|
-
constructor(data,
|
|
3422
|
-
/**
|
|
3423
|
-
* Provides access to the original metadata for this workspace
|
|
3424
|
-
* folder. This can be different from the metadata provided in
|
|
3425
|
-
* this class:
|
|
3426
|
-
* - raw paths can be relative
|
|
3427
|
-
* - raw paths are not normalized
|
|
3428
|
-
*/
|
|
3133
|
+
constructor(data,
|
|
3429
3134
|
raw) {
|
|
3430
3135
|
this.raw = raw;
|
|
3431
3136
|
this.uri = data.uri;
|
|
@@ -3439,11 +3144,6 @@ class WorkspaceFolder {
|
|
|
3439
3144
|
return { uri: this.uri, name: this.name, index: this.index };
|
|
3440
3145
|
}
|
|
3441
3146
|
}
|
|
3442
|
-
|
|
3443
|
-
/*---------------------------------------------------------------------------------------------
|
|
3444
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3445
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
3446
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3447
3147
|
function isConfigurationOverrides(thing) {
|
|
3448
3148
|
return thing
|
|
3449
3149
|
&& typeof thing === 'object'
|
|
@@ -3452,9 +3152,9 @@ function isConfigurationOverrides(thing) {
|
|
|
3452
3152
|
}
|
|
3453
3153
|
class StandaloneConfigurationService {
|
|
3454
3154
|
constructor() {
|
|
3455
|
-
this._onDidChangeConfiguration = (
|
|
3155
|
+
this._onDidChangeConfiguration = ( new Emitter());
|
|
3456
3156
|
this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
|
|
3457
|
-
this._configuration = (
|
|
3157
|
+
this._configuration = ( new Configuration$1(( new DefaultConfigurationModel()), ( new ConfigurationModel$1()), ( new ConfigurationModel$1()), ( new ConfigurationModel$1())));
|
|
3458
3158
|
}
|
|
3459
3159
|
getValue(arg1, arg2) {
|
|
3460
3160
|
const section = typeof arg1 === 'string' ? arg1 : undefined;
|
|
@@ -3473,8 +3173,8 @@ class StandaloneConfigurationService {
|
|
|
3473
3173
|
changedKeys.push(key);
|
|
3474
3174
|
}
|
|
3475
3175
|
if (changedKeys.length > 0) {
|
|
3476
|
-
const configurationChangeEvent = (
|
|
3477
|
-
configurationChangeEvent.source = 8
|
|
3176
|
+
const configurationChangeEvent = ( new ConfigurationChangeEvent({ keys: changedKeys, overrides: [] }, previous, this._configuration));
|
|
3177
|
+
configurationChangeEvent.source = 8 ;
|
|
3478
3178
|
configurationChangeEvent.sourceConfig = null;
|
|
3479
3179
|
this._onDidChangeConfiguration.fire(configurationChangeEvent);
|
|
3480
3180
|
}
|
|
@@ -3487,7 +3187,7 @@ class StandaloneConfigurationService {
|
|
|
3487
3187
|
return this._configuration.inspect(key, options, undefined);
|
|
3488
3188
|
}
|
|
3489
3189
|
keys() {
|
|
3490
|
-
return (
|
|
3190
|
+
return ( this._configuration.keys(undefined));
|
|
3491
3191
|
}
|
|
3492
3192
|
reloadConfiguration() {
|
|
3493
3193
|
return Promise.resolve(undefined);
|
|
@@ -3508,19 +3208,14 @@ class StandaloneConfigurationService {
|
|
|
3508
3208
|
};
|
|
3509
3209
|
}
|
|
3510
3210
|
}
|
|
3511
|
-
|
|
3512
|
-
/*---------------------------------------------------------------------------------------------
|
|
3513
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3514
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
3515
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3516
3211
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3517
3212
|
const NULL_LANGUAGE_ID = 'vs.editor.nullLanguage';
|
|
3518
3213
|
class LanguageIdCodec {
|
|
3519
3214
|
constructor() {
|
|
3520
3215
|
this._languageIdToLanguage = [];
|
|
3521
|
-
this._languageToLanguageId = (
|
|
3522
|
-
this._register(NULL_LANGUAGE_ID, 0
|
|
3523
|
-
this._register(PLAINTEXT_LANGUAGE_ID, 1
|
|
3216
|
+
this._languageToLanguageId = ( new Map());
|
|
3217
|
+
this._register(NULL_LANGUAGE_ID, 0 );
|
|
3218
|
+
this._register(PLAINTEXT_LANGUAGE_ID, 1 );
|
|
3524
3219
|
this._nextLanguageId = 2;
|
|
3525
3220
|
}
|
|
3526
3221
|
_register(language, languageId) {
|
|
@@ -3535,7 +3230,7 @@ class LanguageIdCodec {
|
|
|
3535
3230
|
this._register(language, languageId);
|
|
3536
3231
|
}
|
|
3537
3232
|
encodeLanguageId(languageId) {
|
|
3538
|
-
return this._languageToLanguageId.get(languageId) || 0
|
|
3233
|
+
return this._languageToLanguageId.get(languageId) || 0 ;
|
|
3539
3234
|
}
|
|
3540
3235
|
decodeLanguageId(languageId) {
|
|
3541
3236
|
return this._languageIdToLanguage[languageId] || NULL_LANGUAGE_ID;
|
|
@@ -3544,11 +3239,11 @@ class LanguageIdCodec {
|
|
|
3544
3239
|
class LanguagesRegistry extends Disposable {
|
|
3545
3240
|
constructor(useModesRegistry = true, warnOnOverwrite = false) {
|
|
3546
3241
|
super();
|
|
3547
|
-
this._onDidChange = this._register((
|
|
3242
|
+
this._onDidChange = this._register(( new Emitter()));
|
|
3548
3243
|
this.onDidChange = this._onDidChange.event;
|
|
3549
3244
|
LanguagesRegistry.instanceCount++;
|
|
3550
3245
|
this._warnOnOverwrite = warnOnOverwrite;
|
|
3551
|
-
this.languageIdCodec = (
|
|
3246
|
+
this.languageIdCodec = ( new LanguageIdCodec());
|
|
3552
3247
|
this._dynamicLanguages = [];
|
|
3553
3248
|
this._languages = {};
|
|
3554
3249
|
this._mimeTypesMap = {};
|
|
@@ -3585,11 +3280,10 @@ class LanguagesRegistry extends Disposable {
|
|
|
3585
3280
|
for (const d of desc) {
|
|
3586
3281
|
this._registerLanguage(d);
|
|
3587
3282
|
}
|
|
3588
|
-
// Rebuild fast path maps
|
|
3589
3283
|
this._mimeTypesMap = {};
|
|
3590
3284
|
this._nameMap = {};
|
|
3591
3285
|
this._lowercaseNameMap = {};
|
|
3592
|
-
(
|
|
3286
|
+
( Object.keys(this._languages)).forEach((langId) => {
|
|
3593
3287
|
const language = this._languages[langId];
|
|
3594
3288
|
if (language.name) {
|
|
3595
3289
|
this._nameMap[language.name] = language.identifier;
|
|
@@ -3601,7 +3295,7 @@ class LanguagesRegistry extends Disposable {
|
|
|
3601
3295
|
this._mimeTypesMap[mimetype] = language.identifier;
|
|
3602
3296
|
});
|
|
3603
3297
|
});
|
|
3604
|
-
(
|
|
3298
|
+
( Registry.as(Extensions$2.Configuration)).registerOverrideIdentifiers(this.getRegisteredLanguageIds());
|
|
3605
3299
|
this._onDidChange.fire();
|
|
3606
3300
|
}
|
|
3607
3301
|
_registerLanguage(lang) {
|
|
@@ -3639,7 +3333,6 @@ class LanguagesRegistry extends Disposable {
|
|
|
3639
3333
|
}
|
|
3640
3334
|
if (Array.isArray(lang.extensions)) {
|
|
3641
3335
|
if (lang.configuration) {
|
|
3642
|
-
// insert first as this appears to be the 'primary' language definition
|
|
3643
3336
|
resolvedLanguage.extensions = lang.extensions.concat(resolvedLanguage.extensions);
|
|
3644
3337
|
}
|
|
3645
3338
|
else {
|
|
@@ -3666,13 +3359,12 @@ class LanguagesRegistry extends Disposable {
|
|
|
3666
3359
|
firstLineRegexStr = '^' + firstLineRegexStr;
|
|
3667
3360
|
}
|
|
3668
3361
|
try {
|
|
3669
|
-
const firstLineRegex = (
|
|
3362
|
+
const firstLineRegex = ( new RegExp(firstLineRegexStr));
|
|
3670
3363
|
if (!regExpLeadsToEndlessLoop(firstLineRegex)) {
|
|
3671
3364
|
registerPlatformLanguageAssociation({ id: langId, mime: primaryMime, firstline: firstLineRegex }, this._warnOnOverwrite);
|
|
3672
3365
|
}
|
|
3673
3366
|
}
|
|
3674
3367
|
catch (err) {
|
|
3675
|
-
// Most likely, the regex was bad
|
|
3676
3368
|
onUnexpectedError(err);
|
|
3677
3369
|
}
|
|
3678
3370
|
}
|
|
@@ -3680,7 +3372,6 @@ class LanguagesRegistry extends Disposable {
|
|
|
3680
3372
|
let langAliases = null;
|
|
3681
3373
|
if (typeof lang.aliases !== 'undefined' && Array.isArray(lang.aliases)) {
|
|
3682
3374
|
if (lang.aliases.length === 0) {
|
|
3683
|
-
// signal that this language should not get a name
|
|
3684
3375
|
langAliases = [null];
|
|
3685
3376
|
}
|
|
3686
3377
|
else {
|
|
@@ -3717,7 +3408,7 @@ class LanguagesRegistry extends Disposable {
|
|
|
3717
3408
|
return hasOwnProperty.call(this._languages, languageId);
|
|
3718
3409
|
}
|
|
3719
3410
|
getRegisteredLanguageIds() {
|
|
3720
|
-
return (
|
|
3411
|
+
return ( Object.keys(this._languages));
|
|
3721
3412
|
}
|
|
3722
3413
|
getSortedRegisteredLanguageNames() {
|
|
3723
3414
|
const result = [];
|
|
@@ -3794,11 +3485,6 @@ class LanguagesRegistry extends Disposable {
|
|
|
3794
3485
|
}
|
|
3795
3486
|
}
|
|
3796
3487
|
LanguagesRegistry.instanceCount = 0;
|
|
3797
|
-
|
|
3798
|
-
/*---------------------------------------------------------------------------------------------
|
|
3799
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3800
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
3801
|
-
*--------------------------------------------------------------------------------------------*/
|
|
3802
3488
|
class TraitRenderer {
|
|
3803
3489
|
constructor(trait) {
|
|
3804
3490
|
this.trait = trait;
|
|
@@ -3859,12 +3545,12 @@ class Trait {
|
|
|
3859
3545
|
this.length = 0;
|
|
3860
3546
|
this.indexes = [];
|
|
3861
3547
|
this.sortedIndexes = [];
|
|
3862
|
-
this._onChange = (
|
|
3548
|
+
this._onChange = ( new Emitter());
|
|
3863
3549
|
this.onChange = this._onChange.event;
|
|
3864
3550
|
}
|
|
3865
3551
|
get name() { return this._trait; }
|
|
3866
3552
|
get renderer() {
|
|
3867
|
-
return (
|
|
3553
|
+
return ( new TraitRenderer(this));
|
|
3868
3554
|
}
|
|
3869
3555
|
splice(start, deleteCount, elements) {
|
|
3870
3556
|
deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));
|
|
@@ -3890,12 +3576,6 @@ class Trait {
|
|
|
3890
3576
|
unrender(container) {
|
|
3891
3577
|
container.classList.remove(this._trait);
|
|
3892
3578
|
}
|
|
3893
|
-
/**
|
|
3894
|
-
* Sets the indexes which should have this trait.
|
|
3895
|
-
*
|
|
3896
|
-
* @param indexes Indexes which should have this trait.
|
|
3897
|
-
* @return The old indexes which had this trait.
|
|
3898
|
-
*/
|
|
3899
3579
|
set(indexes, browserEvent) {
|
|
3900
3580
|
return this._set(indexes, [...indexes].sort(numericSort), browserEvent);
|
|
3901
3581
|
}
|
|
@@ -3936,11 +3616,6 @@ class SelectionTrait extends Trait {
|
|
|
3936
3616
|
}
|
|
3937
3617
|
}
|
|
3938
3618
|
}
|
|
3939
|
-
/**
|
|
3940
|
-
* The TraitSpliceable is used as a util class to be able
|
|
3941
|
-
* to preserve traits across splice calls, given an identity
|
|
3942
|
-
* provider.
|
|
3943
|
-
*/
|
|
3944
3619
|
class TraitSpliceable {
|
|
3945
3620
|
constructor(trait, view, identityProvider) {
|
|
3946
3621
|
this.trait = trait;
|
|
@@ -3951,8 +3626,8 @@ class TraitSpliceable {
|
|
|
3951
3626
|
if (!this.identityProvider) {
|
|
3952
3627
|
return this.trait.splice(start, deleteCount, elements.map(() => false));
|
|
3953
3628
|
}
|
|
3954
|
-
const pastElementsWithTrait = this.trait.get().map(i => (
|
|
3955
|
-
const elementsWithTrait = elements.map(e => pastElementsWithTrait.indexOf((
|
|
3629
|
+
const pastElementsWithTrait = this.trait.get().map(i => ( this.identityProvider.getId(this.view.element(i)).toString()));
|
|
3630
|
+
const elementsWithTrait = elements.map(e => pastElementsWithTrait.indexOf(( this.identityProvider.getId(e).toString())) > -1);
|
|
3956
3631
|
this.trait.splice(start, deleteCount, elementsWithTrait);
|
|
3957
3632
|
}
|
|
3958
3633
|
}
|
|
@@ -3975,28 +3650,28 @@ class KeyboardController {
|
|
|
3975
3650
|
constructor(list, view, options) {
|
|
3976
3651
|
this.list = list;
|
|
3977
3652
|
this.view = view;
|
|
3978
|
-
this.disposables = (
|
|
3979
|
-
this.multipleSelectionDisposables = (
|
|
3980
|
-
this.onKeyDown.filter(e => e.keyCode === 3
|
|
3981
|
-
this.onKeyDown.filter(e => e.keyCode === 16
|
|
3982
|
-
this.onKeyDown.filter(e => e.keyCode === 18
|
|
3983
|
-
this.onKeyDown.filter(e => e.keyCode === 11
|
|
3984
|
-
this.onKeyDown.filter(e => e.keyCode === 12
|
|
3985
|
-
this.onKeyDown.filter(e => e.keyCode === 9
|
|
3653
|
+
this.disposables = ( new DisposableStore());
|
|
3654
|
+
this.multipleSelectionDisposables = ( new DisposableStore());
|
|
3655
|
+
this.onKeyDown.filter(e => e.keyCode === 3 ).on(this.onEnter, this, this.disposables);
|
|
3656
|
+
this.onKeyDown.filter(e => e.keyCode === 16 ).on(this.onUpArrow, this, this.disposables);
|
|
3657
|
+
this.onKeyDown.filter(e => e.keyCode === 18 ).on(this.onDownArrow, this, this.disposables);
|
|
3658
|
+
this.onKeyDown.filter(e => e.keyCode === 11 ).on(this.onPageUpArrow, this, this.disposables);
|
|
3659
|
+
this.onKeyDown.filter(e => e.keyCode === 12 ).on(this.onPageDownArrow, this, this.disposables);
|
|
3660
|
+
this.onKeyDown.filter(e => e.keyCode === 9 ).on(this.onEscape, this, this.disposables);
|
|
3986
3661
|
if (options.multipleSelectionSupport !== false) {
|
|
3987
|
-
this.onKeyDown.filter(e => (isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === 31
|
|
3662
|
+
this.onKeyDown.filter(e => (isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === 31 ).on(this.onCtrlA, this, this.multipleSelectionDisposables);
|
|
3988
3663
|
}
|
|
3989
3664
|
}
|
|
3990
3665
|
get onKeyDown() {
|
|
3991
|
-
return this.disposables.add(Event.chain(this.disposables.add((
|
|
3666
|
+
return this.disposables.add(Event.chain(this.disposables.add(( new DomEmitter(this.view.domNode, 'keydown'))).event)
|
|
3992
3667
|
.filter(e => !isInputElement(e.target))
|
|
3993
|
-
.map(e => (
|
|
3668
|
+
.map(e => ( new StandardKeyboardEvent(e))));
|
|
3994
3669
|
}
|
|
3995
3670
|
updateOptions(optionsUpdate) {
|
|
3996
3671
|
if (optionsUpdate.multipleSelectionSupport !== undefined) {
|
|
3997
3672
|
this.multipleSelectionDisposables.clear();
|
|
3998
3673
|
if (optionsUpdate.multipleSelectionSupport) {
|
|
3999
|
-
this.onKeyDown.filter(e => (isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === 31
|
|
3674
|
+
this.onKeyDown.filter(e => (isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === 31 ).on(this.onCtrlA, this, this.multipleSelectionDisposables);
|
|
4000
3675
|
}
|
|
4001
3676
|
}
|
|
4002
3677
|
}
|
|
@@ -4063,12 +3738,12 @@ class KeyboardController {
|
|
|
4063
3738
|
}
|
|
4064
3739
|
}
|
|
4065
3740
|
var TypeNavigationMode;
|
|
4066
|
-
(
|
|
3741
|
+
( (function(TypeNavigationMode) {
|
|
4067
3742
|
TypeNavigationMode[TypeNavigationMode["Automatic"] = 0] = "Automatic";
|
|
4068
3743
|
TypeNavigationMode[TypeNavigationMode["Trigger"] = 1] = "Trigger";
|
|
4069
3744
|
})(TypeNavigationMode || (TypeNavigationMode = {})));
|
|
4070
3745
|
var TypeNavigationControllerState;
|
|
4071
|
-
(
|
|
3746
|
+
( (function(TypeNavigationControllerState) {
|
|
4072
3747
|
TypeNavigationControllerState[TypeNavigationControllerState["Idle"] = 0] = "Idle";
|
|
4073
3748
|
TypeNavigationControllerState[TypeNavigationControllerState["Typing"] = 1] = "Typing";
|
|
4074
3749
|
})(TypeNavigationControllerState || (TypeNavigationControllerState = {})));
|
|
@@ -4077,10 +3752,10 @@ const DefaultKeyboardNavigationDelegate = new class {
|
|
|
4077
3752
|
if (event.ctrlKey || event.metaKey || event.altKey) {
|
|
4078
3753
|
return false;
|
|
4079
3754
|
}
|
|
4080
|
-
return ((event.keyCode >= 31
|
|
4081
|
-
|| ((event.keyCode >= 21
|
|
4082
|
-
|| ((event.keyCode >= 93
|
|
4083
|
-
|| ((event.keyCode >= 80
|
|
3755
|
+
return ((event.keyCode >= 31 && event.keyCode <= 56) )
|
|
3756
|
+
|| ((event.keyCode >= 21 && event.keyCode <= 30) )
|
|
3757
|
+
|| ((event.keyCode >= 93 && event.keyCode <= 102) )
|
|
3758
|
+
|| ((event.keyCode >= 80 && event.keyCode <= 90) );
|
|
4084
3759
|
}
|
|
4085
3760
|
};
|
|
4086
3761
|
class TypeNavigationController {
|
|
@@ -4095,8 +3770,8 @@ class TypeNavigationController {
|
|
|
4095
3770
|
this.mode = TypeNavigationMode.Automatic;
|
|
4096
3771
|
this.triggered = false;
|
|
4097
3772
|
this.previouslyFocused = -1;
|
|
4098
|
-
this.enabledDisposables = (
|
|
4099
|
-
this.disposables = (
|
|
3773
|
+
this.enabledDisposables = ( new DisposableStore());
|
|
3774
|
+
this.disposables = ( new DisposableStore());
|
|
4100
3775
|
this.updateOptions(list.options);
|
|
4101
3776
|
}
|
|
4102
3777
|
updateOptions(options) {
|
|
@@ -4116,10 +3791,10 @@ class TypeNavigationController {
|
|
|
4116
3791
|
return;
|
|
4117
3792
|
}
|
|
4118
3793
|
let typing = false;
|
|
4119
|
-
const onChar = this.enabledDisposables.add(Event.chain(this.enabledDisposables.add((
|
|
3794
|
+
const onChar = this.enabledDisposables.add(Event.chain(this.enabledDisposables.add(( new DomEmitter(this.view.domNode, 'keydown'))).event))
|
|
4120
3795
|
.filter(e => !isInputElement(e.target))
|
|
4121
3796
|
.filter(() => this.mode === TypeNavigationMode.Automatic || this.triggered)
|
|
4122
|
-
.map(event => (
|
|
3797
|
+
.map(event => ( new StandardKeyboardEvent(event)))
|
|
4123
3798
|
.filter(e => typing || this.keyboardNavigationEventFilter(e))
|
|
4124
3799
|
.filter(e => this.delegate.mightProducePrintableCharacter(e))
|
|
4125
3800
|
.forEach(stopEvent)
|
|
@@ -4145,8 +3820,6 @@ class TypeNavigationController {
|
|
|
4145
3820
|
onClear() {
|
|
4146
3821
|
const focus = this.list.getFocus();
|
|
4147
3822
|
if (focus.length > 0 && focus[0] === this.previouslyFocused) {
|
|
4148
|
-
// List: re-announce element on typing end since typed keys will interrupt aria label of focused element
|
|
4149
|
-
// Do not announce if there was a focus change at the end to prevent duplication https://github.com/microsoft/vscode/issues/95961
|
|
4150
3823
|
const ariaLabel = this.list.options.accessibilityProvider?.getAriaLabel(this.list.element(focus[0]));
|
|
4151
3824
|
if (ariaLabel) {
|
|
4152
3825
|
alert(ariaLabel);
|
|
@@ -4167,7 +3840,7 @@ class TypeNavigationController {
|
|
|
4167
3840
|
for (let i = 0; i < this.list.length; i++) {
|
|
4168
3841
|
const index = (start + i + delta) % this.list.length;
|
|
4169
3842
|
const label = this.keyboardNavigationLabelProvider.getKeyboardNavigationLabel(this.view.element(index));
|
|
4170
|
-
const labelStr = label && (
|
|
3843
|
+
const labelStr = label && ( label.toString());
|
|
4171
3844
|
if (typeof labelStr === 'undefined' || matchesPrefix(word, labelStr)) {
|
|
4172
3845
|
this.previouslyFocused = start;
|
|
4173
3846
|
this.list.setFocus([index]);
|
|
@@ -4186,11 +3859,11 @@ class DOMFocusController {
|
|
|
4186
3859
|
constructor(list, view) {
|
|
4187
3860
|
this.list = list;
|
|
4188
3861
|
this.view = view;
|
|
4189
|
-
this.disposables = (
|
|
4190
|
-
const onKeyDown = this.disposables.add(Event.chain(this.disposables.add((
|
|
3862
|
+
this.disposables = ( new DisposableStore());
|
|
3863
|
+
const onKeyDown = this.disposables.add(Event.chain(this.disposables.add(( new DomEmitter(view.domNode, 'keydown'))).event))
|
|
4191
3864
|
.filter(e => !isInputElement(e.target))
|
|
4192
|
-
.map(e => (
|
|
4193
|
-
onKeyDown.filter(e => e.keyCode === 2
|
|
3865
|
+
.map(e => ( new StandardKeyboardEvent(e)));
|
|
3866
|
+
onKeyDown.filter(e => e.keyCode === 2 && !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey)
|
|
4194
3867
|
.on(this.onTab, this, this.disposables);
|
|
4195
3868
|
}
|
|
4196
3869
|
onTab(e) {
|
|
@@ -4237,8 +3910,8 @@ const DefaultMultipleSelectionController = {
|
|
|
4237
3910
|
class MouseController {
|
|
4238
3911
|
constructor(list) {
|
|
4239
3912
|
this.list = list;
|
|
4240
|
-
this.disposables = (
|
|
4241
|
-
this._onPointer = (
|
|
3913
|
+
this.disposables = ( new DisposableStore());
|
|
3914
|
+
this._onPointer = ( new Emitter());
|
|
4242
3915
|
this.onPointer = this._onPointer.event;
|
|
4243
3916
|
if (list.options.multipleSelectionSupport !== false) {
|
|
4244
3917
|
this.multipleSelectionController = this.list.options.multipleSelectionController || DefaultMultipleSelectionController;
|
|
@@ -4378,20 +4051,20 @@ class DefaultStyleController {
|
|
|
4378
4051
|
if (styles.listBackground.isOpaque()) {
|
|
4379
4052
|
content.push(`.monaco-list${suffix} .monaco-list-rows { background: ${styles.listBackground}; }`);
|
|
4380
4053
|
}
|
|
4381
|
-
else if (!isMacintosh) {
|
|
4054
|
+
else if (!isMacintosh) {
|
|
4382
4055
|
console.warn(`List with id '${this.selectorSuffix}' was styled with a non-opaque background color. This will break sub-pixel antialiasing.`);
|
|
4383
4056
|
}
|
|
4384
4057
|
}
|
|
4385
4058
|
if (styles.listFocusBackground) {
|
|
4386
4059
|
content.push(`.monaco-list${suffix}:focus .monaco-list-row.focused { background-color: ${styles.listFocusBackground}; }`);
|
|
4387
|
-
content.push(`.monaco-list${suffix}:focus .monaco-list-row.focused:hover { background-color: ${styles.listFocusBackground}; }`);
|
|
4060
|
+
content.push(`.monaco-list${suffix}:focus .monaco-list-row.focused:hover { background-color: ${styles.listFocusBackground}; }`);
|
|
4388
4061
|
}
|
|
4389
4062
|
if (styles.listFocusForeground) {
|
|
4390
4063
|
content.push(`.monaco-list${suffix}:focus .monaco-list-row.focused { color: ${styles.listFocusForeground}; }`);
|
|
4391
4064
|
}
|
|
4392
4065
|
if (styles.listActiveSelectionBackground) {
|
|
4393
4066
|
content.push(`.monaco-list${suffix}:focus .monaco-list-row.selected { background-color: ${styles.listActiveSelectionBackground}; }`);
|
|
4394
|
-
content.push(`.monaco-list${suffix}:focus .monaco-list-row.selected:hover { background-color: ${styles.listActiveSelectionBackground}; }`);
|
|
4067
|
+
content.push(`.monaco-list${suffix}:focus .monaco-list-row.selected:hover { background-color: ${styles.listActiveSelectionBackground}; }`);
|
|
4395
4068
|
}
|
|
4396
4069
|
if (styles.listActiveSelectionForeground) {
|
|
4397
4070
|
content.push(`.monaco-list${suffix}:focus .monaco-list-row.selected { color: ${styles.listActiveSelectionForeground}; }`);
|
|
@@ -4416,18 +4089,18 @@ class DefaultStyleController {
|
|
|
4416
4089
|
}
|
|
4417
4090
|
if (styles.listInactiveFocusForeground) {
|
|
4418
4091
|
content.push(`.monaco-list${suffix} .monaco-list-row.focused { color: ${styles.listInactiveFocusForeground}; }`);
|
|
4419
|
-
content.push(`.monaco-list${suffix} .monaco-list-row.focused:hover { color: ${styles.listInactiveFocusForeground}; }`);
|
|
4092
|
+
content.push(`.monaco-list${suffix} .monaco-list-row.focused:hover { color: ${styles.listInactiveFocusForeground}; }`);
|
|
4420
4093
|
}
|
|
4421
4094
|
if (styles.listInactiveSelectionIconForeground) {
|
|
4422
4095
|
content.push(`.monaco-list${suffix} .monaco-list-row.focused .codicon { color: ${styles.listInactiveSelectionIconForeground}; }`);
|
|
4423
4096
|
}
|
|
4424
4097
|
if (styles.listInactiveFocusBackground) {
|
|
4425
4098
|
content.push(`.monaco-list${suffix} .monaco-list-row.focused { background-color: ${styles.listInactiveFocusBackground}; }`);
|
|
4426
|
-
content.push(`.monaco-list${suffix} .monaco-list-row.focused:hover { background-color: ${styles.listInactiveFocusBackground}; }`);
|
|
4099
|
+
content.push(`.monaco-list${suffix} .monaco-list-row.focused:hover { background-color: ${styles.listInactiveFocusBackground}; }`);
|
|
4427
4100
|
}
|
|
4428
4101
|
if (styles.listInactiveSelectionBackground) {
|
|
4429
4102
|
content.push(`.monaco-list${suffix} .monaco-list-row.selected { background-color: ${styles.listInactiveSelectionBackground}; }`);
|
|
4430
|
-
content.push(`.monaco-list${suffix} .monaco-list-row.selected:hover { background-color: ${styles.listInactiveSelectionBackground}; }`);
|
|
4103
|
+
content.push(`.monaco-list${suffix} .monaco-list-row.selected:hover { background-color: ${styles.listInactiveSelectionBackground}; }`);
|
|
4431
4104
|
}
|
|
4432
4105
|
if (styles.listInactiveSelectionForeground) {
|
|
4433
4106
|
content.push(`.monaco-list${suffix} .monaco-list-row.selected { color: ${styles.listInactiveSelectionForeground}; }`);
|
|
@@ -4481,20 +4154,20 @@ class DefaultStyleController {
|
|
|
4481
4154
|
}
|
|
4482
4155
|
}
|
|
4483
4156
|
const defaultStyles = {
|
|
4484
|
-
listFocusBackground: (
|
|
4485
|
-
listActiveSelectionBackground: (
|
|
4486
|
-
listActiveSelectionForeground: (
|
|
4487
|
-
listActiveSelectionIconForeground: (
|
|
4488
|
-
listFocusAndSelectionOutline: (
|
|
4489
|
-
listFocusAndSelectionBackground: (
|
|
4490
|
-
listFocusAndSelectionForeground: (
|
|
4491
|
-
listInactiveSelectionBackground: (
|
|
4492
|
-
listInactiveSelectionIconForeground: (
|
|
4493
|
-
listHoverBackground: (
|
|
4494
|
-
listDropBackground: (
|
|
4495
|
-
treeIndentGuidesStroke: (
|
|
4496
|
-
tableColumnsBorder: (
|
|
4497
|
-
tableOddRowsBackgroundColor: (
|
|
4157
|
+
listFocusBackground: ( Color$1.fromHex('#7FB0D0')),
|
|
4158
|
+
listActiveSelectionBackground: ( Color$1.fromHex('#0E639C')),
|
|
4159
|
+
listActiveSelectionForeground: ( Color$1.fromHex('#FFFFFF')),
|
|
4160
|
+
listActiveSelectionIconForeground: ( Color$1.fromHex('#FFFFFF')),
|
|
4161
|
+
listFocusAndSelectionOutline: ( Color$1.fromHex('#90C2F9')),
|
|
4162
|
+
listFocusAndSelectionBackground: ( Color$1.fromHex('#094771')),
|
|
4163
|
+
listFocusAndSelectionForeground: ( Color$1.fromHex('#FFFFFF')),
|
|
4164
|
+
listInactiveSelectionBackground: ( Color$1.fromHex('#3F3F46')),
|
|
4165
|
+
listInactiveSelectionIconForeground: ( Color$1.fromHex('#FFFFFF')),
|
|
4166
|
+
listHoverBackground: ( Color$1.fromHex('#2A2D2E')),
|
|
4167
|
+
listDropBackground: ( Color$1.fromHex('#383B3D')),
|
|
4168
|
+
treeIndentGuidesStroke: ( Color$1.fromHex('#a9a9a9')),
|
|
4169
|
+
tableColumnsBorder: ( ( Color$1.fromHex('#cccccc')).transparent(0.2)),
|
|
4170
|
+
tableOddRowsBackgroundColor: ( ( Color$1.fromHex('#cccccc')).transparent(0.04))
|
|
4498
4171
|
};
|
|
4499
4172
|
const DefaultOptions = {
|
|
4500
4173
|
keyboardSupport: true,
|
|
@@ -4507,7 +4180,6 @@ const DefaultOptions = {
|
|
|
4507
4180
|
drop() { }
|
|
4508
4181
|
}
|
|
4509
4182
|
};
|
|
4510
|
-
// TODO@Joao: move these utils into a SortedArray class
|
|
4511
4183
|
function getContiguousRangeContaining(range, value) {
|
|
4512
4184
|
const index = range.indexOf(value);
|
|
4513
4185
|
if (index === -1) {
|
|
@@ -4525,10 +4197,6 @@ function getContiguousRangeContaining(range, value) {
|
|
|
4525
4197
|
}
|
|
4526
4198
|
return result;
|
|
4527
4199
|
}
|
|
4528
|
-
/**
|
|
4529
|
-
* Given two sorted collections of numbers, returns the intersection
|
|
4530
|
-
* between them (OR).
|
|
4531
|
-
*/
|
|
4532
4200
|
function disjunction(one, other) {
|
|
4533
4201
|
const result = [];
|
|
4534
4202
|
let i = 0, j = 0;
|
|
@@ -4554,10 +4222,6 @@ function disjunction(one, other) {
|
|
|
4554
4222
|
}
|
|
4555
4223
|
return result;
|
|
4556
4224
|
}
|
|
4557
|
-
/**
|
|
4558
|
-
* Given two sorted collections of numbers, returns the relative
|
|
4559
|
-
* complement between them (XOR).
|
|
4560
|
-
*/
|
|
4561
4225
|
function relativeComplement(one, other) {
|
|
4562
4226
|
const result = [];
|
|
4563
4227
|
let i = 0, j = 0;
|
|
@@ -4639,7 +4303,6 @@ class AccessibiltyRenderer {
|
|
|
4639
4303
|
}
|
|
4640
4304
|
}
|
|
4641
4305
|
disposeTemplate(templateData) {
|
|
4642
|
-
// noop
|
|
4643
4306
|
}
|
|
4644
4307
|
}
|
|
4645
4308
|
class ListViewDragAndDrop {
|
|
@@ -4677,59 +4340,44 @@ class ListViewDragAndDrop {
|
|
|
4677
4340
|
this.dnd.drop(data, targetElement, targetIndex, originalEvent);
|
|
4678
4341
|
}
|
|
4679
4342
|
}
|
|
4680
|
-
/**
|
|
4681
|
-
* The {@link List} is a virtual scrolling widget, built on top of the {@link ListView}
|
|
4682
|
-
* widget.
|
|
4683
|
-
*
|
|
4684
|
-
* Features:
|
|
4685
|
-
* - Customizable keyboard and mouse support
|
|
4686
|
-
* - Element traits: focus, selection, achor
|
|
4687
|
-
* - Accessibility support
|
|
4688
|
-
* - Touch support
|
|
4689
|
-
* - Performant template-based rendering
|
|
4690
|
-
* - Horizontal scrolling
|
|
4691
|
-
* - Variable element height support
|
|
4692
|
-
* - Dynamic element height support
|
|
4693
|
-
* - Drag-and-drop support
|
|
4694
|
-
*/
|
|
4695
4343
|
class List {
|
|
4696
4344
|
constructor(user, container, virtualDelegate, renderers, _options = DefaultOptions) {
|
|
4697
4345
|
this.user = user;
|
|
4698
4346
|
this._options = _options;
|
|
4699
|
-
this.focus = (
|
|
4700
|
-
this.anchor = (
|
|
4701
|
-
this.eventBufferer = (
|
|
4347
|
+
this.focus = ( new Trait('focused'));
|
|
4348
|
+
this.anchor = ( new Trait('anchor'));
|
|
4349
|
+
this.eventBufferer = ( new EventBufferer());
|
|
4702
4350
|
this._ariaLabel = '';
|
|
4703
|
-
this.disposables = (
|
|
4704
|
-
this._onDidDispose = (
|
|
4351
|
+
this.disposables = ( new DisposableStore());
|
|
4352
|
+
this._onDidDispose = ( new Emitter());
|
|
4705
4353
|
this.onDidDispose = this._onDidDispose.event;
|
|
4706
4354
|
const role = this._options.accessibilityProvider && this._options.accessibilityProvider.getWidgetRole ? this._options.accessibilityProvider?.getWidgetRole() : 'list';
|
|
4707
|
-
this.selection = (
|
|
4355
|
+
this.selection = ( new SelectionTrait(role !== 'listbox'));
|
|
4708
4356
|
mixin(_options, defaultStyles, false);
|
|
4709
4357
|
const baseRenderers = [this.focus.renderer, this.selection.renderer];
|
|
4710
4358
|
this.accessibilityProvider = _options.accessibilityProvider;
|
|
4711
4359
|
if (this.accessibilityProvider) {
|
|
4712
|
-
baseRenderers.push((
|
|
4360
|
+
baseRenderers.push(( new AccessibiltyRenderer(this.accessibilityProvider)));
|
|
4713
4361
|
this.accessibilityProvider.onDidChangeActiveDescendant?.(this.onDidChangeActiveDescendant, this, this.disposables);
|
|
4714
4362
|
}
|
|
4715
|
-
renderers = renderers.map(r => (
|
|
4363
|
+
renderers = renderers.map(r => ( new PipelineRenderer(r.templateId, [...baseRenderers, r])));
|
|
4716
4364
|
const viewOptions = {
|
|
4717
4365
|
..._options,
|
|
4718
|
-
dnd: _options.dnd && (
|
|
4366
|
+
dnd: _options.dnd && ( new ListViewDragAndDrop(this, _options.dnd))
|
|
4719
4367
|
};
|
|
4720
|
-
this.view = (
|
|
4368
|
+
this.view = ( new ListView(container, virtualDelegate, renderers, viewOptions));
|
|
4721
4369
|
this.view.domNode.setAttribute('role', role);
|
|
4722
4370
|
if (_options.styleController) {
|
|
4723
4371
|
this.styleController = _options.styleController(this.view.domId);
|
|
4724
4372
|
}
|
|
4725
4373
|
else {
|
|
4726
4374
|
const styleElement = createStyleSheet(this.view.domNode);
|
|
4727
|
-
this.styleController = (
|
|
4375
|
+
this.styleController = ( new DefaultStyleController(styleElement, this.view.domId));
|
|
4728
4376
|
}
|
|
4729
|
-
this.spliceable = (
|
|
4730
|
-
(
|
|
4731
|
-
(
|
|
4732
|
-
(
|
|
4377
|
+
this.spliceable = ( new CombinedSpliceable([
|
|
4378
|
+
( new TraitSpliceable(this.focus, this.view, _options.identityProvider)),
|
|
4379
|
+
( new TraitSpliceable(this.selection, this.view, _options.identityProvider)),
|
|
4380
|
+
( new TraitSpliceable(this.anchor, this.view, _options.identityProvider)),
|
|
4733
4381
|
this.view
|
|
4734
4382
|
]));
|
|
4735
4383
|
this.disposables.add(this.focus);
|
|
@@ -4737,14 +4385,14 @@ class List {
|
|
|
4737
4385
|
this.disposables.add(this.anchor);
|
|
4738
4386
|
this.disposables.add(this.view);
|
|
4739
4387
|
this.disposables.add(this._onDidDispose);
|
|
4740
|
-
this.disposables.add((
|
|
4388
|
+
this.disposables.add(( new DOMFocusController(this, this.view)));
|
|
4741
4389
|
if (typeof _options.keyboardSupport !== 'boolean' || _options.keyboardSupport) {
|
|
4742
|
-
this.keyboardController = (
|
|
4390
|
+
this.keyboardController = ( new KeyboardController(this, this.view, _options));
|
|
4743
4391
|
this.disposables.add(this.keyboardController);
|
|
4744
4392
|
}
|
|
4745
4393
|
if (_options.keyboardNavigationLabelProvider) {
|
|
4746
4394
|
const delegate = _options.keyboardNavigationDelegate || DefaultKeyboardNavigationDelegate;
|
|
4747
|
-
this.typeNavigationController = (
|
|
4395
|
+
this.typeNavigationController = ( new TypeNavigationController(
|
|
4748
4396
|
this,
|
|
4749
4397
|
this.view,
|
|
4750
4398
|
_options.keyboardNavigationLabelProvider,
|
|
@@ -4783,25 +4431,18 @@ class List {
|
|
|
4783
4431
|
get onMouseOut() { return this.view.onMouseOut; }
|
|
4784
4432
|
get onTouchStart() { return this.view.onTouchStart; }
|
|
4785
4433
|
get onTap() { return this.view.onTap; }
|
|
4786
|
-
/**
|
|
4787
|
-
* Possible context menu trigger events:
|
|
4788
|
-
* - ContextMenu key
|
|
4789
|
-
* - Shift F10
|
|
4790
|
-
* - Ctrl Option Shift M (macOS with VoiceOver)
|
|
4791
|
-
* - Mouse right click
|
|
4792
|
-
*/
|
|
4793
4434
|
get onContextMenu() {
|
|
4794
4435
|
let didJustPressContextMenuKey = false;
|
|
4795
|
-
const fromKeyDown = this.disposables.add(Event.chain(this.disposables.add((
|
|
4796
|
-
.map(e => (
|
|
4797
|
-
.filter(e => didJustPressContextMenuKey = e.keyCode === 58
|
|
4436
|
+
const fromKeyDown = this.disposables.add(Event.chain(this.disposables.add(( new DomEmitter(this.view.domNode, 'keydown'))).event))
|
|
4437
|
+
.map(e => ( new StandardKeyboardEvent(e)))
|
|
4438
|
+
.filter(e => didJustPressContextMenuKey = e.keyCode === 58 || ((e.shiftKey && e.keyCode === 68) ))
|
|
4798
4439
|
.map(stopEvent)
|
|
4799
4440
|
.filter(() => false)
|
|
4800
4441
|
.event;
|
|
4801
|
-
const fromKeyUp = this.disposables.add(Event.chain(this.disposables.add((
|
|
4442
|
+
const fromKeyUp = this.disposables.add(Event.chain(this.disposables.add(( new DomEmitter(this.view.domNode, 'keyup'))).event))
|
|
4802
4443
|
.forEach(() => didJustPressContextMenuKey = false)
|
|
4803
|
-
.map(e => (
|
|
4804
|
-
.filter(e => e.keyCode === 58
|
|
4444
|
+
.map(e => ( new StandardKeyboardEvent(e)))
|
|
4445
|
+
.filter(e => e.keyCode === 58 || ((e.shiftKey && e.keyCode === 68) ))
|
|
4805
4446
|
.map(stopEvent)
|
|
4806
4447
|
.map(({ browserEvent }) => {
|
|
4807
4448
|
const focus = this.getFocus();
|
|
@@ -4817,13 +4458,13 @@ class List {
|
|
|
4817
4458
|
.event;
|
|
4818
4459
|
return Event.any(fromKeyDown, fromKeyUp, fromMouse);
|
|
4819
4460
|
}
|
|
4820
|
-
get onKeyDown() { return this.disposables.add((
|
|
4821
|
-
get onKeyUp() { return this.disposables.add((
|
|
4822
|
-
get onKeyPress() { return this.disposables.add((
|
|
4823
|
-
get onDidFocus() { return Event.signal(this.disposables.add((
|
|
4824
|
-
get onDidBlur() { return Event.signal(this.disposables.add((
|
|
4461
|
+
get onKeyDown() { return this.disposables.add(( new DomEmitter(this.view.domNode, 'keydown'))).event; }
|
|
4462
|
+
get onKeyUp() { return this.disposables.add(( new DomEmitter(this.view.domNode, 'keyup'))).event; }
|
|
4463
|
+
get onKeyPress() { return this.disposables.add(( new DomEmitter(this.view.domNode, 'keypress'))).event; }
|
|
4464
|
+
get onDidFocus() { return Event.signal(this.disposables.add(( new DomEmitter(this.view.domNode, 'focus', true))).event); }
|
|
4465
|
+
get onDidBlur() { return Event.signal(this.disposables.add(( new DomEmitter(this.view.domNode, 'blur', true))).event); }
|
|
4825
4466
|
createMouseController(options) {
|
|
4826
|
-
return (
|
|
4467
|
+
return ( new MouseController(this));
|
|
4827
4468
|
}
|
|
4828
4469
|
updateOptions(optionsUpdate = {}) {
|
|
4829
4470
|
this._options = { ...this._options, ...optionsUpdate };
|
|
@@ -4997,13 +4638,11 @@ class List {
|
|
|
4997
4638
|
const previousScrollTop = this.view.getScrollTop();
|
|
4998
4639
|
let nextpageScrollTop = previousScrollTop + this.view.renderHeight;
|
|
4999
4640
|
if (lastPageIndex > currentlyFocusedElementIndex) {
|
|
5000
|
-
// scroll last page element to the top only if the last page element is below the focused element
|
|
5001
4641
|
nextpageScrollTop -= this.view.elementHeight(lastPageIndex);
|
|
5002
4642
|
}
|
|
5003
4643
|
this.view.setScrollTop(nextpageScrollTop);
|
|
5004
4644
|
if (this.view.getScrollTop() !== previousScrollTop) {
|
|
5005
4645
|
this.setFocus([]);
|
|
5006
|
-
// Let the scroll event listener run
|
|
5007
4646
|
await timeout(0);
|
|
5008
4647
|
await this.focusNextPage(browserEvent, filter);
|
|
5009
4648
|
}
|
|
@@ -5033,7 +4672,6 @@ class List {
|
|
|
5033
4672
|
this.view.setScrollTop(scrollTop - this.view.renderHeight);
|
|
5034
4673
|
if (this.view.getScrollTop() !== previousScrollTop) {
|
|
5035
4674
|
this.setFocus([]);
|
|
5036
|
-
// Let the scroll event listener run
|
|
5037
4675
|
await timeout(0);
|
|
5038
4676
|
await this.focusPreviousPage(browserEvent, filter);
|
|
5039
4677
|
}
|
|
@@ -5100,7 +4738,6 @@ class List {
|
|
|
5100
4738
|
const elementTop = this.view.elementTop(index);
|
|
5101
4739
|
const elementHeight = this.view.elementHeight(index);
|
|
5102
4740
|
if (isNumber(relativeTop)) {
|
|
5103
|
-
// y = mx + b
|
|
5104
4741
|
const m = elementHeight - this.view.renderHeight;
|
|
5105
4742
|
this.view.setScrollTop(m * clamp(relativeTop, 0, 1) + elementTop);
|
|
5106
4743
|
}
|
|
@@ -5116,10 +4753,6 @@ class List {
|
|
|
5116
4753
|
}
|
|
5117
4754
|
}
|
|
5118
4755
|
}
|
|
5119
|
-
/**
|
|
5120
|
-
* Returns the relative position of an element rendered in the list.
|
|
5121
|
-
* Returns `null` if the element isn't *entirely* in the visible viewport.
|
|
5122
|
-
*/
|
|
5123
4756
|
getRelativeTop(index) {
|
|
5124
4757
|
if (index < 0 || index >= this.length) {
|
|
5125
4758
|
throw new ListError(this.user, `Invalid index ${index}`);
|
|
@@ -5130,7 +4763,6 @@ class List {
|
|
|
5130
4763
|
if (elementTop < scrollTop || elementTop + elementHeight > scrollTop + this.view.renderHeight) {
|
|
5131
4764
|
return null;
|
|
5132
4765
|
}
|
|
5133
|
-
// y = mx + b
|
|
5134
4766
|
const m = elementHeight - this.view.renderHeight;
|
|
5135
4767
|
return Math.abs((scrollTop - elementTop) / m);
|
|
5136
4768
|
}
|
|
@@ -5179,11 +4811,6 @@ class List {
|
|
|
5179
4811
|
this._onDidDispose.dispose();
|
|
5180
4812
|
}
|
|
5181
4813
|
}
|
|
5182
|
-
|
|
5183
|
-
/*---------------------------------------------------------------------------------------------
|
|
5184
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5185
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5186
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5187
4814
|
function roundFloat(number, decimalPoints) {
|
|
5188
4815
|
const decimal = Math.pow(10, decimalPoints);
|
|
5189
4816
|
return Math.round(number * decimal) / decimal;
|
|
@@ -5211,12 +4838,6 @@ class HSLA {
|
|
|
5211
4838
|
static equals(a, b) {
|
|
5212
4839
|
return a.h === b.h && a.s === b.s && a.l === b.l && a.a === b.a;
|
|
5213
4840
|
}
|
|
5214
|
-
/**
|
|
5215
|
-
* Converts an RGB color value to HSL. Conversion formula
|
|
5216
|
-
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
|
5217
|
-
* Assumes r, g, and b are contained in the set [0, 255] and
|
|
5218
|
-
* returns h in the set [0, 360], s, and l in the set [0, 1].
|
|
5219
|
-
*/
|
|
5220
4841
|
static fromRGBA(rgba) {
|
|
5221
4842
|
const r = rgba.r / 255;
|
|
5222
4843
|
const g = rgba.g / 255;
|
|
@@ -5244,7 +4865,7 @@ class HSLA {
|
|
|
5244
4865
|
h *= 60;
|
|
5245
4866
|
h = Math.round(h);
|
|
5246
4867
|
}
|
|
5247
|
-
return (
|
|
4868
|
+
return ( new HSLA(h, s, l, a));
|
|
5248
4869
|
}
|
|
5249
4870
|
static _hue2rgb(p, q, t) {
|
|
5250
4871
|
if (t < 0) {
|
|
@@ -5264,18 +4885,12 @@ class HSLA {
|
|
|
5264
4885
|
}
|
|
5265
4886
|
return p;
|
|
5266
4887
|
}
|
|
5267
|
-
/**
|
|
5268
|
-
* Converts an HSL color value to RGB. Conversion formula
|
|
5269
|
-
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
|
5270
|
-
* Assumes h in the set [0, 360] s, and l are contained in the set [0, 1] and
|
|
5271
|
-
* returns r, g, and b in the set [0, 255].
|
|
5272
|
-
*/
|
|
5273
4888
|
static toRGBA(hsla) {
|
|
5274
4889
|
const h = hsla.h / 360;
|
|
5275
4890
|
const { s, l, a } = hsla;
|
|
5276
4891
|
let r, g, b;
|
|
5277
4892
|
if (s === 0) {
|
|
5278
|
-
r = g = b = l;
|
|
4893
|
+
r = g = b = l;
|
|
5279
4894
|
}
|
|
5280
4895
|
else {
|
|
5281
4896
|
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
@@ -5284,7 +4899,7 @@ class HSLA {
|
|
|
5284
4899
|
g = HSLA._hue2rgb(p, q, h);
|
|
5285
4900
|
b = HSLA._hue2rgb(p, q, h - 1 / 3);
|
|
5286
4901
|
}
|
|
5287
|
-
return (
|
|
4902
|
+
return ( new RGBA(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255), a));
|
|
5288
4903
|
}
|
|
5289
4904
|
}
|
|
5290
4905
|
class HSVA {
|
|
@@ -5298,7 +4913,6 @@ class HSVA {
|
|
|
5298
4913
|
static equals(a, b) {
|
|
5299
4914
|
return a.h === b.h && a.s === b.s && a.v === b.v && a.a === b.a;
|
|
5300
4915
|
}
|
|
5301
|
-
// from http://www.rapidtables.com/convert/color/rgb-to-hsv.htm
|
|
5302
4916
|
static fromRGBA(rgba) {
|
|
5303
4917
|
const r = rgba.r / 255;
|
|
5304
4918
|
const g = rgba.g / 255;
|
|
@@ -5320,9 +4934,8 @@ class HSVA {
|
|
|
5320
4934
|
else {
|
|
5321
4935
|
m = ((r - g) / delta) + 4;
|
|
5322
4936
|
}
|
|
5323
|
-
return (
|
|
4937
|
+
return ( new HSVA(Math.round(m * 60), s, cmax, rgba.a));
|
|
5324
4938
|
}
|
|
5325
|
-
// from http://www.rapidtables.com/convert/color/hsv-to-rgb.htm
|
|
5326
4939
|
static toRGBA(hsva) {
|
|
5327
4940
|
const { h, s, v, a } = hsva;
|
|
5328
4941
|
const c = v * s;
|
|
@@ -5356,7 +4969,7 @@ class HSVA {
|
|
|
5356
4969
|
r = Math.round((r + m) * 255);
|
|
5357
4970
|
g = Math.round((g + m) * 255);
|
|
5358
4971
|
b = Math.round((b + m) * 255);
|
|
5359
|
-
return (
|
|
4972
|
+
return ( new RGBA(r, g, b, a));
|
|
5360
4973
|
}
|
|
5361
4974
|
}
|
|
5362
4975
|
class Color {
|
|
@@ -5399,10 +5012,6 @@ class Color {
|
|
|
5399
5012
|
equals(other) {
|
|
5400
5013
|
return !!other && RGBA.equals(this.rgba, other.rgba) && HSLA.equals(this.hsla, other.hsla) && HSVA.equals(this.hsva, other.hsva);
|
|
5401
5014
|
}
|
|
5402
|
-
/**
|
|
5403
|
-
* http://www.w3.org/TR/WCAG20/#relativeluminancedef
|
|
5404
|
-
* Returns the number in the set [0, 1]. O => Darkest Black. 1 => Lightest white.
|
|
5405
|
-
*/
|
|
5406
5015
|
getRelativeLuminance() {
|
|
5407
5016
|
const R = Color._relativeLuminanceForComponent(this.rgba.r);
|
|
5408
5017
|
const G = Color._relativeLuminanceForComponent(this.rgba.g);
|
|
@@ -5414,27 +5023,15 @@ class Color {
|
|
|
5414
5023
|
const c = color / 255;
|
|
5415
5024
|
return (c <= 0.03928) ? c / 12.92 : Math.pow(((c + 0.055) / 1.055), 2.4);
|
|
5416
5025
|
}
|
|
5417
|
-
/**
|
|
5418
|
-
* http://www.w3.org/TR/WCAG20/#contrast-ratiodef
|
|
5419
|
-
* Returns the contrast ration number in the set [1, 21].
|
|
5420
|
-
*/
|
|
5421
5026
|
getContrastRatio(another) {
|
|
5422
5027
|
const lum1 = this.getRelativeLuminance();
|
|
5423
5028
|
const lum2 = another.getRelativeLuminance();
|
|
5424
5029
|
return lum1 > lum2 ? (lum1 + 0.05) / (lum2 + 0.05) : (lum2 + 0.05) / (lum1 + 0.05);
|
|
5425
5030
|
}
|
|
5426
|
-
/**
|
|
5427
|
-
* http://24ways.org/2010/calculating-color-contrast
|
|
5428
|
-
* Return 'true' if darker color otherwise 'false'
|
|
5429
|
-
*/
|
|
5430
5031
|
isDarker() {
|
|
5431
5032
|
const yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1000;
|
|
5432
5033
|
return yiq < 128;
|
|
5433
5034
|
}
|
|
5434
|
-
/**
|
|
5435
|
-
* http://24ways.org/2010/calculating-color-contrast
|
|
5436
|
-
* Return 'true' if lighter color otherwise 'false'
|
|
5437
|
-
*/
|
|
5438
5035
|
isLighter() {
|
|
5439
5036
|
const yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1000;
|
|
5440
5037
|
return yiq >= 128;
|
|
@@ -5450,14 +5047,14 @@ class Color {
|
|
|
5450
5047
|
return lum1 < lum2;
|
|
5451
5048
|
}
|
|
5452
5049
|
lighten(factor) {
|
|
5453
|
-
return (
|
|
5050
|
+
return ( new Color(( new HSLA(this.hsla.h, this.hsla.s, this.hsla.l + this.hsla.l * factor, this.hsla.a))));
|
|
5454
5051
|
}
|
|
5455
5052
|
darken(factor) {
|
|
5456
|
-
return (
|
|
5053
|
+
return ( new Color(( new HSLA(this.hsla.h, this.hsla.s, this.hsla.l - this.hsla.l * factor, this.hsla.a))));
|
|
5457
5054
|
}
|
|
5458
5055
|
transparent(factor) {
|
|
5459
5056
|
const { r, g, b, a } = this.rgba;
|
|
5460
|
-
return (
|
|
5057
|
+
return ( new Color(( new RGBA(r, g, b, a * factor))));
|
|
5461
5058
|
}
|
|
5462
5059
|
isTransparent() {
|
|
5463
5060
|
return this.rgba.a === 0;
|
|
@@ -5466,11 +5063,10 @@ class Color {
|
|
|
5466
5063
|
return this.rgba.a === 1;
|
|
5467
5064
|
}
|
|
5468
5065
|
opposite() {
|
|
5469
|
-
return (
|
|
5066
|
+
return ( new Color(( new RGBA(255 - this.rgba.r, 255 - this.rgba.g, 255 - this.rgba.b, this.rgba.a))));
|
|
5470
5067
|
}
|
|
5471
5068
|
blend(c) {
|
|
5472
5069
|
const rgba = c.rgba;
|
|
5473
|
-
// Convert to 0..1 opacity
|
|
5474
5070
|
const thisA = this.rgba.a;
|
|
5475
5071
|
const colorA = rgba.a;
|
|
5476
5072
|
const a = thisA + colorA * (1 - thisA);
|
|
@@ -5480,16 +5076,14 @@ class Color {
|
|
|
5480
5076
|
const r = this.rgba.r * thisA / a + rgba.r * colorA * (1 - thisA) / a;
|
|
5481
5077
|
const g = this.rgba.g * thisA / a + rgba.g * colorA * (1 - thisA) / a;
|
|
5482
5078
|
const b = this.rgba.b * thisA / a + rgba.b * colorA * (1 - thisA) / a;
|
|
5483
|
-
return (
|
|
5079
|
+
return ( new Color(( new RGBA(r, g, b, a))));
|
|
5484
5080
|
}
|
|
5485
5081
|
makeOpaque(opaqueBackground) {
|
|
5486
5082
|
if (this.isOpaque() || opaqueBackground.rgba.a !== 1) {
|
|
5487
|
-
// only allow to blend onto a non-opaque color onto a opaque color
|
|
5488
5083
|
return this;
|
|
5489
5084
|
}
|
|
5490
5085
|
const { r, g, b, a } = this.rgba;
|
|
5491
|
-
|
|
5492
|
-
return (/*#__PURE__*/ new Color((/*#__PURE__*/ new RGBA(
|
|
5086
|
+
return ( new Color(( new RGBA(
|
|
5493
5087
|
opaqueBackground.rgba.r - a * (opaqueBackground.rgba.r - r),
|
|
5494
5088
|
opaqueBackground.rgba.g - a * (opaqueBackground.rgba.g - g),
|
|
5495
5089
|
opaqueBackground.rgba.b - a * (opaqueBackground.rgba.b - b),
|
|
@@ -5504,7 +5098,7 @@ class Color {
|
|
|
5504
5098
|
}
|
|
5505
5099
|
static _flatten(foreground, background) {
|
|
5506
5100
|
const backgroundAlpha = 1 - foreground.rgba.a;
|
|
5507
|
-
return (
|
|
5101
|
+
return ( new Color(( new RGBA(
|
|
5508
5102
|
backgroundAlpha * background.rgba.r + foreground.rgba.a * foreground.rgba.r,
|
|
5509
5103
|
backgroundAlpha * background.rgba.g + foreground.rgba.a * foreground.rgba.g,
|
|
5510
5104
|
backgroundAlpha * background.rgba.b + foreground.rgba.a * foreground.rgba.b
|
|
@@ -5524,7 +5118,7 @@ class Color {
|
|
|
5524
5118
|
const lum1 = of.getRelativeLuminance();
|
|
5525
5119
|
const lum2 = relative.getRelativeLuminance();
|
|
5526
5120
|
factor = factor * (lum2 - lum1) / lum2;
|
|
5527
|
-
return (
|
|
5121
|
+
return ( of.lighten(factor));
|
|
5528
5122
|
}
|
|
5529
5123
|
static getDarkerColor(of, relative, factor) {
|
|
5530
5124
|
if (of.isDarkerThan(relative)) {
|
|
@@ -5534,20 +5128,20 @@ class Color {
|
|
|
5534
5128
|
const lum1 = of.getRelativeLuminance();
|
|
5535
5129
|
const lum2 = relative.getRelativeLuminance();
|
|
5536
5130
|
factor = factor * (lum1 - lum2) / lum1;
|
|
5537
|
-
return (
|
|
5131
|
+
return ( of.darken(factor));
|
|
5538
5132
|
}
|
|
5539
5133
|
}
|
|
5540
|
-
Color.white = (
|
|
5541
|
-
Color.black = (
|
|
5542
|
-
Color.red = (
|
|
5543
|
-
Color.blue = (
|
|
5544
|
-
Color.green = (
|
|
5545
|
-
Color.cyan = (
|
|
5546
|
-
Color.lightgrey = (
|
|
5547
|
-
Color.transparent = (
|
|
5548
|
-
(
|
|
5549
|
-
(
|
|
5550
|
-
(
|
|
5134
|
+
Color.white = ( new Color(( new RGBA(255, 255, 255, 1))));
|
|
5135
|
+
Color.black = ( new Color(( new RGBA(0, 0, 0, 1))));
|
|
5136
|
+
Color.red = ( new Color(( new RGBA(255, 0, 0, 1))));
|
|
5137
|
+
Color.blue = ( new Color(( new RGBA(0, 0, 255, 1))));
|
|
5138
|
+
Color.green = ( new Color(( new RGBA(0, 255, 0, 1))));
|
|
5139
|
+
Color.cyan = ( new Color(( new RGBA(0, 255, 255, 1))));
|
|
5140
|
+
Color.lightgrey = ( new Color(( new RGBA(211, 211, 211, 1))));
|
|
5141
|
+
Color.transparent = ( new Color(( new RGBA(0, 0, 0, 0))));
|
|
5142
|
+
( (function(Color) {
|
|
5143
|
+
( (function(Format) {
|
|
5144
|
+
( (function(CSS) {
|
|
5551
5145
|
function formatRGB(color) {
|
|
5552
5146
|
if (color.rgba.a === 1) {
|
|
5553
5147
|
return `rgb(${color.rgba.r}, ${color.rgba.g}, ${color.rgba.b})`;
|
|
@@ -5571,20 +5165,13 @@ Color.transparent = (/*#__PURE__*/ new Color((/*#__PURE__*/ new RGBA(0, 0, 0, 0)
|
|
|
5571
5165
|
}
|
|
5572
5166
|
CSS.formatHSLA = formatHSLA;
|
|
5573
5167
|
function _toTwoDigitHex(n) {
|
|
5574
|
-
const r = (
|
|
5168
|
+
const r = ( n.toString(16));
|
|
5575
5169
|
return r.length !== 2 ? '0' + r : r;
|
|
5576
5170
|
}
|
|
5577
|
-
/**
|
|
5578
|
-
* Formats the color as #RRGGBB
|
|
5579
|
-
*/
|
|
5580
5171
|
function formatHex(color) {
|
|
5581
5172
|
return `#${_toTwoDigitHex(color.rgba.r)}${_toTwoDigitHex(color.rgba.g)}${_toTwoDigitHex(color.rgba.b)}`;
|
|
5582
5173
|
}
|
|
5583
5174
|
CSS.formatHex = formatHex;
|
|
5584
|
-
/**
|
|
5585
|
-
* Formats the color as #RRGGBBAA
|
|
5586
|
-
* If 'compact' is set, colors without transparancy will be printed as #RRGGBB
|
|
5587
|
-
*/
|
|
5588
5175
|
function formatHexA(color, compact = false) {
|
|
5589
5176
|
if (compact && color.rgba.a === 1) {
|
|
5590
5177
|
return Color.Format.CSS.formatHex(color);
|
|
@@ -5592,9 +5179,6 @@ Color.transparent = (/*#__PURE__*/ new Color((/*#__PURE__*/ new RGBA(0, 0, 0, 0)
|
|
|
5592
5179
|
return `#${_toTwoDigitHex(color.rgba.r)}${_toTwoDigitHex(color.rgba.g)}${_toTwoDigitHex(color.rgba.b)}${_toTwoDigitHex(Math.round(color.rgba.a * 255))}`;
|
|
5593
5180
|
}
|
|
5594
5181
|
CSS.formatHexA = formatHexA;
|
|
5595
|
-
/**
|
|
5596
|
-
* The default format will use HEX if opaque and RGBA otherwise.
|
|
5597
|
-
*/
|
|
5598
5182
|
function format(color) {
|
|
5599
5183
|
if (color.isOpaque()) {
|
|
5600
5184
|
return Color.Format.CSS.formatHex(color);
|
|
@@ -5602,90 +5186,74 @@ Color.transparent = (/*#__PURE__*/ new Color((/*#__PURE__*/ new RGBA(0, 0, 0, 0)
|
|
|
5602
5186
|
return Color.Format.CSS.formatRGBA(color);
|
|
5603
5187
|
}
|
|
5604
5188
|
CSS.format = format;
|
|
5605
|
-
/**
|
|
5606
|
-
* Converts an Hex color value to a Color.
|
|
5607
|
-
* returns r, g, and b are contained in the set [0, 255]
|
|
5608
|
-
* @param hex string (#RGB, #RGBA, #RRGGBB or #RRGGBBAA).
|
|
5609
|
-
*/
|
|
5610
5189
|
function parseHex(hex) {
|
|
5611
5190
|
const length = hex.length;
|
|
5612
5191
|
if (length === 0) {
|
|
5613
|
-
// Invalid color
|
|
5614
5192
|
return null;
|
|
5615
5193
|
}
|
|
5616
|
-
if (hex.charCodeAt(0) !== 35
|
|
5617
|
-
// Does not begin with a #
|
|
5194
|
+
if (hex.charCodeAt(0) !== 35 ) {
|
|
5618
5195
|
return null;
|
|
5619
5196
|
}
|
|
5620
5197
|
if (length === 7) {
|
|
5621
|
-
// #RRGGBB format
|
|
5622
5198
|
const r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
|
|
5623
5199
|
const g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
|
|
5624
5200
|
const b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
|
|
5625
|
-
return (
|
|
5201
|
+
return ( new Color(( new RGBA(r, g, b, 1))));
|
|
5626
5202
|
}
|
|
5627
5203
|
if (length === 9) {
|
|
5628
|
-
// #RRGGBBAA format
|
|
5629
5204
|
const r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
|
|
5630
5205
|
const g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
|
|
5631
5206
|
const b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
|
|
5632
5207
|
const a = 16 * _parseHexDigit(hex.charCodeAt(7)) + _parseHexDigit(hex.charCodeAt(8));
|
|
5633
|
-
return (
|
|
5208
|
+
return ( new Color(( new RGBA(r, g, b, a / 255))));
|
|
5634
5209
|
}
|
|
5635
5210
|
if (length === 4) {
|
|
5636
|
-
// #RGB format
|
|
5637
5211
|
const r = _parseHexDigit(hex.charCodeAt(1));
|
|
5638
5212
|
const g = _parseHexDigit(hex.charCodeAt(2));
|
|
5639
5213
|
const b = _parseHexDigit(hex.charCodeAt(3));
|
|
5640
|
-
return (
|
|
5214
|
+
return ( new Color(( new RGBA(16 * r + r, 16 * g + g, 16 * b + b))));
|
|
5641
5215
|
}
|
|
5642
5216
|
if (length === 5) {
|
|
5643
|
-
// #RGBA format
|
|
5644
5217
|
const r = _parseHexDigit(hex.charCodeAt(1));
|
|
5645
5218
|
const g = _parseHexDigit(hex.charCodeAt(2));
|
|
5646
5219
|
const b = _parseHexDigit(hex.charCodeAt(3));
|
|
5647
5220
|
const a = _parseHexDigit(hex.charCodeAt(4));
|
|
5648
|
-
return (
|
|
5221
|
+
return ( new Color(( new RGBA(16 * r + r, 16 * g + g, 16 * b + b, (16 * a + a) / 255))));
|
|
5649
5222
|
}
|
|
5650
|
-
// Invalid color
|
|
5651
5223
|
return null;
|
|
5652
5224
|
}
|
|
5653
5225
|
CSS.parseHex = parseHex;
|
|
5654
5226
|
function _parseHexDigit(charCode) {
|
|
5655
5227
|
switch (charCode) {
|
|
5656
|
-
case 48
|
|
5657
|
-
case 49
|
|
5658
|
-
case 50
|
|
5659
|
-
case 51
|
|
5660
|
-
case 52
|
|
5661
|
-
case 53
|
|
5662
|
-
case 54
|
|
5663
|
-
case 55
|
|
5664
|
-
case 56
|
|
5665
|
-
case 57
|
|
5666
|
-
case 97
|
|
5667
|
-
case 65
|
|
5668
|
-
case 98
|
|
5669
|
-
case 66
|
|
5670
|
-
case 99
|
|
5671
|
-
case 67
|
|
5672
|
-
case 100
|
|
5673
|
-
case 68
|
|
5674
|
-
case 101
|
|
5675
|
-
case 69
|
|
5676
|
-
case 102
|
|
5677
|
-
case 70
|
|
5228
|
+
case 48 : return 0;
|
|
5229
|
+
case 49 : return 1;
|
|
5230
|
+
case 50 : return 2;
|
|
5231
|
+
case 51 : return 3;
|
|
5232
|
+
case 52 : return 4;
|
|
5233
|
+
case 53 : return 5;
|
|
5234
|
+
case 54 : return 6;
|
|
5235
|
+
case 55 : return 7;
|
|
5236
|
+
case 56 : return 8;
|
|
5237
|
+
case 57 : return 9;
|
|
5238
|
+
case 97 : return 10;
|
|
5239
|
+
case 65 : return 10;
|
|
5240
|
+
case 98 : return 11;
|
|
5241
|
+
case 66 : return 11;
|
|
5242
|
+
case 99 : return 12;
|
|
5243
|
+
case 67 : return 12;
|
|
5244
|
+
case 100 : return 13;
|
|
5245
|
+
case 68 : return 13;
|
|
5246
|
+
case 101 : return 14;
|
|
5247
|
+
case 69 : return 14;
|
|
5248
|
+
case 102 : return 15;
|
|
5249
|
+
case 70 : return 15;
|
|
5678
5250
|
}
|
|
5679
5251
|
return 0;
|
|
5680
5252
|
}
|
|
5681
5253
|
})(Format.CSS || (Format.CSS = {})));
|
|
5682
5254
|
})(Color.Format || (Color.Format = {})));
|
|
5683
5255
|
})(Color || (Color = {})));
|
|
5684
|
-
|
|
5685
5256
|
var _a, _b;
|
|
5686
|
-
// Monaco build process treeshaking is very aggressive and everything that is not used in monaco is removed
|
|
5687
|
-
// Unfortunately, it makes some class not respect anymore the interface they are supposed to implement
|
|
5688
|
-
// In this file we are restoring some method that are treeshaked out of monaco-editor but that are needed in this library
|
|
5689
5257
|
if (SnippetParser.prototype.text == null) {
|
|
5690
5258
|
SnippetParser.prototype.text = function (value) {
|
|
5691
5259
|
return this.parse(value).toString();
|
|
@@ -5694,23 +5262,13 @@ if (SnippetParser.prototype.text == null) {
|
|
|
5694
5262
|
else {
|
|
5695
5263
|
console.warn('Useless polyfill: SnippetParser');
|
|
5696
5264
|
}
|
|
5697
|
-
/**
|
|
5698
|
-
* Assign all properties of b to A
|
|
5699
|
-
*/
|
|
5700
5265
|
function polyfillPrototypeSimple(a, b) {
|
|
5701
5266
|
Object.defineProperties(a, Object.getOwnPropertyDescriptors(b));
|
|
5702
5267
|
}
|
|
5703
|
-
/**
|
|
5704
|
-
* Sometime, the simple prototype is not enough
|
|
5705
|
-
* It can happens if the function are returning or taking as parameter instances of the said class
|
|
5706
|
-
* In that case, we need to transform parameters to VSCode instances and result back to a monaco instance
|
|
5707
|
-
*/
|
|
5708
5268
|
function polyfillPrototype(a, b, toA, toB) {
|
|
5709
5269
|
for (const key of Object.getOwnPropertyNames(b)) {
|
|
5710
5270
|
if (!Object.hasOwnProperty.call(a, key)) {
|
|
5711
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5712
5271
|
a[key] = function (...args) {
|
|
5713
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5714
5272
|
return toA(b[key].call(this, ...args.map(toB)));
|
|
5715
5273
|
};
|
|
5716
5274
|
}
|
|
@@ -5730,49 +5288,31 @@ polyfillPrototypeSimple(Themable$1.prototype, Themable.prototype);
|
|
|
5730
5288
|
polyfillPrototypeSimple(ProgressBar$1.prototype, ProgressBar.prototype);
|
|
5731
5289
|
const jsonContributionRegistry = Registry.as(Extensions.JSONContribution);
|
|
5732
5290
|
jsonContributionRegistry.getSchemaContributions ?? (jsonContributionRegistry.getSchemaContributions = () => ({
|
|
5733
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5734
5291
|
schemas: jsonContributionRegistry.schemasById
|
|
5735
5292
|
}));
|
|
5736
|
-
// @ts-ignore Override of a readonly property
|
|
5737
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5738
5293
|
jsonContributionRegistry.onDidChangeSchema ?? (jsonContributionRegistry.onDidChangeSchema = jsonContributionRegistry._onDidChangeSchema.event);
|
|
5739
5294
|
const themeRegistry = Registry.as(Extensions$1.ThemingContribution);
|
|
5740
|
-
// @ts-ignore Override of a readonly property
|
|
5741
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5742
5295
|
themeRegistry.onThemingParticipantAdded ?? (themeRegistry.onThemingParticipantAdded = themeRegistry.onThemingParticipantAddedEmitter.event);
|
|
5743
5296
|
const configurationRegistry = Registry.as(Extensions$2.Configuration);
|
|
5744
|
-
// @ts-ignore Override of a readonly property
|
|
5745
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5746
5297
|
configurationRegistry.onDidUpdateConfiguration ?? (configurationRegistry.onDidUpdateConfiguration = configurationRegistry._onDidUpdateConfiguration.event);
|
|
5747
|
-
// @ts-ignore Override of a readonly property
|
|
5748
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5749
5298
|
configurationRegistry.onDidSchemaChange ?? (configurationRegistry.onDidSchemaChange = configurationRegistry._onDidSchemaChange.event);
|
|
5750
5299
|
configurationRegistry.notifyConfigurationSchemaUpdated ?? (configurationRegistry.notifyConfigurationSchemaUpdated = () => {
|
|
5751
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5752
5300
|
configurationRegistry._onDidSchemaChange.fire();
|
|
5753
5301
|
});
|
|
5754
|
-
// @ts-ignore Override of a readonly property
|
|
5755
5302
|
(_a = NoOpNotification$1.prototype).onDidClose ?? (_a.onDidClose = Event.None);
|
|
5756
5303
|
function polyfillQuickInput(fn) {
|
|
5757
5304
|
return function () {
|
|
5758
5305
|
const quickInput = fn.call(this);
|
|
5759
|
-
// @ts-ignore Override of a readonly property
|
|
5760
5306
|
quickInput.onDidTriggerButton ?? (quickInput.onDidTriggerButton = quickInput.onDidTriggerButtonEmitter.event);
|
|
5761
5307
|
return quickInput;
|
|
5762
5308
|
};
|
|
5763
5309
|
}
|
|
5764
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5765
5310
|
QuickInputController.prototype.createQuickPick = polyfillQuickInput(QuickInputController.prototype.createQuickPick);
|
|
5766
5311
|
QuickInputController.prototype.createInputBox = polyfillQuickInput(QuickInputController.prototype.createInputBox);
|
|
5767
5312
|
const StandaloneUriLabelService = getSingletonServiceDescriptors().find(([id]) => id === ILabelService)[1].ctor;
|
|
5768
5313
|
(_b = StandaloneUriLabelService.prototype).onDidChangeFormatters ?? (_b.onDidChangeFormatters = Event.None);
|
|
5769
|
-
// A lot of methods from VSBuffer are treeshaked out of monaco editor, we need to restore them here
|
|
5770
|
-
// Also we cannot just use the VSCode impl because:
|
|
5771
|
-
// - The vscode code receives instances created inside monaco code
|
|
5772
|
-
// - VSCode does `instanceof` on instances that need to work
|
|
5773
5314
|
function toVSCodeVSBuffer(value) {
|
|
5774
5315
|
if (value instanceof VSBuffer$1) {
|
|
5775
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5776
5316
|
return VSBuffer.wrap(value.buffer);
|
|
5777
5317
|
}
|
|
5778
5318
|
return value;
|
|
@@ -5785,18 +5325,13 @@ function toMonacoVSBuffer(value) {
|
|
|
5785
5325
|
}
|
|
5786
5326
|
for (const key of Object.getOwnPropertyNames(VSBuffer)) {
|
|
5787
5327
|
if (!Object.hasOwnProperty.call(VSBuffer$1, key)) {
|
|
5788
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5789
5328
|
const method = VSBuffer[key];
|
|
5790
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5791
5329
|
VSBuffer[key] = VSBuffer$1[key] = function (...args) {
|
|
5792
5330
|
return toMonacoVSBuffer(method.call(VSBuffer$1, ...args.map(toVSCodeVSBuffer)));
|
|
5793
5331
|
};
|
|
5794
5332
|
}
|
|
5795
5333
|
}
|
|
5796
5334
|
polyfillPrototype(VSBuffer$1.prototype, VSBuffer.prototype, toMonacoVSBuffer, toVSCodeVSBuffer);
|
|
5797
|
-
// Some methods of the Color class need to be restored, but they sometime return an instance of the Color class
|
|
5798
|
-
// We need the returned instance to be an instance of the monaco Color class (and not the VSCode one) because there is some `instanceof` in the monaco code
|
|
5799
|
-
// So we transform the returned VSCode Color instance to monaco Color instance in polyfilled methods
|
|
5800
5335
|
function toMonacoColor(value) {
|
|
5801
5336
|
if (value instanceof Color) {
|
|
5802
5337
|
return new Color$1(value.rgba);
|
|
@@ -5805,11 +5340,9 @@ function toMonacoColor(value) {
|
|
|
5805
5340
|
}
|
|
5806
5341
|
function toVSCodeColor(value) {
|
|
5807
5342
|
if (value instanceof Color$1) {
|
|
5808
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5809
5343
|
return new Color(value.rgba);
|
|
5810
5344
|
}
|
|
5811
5345
|
return value;
|
|
5812
5346
|
}
|
|
5813
5347
|
polyfillPrototype(Color$1.prototype, Color.prototype, toMonacoColor, toVSCodeColor);
|
|
5814
|
-
|
|
5815
5348
|
export { ConfigurationModelParser as C, Emitter as E, NotImplementedError as N, ResourceSet as R, UserSettings as U, parseTree as a, isReadableStream as b, createScanner as c, disposed as d, peekStream as e, findNodeAtLocation as f, getErrorMessage as g, peekReadable as h, isWorkspaceIdentifier as i, bufferToReadable as j, consumeStream as k, isReadableBufferedStream as l, listenStream as m, bufferedStreamToBuffer as n, readableToBuffer as o, parse as p, newWriteableBufferStream as q, readonly as r, streamToBuffer as s, transform as t, newWriteableStream as u, visit as v, getNodeType as w };
|