@codingame/monaco-vscode-api 1.69.7 → 1.69.10
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 +2 -1
- package/dist/configuration.js +5 -4
- package/dist/dialogs.js +3 -2
- package/dist/extHost.js +17 -118
- package/dist/files.js +4 -3
- package/dist/keybindings.js +4 -3
- package/dist/languageConfiguration.js +3 -2
- package/dist/languageService.js +1 -1
- package/dist/languages.js +2 -1
- package/dist/layout.js +3 -2
- package/dist/messages.js +2 -0
- package/dist/missing-services.js +27 -5356
- package/dist/modelEditor.js +4 -3
- package/dist/monaco.js +1 -0
- package/dist/notifications.js +5 -4
- package/dist/polyfill.js +789 -1114
- package/dist/services.js +1 -1
- package/dist/services2.js +2 -1
- package/dist/snippets.js +5 -4
- package/dist/textmate.js +4 -3
- package/dist/theme.js +7 -6
- package/dist/tokenClassification.js +2 -1
- package/dist/tokenClassificationRegistry.js +1 -1
- package/dist/tools.js +2 -1
- package/dist/workspaceContext.js +1 -0
- package/package.json +1 -1
package/dist/polyfill.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VSBuffer as VSBuffer$1 } from 'monaco-editor/esm/vs/base/common/buffer.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Disposable, DisposableStore, dispose, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
3
3
|
import { onUnexpectedError, ErrorHandler as ErrorHandler$1 } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
4
4
|
import { Themable as Themable$1 } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
|
|
5
5
|
import { ProgressBar as ProgressBar$1 } from 'monaco-editor/esm/vs/base/browser/ui/progressbar/progressbar.js';
|
|
@@ -14,15 +14,15 @@ import { LanguagesRegistry as LanguagesRegistry$1 } from 'monaco-editor/esm/vs/e
|
|
|
14
14
|
import { firstOrDefault, distinct, equals as equals$1, binarySearch, range } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
15
15
|
import { PLAINTEXT_LANGUAGE_ID, ModesRegistry } from 'monaco-editor/esm/vs/editor/common/languages/modesRegistry.js';
|
|
16
16
|
import { TokenizationRegistry } from 'monaco-editor/esm/vs/editor/common/languages.js';
|
|
17
|
-
import { NoOpNotification
|
|
18
|
-
import {
|
|
17
|
+
import { NoOpNotification } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
18
|
+
import { R as RawContextKey, N as NoOpNotification$1, s as shuffle } from './contextkey.js';
|
|
19
19
|
import { StandaloneConfigurationService as StandaloneConfigurationService$1 } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
|
|
20
20
|
import { Configuration as Configuration$1, ConfigurationModel as ConfigurationModel$1, ConfigurationChangeEvent } from 'monaco-editor/esm/vs/platform/configuration/common/configurationModels.js';
|
|
21
21
|
import { DefaultConfigurationModel } from 'monaco-editor/esm/vs/platform/configuration/common/configurations.js';
|
|
22
22
|
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
23
|
-
import {
|
|
24
|
-
import { compareSubstring, compareSubstringIgnoreCase,
|
|
25
|
-
import {
|
|
23
|
+
import { TernarySearchTree as TernarySearchTree$1, ResourceMap as ResourceMap$1 } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
24
|
+
import { regExpLeadsToEndlessLoop, compareIgnoreCase, compareSubstring, compareSubstringIgnoreCase, compare as compare$1 } from 'monaco-editor/esm/vs/base/common/strings.js';
|
|
25
|
+
import { Extensions as Extensions$2, overrideIdentifiersFromKey, OVERRIDE_PROPERTY_REGEX } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
|
|
26
26
|
import { getConfigurationValue, addToValueTree, removeFromValueTree, toValuesTree } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
27
27
|
import { Event, EventBufferer } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
28
28
|
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
@@ -37,20 +37,15 @@ import { DomEmitter, stopEvent } from 'monaco-editor/esm/vs/base/browser/event.j
|
|
|
37
37
|
import { StandardKeyboardEvent } from 'monaco-editor/esm/vs/base/browser/keyboardEvent.js';
|
|
38
38
|
import { ListError } from 'monaco-editor/esm/vs/base/browser/ui/list/list.js';
|
|
39
39
|
import { clamp } from 'monaco-editor/esm/vs/base/common/numbers.js';
|
|
40
|
-
import { isMacintosh } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
40
|
+
import { isMacintosh, isWindows } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
41
41
|
import { alert } from 'monaco-editor/esm/vs/base/browser/ui/aria/aria.js';
|
|
42
42
|
import { matchesPrefix } from 'monaco-editor/esm/vs/base/common/filters.js';
|
|
43
43
|
import { Gesture } from 'monaco-editor/esm/vs/base/browser/touch.js';
|
|
44
|
+
import { LogService as LogService$1 } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
44
45
|
import { SnippetParser } from 'monaco-editor/esm/vs/editor/contrib/snippet/browser/snippetParser.js';
|
|
45
46
|
import { QuickInputController } from 'monaco-editor/esm/vs/base/parts/quickinput/browser/quickInput.js';
|
|
46
47
|
import { getSingletonServiceDescriptors } from 'monaco-editor/esm/vs/platform/instantiation/common/extensions.js';
|
|
47
48
|
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
49
|
class ErrorHandler {
|
|
55
50
|
constructor() {
|
|
56
51
|
this.listeners = [];
|
|
@@ -90,33 +85,20 @@ class ErrorHandler {
|
|
|
90
85
|
this.unexpectedErrorHandler(e);
|
|
91
86
|
this.emit(e);
|
|
92
87
|
}
|
|
93
|
-
// For external errors, we don't want the listeners to be called
|
|
94
88
|
onUnexpectedExternalError(e) {
|
|
95
89
|
this.unexpectedErrorHandler(e);
|
|
96
90
|
}
|
|
97
91
|
}
|
|
98
92
|
function readonly(name) {
|
|
99
93
|
return name
|
|
100
|
-
? (
|
|
101
|
-
: (
|
|
94
|
+
? ( (new Error(`readonly property '${name} cannot be changed'`)))
|
|
95
|
+
: ( (new Error('readonly property cannot be changed')));
|
|
102
96
|
}
|
|
103
97
|
function disposed(what) {
|
|
104
|
-
const result = (
|
|
98
|
+
const result = ( (new Error(`${what} has been disposed`)));
|
|
105
99
|
result.name = 'DISPOSED';
|
|
106
100
|
return result;
|
|
107
101
|
}
|
|
108
|
-
function getErrorMessage(err) {
|
|
109
|
-
if (!err) {
|
|
110
|
-
return 'Error';
|
|
111
|
-
}
|
|
112
|
-
if (err.message) {
|
|
113
|
-
return err.message;
|
|
114
|
-
}
|
|
115
|
-
if (err.stack) {
|
|
116
|
-
return err.stack.split('\n')[0];
|
|
117
|
-
}
|
|
118
|
-
return String(err);
|
|
119
|
-
}
|
|
120
102
|
class NotImplementedError extends Error {
|
|
121
103
|
constructor(message) {
|
|
122
104
|
super('NotImplemented');
|
|
@@ -125,9 +107,6 @@ class NotImplementedError extends Error {
|
|
|
125
107
|
}
|
|
126
108
|
}
|
|
127
109
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Error that when thrown won't be logged in telemetry as an unhandled error.
|
|
130
|
-
*/
|
|
131
110
|
class ErrorNoTelemetry extends Error {
|
|
132
111
|
constructor(msg) {
|
|
133
112
|
super(msg);
|
|
@@ -137,7 +116,7 @@ class ErrorNoTelemetry extends Error {
|
|
|
137
116
|
if (err instanceof ErrorNoTelemetry) {
|
|
138
117
|
return err;
|
|
139
118
|
}
|
|
140
|
-
const result = (
|
|
119
|
+
const result = ( (new ErrorNoTelemetry()));
|
|
141
120
|
result.message = err.message;
|
|
142
121
|
result.stack = err.stack;
|
|
143
122
|
return result;
|
|
@@ -146,11 +125,6 @@ class ErrorNoTelemetry extends Error {
|
|
|
146
125
|
return err.name === 'ErrorNoTelemetry';
|
|
147
126
|
}
|
|
148
127
|
}
|
|
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
128
|
function isReadableStream(obj) {
|
|
155
129
|
const candidate = obj;
|
|
156
130
|
if (!candidate) {
|
|
@@ -166,7 +140,9 @@ function isReadableBufferedStream(obj) {
|
|
|
166
140
|
return isReadableStream(candidate.stream) && Array.isArray(candidate.buffer) && typeof candidate.ended === 'boolean';
|
|
167
141
|
}
|
|
168
142
|
function newWriteableStream(reducer, options) {
|
|
169
|
-
return (
|
|
143
|
+
return (
|
|
144
|
+
(new WriteableStreamImpl(reducer, options))
|
|
145
|
+
);
|
|
170
146
|
}
|
|
171
147
|
class WriteableStreamImpl {
|
|
172
148
|
constructor(reducer, options) {
|
|
@@ -200,7 +176,6 @@ class WriteableStreamImpl {
|
|
|
200
176
|
}
|
|
201
177
|
if (!this.state.flowing) {
|
|
202
178
|
this.state.flowing = true;
|
|
203
|
-
// emit buffered events
|
|
204
179
|
this.flowData();
|
|
205
180
|
this.flowErrors();
|
|
206
181
|
this.flowEnd();
|
|
@@ -210,16 +185,15 @@ class WriteableStreamImpl {
|
|
|
210
185
|
if (this.state.destroyed) {
|
|
211
186
|
return;
|
|
212
187
|
}
|
|
213
|
-
// flowing: directly send the data to listeners
|
|
214
188
|
if (this.state.flowing) {
|
|
215
189
|
this.emitData(data);
|
|
216
190
|
}
|
|
217
|
-
// not yet flowing: buffer data until flowing
|
|
218
191
|
else {
|
|
219
192
|
this.buffer.data.push(data);
|
|
220
|
-
// highWaterMark: if configured, signal back when buffer reached limits
|
|
221
193
|
if (typeof this.options?.highWaterMark === 'number' && this.buffer.data.length > this.options.highWaterMark) {
|
|
222
|
-
return (
|
|
194
|
+
return (
|
|
195
|
+
(new Promise(resolve => this.pendingWritePromises.push(resolve)))
|
|
196
|
+
);
|
|
223
197
|
}
|
|
224
198
|
}
|
|
225
199
|
}
|
|
@@ -227,11 +201,9 @@ class WriteableStreamImpl {
|
|
|
227
201
|
if (this.state.destroyed) {
|
|
228
202
|
return;
|
|
229
203
|
}
|
|
230
|
-
// flowing: directly send the error to listeners
|
|
231
204
|
if (this.state.flowing) {
|
|
232
205
|
this.emitError(error);
|
|
233
206
|
}
|
|
234
|
-
// not yet flowing: buffer errors until flowing
|
|
235
207
|
else {
|
|
236
208
|
this.buffer.error.push(error);
|
|
237
209
|
}
|
|
@@ -240,33 +212,30 @@ class WriteableStreamImpl {
|
|
|
240
212
|
if (this.state.destroyed) {
|
|
241
213
|
return;
|
|
242
214
|
}
|
|
243
|
-
// end with data if provided
|
|
244
215
|
if (typeof result !== 'undefined') {
|
|
245
216
|
this.write(result);
|
|
246
217
|
}
|
|
247
|
-
// flowing: send end event to listeners
|
|
248
218
|
if (this.state.flowing) {
|
|
249
219
|
this.emitEnd();
|
|
250
220
|
this.destroy();
|
|
251
221
|
}
|
|
252
|
-
// not yet flowing: remember state
|
|
253
222
|
else {
|
|
254
223
|
this.state.ended = true;
|
|
255
224
|
}
|
|
256
225
|
}
|
|
257
226
|
emitData(data) {
|
|
258
|
-
this.listeners.data.slice(0).forEach(listener => listener(data));
|
|
227
|
+
this.listeners.data.slice(0).forEach(listener => listener(data));
|
|
259
228
|
}
|
|
260
229
|
emitError(error) {
|
|
261
230
|
if (this.listeners.error.length === 0) {
|
|
262
|
-
onUnexpectedError(error);
|
|
231
|
+
onUnexpectedError(error);
|
|
263
232
|
}
|
|
264
233
|
else {
|
|
265
|
-
this.listeners.error.slice(0).forEach(listener => listener(error));
|
|
234
|
+
this.listeners.error.slice(0).forEach(listener => listener(error));
|
|
266
235
|
}
|
|
267
236
|
}
|
|
268
237
|
emitEnd() {
|
|
269
|
-
this.listeners.end.slice(0).forEach(listener => listener());
|
|
238
|
+
this.listeners.end.slice(0).forEach(listener => listener());
|
|
270
239
|
}
|
|
271
240
|
on(event, callback) {
|
|
272
241
|
if (this.state.destroyed) {
|
|
@@ -275,24 +244,16 @@ class WriteableStreamImpl {
|
|
|
275
244
|
switch (event) {
|
|
276
245
|
case 'data':
|
|
277
246
|
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
247
|
this.resume();
|
|
281
248
|
break;
|
|
282
249
|
case 'end':
|
|
283
250
|
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
251
|
if (this.state.flowing && this.flowEnd()) {
|
|
289
252
|
this.destroy();
|
|
290
253
|
}
|
|
291
254
|
break;
|
|
292
255
|
case 'error':
|
|
293
256
|
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
257
|
if (this.state.flowing) {
|
|
297
258
|
this.flowErrors();
|
|
298
259
|
}
|
|
@@ -327,7 +288,6 @@ class WriteableStreamImpl {
|
|
|
327
288
|
const fullDataBuffer = this.reducer(this.buffer.data);
|
|
328
289
|
this.emitData(fullDataBuffer);
|
|
329
290
|
this.buffer.data.length = 0;
|
|
330
|
-
// When the buffer is empty, resolve all pending writers
|
|
331
291
|
const pendingWritePromises = [...this.pendingWritePromises];
|
|
332
292
|
this.pendingWritePromises.length = 0;
|
|
333
293
|
pendingWritePromises.forEach(pendingWritePromise => pendingWritePromise());
|
|
@@ -361,9 +321,6 @@ class WriteableStreamImpl {
|
|
|
361
321
|
}
|
|
362
322
|
}
|
|
363
323
|
}
|
|
364
|
-
/**
|
|
365
|
-
* Helper to fully read a T readable into a T.
|
|
366
|
-
*/
|
|
367
324
|
function consumeReadable(readable, reducer) {
|
|
368
325
|
const chunks = [];
|
|
369
326
|
let chunk;
|
|
@@ -372,76 +329,59 @@ function consumeReadable(readable, reducer) {
|
|
|
372
329
|
}
|
|
373
330
|
return reducer(chunks);
|
|
374
331
|
}
|
|
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
332
|
function peekReadable(readable, reducer, maxChunks) {
|
|
381
333
|
const chunks = [];
|
|
382
334
|
let chunk = undefined;
|
|
383
335
|
while ((chunk = readable.read()) !== null && chunks.length < maxChunks) {
|
|
384
336
|
chunks.push(chunk);
|
|
385
337
|
}
|
|
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
338
|
if (chunk === null && chunks.length > 0) {
|
|
389
339
|
return reducer(chunks);
|
|
390
340
|
}
|
|
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
341
|
return {
|
|
396
342
|
read: () => {
|
|
397
|
-
// First consume chunks from our array
|
|
398
343
|
if (chunks.length > 0) {
|
|
399
344
|
return chunks.shift();
|
|
400
345
|
}
|
|
401
|
-
// Then ensure to return our last read chunk
|
|
402
346
|
if (typeof chunk !== 'undefined') {
|
|
403
347
|
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
348
|
chunk = undefined;
|
|
407
349
|
return lastReadChunk;
|
|
408
350
|
}
|
|
409
|
-
// Finally delegate back to the Readable
|
|
410
351
|
return readable.read();
|
|
411
352
|
}
|
|
412
353
|
};
|
|
413
354
|
}
|
|
414
355
|
function consumeStream(stream, reducer) {
|
|
415
|
-
return (
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
356
|
+
return (
|
|
357
|
+
(new Promise((resolve, reject) => {
|
|
358
|
+
const chunks = [];
|
|
359
|
+
listenStream(stream, {
|
|
360
|
+
onData: chunk => {
|
|
361
|
+
if (reducer) {
|
|
362
|
+
chunks.push(chunk);
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
onError: error => {
|
|
366
|
+
if (reducer) {
|
|
367
|
+
reject(error);
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
resolve(undefined);
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
onEnd: () => {
|
|
374
|
+
if (reducer) {
|
|
375
|
+
resolve(reducer(chunks));
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
resolve(undefined);
|
|
379
|
+
}
|
|
437
380
|
}
|
|
438
|
-
}
|
|
439
|
-
})
|
|
440
|
-
|
|
381
|
+
});
|
|
382
|
+
}))
|
|
383
|
+
);
|
|
441
384
|
}
|
|
442
|
-
/**
|
|
443
|
-
* Helper to listen to all events of a T stream in proper order.
|
|
444
|
-
*/
|
|
445
385
|
function listenStream(stream, listener) {
|
|
446
386
|
let destroyed = false;
|
|
447
387
|
stream.on('error', error => {
|
|
@@ -454,9 +394,6 @@ function listenStream(stream, listener) {
|
|
|
454
394
|
listener.onEnd();
|
|
455
395
|
}
|
|
456
396
|
});
|
|
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
397
|
stream.on('data', data => {
|
|
461
398
|
if (!destroyed) {
|
|
462
399
|
listener.onData(data);
|
|
@@ -464,50 +401,34 @@ function listenStream(stream, listener) {
|
|
|
464
401
|
});
|
|
465
402
|
return toDisposable(() => destroyed = true);
|
|
466
403
|
}
|
|
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
404
|
function peekStream(stream, maxChunks) {
|
|
473
|
-
return (
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
return
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
streamListeners.add(toDisposable(() => stream.removeListener('end', endListener)));
|
|
500
|
-
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
|
-
streamListeners.add(toDisposable(() => stream.removeListener('data', dataListener)));
|
|
505
|
-
stream.on('data', dataListener);
|
|
506
|
-
}));
|
|
405
|
+
return (
|
|
406
|
+
(new Promise((resolve, reject) => {
|
|
407
|
+
const streamListeners = ( (new DisposableStore()));
|
|
408
|
+
const buffer = [];
|
|
409
|
+
const dataListener = (chunk) => {
|
|
410
|
+
buffer.push(chunk);
|
|
411
|
+
if (buffer.length > maxChunks) {
|
|
412
|
+
streamListeners.dispose();
|
|
413
|
+
stream.pause();
|
|
414
|
+
return resolve({ stream, buffer, ended: false });
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
const errorListener = (error) => {
|
|
418
|
+
return reject(error);
|
|
419
|
+
};
|
|
420
|
+
const endListener = () => {
|
|
421
|
+
return resolve({ stream, buffer, ended: true });
|
|
422
|
+
};
|
|
423
|
+
streamListeners.add(toDisposable(() => stream.removeListener('error', errorListener)));
|
|
424
|
+
stream.on('error', errorListener);
|
|
425
|
+
streamListeners.add(toDisposable(() => stream.removeListener('end', endListener)));
|
|
426
|
+
stream.on('end', endListener);
|
|
427
|
+
streamListeners.add(toDisposable(() => stream.removeListener('data', dataListener)));
|
|
428
|
+
stream.on('data', dataListener);
|
|
429
|
+
}))
|
|
430
|
+
);
|
|
507
431
|
}
|
|
508
|
-
/**
|
|
509
|
-
* Helper to convert a T into a Readable<T>.
|
|
510
|
-
*/
|
|
511
432
|
function toReadable(t) {
|
|
512
433
|
let consumed = false;
|
|
513
434
|
return {
|
|
@@ -520,9 +441,6 @@ function toReadable(t) {
|
|
|
520
441
|
}
|
|
521
442
|
};
|
|
522
443
|
}
|
|
523
|
-
/**
|
|
524
|
-
* Helper to transform a readable stream into another stream.
|
|
525
|
-
*/
|
|
526
444
|
function transform(stream, transformer, reducer) {
|
|
527
445
|
const target = newWriteableStream(reducer);
|
|
528
446
|
listenStream(stream, {
|
|
@@ -532,11 +450,6 @@ function transform(stream, transformer, reducer) {
|
|
|
532
450
|
});
|
|
533
451
|
return target;
|
|
534
452
|
}
|
|
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
453
|
const hasBuffer = (typeof Buffer !== 'undefined');
|
|
541
454
|
let textEncoder;
|
|
542
455
|
let textDecoder;
|
|
@@ -545,51 +458,42 @@ class VSBuffer {
|
|
|
545
458
|
this.buffer = buffer;
|
|
546
459
|
this.byteLength = this.buffer.byteLength;
|
|
547
460
|
}
|
|
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
461
|
static alloc(byteLength) {
|
|
553
462
|
if (hasBuffer) {
|
|
554
|
-
return (
|
|
463
|
+
return (
|
|
464
|
+
(new VSBuffer(Buffer.allocUnsafe(byteLength)))
|
|
465
|
+
);
|
|
555
466
|
}
|
|
556
467
|
else {
|
|
557
|
-
return (
|
|
468
|
+
return (
|
|
469
|
+
(new VSBuffer( (new Uint8Array(byteLength))))
|
|
470
|
+
);
|
|
558
471
|
}
|
|
559
472
|
}
|
|
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
473
|
static wrap(actual) {
|
|
566
474
|
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
475
|
actual = Buffer.from(actual.buffer, actual.byteOffset, actual.byteLength);
|
|
570
476
|
}
|
|
571
|
-
return (
|
|
477
|
+
return (
|
|
478
|
+
(new VSBuffer(actual))
|
|
479
|
+
);
|
|
572
480
|
}
|
|
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
481
|
static fromString(source, options) {
|
|
578
482
|
const dontUseNodeBuffer = options?.dontUseNodeBuffer || false;
|
|
579
483
|
if (!dontUseNodeBuffer && hasBuffer) {
|
|
580
|
-
return (
|
|
484
|
+
return (
|
|
485
|
+
(new VSBuffer(Buffer.from(source)))
|
|
486
|
+
);
|
|
581
487
|
}
|
|
582
488
|
else {
|
|
583
489
|
if (!textEncoder) {
|
|
584
|
-
textEncoder = (
|
|
490
|
+
textEncoder = ( (new TextEncoder()));
|
|
585
491
|
}
|
|
586
|
-
return (
|
|
492
|
+
return (
|
|
493
|
+
(new VSBuffer(textEncoder.encode(source)))
|
|
494
|
+
);
|
|
587
495
|
}
|
|
588
496
|
}
|
|
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
497
|
static fromByteArray(source) {
|
|
594
498
|
const result = VSBuffer.alloc(source.length);
|
|
595
499
|
for (let i = 0, len = source.length; i < len; i++) {
|
|
@@ -597,10 +501,6 @@ class VSBuffer {
|
|
|
597
501
|
}
|
|
598
502
|
return result;
|
|
599
503
|
}
|
|
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
504
|
static concat(buffers, totalLength) {
|
|
605
505
|
if (typeof totalLength === 'undefined') {
|
|
606
506
|
totalLength = 0;
|
|
@@ -617,10 +517,6 @@ class VSBuffer {
|
|
|
617
517
|
}
|
|
618
518
|
return ret;
|
|
619
519
|
}
|
|
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
520
|
clone() {
|
|
625
521
|
const result = VSBuffer.alloc(this.byteLength);
|
|
626
522
|
result.set(this);
|
|
@@ -628,20 +524,21 @@ class VSBuffer {
|
|
|
628
524
|
}
|
|
629
525
|
toString() {
|
|
630
526
|
if (hasBuffer) {
|
|
631
|
-
return (
|
|
527
|
+
return (
|
|
528
|
+
(this.buffer.toString())
|
|
529
|
+
);
|
|
632
530
|
}
|
|
633
531
|
else {
|
|
634
532
|
if (!textDecoder) {
|
|
635
|
-
textDecoder = (
|
|
533
|
+
textDecoder = ( (new TextDecoder()));
|
|
636
534
|
}
|
|
637
535
|
return textDecoder.decode(this.buffer);
|
|
638
536
|
}
|
|
639
537
|
}
|
|
640
538
|
slice(start, end) {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
return (/*#__PURE__*/ new VSBuffer(this.buffer.subarray(start, end)));
|
|
539
|
+
return (
|
|
540
|
+
(new VSBuffer(this.buffer.subarray(start, end)))
|
|
541
|
+
);
|
|
645
542
|
}
|
|
646
543
|
set(array, offset) {
|
|
647
544
|
if (array instanceof VSBuffer) {
|
|
@@ -651,10 +548,10 @@ class VSBuffer {
|
|
|
651
548
|
this.buffer.set(array, offset);
|
|
652
549
|
}
|
|
653
550
|
else if (array instanceof ArrayBuffer) {
|
|
654
|
-
this.buffer.set((
|
|
551
|
+
this.buffer.set(( (new Uint8Array(array))), offset);
|
|
655
552
|
}
|
|
656
553
|
else if (ArrayBuffer.isView(array)) {
|
|
657
|
-
this.buffer.set((
|
|
554
|
+
this.buffer.set(( (new Uint8Array(array.buffer, array.byteOffset, array.byteLength))), offset);
|
|
658
555
|
}
|
|
659
556
|
else {
|
|
660
557
|
throw new Error(`Unknown argument 'array'`);
|
|
@@ -729,35 +626,22 @@ async function bufferedStreamToBuffer(bufferedStream) {
|
|
|
729
626
|
return VSBuffer.concat(bufferedStream.buffer);
|
|
730
627
|
}
|
|
731
628
|
return VSBuffer.concat([
|
|
732
|
-
// Include already read chunks...
|
|
733
629
|
...bufferedStream.buffer,
|
|
734
|
-
// ...and all additional chunks
|
|
735
630
|
await streamToBuffer(bufferedStream.stream)
|
|
736
631
|
]);
|
|
737
632
|
}
|
|
738
633
|
function newWriteableBufferStream(options) {
|
|
739
634
|
return newWriteableStream(chunks => VSBuffer.concat(chunks), options);
|
|
740
635
|
}
|
|
741
|
-
|
|
742
636
|
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
637
|
const Extensions$1 = {
|
|
750
638
|
ThemingContribution: 'base.contributions.theming'
|
|
751
639
|
};
|
|
752
|
-
/**
|
|
753
|
-
* Utility base class for all themable components.
|
|
754
|
-
*/
|
|
755
640
|
class Themable extends Disposable {
|
|
756
641
|
constructor(themeService) {
|
|
757
642
|
super();
|
|
758
643
|
this.themeService = themeService;
|
|
759
644
|
this.theme = themeService.getColorTheme();
|
|
760
|
-
// Hook up to theme changes
|
|
761
645
|
this._register(this.themeService.onDidColorThemeChange(theme => this.onThemeChange(theme)));
|
|
762
646
|
}
|
|
763
647
|
onThemeChange(theme) {
|
|
@@ -765,40 +649,26 @@ class Themable extends Disposable {
|
|
|
765
649
|
this.updateStyles();
|
|
766
650
|
}
|
|
767
651
|
updateStyles() {
|
|
768
|
-
// Subclasses to override
|
|
769
652
|
}
|
|
770
653
|
getColor(id, modify) {
|
|
771
654
|
let color = this.theme.getColor(id);
|
|
772
655
|
if (color && modify) {
|
|
773
656
|
color = modify(color, this.theme);
|
|
774
657
|
}
|
|
775
|
-
return color ? (
|
|
658
|
+
return color ? ( (color.toString())) : null;
|
|
776
659
|
}
|
|
777
660
|
}
|
|
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
661
|
const Extensions = {
|
|
784
662
|
JSONContribution: 'base.contributions.json'
|
|
785
663
|
};
|
|
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
664
|
const CSS_DONE = 'done';
|
|
792
665
|
const CSS_ACTIVE = 'active';
|
|
793
666
|
const CSS_INFINITE = 'infinite';
|
|
794
667
|
const CSS_INFINITE_LONG_RUNNING = 'infinite-long-running';
|
|
795
668
|
const CSS_DISCRETE = 'discrete';
|
|
796
669
|
const defaultOpts = {
|
|
797
|
-
progressBarBackground: (
|
|
670
|
+
progressBarBackground: ( (Color$1.fromHex('#0E70C0')))
|
|
798
671
|
};
|
|
799
|
-
/**
|
|
800
|
-
* A progress bar with support for infinite or discrete progress.
|
|
801
|
-
*/
|
|
802
672
|
class ProgressBar extends Disposable {
|
|
803
673
|
constructor(container, options) {
|
|
804
674
|
super();
|
|
@@ -806,11 +676,11 @@ class ProgressBar extends Disposable {
|
|
|
806
676
|
mixin(this.options, defaultOpts, false);
|
|
807
677
|
this.workedVal = 0;
|
|
808
678
|
this.progressBarBackground = this.options.progressBarBackground;
|
|
809
|
-
this.showDelayedScheduler = this._register((
|
|
810
|
-
this.longRunningScheduler = this._register((
|
|
679
|
+
this.showDelayedScheduler = this._register(( (new RunOnceScheduler(() => show(this.element), 0))));
|
|
680
|
+
this.longRunningScheduler = this._register(( (new RunOnceScheduler(
|
|
811
681
|
() => this.infiniteLongRunning(),
|
|
812
682
|
ProgressBar.LONG_RUNNING_INFINITE_THRESHOLD
|
|
813
|
-
)));
|
|
683
|
+
))));
|
|
814
684
|
this.create(container);
|
|
815
685
|
}
|
|
816
686
|
create(container) {
|
|
@@ -832,21 +702,14 @@ class ProgressBar extends Disposable {
|
|
|
832
702
|
this.totalWork = undefined;
|
|
833
703
|
this.longRunningScheduler.cancel();
|
|
834
704
|
}
|
|
835
|
-
/**
|
|
836
|
-
* Indicates to the progress bar that all work is done.
|
|
837
|
-
*/
|
|
838
705
|
done() {
|
|
839
706
|
return this.doDone(true);
|
|
840
707
|
}
|
|
841
|
-
/**
|
|
842
|
-
* Stops the progressbar from showing any progress instantly without fading out.
|
|
843
|
-
*/
|
|
844
708
|
stop() {
|
|
845
709
|
return this.doDone(false);
|
|
846
710
|
}
|
|
847
711
|
doDone(delayed) {
|
|
848
712
|
this.element.classList.add(CSS_DONE);
|
|
849
|
-
// discrete: let it grow to 100% width and hide afterwards
|
|
850
713
|
if (!this.element.classList.contains(CSS_INFINITE)) {
|
|
851
714
|
this.bit.style.width = 'inherit';
|
|
852
715
|
if (delayed) {
|
|
@@ -856,7 +719,6 @@ class ProgressBar extends Disposable {
|
|
|
856
719
|
this.off();
|
|
857
720
|
}
|
|
858
721
|
}
|
|
859
|
-
// infinite: let it fade out and hide afterwards
|
|
860
722
|
else {
|
|
861
723
|
this.bit.style.opacity = '0';
|
|
862
724
|
if (delayed) {
|
|
@@ -868,9 +730,6 @@ class ProgressBar extends Disposable {
|
|
|
868
730
|
}
|
|
869
731
|
return this;
|
|
870
732
|
}
|
|
871
|
-
/**
|
|
872
|
-
* Use this mode to indicate progress that has no total number of work units.
|
|
873
|
-
*/
|
|
874
733
|
infinite() {
|
|
875
734
|
this.bit.style.width = '2%';
|
|
876
735
|
this.bit.style.opacity = '1';
|
|
@@ -882,32 +741,19 @@ class ProgressBar extends Disposable {
|
|
|
882
741
|
infiniteLongRunning() {
|
|
883
742
|
this.element.classList.add(CSS_INFINITE_LONG_RUNNING);
|
|
884
743
|
}
|
|
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
744
|
total(value) {
|
|
890
745
|
this.workedVal = 0;
|
|
891
746
|
this.totalWork = value;
|
|
892
|
-
this.element.setAttribute('aria-valuemax', (
|
|
747
|
+
this.element.setAttribute('aria-valuemax', ( (value.toString())));
|
|
893
748
|
return this;
|
|
894
749
|
}
|
|
895
|
-
/**
|
|
896
|
-
* Finds out if this progress bar is configured with total work
|
|
897
|
-
*/
|
|
898
750
|
hasTotal() {
|
|
899
751
|
return isNumber(this.totalWork);
|
|
900
752
|
}
|
|
901
|
-
/**
|
|
902
|
-
* Tells the progress bar that an increment of work has been completed.
|
|
903
|
-
*/
|
|
904
753
|
worked(value) {
|
|
905
754
|
value = Math.max(1, Number(value));
|
|
906
755
|
return this.doSetWorked(this.workedVal + value);
|
|
907
756
|
}
|
|
908
|
-
/**
|
|
909
|
-
* Tells the progress bar the total amount of work that has been completed.
|
|
910
|
-
*/
|
|
911
757
|
setWorked(value) {
|
|
912
758
|
value = Math.max(1, Number(value));
|
|
913
759
|
return this.doSetWorked(value);
|
|
@@ -918,7 +764,7 @@ class ProgressBar extends Disposable {
|
|
|
918
764
|
this.workedVal = Math.min(totalWork, this.workedVal);
|
|
919
765
|
this.element.classList.remove(CSS_INFINITE, CSS_INFINITE_LONG_RUNNING, CSS_DONE);
|
|
920
766
|
this.element.classList.add(CSS_ACTIVE, CSS_DISCRETE);
|
|
921
|
-
this.element.setAttribute('aria-valuenow', (
|
|
767
|
+
this.element.setAttribute('aria-valuenow', ( (value.toString())));
|
|
922
768
|
this.bit.style.width = 100 * (this.workedVal / (totalWork)) + '%';
|
|
923
769
|
return this;
|
|
924
770
|
}
|
|
@@ -944,37 +790,24 @@ class ProgressBar extends Disposable {
|
|
|
944
790
|
}
|
|
945
791
|
applyStyles() {
|
|
946
792
|
if (this.bit) {
|
|
947
|
-
const background = this.progressBarBackground ? (
|
|
793
|
+
const background = this.progressBarBackground ? ( (this.progressBarBackground.toString())) : '';
|
|
948
794
|
this.bit.style.backgroundColor = background;
|
|
949
795
|
}
|
|
950
796
|
}
|
|
951
797
|
}
|
|
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
798
|
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
799
|
class LanguageService extends Disposable {
|
|
967
800
|
constructor(warnOnOverwrite = false) {
|
|
968
801
|
super();
|
|
969
|
-
this._onDidEncounterLanguage = this._register((
|
|
802
|
+
this._onDidEncounterLanguage = this._register(( (new Emitter())));
|
|
970
803
|
this.onDidEncounterLanguage = this._onDidEncounterLanguage.event;
|
|
971
|
-
this._onDidChange = this._register((
|
|
972
|
-
{ leakWarningThreshold: 200
|
|
973
|
-
)));
|
|
804
|
+
this._onDidChange = this._register(( (new Emitter(
|
|
805
|
+
{ leakWarningThreshold: 200 }
|
|
806
|
+
))));
|
|
974
807
|
this.onDidChange = this._onDidChange.event;
|
|
975
808
|
LanguageService.instanceCount++;
|
|
976
|
-
this._encounteredLanguages = (
|
|
977
|
-
this._registry = this._register((
|
|
809
|
+
this._encounteredLanguages = ( (new Set()));
|
|
810
|
+
this._registry = this._register(( (new LanguagesRegistry$1(true, warnOnOverwrite))));
|
|
978
811
|
this.languageIdCodec = this._registry.languageIdCodec;
|
|
979
812
|
this._register(this._registry.onDidChange(() => this._onDidChange.fire()));
|
|
980
813
|
}
|
|
@@ -1023,32 +856,35 @@ class LanguageService extends Disposable {
|
|
|
1023
856
|
return firstOrDefault(languageIds, null);
|
|
1024
857
|
}
|
|
1025
858
|
createById(languageId) {
|
|
1026
|
-
return (
|
|
1027
|
-
|
|
1028
|
-
|
|
859
|
+
return (
|
|
860
|
+
(new LanguageSelection(this.onDidChange, () => {
|
|
861
|
+
return this._createAndGetLanguageIdentifier(languageId);
|
|
862
|
+
}))
|
|
863
|
+
);
|
|
1029
864
|
}
|
|
1030
865
|
createByMimeType(mimeType) {
|
|
1031
|
-
return (
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
866
|
+
return (
|
|
867
|
+
(new LanguageSelection(this.onDidChange, () => {
|
|
868
|
+
const languageId = this.getLanguageIdByMimeType(mimeType);
|
|
869
|
+
return this._createAndGetLanguageIdentifier(languageId);
|
|
870
|
+
}))
|
|
871
|
+
);
|
|
1035
872
|
}
|
|
1036
873
|
createByFilepathOrFirstLine(resource, firstLine) {
|
|
1037
|
-
return (
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
874
|
+
return (
|
|
875
|
+
(new LanguageSelection(this.onDidChange, () => {
|
|
876
|
+
const languageId = this.guessLanguageIdByFilepathOrFirstLine(resource, firstLine);
|
|
877
|
+
return this._createAndGetLanguageIdentifier(languageId);
|
|
878
|
+
}))
|
|
879
|
+
);
|
|
1041
880
|
}
|
|
1042
881
|
_createAndGetLanguageIdentifier(languageId) {
|
|
1043
882
|
if (!languageId || !this.isRegisteredLanguageId(languageId)) {
|
|
1044
|
-
// Fall back to plain text if language is unknown
|
|
1045
883
|
languageId = PLAINTEXT_LANGUAGE_ID;
|
|
1046
884
|
}
|
|
1047
885
|
if (!this._encounteredLanguages.has(languageId)) {
|
|
1048
886
|
this._encounteredLanguages.add(languageId);
|
|
1049
|
-
// Ensure tokenizers are created
|
|
1050
887
|
TokenizationRegistry.getOrCreate(languageId);
|
|
1051
|
-
// Fire event
|
|
1052
888
|
this._onDidEncounterLanguage.fire(languageId);
|
|
1053
889
|
}
|
|
1054
890
|
return languageId;
|
|
@@ -1078,59 +914,49 @@ class LanguageSelection {
|
|
|
1078
914
|
this._listener = this._onDidChangeLanguages(() => this._evaluate());
|
|
1079
915
|
}
|
|
1080
916
|
if (!this._emitter) {
|
|
1081
|
-
this._emitter = (
|
|
917
|
+
this._emitter = ( (new Emitter({
|
|
1082
918
|
onLastListenerRemove: () => {
|
|
1083
919
|
this._dispose();
|
|
1084
920
|
}
|
|
1085
|
-
}));
|
|
921
|
+
})));
|
|
1086
922
|
}
|
|
1087
923
|
return this._emitter.event;
|
|
1088
924
|
}
|
|
1089
925
|
_evaluate() {
|
|
1090
926
|
const languageId = this._selector();
|
|
1091
927
|
if (languageId === this.languageId) {
|
|
1092
|
-
// no change
|
|
1093
928
|
return;
|
|
1094
929
|
}
|
|
1095
930
|
this.languageId = languageId;
|
|
1096
931
|
this._emitter?.fire(this.languageId);
|
|
1097
932
|
}
|
|
1098
933
|
}
|
|
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
934
|
var ParseOptions;
|
|
1105
|
-
(
|
|
935
|
+
( ((function(ParseOptions) {
|
|
1106
936
|
ParseOptions.DEFAULT = {
|
|
1107
937
|
allowTrailingComma: true
|
|
1108
938
|
};
|
|
1109
|
-
})(ParseOptions || (ParseOptions = {})));
|
|
1110
|
-
/**
|
|
1111
|
-
* Creates a JSON scanner on the given text.
|
|
1112
|
-
* If ignoreTrivia is set, whitespaces or comments are ignored.
|
|
1113
|
-
*/
|
|
939
|
+
})(ParseOptions || (ParseOptions = {}))));
|
|
1114
940
|
function createScanner(text, ignoreTrivia = false) {
|
|
1115
941
|
let pos = 0;
|
|
1116
942
|
const len = text.length;
|
|
1117
943
|
let value = '';
|
|
1118
944
|
let tokenOffset = 0;
|
|
1119
|
-
let token = 16
|
|
1120
|
-
let scanError = 0
|
|
945
|
+
let token = 16 ;
|
|
946
|
+
let scanError = 0 ;
|
|
1121
947
|
function scanHexDigits(count) {
|
|
1122
948
|
let digits = 0;
|
|
1123
949
|
let hexValue = 0;
|
|
1124
950
|
while (digits < count) {
|
|
1125
951
|
const ch = text.charCodeAt(pos);
|
|
1126
|
-
if (ch >= 48
|
|
1127
|
-
hexValue = hexValue * 16 + ch - 48
|
|
952
|
+
if (ch >= 48 && ch <= 57 ) {
|
|
953
|
+
hexValue = hexValue * 16 + ch - 48 ;
|
|
1128
954
|
}
|
|
1129
|
-
else if (ch >= 65
|
|
1130
|
-
hexValue = hexValue * 16 + ch - 65
|
|
955
|
+
else if (ch >= 65 && ch <= 70 ) {
|
|
956
|
+
hexValue = hexValue * 16 + ch - 65 + 10;
|
|
1131
957
|
}
|
|
1132
|
-
else if (ch >= 97
|
|
1133
|
-
hexValue = hexValue * 16 + ch - 97
|
|
958
|
+
else if (ch >= 97 && ch <= 102 ) {
|
|
959
|
+
hexValue = hexValue * 16 + ch - 97 + 10;
|
|
1134
960
|
}
|
|
1135
961
|
else {
|
|
1136
962
|
break;
|
|
@@ -1147,12 +973,12 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1147
973
|
pos = newPosition;
|
|
1148
974
|
value = '';
|
|
1149
975
|
tokenOffset = 0;
|
|
1150
|
-
token = 16
|
|
1151
|
-
scanError = 0
|
|
976
|
+
token = 16 ;
|
|
977
|
+
scanError = 0 ;
|
|
1152
978
|
}
|
|
1153
979
|
function scanNumber() {
|
|
1154
980
|
const start = pos;
|
|
1155
|
-
if (text.charCodeAt(pos) === 48
|
|
981
|
+
if (text.charCodeAt(pos) === 48 ) {
|
|
1156
982
|
pos++;
|
|
1157
983
|
}
|
|
1158
984
|
else {
|
|
@@ -1161,7 +987,7 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1161
987
|
pos++;
|
|
1162
988
|
}
|
|
1163
989
|
}
|
|
1164
|
-
if (pos < text.length && text.charCodeAt(pos) === 46
|
|
990
|
+
if (pos < text.length && text.charCodeAt(pos) === 46 ) {
|
|
1165
991
|
pos++;
|
|
1166
992
|
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
1167
993
|
pos++;
|
|
@@ -1170,14 +996,14 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1170
996
|
}
|
|
1171
997
|
}
|
|
1172
998
|
else {
|
|
1173
|
-
scanError = 3
|
|
999
|
+
scanError = 3 ;
|
|
1174
1000
|
return text.substring(start, pos);
|
|
1175
1001
|
}
|
|
1176
1002
|
}
|
|
1177
1003
|
let end = pos;
|
|
1178
|
-
if (pos < text.length && ((text.charCodeAt(pos) === 69
|
|
1004
|
+
if (pos < text.length && ((text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) )) {
|
|
1179
1005
|
pos++;
|
|
1180
|
-
if (pos < text.length && text.charCodeAt(pos) === 43
|
|
1006
|
+
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45 ) {
|
|
1181
1007
|
pos++;
|
|
1182
1008
|
}
|
|
1183
1009
|
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
@@ -1188,7 +1014,7 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1188
1014
|
end = pos;
|
|
1189
1015
|
}
|
|
1190
1016
|
else {
|
|
1191
|
-
scanError = 3
|
|
1017
|
+
scanError = 3 ;
|
|
1192
1018
|
}
|
|
1193
1019
|
}
|
|
1194
1020
|
return text.substring(start, end);
|
|
@@ -1198,60 +1024,60 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1198
1024
|
while (true) {
|
|
1199
1025
|
if (pos >= len) {
|
|
1200
1026
|
result += text.substring(start, pos);
|
|
1201
|
-
scanError = 2
|
|
1027
|
+
scanError = 2 ;
|
|
1202
1028
|
break;
|
|
1203
1029
|
}
|
|
1204
1030
|
const ch = text.charCodeAt(pos);
|
|
1205
|
-
if (ch === 34
|
|
1031
|
+
if (ch === 34 ) {
|
|
1206
1032
|
result += text.substring(start, pos);
|
|
1207
1033
|
pos++;
|
|
1208
1034
|
break;
|
|
1209
1035
|
}
|
|
1210
|
-
if (ch === 92
|
|
1036
|
+
if (ch === 92 ) {
|
|
1211
1037
|
result += text.substring(start, pos);
|
|
1212
1038
|
pos++;
|
|
1213
1039
|
if (pos >= len) {
|
|
1214
|
-
scanError = 2
|
|
1040
|
+
scanError = 2 ;
|
|
1215
1041
|
break;
|
|
1216
1042
|
}
|
|
1217
1043
|
const ch2 = text.charCodeAt(pos++);
|
|
1218
1044
|
switch (ch2) {
|
|
1219
|
-
case 34
|
|
1045
|
+
case 34 :
|
|
1220
1046
|
result += '\"';
|
|
1221
1047
|
break;
|
|
1222
|
-
case 92
|
|
1048
|
+
case 92 :
|
|
1223
1049
|
result += '\\';
|
|
1224
1050
|
break;
|
|
1225
|
-
case 47
|
|
1051
|
+
case 47 :
|
|
1226
1052
|
result += '/';
|
|
1227
1053
|
break;
|
|
1228
|
-
case 98
|
|
1054
|
+
case 98 :
|
|
1229
1055
|
result += '\b';
|
|
1230
1056
|
break;
|
|
1231
|
-
case 102
|
|
1057
|
+
case 102 :
|
|
1232
1058
|
result += '\f';
|
|
1233
1059
|
break;
|
|
1234
|
-
case 110
|
|
1060
|
+
case 110 :
|
|
1235
1061
|
result += '\n';
|
|
1236
1062
|
break;
|
|
1237
|
-
case 114
|
|
1063
|
+
case 114 :
|
|
1238
1064
|
result += '\r';
|
|
1239
1065
|
break;
|
|
1240
|
-
case 116
|
|
1066
|
+
case 116 :
|
|
1241
1067
|
result += '\t';
|
|
1242
1068
|
break;
|
|
1243
|
-
case 117
|
|
1069
|
+
case 117 : {
|
|
1244
1070
|
const ch3 = scanHexDigits(4);
|
|
1245
1071
|
if (ch3 >= 0) {
|
|
1246
1072
|
result += String.fromCharCode(ch3);
|
|
1247
1073
|
}
|
|
1248
1074
|
else {
|
|
1249
|
-
scanError = 4
|
|
1075
|
+
scanError = 4 ;
|
|
1250
1076
|
}
|
|
1251
1077
|
break;
|
|
1252
1078
|
}
|
|
1253
1079
|
default:
|
|
1254
|
-
scanError = 5
|
|
1080
|
+
scanError = 5 ;
|
|
1255
1081
|
}
|
|
1256
1082
|
start = pos;
|
|
1257
1083
|
continue;
|
|
@@ -1259,12 +1085,11 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1259
1085
|
if (ch >= 0 && ch <= 0x1F) {
|
|
1260
1086
|
if (isLineBreak(ch)) {
|
|
1261
1087
|
result += text.substring(start, pos);
|
|
1262
|
-
scanError = 2
|
|
1088
|
+
scanError = 2 ;
|
|
1263
1089
|
break;
|
|
1264
1090
|
}
|
|
1265
1091
|
else {
|
|
1266
|
-
scanError = 6
|
|
1267
|
-
// mark as error but continue with string
|
|
1092
|
+
scanError = 6 ;
|
|
1268
1093
|
}
|
|
1269
1094
|
}
|
|
1270
1095
|
pos++;
|
|
@@ -1273,63 +1098,56 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1273
1098
|
}
|
|
1274
1099
|
function scanNext() {
|
|
1275
1100
|
value = '';
|
|
1276
|
-
scanError = 0
|
|
1101
|
+
scanError = 0 ;
|
|
1277
1102
|
tokenOffset = pos;
|
|
1278
1103
|
if (pos >= len) {
|
|
1279
|
-
// at the end
|
|
1280
1104
|
tokenOffset = len;
|
|
1281
|
-
return token = 17
|
|
1105
|
+
return token = 17 ;
|
|
1282
1106
|
}
|
|
1283
1107
|
let code = text.charCodeAt(pos);
|
|
1284
|
-
// trivia: whitespace
|
|
1285
1108
|
if (isWhitespace(code)) {
|
|
1286
1109
|
do {
|
|
1287
1110
|
pos++;
|
|
1288
1111
|
value += String.fromCharCode(code);
|
|
1289
1112
|
code = text.charCodeAt(pos);
|
|
1290
1113
|
} while (isWhitespace(code));
|
|
1291
|
-
return token = 15
|
|
1114
|
+
return token = 15 ;
|
|
1292
1115
|
}
|
|
1293
|
-
// trivia: newlines
|
|
1294
1116
|
if (isLineBreak(code)) {
|
|
1295
1117
|
pos++;
|
|
1296
1118
|
value += String.fromCharCode(code);
|
|
1297
|
-
if (code === 13
|
|
1119
|
+
if (code === 13 && text.charCodeAt(pos) === 10 ) {
|
|
1298
1120
|
pos++;
|
|
1299
1121
|
value += '\n';
|
|
1300
1122
|
}
|
|
1301
|
-
return token = 14
|
|
1123
|
+
return token = 14 ;
|
|
1302
1124
|
}
|
|
1303
1125
|
switch (code) {
|
|
1304
|
-
|
|
1305
|
-
case 123 /* CharacterCodes.openBrace */:
|
|
1126
|
+
case 123 :
|
|
1306
1127
|
pos++;
|
|
1307
|
-
return token = 1
|
|
1308
|
-
case 125
|
|
1128
|
+
return token = 1 ;
|
|
1129
|
+
case 125 :
|
|
1309
1130
|
pos++;
|
|
1310
|
-
return token = 2
|
|
1311
|
-
case 91
|
|
1131
|
+
return token = 2 ;
|
|
1132
|
+
case 91 :
|
|
1312
1133
|
pos++;
|
|
1313
|
-
return token = 3
|
|
1314
|
-
case 93
|
|
1134
|
+
return token = 3 ;
|
|
1135
|
+
case 93 :
|
|
1315
1136
|
pos++;
|
|
1316
|
-
return token = 4
|
|
1317
|
-
case 58
|
|
1137
|
+
return token = 4 ;
|
|
1138
|
+
case 58 :
|
|
1318
1139
|
pos++;
|
|
1319
|
-
return token = 6
|
|
1320
|
-
case 44
|
|
1140
|
+
return token = 6 ;
|
|
1141
|
+
case 44 :
|
|
1321
1142
|
pos++;
|
|
1322
|
-
return token = 5
|
|
1323
|
-
|
|
1324
|
-
case 34 /* CharacterCodes.doubleQuote */:
|
|
1143
|
+
return token = 5 ;
|
|
1144
|
+
case 34 :
|
|
1325
1145
|
pos++;
|
|
1326
1146
|
value = scanString();
|
|
1327
|
-
return token = 10
|
|
1328
|
-
|
|
1329
|
-
case 47 /* CharacterCodes.slash */: {
|
|
1147
|
+
return token = 10 ;
|
|
1148
|
+
case 47 : {
|
|
1330
1149
|
const start = pos - 1;
|
|
1331
|
-
|
|
1332
|
-
if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
|
|
1150
|
+
if (text.charCodeAt(pos + 1) === 47 ) {
|
|
1333
1151
|
pos += 2;
|
|
1334
1152
|
while (pos < len) {
|
|
1335
1153
|
if (isLineBreak(text.charCodeAt(pos))) {
|
|
@@ -1338,16 +1156,15 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1338
1156
|
pos++;
|
|
1339
1157
|
}
|
|
1340
1158
|
value = text.substring(start, pos);
|
|
1341
|
-
return token = 12
|
|
1159
|
+
return token = 12 ;
|
|
1342
1160
|
}
|
|
1343
|
-
|
|
1344
|
-
if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
|
|
1161
|
+
if (text.charCodeAt(pos + 1) === 42 ) {
|
|
1345
1162
|
pos += 2;
|
|
1346
|
-
const safeLength = len - 1;
|
|
1163
|
+
const safeLength = len - 1;
|
|
1347
1164
|
let commentClosed = false;
|
|
1348
1165
|
while (pos < safeLength) {
|
|
1349
1166
|
const ch = text.charCodeAt(pos);
|
|
1350
|
-
if (ch === 42
|
|
1167
|
+
if (ch === 42 && text.charCodeAt(pos + 1) === 47 ) {
|
|
1351
1168
|
pos += 2;
|
|
1352
1169
|
commentClosed = true;
|
|
1353
1170
|
break;
|
|
@@ -1356,59 +1173,50 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1356
1173
|
}
|
|
1357
1174
|
if (!commentClosed) {
|
|
1358
1175
|
pos++;
|
|
1359
|
-
scanError = 1
|
|
1176
|
+
scanError = 1 ;
|
|
1360
1177
|
}
|
|
1361
1178
|
value = text.substring(start, pos);
|
|
1362
|
-
return token = 13
|
|
1179
|
+
return token = 13 ;
|
|
1363
1180
|
}
|
|
1364
|
-
// just a single slash
|
|
1365
1181
|
value += String.fromCharCode(code);
|
|
1366
1182
|
pos++;
|
|
1367
|
-
return token = 16
|
|
1183
|
+
return token = 16 ;
|
|
1368
1184
|
}
|
|
1369
|
-
|
|
1370
|
-
case 45 /* CharacterCodes.minus */:
|
|
1185
|
+
case 45 :
|
|
1371
1186
|
value += String.fromCharCode(code);
|
|
1372
1187
|
pos++;
|
|
1373
1188
|
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
1374
|
-
return token = 16
|
|
1189
|
+
return token = 16 ;
|
|
1375
1190
|
}
|
|
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 */:
|
|
1191
|
+
case 48 :
|
|
1192
|
+
case 49 :
|
|
1193
|
+
case 50 :
|
|
1194
|
+
case 51 :
|
|
1195
|
+
case 52 :
|
|
1196
|
+
case 53 :
|
|
1197
|
+
case 54 :
|
|
1198
|
+
case 55 :
|
|
1199
|
+
case 56 :
|
|
1200
|
+
case 57 :
|
|
1389
1201
|
value += scanNumber();
|
|
1390
|
-
return token = 11
|
|
1391
|
-
// literals and unknown symbols
|
|
1202
|
+
return token = 11 ;
|
|
1392
1203
|
default:
|
|
1393
|
-
// is a literal? Read the full word.
|
|
1394
1204
|
while (pos < len && isUnknownContentCharacter(code)) {
|
|
1395
1205
|
pos++;
|
|
1396
1206
|
code = text.charCodeAt(pos);
|
|
1397
1207
|
}
|
|
1398
1208
|
if (tokenOffset !== pos) {
|
|
1399
1209
|
value = text.substring(tokenOffset, pos);
|
|
1400
|
-
// keywords: true, false, null
|
|
1401
1210
|
switch (value) {
|
|
1402
|
-
case 'true': return token = 8
|
|
1403
|
-
case 'false': return token = 9
|
|
1404
|
-
case 'null': return token = 7
|
|
1211
|
+
case 'true': return token = 8 ;
|
|
1212
|
+
case 'false': return token = 9 ;
|
|
1213
|
+
case 'null': return token = 7 ;
|
|
1405
1214
|
}
|
|
1406
|
-
return token = 16
|
|
1215
|
+
return token = 16 ;
|
|
1407
1216
|
}
|
|
1408
|
-
// some
|
|
1409
1217
|
value += String.fromCharCode(code);
|
|
1410
1218
|
pos++;
|
|
1411
|
-
return token = 16
|
|
1219
|
+
return token = 16 ;
|
|
1412
1220
|
}
|
|
1413
1221
|
}
|
|
1414
1222
|
function isUnknownContentCharacter(code) {
|
|
@@ -1416,14 +1224,14 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1416
1224
|
return false;
|
|
1417
1225
|
}
|
|
1418
1226
|
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
|
|
1227
|
+
case 125 :
|
|
1228
|
+
case 93 :
|
|
1229
|
+
case 123 :
|
|
1230
|
+
case 91 :
|
|
1231
|
+
case 34 :
|
|
1232
|
+
case 58 :
|
|
1233
|
+
case 44 :
|
|
1234
|
+
case 47 :
|
|
1427
1235
|
return false;
|
|
1428
1236
|
}
|
|
1429
1237
|
return true;
|
|
@@ -1432,7 +1240,7 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1432
1240
|
let result;
|
|
1433
1241
|
do {
|
|
1434
1242
|
result = scanNext();
|
|
1435
|
-
} while (result >= 12
|
|
1243
|
+
} while (result >= 12 && result <= 15 );
|
|
1436
1244
|
return result;
|
|
1437
1245
|
}
|
|
1438
1246
|
return {
|
|
@@ -1447,20 +1255,16 @@ function createScanner(text, ignoreTrivia = false) {
|
|
|
1447
1255
|
};
|
|
1448
1256
|
}
|
|
1449
1257
|
function isWhitespace(ch) {
|
|
1450
|
-
return ch === 32
|
|
1451
|
-
ch === 160
|
|
1452
|
-
ch === 8239
|
|
1258
|
+
return ch === 32 || ch === 9 || ch === 11 || ch === 12 ||
|
|
1259
|
+
ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 ||
|
|
1260
|
+
ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279 ;
|
|
1453
1261
|
}
|
|
1454
1262
|
function isLineBreak(ch) {
|
|
1455
|
-
return ch === 10
|
|
1263
|
+
return ch === 10 || ch === 13 || ch === 8232 || ch === 8233 ;
|
|
1456
1264
|
}
|
|
1457
1265
|
function isDigit(ch) {
|
|
1458
|
-
return ch >= 48
|
|
1266
|
+
return ch >= 48 && ch <= 57 ;
|
|
1459
1267
|
}
|
|
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
1268
|
function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
1465
1269
|
let currentProperty = null;
|
|
1466
1270
|
let currentParent = [];
|
|
@@ -1505,105 +1309,6 @@ function parse(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
|
1505
1309
|
visit(text, visitor, options);
|
|
1506
1310
|
return currentParent[0];
|
|
1507
1311
|
}
|
|
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
|
-
function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
1512
|
-
let currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root
|
|
1513
|
-
function ensurePropertyComplete(endOffset) {
|
|
1514
|
-
if (currentParent.type === 'property') {
|
|
1515
|
-
currentParent.length = endOffset - currentParent.offset;
|
|
1516
|
-
currentParent = currentParent.parent;
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
function onValue(valueNode) {
|
|
1520
|
-
currentParent.children.push(valueNode);
|
|
1521
|
-
return valueNode;
|
|
1522
|
-
}
|
|
1523
|
-
const visitor = {
|
|
1524
|
-
onObjectBegin: (offset) => {
|
|
1525
|
-
currentParent = onValue({ type: 'object', offset, length: -1, parent: currentParent, children: [] });
|
|
1526
|
-
},
|
|
1527
|
-
onObjectProperty: (name, offset, length) => {
|
|
1528
|
-
currentParent = onValue({ type: 'property', offset, length: -1, parent: currentParent, children: [] });
|
|
1529
|
-
currentParent.children.push({ type: 'string', value: name, offset, length, parent: currentParent });
|
|
1530
|
-
},
|
|
1531
|
-
onObjectEnd: (offset, length) => {
|
|
1532
|
-
currentParent.length = offset + length - currentParent.offset;
|
|
1533
|
-
currentParent = currentParent.parent;
|
|
1534
|
-
ensurePropertyComplete(offset + length);
|
|
1535
|
-
},
|
|
1536
|
-
onArrayBegin: (offset, length) => {
|
|
1537
|
-
currentParent = onValue({ type: 'array', offset, length: -1, parent: currentParent, children: [] });
|
|
1538
|
-
},
|
|
1539
|
-
onArrayEnd: (offset, length) => {
|
|
1540
|
-
currentParent.length = offset + length - currentParent.offset;
|
|
1541
|
-
currentParent = currentParent.parent;
|
|
1542
|
-
ensurePropertyComplete(offset + length);
|
|
1543
|
-
},
|
|
1544
|
-
onLiteralValue: (value, offset, length) => {
|
|
1545
|
-
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
|
1546
|
-
ensurePropertyComplete(offset + length);
|
|
1547
|
-
},
|
|
1548
|
-
onSeparator: (sep, offset, length) => {
|
|
1549
|
-
if (currentParent.type === 'property') {
|
|
1550
|
-
if (sep === ':') {
|
|
1551
|
-
currentParent.colonOffset = offset;
|
|
1552
|
-
}
|
|
1553
|
-
else if (sep === ',') {
|
|
1554
|
-
ensurePropertyComplete(offset);
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
},
|
|
1558
|
-
onError: (error, offset, length) => {
|
|
1559
|
-
errors.push({ error, offset, length });
|
|
1560
|
-
}
|
|
1561
|
-
};
|
|
1562
|
-
visit(text, visitor, options);
|
|
1563
|
-
const result = currentParent.children[0];
|
|
1564
|
-
if (result) {
|
|
1565
|
-
delete result.parent;
|
|
1566
|
-
}
|
|
1567
|
-
return result;
|
|
1568
|
-
}
|
|
1569
|
-
/**
|
|
1570
|
-
* Finds the node at the given path in a JSON DOM.
|
|
1571
|
-
*/
|
|
1572
|
-
function findNodeAtLocation(root, path) {
|
|
1573
|
-
if (!root) {
|
|
1574
|
-
return undefined;
|
|
1575
|
-
}
|
|
1576
|
-
let node = root;
|
|
1577
|
-
for (const segment of path) {
|
|
1578
|
-
if (typeof segment === 'string') {
|
|
1579
|
-
if (node.type !== 'object' || !Array.isArray(node.children)) {
|
|
1580
|
-
return undefined;
|
|
1581
|
-
}
|
|
1582
|
-
let found = false;
|
|
1583
|
-
for (const propertyNode of node.children) {
|
|
1584
|
-
if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment) {
|
|
1585
|
-
node = propertyNode.children[1];
|
|
1586
|
-
found = true;
|
|
1587
|
-
break;
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
if (!found) {
|
|
1591
|
-
return undefined;
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
else {
|
|
1595
|
-
const index = segment;
|
|
1596
|
-
if (node.type !== 'array' || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
|
|
1597
|
-
return undefined;
|
|
1598
|
-
}
|
|
1599
|
-
node = node.children[index];
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
return node;
|
|
1603
|
-
}
|
|
1604
|
-
/**
|
|
1605
|
-
* Parses the given text and invokes the visitor functions for each object, array and literal reached.
|
|
1606
|
-
*/
|
|
1607
1312
|
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
1608
1313
|
const _scanner = createScanner(text, false);
|
|
1609
1314
|
function toNoArgVisit(visitFunction) {
|
|
@@ -1619,42 +1324,42 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
1619
1324
|
while (true) {
|
|
1620
1325
|
const token = _scanner.scan();
|
|
1621
1326
|
switch (_scanner.getTokenError()) {
|
|
1622
|
-
case 4
|
|
1623
|
-
handleError(14
|
|
1327
|
+
case 4 :
|
|
1328
|
+
handleError(14 );
|
|
1624
1329
|
break;
|
|
1625
|
-
case 5
|
|
1626
|
-
handleError(15
|
|
1330
|
+
case 5 :
|
|
1331
|
+
handleError(15 );
|
|
1627
1332
|
break;
|
|
1628
|
-
case 3
|
|
1629
|
-
handleError(13
|
|
1333
|
+
case 3 :
|
|
1334
|
+
handleError(13 );
|
|
1630
1335
|
break;
|
|
1631
|
-
case 1
|
|
1336
|
+
case 1 :
|
|
1632
1337
|
if (!disallowComments) {
|
|
1633
|
-
handleError(11
|
|
1338
|
+
handleError(11 );
|
|
1634
1339
|
}
|
|
1635
1340
|
break;
|
|
1636
|
-
case 2
|
|
1637
|
-
handleError(12
|
|
1341
|
+
case 2 :
|
|
1342
|
+
handleError(12 );
|
|
1638
1343
|
break;
|
|
1639
|
-
case 6
|
|
1640
|
-
handleError(16
|
|
1344
|
+
case 6 :
|
|
1345
|
+
handleError(16 );
|
|
1641
1346
|
break;
|
|
1642
1347
|
}
|
|
1643
1348
|
switch (token) {
|
|
1644
|
-
case 12
|
|
1645
|
-
case 13
|
|
1349
|
+
case 12 :
|
|
1350
|
+
case 13 :
|
|
1646
1351
|
if (disallowComments) {
|
|
1647
|
-
handleError(10
|
|
1352
|
+
handleError(10 );
|
|
1648
1353
|
}
|
|
1649
1354
|
else {
|
|
1650
1355
|
onComment();
|
|
1651
1356
|
}
|
|
1652
1357
|
break;
|
|
1653
|
-
case 16
|
|
1654
|
-
handleError(1
|
|
1358
|
+
case 16 :
|
|
1359
|
+
handleError(1 );
|
|
1655
1360
|
break;
|
|
1656
|
-
case 15
|
|
1657
|
-
case 14
|
|
1361
|
+
case 15 :
|
|
1362
|
+
case 14 :
|
|
1658
1363
|
break;
|
|
1659
1364
|
default:
|
|
1660
1365
|
return token;
|
|
@@ -1665,7 +1370,7 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
1665
1370
|
onError(error);
|
|
1666
1371
|
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
1667
1372
|
let token = _scanner.getToken();
|
|
1668
|
-
while (token !== 17
|
|
1373
|
+
while (token !== 17 ) {
|
|
1669
1374
|
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
1670
1375
|
scanNext();
|
|
1671
1376
|
break;
|
|
@@ -1690,28 +1395,28 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
1690
1395
|
}
|
|
1691
1396
|
function parseLiteral() {
|
|
1692
1397
|
switch (_scanner.getToken()) {
|
|
1693
|
-
case 11
|
|
1398
|
+
case 11 : {
|
|
1694
1399
|
let value = 0;
|
|
1695
1400
|
try {
|
|
1696
1401
|
value = JSON.parse(_scanner.getTokenValue());
|
|
1697
1402
|
if (typeof value !== 'number') {
|
|
1698
|
-
handleError(2
|
|
1403
|
+
handleError(2 );
|
|
1699
1404
|
value = 0;
|
|
1700
1405
|
}
|
|
1701
1406
|
}
|
|
1702
1407
|
catch (e) {
|
|
1703
|
-
handleError(2
|
|
1408
|
+
handleError(2 );
|
|
1704
1409
|
}
|
|
1705
1410
|
onLiteralValue(value);
|
|
1706
1411
|
break;
|
|
1707
1412
|
}
|
|
1708
|
-
case 7
|
|
1413
|
+
case 7 :
|
|
1709
1414
|
onLiteralValue(null);
|
|
1710
1415
|
break;
|
|
1711
|
-
case 8
|
|
1416
|
+
case 8 :
|
|
1712
1417
|
onLiteralValue(true);
|
|
1713
1418
|
break;
|
|
1714
|
-
case 9
|
|
1419
|
+
case 9 :
|
|
1715
1420
|
onLiteralValue(false);
|
|
1716
1421
|
break;
|
|
1717
1422
|
default:
|
|
@@ -1721,113 +1426,113 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
1721
1426
|
return true;
|
|
1722
1427
|
}
|
|
1723
1428
|
function parseProperty() {
|
|
1724
|
-
if (_scanner.getToken() !== 10
|
|
1725
|
-
handleError(3
|
|
1429
|
+
if (_scanner.getToken() !== 10 ) {
|
|
1430
|
+
handleError(3 , [], [2 , 5 ]);
|
|
1726
1431
|
return false;
|
|
1727
1432
|
}
|
|
1728
1433
|
parseString(false);
|
|
1729
|
-
if (_scanner.getToken() === 6
|
|
1434
|
+
if (_scanner.getToken() === 6 ) {
|
|
1730
1435
|
onSeparator(':');
|
|
1731
|
-
scanNext();
|
|
1436
|
+
scanNext();
|
|
1732
1437
|
if (!parseValue()) {
|
|
1733
|
-
handleError(4
|
|
1438
|
+
handleError(4 , [], [2 , 5 ]);
|
|
1734
1439
|
}
|
|
1735
1440
|
}
|
|
1736
1441
|
else {
|
|
1737
|
-
handleError(5
|
|
1442
|
+
handleError(5 , [], [2 , 5 ]);
|
|
1738
1443
|
}
|
|
1739
1444
|
return true;
|
|
1740
1445
|
}
|
|
1741
1446
|
function parseObject() {
|
|
1742
1447
|
onObjectBegin();
|
|
1743
|
-
scanNext();
|
|
1448
|
+
scanNext();
|
|
1744
1449
|
let needsComma = false;
|
|
1745
|
-
while (_scanner.getToken() !== 2
|
|
1746
|
-
if (_scanner.getToken() === 5
|
|
1450
|
+
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17 ) {
|
|
1451
|
+
if (_scanner.getToken() === 5 ) {
|
|
1747
1452
|
if (!needsComma) {
|
|
1748
|
-
handleError(4
|
|
1453
|
+
handleError(4 , [], []);
|
|
1749
1454
|
}
|
|
1750
1455
|
onSeparator(',');
|
|
1751
|
-
scanNext();
|
|
1752
|
-
if (_scanner.getToken() === 2
|
|
1456
|
+
scanNext();
|
|
1457
|
+
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
1753
1458
|
break;
|
|
1754
1459
|
}
|
|
1755
1460
|
}
|
|
1756
1461
|
else if (needsComma) {
|
|
1757
|
-
handleError(6
|
|
1462
|
+
handleError(6 , [], []);
|
|
1758
1463
|
}
|
|
1759
1464
|
if (!parseProperty()) {
|
|
1760
|
-
handleError(4
|
|
1465
|
+
handleError(4 , [], [2 , 5 ]);
|
|
1761
1466
|
}
|
|
1762
1467
|
needsComma = true;
|
|
1763
1468
|
}
|
|
1764
1469
|
onObjectEnd();
|
|
1765
|
-
if (_scanner.getToken() !== 2
|
|
1766
|
-
handleError(7
|
|
1470
|
+
if (_scanner.getToken() !== 2 ) {
|
|
1471
|
+
handleError(7 , [2 ], []);
|
|
1767
1472
|
}
|
|
1768
1473
|
else {
|
|
1769
|
-
scanNext();
|
|
1474
|
+
scanNext();
|
|
1770
1475
|
}
|
|
1771
1476
|
return true;
|
|
1772
1477
|
}
|
|
1773
1478
|
function parseArray() {
|
|
1774
1479
|
onArrayBegin();
|
|
1775
|
-
scanNext();
|
|
1480
|
+
scanNext();
|
|
1776
1481
|
let needsComma = false;
|
|
1777
|
-
while (_scanner.getToken() !== 4
|
|
1778
|
-
if (_scanner.getToken() === 5
|
|
1482
|
+
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17 ) {
|
|
1483
|
+
if (_scanner.getToken() === 5 ) {
|
|
1779
1484
|
if (!needsComma) {
|
|
1780
|
-
handleError(4
|
|
1485
|
+
handleError(4 , [], []);
|
|
1781
1486
|
}
|
|
1782
1487
|
onSeparator(',');
|
|
1783
|
-
scanNext();
|
|
1784
|
-
if (_scanner.getToken() === 4
|
|
1488
|
+
scanNext();
|
|
1489
|
+
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
1785
1490
|
break;
|
|
1786
1491
|
}
|
|
1787
1492
|
}
|
|
1788
1493
|
else if (needsComma) {
|
|
1789
|
-
handleError(6
|
|
1494
|
+
handleError(6 , [], []);
|
|
1790
1495
|
}
|
|
1791
1496
|
if (!parseValue()) {
|
|
1792
|
-
handleError(4
|
|
1497
|
+
handleError(4 , [], [4 , 5 ]);
|
|
1793
1498
|
}
|
|
1794
1499
|
needsComma = true;
|
|
1795
1500
|
}
|
|
1796
1501
|
onArrayEnd();
|
|
1797
|
-
if (_scanner.getToken() !== 4
|
|
1798
|
-
handleError(8
|
|
1502
|
+
if (_scanner.getToken() !== 4 ) {
|
|
1503
|
+
handleError(8 , [4 ], []);
|
|
1799
1504
|
}
|
|
1800
1505
|
else {
|
|
1801
|
-
scanNext();
|
|
1506
|
+
scanNext();
|
|
1802
1507
|
}
|
|
1803
1508
|
return true;
|
|
1804
1509
|
}
|
|
1805
1510
|
function parseValue() {
|
|
1806
1511
|
switch (_scanner.getToken()) {
|
|
1807
|
-
case 3
|
|
1512
|
+
case 3 :
|
|
1808
1513
|
return parseArray();
|
|
1809
|
-
case 1
|
|
1514
|
+
case 1 :
|
|
1810
1515
|
return parseObject();
|
|
1811
|
-
case 10
|
|
1516
|
+
case 10 :
|
|
1812
1517
|
return parseString(true);
|
|
1813
1518
|
default:
|
|
1814
1519
|
return parseLiteral();
|
|
1815
1520
|
}
|
|
1816
1521
|
}
|
|
1817
1522
|
scanNext();
|
|
1818
|
-
if (_scanner.getToken() === 17
|
|
1523
|
+
if (_scanner.getToken() === 17 ) {
|
|
1819
1524
|
if (options.allowEmptyContent) {
|
|
1820
1525
|
return true;
|
|
1821
1526
|
}
|
|
1822
|
-
handleError(4
|
|
1527
|
+
handleError(4 , [], []);
|
|
1823
1528
|
return false;
|
|
1824
1529
|
}
|
|
1825
1530
|
if (!parseValue()) {
|
|
1826
|
-
handleError(4
|
|
1531
|
+
handleError(4 , [], []);
|
|
1827
1532
|
return false;
|
|
1828
1533
|
}
|
|
1829
|
-
if (_scanner.getToken() !== 17
|
|
1830
|
-
handleError(9
|
|
1534
|
+
if (_scanner.getToken() !== 17 ) {
|
|
1535
|
+
handleError(9 , [], []);
|
|
1831
1536
|
}
|
|
1832
1537
|
return true;
|
|
1833
1538
|
}
|
|
@@ -1848,11 +1553,6 @@ function getNodeType(value) {
|
|
|
1848
1553
|
default: return 'null';
|
|
1849
1554
|
}
|
|
1850
1555
|
}
|
|
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
1556
|
var _a$1, _b$1;
|
|
1857
1557
|
class StringIterator {
|
|
1858
1558
|
constructor() {
|
|
@@ -1894,12 +1594,11 @@ class ConfigKeysIterator {
|
|
|
1894
1594
|
return this._to < this._value.length;
|
|
1895
1595
|
}
|
|
1896
1596
|
next() {
|
|
1897
|
-
// this._data = key.split(/[\\/]/).filter(s => !!s);
|
|
1898
1597
|
this._from = this._to;
|
|
1899
1598
|
let justSeps = true;
|
|
1900
1599
|
for (; this._to < this._value.length; this._to++) {
|
|
1901
1600
|
const ch = this._value.charCodeAt(this._to);
|
|
1902
|
-
if (ch === 46
|
|
1601
|
+
if (ch === 46 ) {
|
|
1903
1602
|
if (justSeps) {
|
|
1904
1603
|
this._from++;
|
|
1905
1604
|
}
|
|
@@ -1934,7 +1633,7 @@ class PathIterator {
|
|
|
1934
1633
|
this._valueLen = key.length;
|
|
1935
1634
|
for (let pos = key.length - 1; pos >= 0; pos--, this._valueLen--) {
|
|
1936
1635
|
const ch = this._value.charCodeAt(pos);
|
|
1937
|
-
if (!((ch === 47
|
|
1636
|
+
if (!((ch === 47 || this._splitOnBackslash && ch === 92) )) {
|
|
1938
1637
|
break;
|
|
1939
1638
|
}
|
|
1940
1639
|
}
|
|
@@ -1944,12 +1643,11 @@ class PathIterator {
|
|
|
1944
1643
|
return this._to < this._valueLen;
|
|
1945
1644
|
}
|
|
1946
1645
|
next() {
|
|
1947
|
-
// this._data = key.split(/[\\/]/).filter(s => !!s);
|
|
1948
1646
|
this._from = this._to;
|
|
1949
1647
|
let justSeps = true;
|
|
1950
1648
|
for (; this._to < this._valueLen; this._to++) {
|
|
1951
1649
|
const ch = this._value.charCodeAt(this._to);
|
|
1952
|
-
if (ch === 47
|
|
1650
|
+
if (ch === 47 || this._splitOnBackslash && ch === 92 ) {
|
|
1953
1651
|
if (justSeps) {
|
|
1954
1652
|
this._from++;
|
|
1955
1653
|
}
|
|
@@ -1983,31 +1681,31 @@ class UriIterator {
|
|
|
1983
1681
|
this._value = key;
|
|
1984
1682
|
this._states = [];
|
|
1985
1683
|
if (this._value.scheme) {
|
|
1986
|
-
this._states.push(1
|
|
1684
|
+
this._states.push(1 );
|
|
1987
1685
|
}
|
|
1988
1686
|
if (this._value.authority) {
|
|
1989
|
-
this._states.push(2
|
|
1687
|
+
this._states.push(2 );
|
|
1990
1688
|
}
|
|
1991
1689
|
if (this._value.path) {
|
|
1992
|
-
this._pathIterator = (
|
|
1690
|
+
this._pathIterator = ( (new PathIterator(false, !this._ignorePathCasing(key))));
|
|
1993
1691
|
this._pathIterator.reset(key.path);
|
|
1994
1692
|
if (this._pathIterator.value()) {
|
|
1995
|
-
this._states.push(3
|
|
1693
|
+
this._states.push(3 );
|
|
1996
1694
|
}
|
|
1997
1695
|
}
|
|
1998
1696
|
if (!this._ignoreQueryAndFragment(key)) {
|
|
1999
1697
|
if (this._value.query) {
|
|
2000
|
-
this._states.push(4
|
|
1698
|
+
this._states.push(4 );
|
|
2001
1699
|
}
|
|
2002
1700
|
if (this._value.fragment) {
|
|
2003
|
-
this._states.push(5
|
|
1701
|
+
this._states.push(5 );
|
|
2004
1702
|
}
|
|
2005
1703
|
}
|
|
2006
1704
|
this._stateIdx = 0;
|
|
2007
1705
|
return this;
|
|
2008
1706
|
}
|
|
2009
1707
|
next() {
|
|
2010
|
-
if (this._states[this._stateIdx] === 3
|
|
1708
|
+
if (this._states[this._stateIdx] === 3 && this._pathIterator.hasNext()) {
|
|
2011
1709
|
this._pathIterator.next();
|
|
2012
1710
|
}
|
|
2013
1711
|
else {
|
|
@@ -2016,41 +1714,41 @@ class UriIterator {
|
|
|
2016
1714
|
return this;
|
|
2017
1715
|
}
|
|
2018
1716
|
hasNext() {
|
|
2019
|
-
return (this._states[this._stateIdx] === 3
|
|
1717
|
+
return (this._states[this._stateIdx] === 3 && this._pathIterator.hasNext())
|
|
2020
1718
|
|| this._stateIdx < this._states.length - 1;
|
|
2021
1719
|
}
|
|
2022
1720
|
cmp(a) {
|
|
2023
|
-
if (this._states[this._stateIdx] === 1
|
|
1721
|
+
if (this._states[this._stateIdx] === 1 ) {
|
|
2024
1722
|
return compareIgnoreCase(a, this._value.scheme);
|
|
2025
1723
|
}
|
|
2026
|
-
else if (this._states[this._stateIdx] === 2
|
|
1724
|
+
else if (this._states[this._stateIdx] === 2 ) {
|
|
2027
1725
|
return compareIgnoreCase(a, this._value.authority);
|
|
2028
1726
|
}
|
|
2029
|
-
else if (this._states[this._stateIdx] === 3
|
|
1727
|
+
else if (this._states[this._stateIdx] === 3 ) {
|
|
2030
1728
|
return this._pathIterator.cmp(a);
|
|
2031
1729
|
}
|
|
2032
|
-
else if (this._states[this._stateIdx] === 4
|
|
1730
|
+
else if (this._states[this._stateIdx] === 4 ) {
|
|
2033
1731
|
return compare$1(a, this._value.query);
|
|
2034
1732
|
}
|
|
2035
|
-
else if (this._states[this._stateIdx] === 5
|
|
1733
|
+
else if (this._states[this._stateIdx] === 5 ) {
|
|
2036
1734
|
return compare$1(a, this._value.fragment);
|
|
2037
1735
|
}
|
|
2038
1736
|
throw new Error();
|
|
2039
1737
|
}
|
|
2040
1738
|
value() {
|
|
2041
|
-
if (this._states[this._stateIdx] === 1
|
|
1739
|
+
if (this._states[this._stateIdx] === 1 ) {
|
|
2042
1740
|
return this._value.scheme;
|
|
2043
1741
|
}
|
|
2044
|
-
else if (this._states[this._stateIdx] === 2
|
|
1742
|
+
else if (this._states[this._stateIdx] === 2 ) {
|
|
2045
1743
|
return this._value.authority;
|
|
2046
1744
|
}
|
|
2047
|
-
else if (this._states[this._stateIdx] === 3
|
|
1745
|
+
else if (this._states[this._stateIdx] === 3 ) {
|
|
2048
1746
|
return this._pathIterator.value();
|
|
2049
1747
|
}
|
|
2050
|
-
else if (this._states[this._stateIdx] === 4
|
|
1748
|
+
else if (this._states[this._stateIdx] === 4 ) {
|
|
2051
1749
|
return this._value.query;
|
|
2052
1750
|
}
|
|
2053
|
-
else if (this._states[this._stateIdx] === 5
|
|
1751
|
+
else if (this._states[this._stateIdx] === 5 ) {
|
|
2054
1752
|
return this._value.fragment;
|
|
2055
1753
|
}
|
|
2056
1754
|
throw new Error();
|
|
@@ -2097,16 +1795,24 @@ class TernarySearchTree {
|
|
|
2097
1795
|
this._iter = segments;
|
|
2098
1796
|
}
|
|
2099
1797
|
static forUris(ignorePathCasing = () => false, ignoreQueryAndFragment = () => false) {
|
|
2100
|
-
return (
|
|
1798
|
+
return (
|
|
1799
|
+
(new TernarySearchTree( (new UriIterator(ignorePathCasing, ignoreQueryAndFragment))))
|
|
1800
|
+
);
|
|
2101
1801
|
}
|
|
2102
1802
|
static forPaths(ignorePathCasing = false) {
|
|
2103
|
-
return (
|
|
1803
|
+
return (
|
|
1804
|
+
(new TernarySearchTree( (new PathIterator(undefined, !ignorePathCasing))))
|
|
1805
|
+
);
|
|
2104
1806
|
}
|
|
2105
1807
|
static forStrings() {
|
|
2106
|
-
return (
|
|
1808
|
+
return (
|
|
1809
|
+
(new TernarySearchTree( (new StringIterator())))
|
|
1810
|
+
);
|
|
2107
1811
|
}
|
|
2108
1812
|
static forConfigKeys() {
|
|
2109
|
-
return (
|
|
1813
|
+
return (
|
|
1814
|
+
(new TernarySearchTree( (new ConfigKeysIterator())))
|
|
1815
|
+
);
|
|
2110
1816
|
}
|
|
2111
1817
|
clear() {
|
|
2112
1818
|
this._root = undefined;
|
|
@@ -2131,90 +1837,78 @@ class TernarySearchTree {
|
|
|
2131
1837
|
const iter = this._iter.reset(key);
|
|
2132
1838
|
let node;
|
|
2133
1839
|
if (!this._root) {
|
|
2134
|
-
this._root = (
|
|
1840
|
+
this._root = ( (new TernarySearchTreeNode()));
|
|
2135
1841
|
this._root.segment = iter.value();
|
|
2136
1842
|
}
|
|
2137
1843
|
const stack = [];
|
|
2138
|
-
// find insert_node
|
|
2139
1844
|
node = this._root;
|
|
2140
1845
|
while (true) {
|
|
2141
1846
|
const val = iter.cmp(node.segment);
|
|
2142
1847
|
if (val > 0) {
|
|
2143
|
-
// left
|
|
2144
1848
|
if (!node.left) {
|
|
2145
|
-
node.left = (
|
|
1849
|
+
node.left = ( (new TernarySearchTreeNode()));
|
|
2146
1850
|
node.left.segment = iter.value();
|
|
2147
1851
|
}
|
|
2148
|
-
stack.push([-1
|
|
1852
|
+
stack.push([-1 , node]);
|
|
2149
1853
|
node = node.left;
|
|
2150
1854
|
}
|
|
2151
1855
|
else if (val < 0) {
|
|
2152
|
-
// right
|
|
2153
1856
|
if (!node.right) {
|
|
2154
|
-
node.right = (
|
|
1857
|
+
node.right = ( (new TernarySearchTreeNode()));
|
|
2155
1858
|
node.right.segment = iter.value();
|
|
2156
1859
|
}
|
|
2157
|
-
stack.push([1
|
|
1860
|
+
stack.push([1 , node]);
|
|
2158
1861
|
node = node.right;
|
|
2159
1862
|
}
|
|
2160
1863
|
else if (iter.hasNext()) {
|
|
2161
|
-
// mid
|
|
2162
1864
|
iter.next();
|
|
2163
1865
|
if (!node.mid) {
|
|
2164
|
-
node.mid = (
|
|
1866
|
+
node.mid = ( (new TernarySearchTreeNode()));
|
|
2165
1867
|
node.mid.segment = iter.value();
|
|
2166
1868
|
}
|
|
2167
|
-
stack.push([0
|
|
1869
|
+
stack.push([0 , node]);
|
|
2168
1870
|
node = node.mid;
|
|
2169
1871
|
}
|
|
2170
1872
|
else {
|
|
2171
1873
|
break;
|
|
2172
1874
|
}
|
|
2173
1875
|
}
|
|
2174
|
-
// set value
|
|
2175
1876
|
const oldElement = node.value;
|
|
2176
1877
|
node.value = element;
|
|
2177
1878
|
node.key = key;
|
|
2178
|
-
// balance
|
|
2179
1879
|
for (let i = stack.length - 1; i >= 0; i--) {
|
|
2180
1880
|
const node = stack[i][1];
|
|
2181
1881
|
node.updateHeight();
|
|
2182
1882
|
const bf = node.balanceFactor();
|
|
2183
1883
|
if (bf < -1 || bf > 1) {
|
|
2184
|
-
// needs rotate
|
|
2185
1884
|
const d1 = stack[i][0];
|
|
2186
1885
|
const d2 = stack[i + 1][0];
|
|
2187
|
-
if (d1 === 1
|
|
2188
|
-
//right, right -> rotate left
|
|
1886
|
+
if (d1 === 1 && d2 === 1 ) {
|
|
2189
1887
|
stack[i][1] = node.rotateLeft();
|
|
2190
1888
|
}
|
|
2191
|
-
else if (d1 === -1
|
|
2192
|
-
// left, left -> rotate right
|
|
1889
|
+
else if (d1 === -1 && d2 === -1 ) {
|
|
2193
1890
|
stack[i][1] = node.rotateRight();
|
|
2194
1891
|
}
|
|
2195
|
-
else if (d1 === 1
|
|
2196
|
-
// right, left -> double rotate right, left
|
|
1892
|
+
else if (d1 === 1 && d2 === -1 ) {
|
|
2197
1893
|
node.right = stack[i + 1][1] = stack[i + 1][1].rotateRight();
|
|
2198
1894
|
stack[i][1] = node.rotateLeft();
|
|
2199
1895
|
}
|
|
2200
|
-
else if (d1 === -1
|
|
2201
|
-
// left, right -> double rotate left, right
|
|
1896
|
+
else if (d1 === -1 && d2 === 1 ) {
|
|
2202
1897
|
node.left = stack[i + 1][1] = stack[i + 1][1].rotateLeft();
|
|
2203
1898
|
stack[i][1] = node.rotateRight();
|
|
2204
1899
|
}
|
|
2205
1900
|
else {
|
|
2206
1901
|
throw new Error();
|
|
2207
1902
|
}
|
|
2208
|
-
// patch path to parent
|
|
2209
1903
|
if (i > 0) {
|
|
2210
1904
|
switch (stack[i - 1][0]) {
|
|
2211
|
-
case -1
|
|
1905
|
+
case -1 :
|
|
2212
1906
|
stack[i - 1][1].left = stack[i][1];
|
|
2213
1907
|
break;
|
|
2214
|
-
case 1
|
|
1908
|
+
case 1 :
|
|
2215
1909
|
stack[i - 1][1].right = stack[i][1];
|
|
2216
1910
|
break;
|
|
2217
|
-
case 0
|
|
1911
|
+
case 0 :
|
|
2218
1912
|
stack[i - 1][1].mid = stack[i][1];
|
|
2219
1913
|
break;
|
|
2220
1914
|
}
|
|
@@ -2235,15 +1929,12 @@ class TernarySearchTree {
|
|
|
2235
1929
|
while (node) {
|
|
2236
1930
|
const val = iter.cmp(node.segment);
|
|
2237
1931
|
if (val > 0) {
|
|
2238
|
-
// left
|
|
2239
1932
|
node = node.left;
|
|
2240
1933
|
}
|
|
2241
1934
|
else if (val < 0) {
|
|
2242
|
-
// right
|
|
2243
1935
|
node = node.right;
|
|
2244
1936
|
}
|
|
2245
1937
|
else if (iter.hasNext()) {
|
|
2246
|
-
// mid
|
|
2247
1938
|
iter.next();
|
|
2248
1939
|
node = node.mid;
|
|
2249
1940
|
}
|
|
@@ -2267,23 +1958,19 @@ class TernarySearchTree {
|
|
|
2267
1958
|
const iter = this._iter.reset(key);
|
|
2268
1959
|
const stack = [];
|
|
2269
1960
|
let node = this._root;
|
|
2270
|
-
// find node
|
|
2271
1961
|
while (node) {
|
|
2272
1962
|
const val = iter.cmp(node.segment);
|
|
2273
1963
|
if (val > 0) {
|
|
2274
|
-
|
|
2275
|
-
stack.push([-1 /* Dir.Left */, node]);
|
|
1964
|
+
stack.push([-1 , node]);
|
|
2276
1965
|
node = node.left;
|
|
2277
1966
|
}
|
|
2278
1967
|
else if (val < 0) {
|
|
2279
|
-
|
|
2280
|
-
stack.push([1 /* Dir.Right */, node]);
|
|
1968
|
+
stack.push([1 , node]);
|
|
2281
1969
|
node = node.right;
|
|
2282
1970
|
}
|
|
2283
1971
|
else if (iter.hasNext()) {
|
|
2284
|
-
// mid
|
|
2285
1972
|
iter.next();
|
|
2286
|
-
stack.push([0
|
|
1973
|
+
stack.push([0 , node]);
|
|
2287
1974
|
node = node.mid;
|
|
2288
1975
|
}
|
|
2289
1976
|
else {
|
|
@@ -2291,25 +1978,20 @@ class TernarySearchTree {
|
|
|
2291
1978
|
}
|
|
2292
1979
|
}
|
|
2293
1980
|
if (!node) {
|
|
2294
|
-
// node not found
|
|
2295
1981
|
return;
|
|
2296
1982
|
}
|
|
2297
1983
|
if (superStr) {
|
|
2298
|
-
// removing children, reset height
|
|
2299
1984
|
node.left = undefined;
|
|
2300
1985
|
node.mid = undefined;
|
|
2301
1986
|
node.right = undefined;
|
|
2302
1987
|
node.height = 1;
|
|
2303
1988
|
}
|
|
2304
1989
|
else {
|
|
2305
|
-
// removing element
|
|
2306
1990
|
node.key = undefined;
|
|
2307
1991
|
node.value = undefined;
|
|
2308
1992
|
}
|
|
2309
|
-
// BST node removal
|
|
2310
1993
|
if (!node.mid && !node.value) {
|
|
2311
1994
|
if (node.left && node.right) {
|
|
2312
|
-
// full node
|
|
2313
1995
|
const min = this._min(node.right);
|
|
2314
1996
|
const { key, value, segment } = min;
|
|
2315
1997
|
this._delete(min.key, false);
|
|
@@ -2318,18 +2000,17 @@ class TernarySearchTree {
|
|
|
2318
2000
|
node.segment = segment;
|
|
2319
2001
|
}
|
|
2320
2002
|
else {
|
|
2321
|
-
// empty or half empty
|
|
2322
2003
|
const newChild = node.left ?? node.right;
|
|
2323
2004
|
if (stack.length > 0) {
|
|
2324
2005
|
const [dir, parent] = stack[stack.length - 1];
|
|
2325
2006
|
switch (dir) {
|
|
2326
|
-
case -1
|
|
2007
|
+
case -1 :
|
|
2327
2008
|
parent.left = newChild;
|
|
2328
2009
|
break;
|
|
2329
|
-
case 0
|
|
2010
|
+
case 0 :
|
|
2330
2011
|
parent.mid = newChild;
|
|
2331
2012
|
break;
|
|
2332
|
-
case 1
|
|
2013
|
+
case 1 :
|
|
2333
2014
|
parent.right = newChild;
|
|
2334
2015
|
break;
|
|
2335
2016
|
}
|
|
@@ -2339,45 +2020,37 @@ class TernarySearchTree {
|
|
|
2339
2020
|
}
|
|
2340
2021
|
}
|
|
2341
2022
|
}
|
|
2342
|
-
// AVL balance
|
|
2343
2023
|
for (let i = stack.length - 1; i >= 0; i--) {
|
|
2344
2024
|
const node = stack[i][1];
|
|
2345
2025
|
node.updateHeight();
|
|
2346
2026
|
const bf = node.balanceFactor();
|
|
2347
2027
|
if (bf > 1) {
|
|
2348
|
-
// right heavy
|
|
2349
2028
|
if (node.right.balanceFactor() >= 0) {
|
|
2350
|
-
// right, right -> rotate left
|
|
2351
2029
|
stack[i][1] = node.rotateLeft();
|
|
2352
2030
|
}
|
|
2353
2031
|
else {
|
|
2354
|
-
// right, left -> double rotate
|
|
2355
2032
|
node.right = node.right.rotateRight();
|
|
2356
2033
|
stack[i][1] = node.rotateLeft();
|
|
2357
2034
|
}
|
|
2358
2035
|
}
|
|
2359
2036
|
else if (bf < -1) {
|
|
2360
|
-
// left heavy
|
|
2361
2037
|
if (node.left.balanceFactor() <= 0) {
|
|
2362
|
-
// left, left -> rotate right
|
|
2363
2038
|
stack[i][1] = node.rotateRight();
|
|
2364
2039
|
}
|
|
2365
2040
|
else {
|
|
2366
|
-
// left, right -> double rotate
|
|
2367
2041
|
node.left = node.left.rotateLeft();
|
|
2368
2042
|
stack[i][1] = node.rotateRight();
|
|
2369
2043
|
}
|
|
2370
2044
|
}
|
|
2371
|
-
// patch path to parent
|
|
2372
2045
|
if (i > 0) {
|
|
2373
2046
|
switch (stack[i - 1][0]) {
|
|
2374
|
-
case -1
|
|
2047
|
+
case -1 :
|
|
2375
2048
|
stack[i - 1][1].left = stack[i][1];
|
|
2376
2049
|
break;
|
|
2377
|
-
case 1
|
|
2050
|
+
case 1 :
|
|
2378
2051
|
stack[i - 1][1].right = stack[i][1];
|
|
2379
2052
|
break;
|
|
2380
|
-
case 0
|
|
2053
|
+
case 0 :
|
|
2381
2054
|
stack[i - 1][1].mid = stack[i][1];
|
|
2382
2055
|
break;
|
|
2383
2056
|
}
|
|
@@ -2400,15 +2073,12 @@ class TernarySearchTree {
|
|
|
2400
2073
|
while (node) {
|
|
2401
2074
|
const val = iter.cmp(node.segment);
|
|
2402
2075
|
if (val > 0) {
|
|
2403
|
-
// left
|
|
2404
2076
|
node = node.left;
|
|
2405
2077
|
}
|
|
2406
2078
|
else if (val < 0) {
|
|
2407
|
-
// right
|
|
2408
2079
|
node = node.right;
|
|
2409
2080
|
}
|
|
2410
2081
|
else if (iter.hasNext()) {
|
|
2411
|
-
// mid
|
|
2412
2082
|
iter.next();
|
|
2413
2083
|
candidate = node.value || candidate;
|
|
2414
2084
|
node = node.mid;
|
|
@@ -2425,20 +2095,16 @@ class TernarySearchTree {
|
|
|
2425
2095
|
while (node) {
|
|
2426
2096
|
const val = iter.cmp(node.segment);
|
|
2427
2097
|
if (val > 0) {
|
|
2428
|
-
// left
|
|
2429
2098
|
node = node.left;
|
|
2430
2099
|
}
|
|
2431
2100
|
else if (val < 0) {
|
|
2432
|
-
// right
|
|
2433
2101
|
node = node.right;
|
|
2434
2102
|
}
|
|
2435
2103
|
else if (iter.hasNext()) {
|
|
2436
|
-
// mid
|
|
2437
2104
|
iter.next();
|
|
2438
2105
|
node = node.mid;
|
|
2439
2106
|
}
|
|
2440
2107
|
else {
|
|
2441
|
-
// collect
|
|
2442
2108
|
if (!node.mid) {
|
|
2443
2109
|
return undefined;
|
|
2444
2110
|
}
|
|
@@ -2463,7 +2129,6 @@ class TernarySearchTree {
|
|
|
2463
2129
|
return result[Symbol.iterator]();
|
|
2464
2130
|
}
|
|
2465
2131
|
_dfsEntries(node, bucket) {
|
|
2466
|
-
// DFS
|
|
2467
2132
|
if (!node) {
|
|
2468
2133
|
return;
|
|
2469
2134
|
}
|
|
@@ -2480,7 +2145,6 @@ class TernarySearchTree {
|
|
|
2480
2145
|
this._dfsEntries(node.right, bucket);
|
|
2481
2146
|
}
|
|
2482
2147
|
}
|
|
2483
|
-
// for debug/testing
|
|
2484
2148
|
_isBalanced() {
|
|
2485
2149
|
const nodeIsBalanced = (node) => {
|
|
2486
2150
|
if (!node) {
|
|
@@ -2505,16 +2169,16 @@ class ResourceMap {
|
|
|
2505
2169
|
constructor(mapOrKeyFn, toKey) {
|
|
2506
2170
|
this[_a$1] = 'ResourceMap';
|
|
2507
2171
|
if (mapOrKeyFn instanceof ResourceMap) {
|
|
2508
|
-
this.map = (
|
|
2172
|
+
this.map = ( (new Map(mapOrKeyFn.map)));
|
|
2509
2173
|
this.toKey = toKey ?? ResourceMap.defaultToKey;
|
|
2510
2174
|
}
|
|
2511
2175
|
else {
|
|
2512
|
-
this.map = (
|
|
2176
|
+
this.map = ( (new Map()));
|
|
2513
2177
|
this.toKey = mapOrKeyFn ?? ResourceMap.defaultToKey;
|
|
2514
2178
|
}
|
|
2515
2179
|
}
|
|
2516
2180
|
set(resource, value) {
|
|
2517
|
-
this.map.set(this.toKey(resource), (
|
|
2181
|
+
this.map.set(this.toKey(resource), ( (new ResourceMapEntry(resource, value))));
|
|
2518
2182
|
return this;
|
|
2519
2183
|
}
|
|
2520
2184
|
get(resource) {
|
|
@@ -2541,17 +2205,17 @@ class ResourceMap {
|
|
|
2541
2205
|
}
|
|
2542
2206
|
}
|
|
2543
2207
|
*values() {
|
|
2544
|
-
for (const entry of (
|
|
2208
|
+
for (const entry of ( (this.map.values()))) {
|
|
2545
2209
|
yield entry.value;
|
|
2546
2210
|
}
|
|
2547
2211
|
}
|
|
2548
2212
|
*keys() {
|
|
2549
|
-
for (const entry of (
|
|
2213
|
+
for (const entry of ( (this.map.values()))) {
|
|
2550
2214
|
yield entry.uri;
|
|
2551
2215
|
}
|
|
2552
2216
|
}
|
|
2553
2217
|
*entries() {
|
|
2554
|
-
for (const entry of (
|
|
2218
|
+
for (const entry of ( (this.map.values()))) {
|
|
2555
2219
|
yield [entry.uri, entry.value];
|
|
2556
2220
|
}
|
|
2557
2221
|
}
|
|
@@ -2561,15 +2225,15 @@ class ResourceMap {
|
|
|
2561
2225
|
}
|
|
2562
2226
|
}
|
|
2563
2227
|
}
|
|
2564
|
-
ResourceMap.defaultToKey = (resource) => (
|
|
2228
|
+
ResourceMap.defaultToKey = (resource) => ( (resource.toString()));
|
|
2565
2229
|
class ResourceSet {
|
|
2566
2230
|
constructor(entriesOrKey, toKey) {
|
|
2567
2231
|
this[_b$1] = 'ResourceSet';
|
|
2568
2232
|
if (!entriesOrKey || typeof entriesOrKey === 'function') {
|
|
2569
|
-
this._map = (
|
|
2233
|
+
this._map = ( (new ResourceMap(entriesOrKey)));
|
|
2570
2234
|
}
|
|
2571
2235
|
else {
|
|
2572
|
-
this._map = (
|
|
2236
|
+
this._map = ( (new ResourceMap(toKey)));
|
|
2573
2237
|
entriesOrKey.forEach(this.add, this);
|
|
2574
2238
|
}
|
|
2575
2239
|
}
|
|
@@ -2596,27 +2260,28 @@ class ResourceSet {
|
|
|
2596
2260
|
return this._map.entries();
|
|
2597
2261
|
}
|
|
2598
2262
|
keys() {
|
|
2599
|
-
return (
|
|
2263
|
+
return (
|
|
2264
|
+
(this._map.keys())
|
|
2265
|
+
);
|
|
2600
2266
|
}
|
|
2601
2267
|
values() {
|
|
2602
|
-
return (
|
|
2268
|
+
return (
|
|
2269
|
+
(this._map.keys())
|
|
2270
|
+
);
|
|
2603
2271
|
}
|
|
2604
2272
|
[(_b$1 = Symbol.toStringTag, Symbol.iterator)]() {
|
|
2605
|
-
return (
|
|
2273
|
+
return (
|
|
2274
|
+
(this.keys())
|
|
2275
|
+
);
|
|
2606
2276
|
}
|
|
2607
2277
|
}
|
|
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
2278
|
class ConfigurationModel {
|
|
2614
2279
|
constructor(_contents = {}, _keys = [], _overrides = []) {
|
|
2615
2280
|
this._contents = _contents;
|
|
2616
2281
|
this._keys = _keys;
|
|
2617
2282
|
this._overrides = _overrides;
|
|
2618
2283
|
this.frozen = false;
|
|
2619
|
-
this.overrideConfigurations = (
|
|
2284
|
+
this.overrideConfigurations = ( (new Map()));
|
|
2620
2285
|
}
|
|
2621
2286
|
get contents() {
|
|
2622
2287
|
return this.checkAndFreeze(this._contents);
|
|
@@ -2628,7 +2293,7 @@ class ConfigurationModel {
|
|
|
2628
2293
|
return this.checkAndFreeze(this._keys);
|
|
2629
2294
|
}
|
|
2630
2295
|
isEmpty() {
|
|
2631
|
-
return this._keys.length === 0 && (
|
|
2296
|
+
return this._keys.length === 0 && ( (Object.keys(this._contents))).length === 0 && this._overrides.length === 0;
|
|
2632
2297
|
}
|
|
2633
2298
|
isFrozen() {
|
|
2634
2299
|
return this.frozen;
|
|
@@ -2692,32 +2357,29 @@ class ConfigurationModel {
|
|
|
2692
2357
|
}
|
|
2693
2358
|
}
|
|
2694
2359
|
}
|
|
2695
|
-
return (
|
|
2360
|
+
return (
|
|
2361
|
+
(new ConfigurationModel(contents, keys, overrides))
|
|
2362
|
+
);
|
|
2696
2363
|
}
|
|
2697
2364
|
freeze() {
|
|
2698
2365
|
this.frozen = true;
|
|
2699
2366
|
return this;
|
|
2700
2367
|
}
|
|
2701
2368
|
clone() {
|
|
2702
|
-
return (
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
deepClone(this.overrides)
|
|
2706
|
-
));
|
|
2369
|
+
return (
|
|
2370
|
+
(new ConfigurationModel(deepClone(this.contents), [...this.keys], deepClone(this.overrides)))
|
|
2371
|
+
);
|
|
2707
2372
|
}
|
|
2708
2373
|
createOverrideConfigurationModel(identifier) {
|
|
2709
2374
|
const overrideContents = this.getContentsForOverrideIdentifer(identifier);
|
|
2710
|
-
if (!overrideContents || typeof overrideContents !== 'object' || !(
|
|
2711
|
-
// If there are no valid overrides, return self
|
|
2375
|
+
if (!overrideContents || typeof overrideContents !== 'object' || !( (Object.keys(overrideContents))).length) {
|
|
2712
2376
|
return this;
|
|
2713
2377
|
}
|
|
2714
2378
|
const contents = {};
|
|
2715
|
-
for (const key of distinct([...(
|
|
2379
|
+
for (const key of distinct([...( (Object.keys(this.contents))), ...( (Object.keys(overrideContents)))])) {
|
|
2716
2380
|
let contentsForKey = this.contents[key];
|
|
2717
2381
|
const overrideContentsForKey = overrideContents[key];
|
|
2718
|
-
// If there are override contents for the key, clone and merge otherwise use base contents
|
|
2719
2382
|
if (overrideContentsForKey) {
|
|
2720
|
-
// Clone and merge only if base contents and override contents are of type object otherwise just override
|
|
2721
2383
|
if (typeof contentsForKey === 'object' && typeof overrideContentsForKey === 'object') {
|
|
2722
2384
|
contentsForKey = deepClone(contentsForKey);
|
|
2723
2385
|
this.mergeContents(contentsForKey, overrideContentsForKey);
|
|
@@ -2728,10 +2390,12 @@ class ConfigurationModel {
|
|
|
2728
2390
|
}
|
|
2729
2391
|
contents[key] = contentsForKey;
|
|
2730
2392
|
}
|
|
2731
|
-
return (
|
|
2393
|
+
return (
|
|
2394
|
+
(new ConfigurationModel(contents, this.keys, this.overrides))
|
|
2395
|
+
);
|
|
2732
2396
|
}
|
|
2733
2397
|
mergeContents(source, target) {
|
|
2734
|
-
for (const key of (
|
|
2398
|
+
for (const key of ( (Object.keys(target)))) {
|
|
2735
2399
|
if (key in source) {
|
|
2736
2400
|
if (isObject(source[key]) && isObject(target[key])) {
|
|
2737
2401
|
this.mergeContents(source[key], target[key]);
|
|
@@ -2768,7 +2432,6 @@ class ConfigurationModel {
|
|
|
2768
2432
|
mergeContents(override.contents);
|
|
2769
2433
|
}
|
|
2770
2434
|
}
|
|
2771
|
-
// Merge contents of the identifier only at the end to take precedence.
|
|
2772
2435
|
mergeContents(contentsForIdentifierOnly);
|
|
2773
2436
|
return contents;
|
|
2774
2437
|
}
|
|
@@ -2779,7 +2442,6 @@ class ConfigurationModel {
|
|
|
2779
2442
|
keys: this.keys
|
|
2780
2443
|
};
|
|
2781
2444
|
}
|
|
2782
|
-
// Update methods
|
|
2783
2445
|
setValue(key, value) {
|
|
2784
2446
|
this.addKey(key);
|
|
2785
2447
|
addToValueTree(this.contents, key, value, e => { throw new Error(e); });
|
|
@@ -2816,7 +2478,7 @@ class ConfigurationModelParser {
|
|
|
2816
2478
|
this._parseErrors = [];
|
|
2817
2479
|
}
|
|
2818
2480
|
get configurationModel() {
|
|
2819
|
-
return this._configurationModel || (
|
|
2481
|
+
return this._configurationModel || ( (new ConfigurationModel()));
|
|
2820
2482
|
}
|
|
2821
2483
|
get restrictedConfigurations() {
|
|
2822
2484
|
return this._restrictedConfigurations;
|
|
@@ -2838,7 +2500,7 @@ class ConfigurationModelParser {
|
|
|
2838
2500
|
parseRaw(raw, options) {
|
|
2839
2501
|
this._raw = raw;
|
|
2840
2502
|
const { contents, keys, overrides, restricted } = this.doParseRaw(raw, options);
|
|
2841
|
-
this._configurationModel = (
|
|
2503
|
+
this._configurationModel = ( (new ConfigurationModel(contents, keys, overrides)));
|
|
2842
2504
|
this._restrictedConfigurations = restricted || [];
|
|
2843
2505
|
}
|
|
2844
2506
|
doParseContent(content) {
|
|
@@ -2895,11 +2557,11 @@ class ConfigurationModelParser {
|
|
|
2895
2557
|
return raw;
|
|
2896
2558
|
}
|
|
2897
2559
|
doParseRaw(raw, options) {
|
|
2898
|
-
const configurationProperties = (
|
|
2560
|
+
const configurationProperties = ( (Registry.as(Extensions$2.Configuration))).getConfigurationProperties();
|
|
2899
2561
|
const filtered = this.filter(raw, configurationProperties, true, options);
|
|
2900
2562
|
raw = filtered.raw;
|
|
2901
2563
|
const contents = toValuesTree(raw, message => console.error(`Conflict in settings file ${this._name}: ${message}`));
|
|
2902
|
-
const keys = (
|
|
2564
|
+
const keys = ( (Object.keys(raw)));
|
|
2903
2565
|
const overrides = this.toOverrides(raw, message => console.error(`Conflict in settings file ${this._name}: ${message}`));
|
|
2904
2566
|
return { contents, keys, overrides, restricted: filtered.restricted };
|
|
2905
2567
|
}
|
|
@@ -2917,11 +2579,10 @@ class ConfigurationModelParser {
|
|
|
2917
2579
|
}
|
|
2918
2580
|
else {
|
|
2919
2581
|
const propertySchema = configurationProperties[key];
|
|
2920
|
-
const scope = propertySchema ? typeof propertySchema.scope !== 'undefined' ? propertySchema.scope : 3
|
|
2582
|
+
const scope = propertySchema ? typeof propertySchema.scope !== 'undefined' ? propertySchema.scope : 3 : undefined;
|
|
2921
2583
|
if (propertySchema?.restricted) {
|
|
2922
2584
|
restricted.push(key);
|
|
2923
2585
|
}
|
|
2924
|
-
// Load unregistered configurations always.
|
|
2925
2586
|
if (scope === undefined || options.scopes === undefined || options.scopes.includes(scope)) {
|
|
2926
2587
|
if (!(options.skipRestricted && propertySchema?.restricted)) {
|
|
2927
2588
|
raw[key] = properties[key];
|
|
@@ -2933,7 +2594,7 @@ class ConfigurationModelParser {
|
|
|
2933
2594
|
}
|
|
2934
2595
|
toOverrides(raw, conflictReporter) {
|
|
2935
2596
|
const overrides = [];
|
|
2936
|
-
for (const key of (
|
|
2597
|
+
for (const key of ( (Object.keys(raw)))) {
|
|
2937
2598
|
if (OVERRIDE_PROPERTY_REGEX.test(key)) {
|
|
2938
2599
|
const overrideRaw = {};
|
|
2939
2600
|
for (const keyInOverrideRaw in raw[key]) {
|
|
@@ -2941,7 +2602,7 @@ class ConfigurationModelParser {
|
|
|
2941
2602
|
}
|
|
2942
2603
|
overrides.push({
|
|
2943
2604
|
identifiers: overrideIdentifiersFromKey(key),
|
|
2944
|
-
keys: (
|
|
2605
|
+
keys: ( (Object.keys(overrideRaw))),
|
|
2945
2606
|
contents: toValuesTree(overrideRaw, conflictReporter)
|
|
2946
2607
|
});
|
|
2947
2608
|
}
|
|
@@ -2955,23 +2616,24 @@ class UserSettings extends Disposable {
|
|
|
2955
2616
|
this.userSettingsResource = userSettingsResource;
|
|
2956
2617
|
this.scopes = scopes;
|
|
2957
2618
|
this.fileService = fileService;
|
|
2958
|
-
this._onDidChange = this._register((
|
|
2619
|
+
this._onDidChange = this._register(( (new Emitter())));
|
|
2959
2620
|
this.onDidChange = this._onDidChange.event;
|
|
2960
|
-
this.parser = (
|
|
2621
|
+
this.parser = ( (new ConfigurationModelParser( (this.userSettingsResource.toString()))));
|
|
2961
2622
|
this.parseOptions = { scopes: this.scopes };
|
|
2962
2623
|
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
2624
|
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
|
|
2625
|
+
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
2626
|
}
|
|
2967
2627
|
async loadConfiguration() {
|
|
2968
2628
|
try {
|
|
2969
2629
|
const content = await this.fileService.readFile(this.userSettingsResource);
|
|
2970
|
-
this.parser.parse((
|
|
2630
|
+
this.parser.parse(( (content.value.toString())) || '{}', this.parseOptions);
|
|
2971
2631
|
return this.parser.configurationModel;
|
|
2972
2632
|
}
|
|
2973
2633
|
catch (e) {
|
|
2974
|
-
return (
|
|
2634
|
+
return (
|
|
2635
|
+
(new ConfigurationModel())
|
|
2636
|
+
);
|
|
2975
2637
|
}
|
|
2976
2638
|
}
|
|
2977
2639
|
reparse() {
|
|
@@ -2983,7 +2645,7 @@ class UserSettings extends Disposable {
|
|
|
2983
2645
|
}
|
|
2984
2646
|
}
|
|
2985
2647
|
class Configuration {
|
|
2986
|
-
constructor(_defaultConfiguration, _policyConfiguration, _applicationConfiguration, _localUserConfiguration, _remoteUserConfiguration = (
|
|
2648
|
+
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
2649
|
this._defaultConfiguration = _defaultConfiguration;
|
|
2988
2650
|
this._policyConfiguration = _policyConfiguration;
|
|
2989
2651
|
this._applicationConfiguration = _applicationConfiguration;
|
|
@@ -2995,7 +2657,7 @@ class Configuration {
|
|
|
2995
2657
|
this._memoryConfigurationByResource = _memoryConfigurationByResource;
|
|
2996
2658
|
this._freeze = _freeze;
|
|
2997
2659
|
this._workspaceConsolidatedConfiguration = null;
|
|
2998
|
-
this._foldersConsolidatedConfigurations = (
|
|
2660
|
+
this._foldersConsolidatedConfigurations = ( (new ResourceMap$1()));
|
|
2999
2661
|
this._userConfiguration = null;
|
|
3000
2662
|
}
|
|
3001
2663
|
getValue(section, overrides, workspace) {
|
|
@@ -3007,7 +2669,7 @@ class Configuration {
|
|
|
3007
2669
|
if (overrides.resource) {
|
|
3008
2670
|
memoryConfiguration = this._memoryConfigurationByResource.get(overrides.resource);
|
|
3009
2671
|
if (!memoryConfiguration) {
|
|
3010
|
-
memoryConfiguration = (
|
|
2672
|
+
memoryConfiguration = ( (new ConfigurationModel()));
|
|
3011
2673
|
this._memoryConfigurationByResource.set(overrides.resource, memoryConfiguration);
|
|
3012
2674
|
}
|
|
3013
2675
|
}
|
|
@@ -3034,7 +2696,7 @@ class Configuration {
|
|
|
3034
2696
|
const userValue = overrides.overrideIdentifier ? this.userConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.userConfiguration.freeze().getValue(key);
|
|
3035
2697
|
const userLocalValue = overrides.overrideIdentifier ? this.localUserConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.localUserConfiguration.freeze().getValue(key);
|
|
3036
2698
|
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;
|
|
2699
|
+
const workspaceValue = workspace ? overrides.overrideIdentifier ? this._workspaceConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this._workspaceConfiguration.freeze().getValue(key) : undefined;
|
|
3038
2700
|
const workspaceFolderValue = folderConfigurationModel ? overrides.overrideIdentifier ? folderConfigurationModel.freeze().override(overrides.overrideIdentifier).getValue(key) : folderConfigurationModel.freeze().getValue(key) : undefined;
|
|
3039
2701
|
const memoryValue = overrides.overrideIdentifier ? memoryConfigurationModel.override(overrides.overrideIdentifier).getValue(key) : memoryConfigurationModel.getValue(key);
|
|
3040
2702
|
const value = consolidateConfigurationModel.getValue(key);
|
|
@@ -3302,7 +2964,7 @@ class Configuration {
|
|
|
3302
2964
|
overrides: this._workspaceConfiguration.overrides,
|
|
3303
2965
|
keys: this._workspaceConfiguration.keys
|
|
3304
2966
|
},
|
|
3305
|
-
folders: [...(
|
|
2967
|
+
folders: [...( (this._folderConfigurations.keys()))].reduce((result, folder) => {
|
|
3306
2968
|
const { contents, overrides, keys } = this._folderConfigurations.get(folder);
|
|
3307
2969
|
result.push([folder, { contents, overrides, keys }]);
|
|
3308
2970
|
return result;
|
|
@@ -3310,28 +2972,28 @@ class Configuration {
|
|
|
3310
2972
|
};
|
|
3311
2973
|
}
|
|
3312
2974
|
allKeys() {
|
|
3313
|
-
const keys = (
|
|
2975
|
+
const keys = ( (new Set()));
|
|
3314
2976
|
this._defaultConfiguration.freeze().keys.forEach(key => keys.add(key));
|
|
3315
2977
|
this.userConfiguration.freeze().keys.forEach(key => keys.add(key));
|
|
3316
2978
|
this._workspaceConfiguration.freeze().keys.forEach(key => keys.add(key));
|
|
3317
2979
|
this._folderConfigurations.forEach(folderConfiguraiton => folderConfiguraiton.freeze().keys.forEach(key => keys.add(key)));
|
|
3318
|
-
return [...(
|
|
2980
|
+
return [...( (keys.values()))];
|
|
3319
2981
|
}
|
|
3320
2982
|
allOverrideIdentifiers() {
|
|
3321
|
-
const keys = (
|
|
2983
|
+
const keys = ( (new Set()));
|
|
3322
2984
|
this._defaultConfiguration.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key));
|
|
3323
2985
|
this.userConfiguration.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key));
|
|
3324
2986
|
this._workspaceConfiguration.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key));
|
|
3325
2987
|
this._folderConfigurations.forEach(folderConfiguraiton => folderConfiguraiton.freeze().getAllOverrideIdentifiers().forEach(key => keys.add(key)));
|
|
3326
|
-
return [...(
|
|
2988
|
+
return [...( (keys.values()))];
|
|
3327
2989
|
}
|
|
3328
2990
|
getAllKeysForOverrideIdentifier(overrideIdentifier) {
|
|
3329
|
-
const keys = (
|
|
2991
|
+
const keys = ( (new Set()));
|
|
3330
2992
|
this._defaultConfiguration.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key));
|
|
3331
2993
|
this.userConfiguration.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key));
|
|
3332
2994
|
this._workspaceConfiguration.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key));
|
|
3333
2995
|
this._folderConfigurations.forEach(folderConfiguraiton => folderConfiguraiton.getKeysForOverrideIdentifier(overrideIdentifier).forEach(key => keys.add(key)));
|
|
3334
|
-
return [...(
|
|
2996
|
+
return [...( (keys.values()))];
|
|
3335
2997
|
}
|
|
3336
2998
|
static parse(data) {
|
|
3337
2999
|
const defaultConfiguration = this.parseConfigurationModel(data.defaults);
|
|
@@ -3342,22 +3004,24 @@ class Configuration {
|
|
|
3342
3004
|
const folders = data.folders.reduce((result, value) => {
|
|
3343
3005
|
result.set(URI.revive(value[0]), this.parseConfigurationModel(value[1]));
|
|
3344
3006
|
return result;
|
|
3345
|
-
}, (
|
|
3346
|
-
return (
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3007
|
+
}, ( (new ResourceMap$1())));
|
|
3008
|
+
return (
|
|
3009
|
+
(new Configuration(
|
|
3010
|
+
defaultConfiguration,
|
|
3011
|
+
policyConfiguration,
|
|
3012
|
+
applicationConfiguration,
|
|
3013
|
+
userConfiguration,
|
|
3014
|
+
(new ConfigurationModel()),
|
|
3015
|
+
workspaceConfiguration,
|
|
3016
|
+
folders,
|
|
3017
|
+
(new ConfigurationModel()),
|
|
3018
|
+
(new ResourceMap$1()),
|
|
3019
|
+
false
|
|
3020
|
+
))
|
|
3021
|
+
);
|
|
3358
3022
|
}
|
|
3359
3023
|
static parseConfigurationModel(model) {
|
|
3360
|
-
return (
|
|
3024
|
+
return ( (new ConfigurationModel(model.contents, model.keys, model.overrides))).freeze();
|
|
3361
3025
|
}
|
|
3362
3026
|
}
|
|
3363
3027
|
function compare(from, to) {
|
|
@@ -3408,24 +3072,12 @@ function compareConfigurationContents(to, from) {
|
|
|
3408
3072
|
}
|
|
3409
3073
|
return { added, removed, updated };
|
|
3410
3074
|
}
|
|
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
3075
|
function isWorkspaceIdentifier(obj) {
|
|
3417
3076
|
const workspaceIdentifier = obj;
|
|
3418
3077
|
return typeof workspaceIdentifier?.id === 'string' && URI.isUri(workspaceIdentifier.configPath);
|
|
3419
3078
|
}
|
|
3420
3079
|
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
|
-
*/
|
|
3080
|
+
constructor(data,
|
|
3429
3081
|
raw) {
|
|
3430
3082
|
this.raw = raw;
|
|
3431
3083
|
this.uri = data.uri;
|
|
@@ -3439,11 +3091,145 @@ class WorkspaceFolder {
|
|
|
3439
3091
|
return { uri: this.uri, name: this.name, index: this.index };
|
|
3440
3092
|
}
|
|
3441
3093
|
}
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3094
|
+
function now() {
|
|
3095
|
+
return ( (new Date())).toISOString();
|
|
3096
|
+
}
|
|
3097
|
+
var LogLevel;
|
|
3098
|
+
( ((function(LogLevel) {
|
|
3099
|
+
LogLevel[LogLevel["Trace"] = 0] = "Trace";
|
|
3100
|
+
LogLevel[LogLevel["Debug"] = 1] = "Debug";
|
|
3101
|
+
LogLevel[LogLevel["Info"] = 2] = "Info";
|
|
3102
|
+
LogLevel[LogLevel["Warning"] = 3] = "Warning";
|
|
3103
|
+
LogLevel[LogLevel["Error"] = 4] = "Error";
|
|
3104
|
+
LogLevel[LogLevel["Critical"] = 5] = "Critical";
|
|
3105
|
+
LogLevel[LogLevel["Off"] = 6] = "Off";
|
|
3106
|
+
})(LogLevel || (LogLevel = {}))));
|
|
3107
|
+
const DEFAULT_LOG_LEVEL = LogLevel.Info;
|
|
3108
|
+
class AbstractLogger extends Disposable {
|
|
3109
|
+
constructor() {
|
|
3110
|
+
super(...arguments);
|
|
3111
|
+
this.level = DEFAULT_LOG_LEVEL;
|
|
3112
|
+
this._onDidChangeLogLevel = this._register(( (new Emitter())));
|
|
3113
|
+
this.onDidChangeLogLevel = this._onDidChangeLogLevel.event;
|
|
3114
|
+
}
|
|
3115
|
+
setLevel(level) {
|
|
3116
|
+
if (this.level !== level) {
|
|
3117
|
+
this.level = level;
|
|
3118
|
+
this._onDidChangeLogLevel.fire(this.level);
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
getLevel() {
|
|
3122
|
+
return this.level;
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
class ConsoleMainLogger extends AbstractLogger {
|
|
3126
|
+
constructor(logLevel = DEFAULT_LOG_LEVEL) {
|
|
3127
|
+
super();
|
|
3128
|
+
this.setLevel(logLevel);
|
|
3129
|
+
this.useColors = !isWindows;
|
|
3130
|
+
}
|
|
3131
|
+
trace(message, ...args) {
|
|
3132
|
+
if (this.getLevel() <= LogLevel.Trace) {
|
|
3133
|
+
if (this.useColors) {
|
|
3134
|
+
console.log(`\x1b[90m[main ${now()}]\x1b[0m`, message, ...args);
|
|
3135
|
+
}
|
|
3136
|
+
else {
|
|
3137
|
+
console.log(`[main ${now()}]`, message, ...args);
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
debug(message, ...args) {
|
|
3142
|
+
if (this.getLevel() <= LogLevel.Debug) {
|
|
3143
|
+
if (this.useColors) {
|
|
3144
|
+
console.log(`\x1b[90m[main ${now()}]\x1b[0m`, message, ...args);
|
|
3145
|
+
}
|
|
3146
|
+
else {
|
|
3147
|
+
console.log(`[main ${now()}]`, message, ...args);
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
info(message, ...args) {
|
|
3152
|
+
if (this.getLevel() <= LogLevel.Info) {
|
|
3153
|
+
if (this.useColors) {
|
|
3154
|
+
console.log(`\x1b[90m[main ${now()}]\x1b[0m`, message, ...args);
|
|
3155
|
+
}
|
|
3156
|
+
else {
|
|
3157
|
+
console.log(`[main ${now()}]`, message, ...args);
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
warn(message, ...args) {
|
|
3162
|
+
if (this.getLevel() <= LogLevel.Warning) {
|
|
3163
|
+
if (this.useColors) {
|
|
3164
|
+
console.warn(`\x1b[93m[main ${now()}]\x1b[0m`, message, ...args);
|
|
3165
|
+
}
|
|
3166
|
+
else {
|
|
3167
|
+
console.warn(`[main ${now()}]`, message, ...args);
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
error(message, ...args) {
|
|
3172
|
+
if (this.getLevel() <= LogLevel.Error) {
|
|
3173
|
+
if (this.useColors) {
|
|
3174
|
+
console.error(`\x1b[91m[main ${now()}]\x1b[0m`, message, ...args);
|
|
3175
|
+
}
|
|
3176
|
+
else {
|
|
3177
|
+
console.error(`[main ${now()}]`, message, ...args);
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
critical(message, ...args) {
|
|
3182
|
+
if (this.getLevel() <= LogLevel.Critical) {
|
|
3183
|
+
if (this.useColors) {
|
|
3184
|
+
console.error(`\x1b[90m[main ${now()}]\x1b[0m`, message, ...args);
|
|
3185
|
+
}
|
|
3186
|
+
else {
|
|
3187
|
+
console.error(`[main ${now()}]`, message, ...args);
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
dispose() {
|
|
3192
|
+
}
|
|
3193
|
+
flush() {
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
class LogService extends Disposable {
|
|
3197
|
+
constructor(logger) {
|
|
3198
|
+
super();
|
|
3199
|
+
this.logger = logger;
|
|
3200
|
+
this._register(logger);
|
|
3201
|
+
}
|
|
3202
|
+
get onDidChangeLogLevel() {
|
|
3203
|
+
return this.logger.onDidChangeLogLevel;
|
|
3204
|
+
}
|
|
3205
|
+
setLevel(level) {
|
|
3206
|
+
this.logger.setLevel(level);
|
|
3207
|
+
}
|
|
3208
|
+
getLevel() {
|
|
3209
|
+
return this.logger.getLevel();
|
|
3210
|
+
}
|
|
3211
|
+
trace(message, ...args) {
|
|
3212
|
+
this.logger.trace(message, ...args);
|
|
3213
|
+
}
|
|
3214
|
+
debug(message, ...args) {
|
|
3215
|
+
this.logger.debug(message, ...args);
|
|
3216
|
+
}
|
|
3217
|
+
info(message, ...args) {
|
|
3218
|
+
this.logger.info(message, ...args);
|
|
3219
|
+
}
|
|
3220
|
+
warn(message, ...args) {
|
|
3221
|
+
this.logger.warn(message, ...args);
|
|
3222
|
+
}
|
|
3223
|
+
error(message, ...args) {
|
|
3224
|
+
this.logger.error(message, ...args);
|
|
3225
|
+
}
|
|
3226
|
+
critical(message, ...args) {
|
|
3227
|
+
this.logger.critical(message, ...args);
|
|
3228
|
+
}
|
|
3229
|
+
flush() {
|
|
3230
|
+
this.logger.flush();
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3447
3233
|
function isConfigurationOverrides(thing) {
|
|
3448
3234
|
return thing
|
|
3449
3235
|
&& typeof thing === 'object'
|
|
@@ -3452,9 +3238,14 @@ function isConfigurationOverrides(thing) {
|
|
|
3452
3238
|
}
|
|
3453
3239
|
class StandaloneConfigurationService {
|
|
3454
3240
|
constructor() {
|
|
3455
|
-
this._onDidChangeConfiguration = (
|
|
3241
|
+
this._onDidChangeConfiguration = ( (new Emitter()));
|
|
3456
3242
|
this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
|
|
3457
|
-
this._configuration = (
|
|
3243
|
+
this._configuration = ( (new Configuration$1(
|
|
3244
|
+
(new DefaultConfigurationModel()),
|
|
3245
|
+
(new ConfigurationModel$1()),
|
|
3246
|
+
(new ConfigurationModel$1()),
|
|
3247
|
+
(new ConfigurationModel$1())
|
|
3248
|
+
)));
|
|
3458
3249
|
}
|
|
3459
3250
|
getValue(arg1, arg2) {
|
|
3460
3251
|
const section = typeof arg1 === 'string' ? arg1 : undefined;
|
|
@@ -3473,8 +3264,8 @@ class StandaloneConfigurationService {
|
|
|
3473
3264
|
changedKeys.push(key);
|
|
3474
3265
|
}
|
|
3475
3266
|
if (changedKeys.length > 0) {
|
|
3476
|
-
const configurationChangeEvent = (
|
|
3477
|
-
configurationChangeEvent.source = 8
|
|
3267
|
+
const configurationChangeEvent = ( (new ConfigurationChangeEvent({ keys: changedKeys, overrides: [] }, previous, this._configuration)));
|
|
3268
|
+
configurationChangeEvent.source = 8 ;
|
|
3478
3269
|
configurationChangeEvent.sourceConfig = null;
|
|
3479
3270
|
this._onDidChangeConfiguration.fire(configurationChangeEvent);
|
|
3480
3271
|
}
|
|
@@ -3487,7 +3278,9 @@ class StandaloneConfigurationService {
|
|
|
3487
3278
|
return this._configuration.inspect(key, options, undefined);
|
|
3488
3279
|
}
|
|
3489
3280
|
keys() {
|
|
3490
|
-
return (
|
|
3281
|
+
return (
|
|
3282
|
+
(this._configuration.keys(undefined))
|
|
3283
|
+
);
|
|
3491
3284
|
}
|
|
3492
3285
|
reloadConfiguration() {
|
|
3493
3286
|
return Promise.resolve(undefined);
|
|
@@ -3508,19 +3301,14 @@ class StandaloneConfigurationService {
|
|
|
3508
3301
|
};
|
|
3509
3302
|
}
|
|
3510
3303
|
}
|
|
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
3304
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3517
3305
|
const NULL_LANGUAGE_ID = 'vs.editor.nullLanguage';
|
|
3518
3306
|
class LanguageIdCodec {
|
|
3519
3307
|
constructor() {
|
|
3520
3308
|
this._languageIdToLanguage = [];
|
|
3521
|
-
this._languageToLanguageId = (
|
|
3522
|
-
this._register(NULL_LANGUAGE_ID, 0
|
|
3523
|
-
this._register(PLAINTEXT_LANGUAGE_ID, 1
|
|
3309
|
+
this._languageToLanguageId = ( (new Map()));
|
|
3310
|
+
this._register(NULL_LANGUAGE_ID, 0 );
|
|
3311
|
+
this._register(PLAINTEXT_LANGUAGE_ID, 1 );
|
|
3524
3312
|
this._nextLanguageId = 2;
|
|
3525
3313
|
}
|
|
3526
3314
|
_register(language, languageId) {
|
|
@@ -3535,7 +3323,7 @@ class LanguageIdCodec {
|
|
|
3535
3323
|
this._register(language, languageId);
|
|
3536
3324
|
}
|
|
3537
3325
|
encodeLanguageId(languageId) {
|
|
3538
|
-
return this._languageToLanguageId.get(languageId) || 0
|
|
3326
|
+
return this._languageToLanguageId.get(languageId) || 0 ;
|
|
3539
3327
|
}
|
|
3540
3328
|
decodeLanguageId(languageId) {
|
|
3541
3329
|
return this._languageIdToLanguage[languageId] || NULL_LANGUAGE_ID;
|
|
@@ -3544,11 +3332,11 @@ class LanguageIdCodec {
|
|
|
3544
3332
|
class LanguagesRegistry extends Disposable {
|
|
3545
3333
|
constructor(useModesRegistry = true, warnOnOverwrite = false) {
|
|
3546
3334
|
super();
|
|
3547
|
-
this._onDidChange = this._register((
|
|
3335
|
+
this._onDidChange = this._register(( (new Emitter())));
|
|
3548
3336
|
this.onDidChange = this._onDidChange.event;
|
|
3549
3337
|
LanguagesRegistry.instanceCount++;
|
|
3550
3338
|
this._warnOnOverwrite = warnOnOverwrite;
|
|
3551
|
-
this.languageIdCodec = (
|
|
3339
|
+
this.languageIdCodec = ( (new LanguageIdCodec()));
|
|
3552
3340
|
this._dynamicLanguages = [];
|
|
3553
3341
|
this._languages = {};
|
|
3554
3342
|
this._mimeTypesMap = {};
|
|
@@ -3585,11 +3373,10 @@ class LanguagesRegistry extends Disposable {
|
|
|
3585
3373
|
for (const d of desc) {
|
|
3586
3374
|
this._registerLanguage(d);
|
|
3587
3375
|
}
|
|
3588
|
-
// Rebuild fast path maps
|
|
3589
3376
|
this._mimeTypesMap = {};
|
|
3590
3377
|
this._nameMap = {};
|
|
3591
3378
|
this._lowercaseNameMap = {};
|
|
3592
|
-
(
|
|
3379
|
+
( (Object.keys(this._languages))).forEach((langId) => {
|
|
3593
3380
|
const language = this._languages[langId];
|
|
3594
3381
|
if (language.name) {
|
|
3595
3382
|
this._nameMap[language.name] = language.identifier;
|
|
@@ -3601,7 +3388,7 @@ class LanguagesRegistry extends Disposable {
|
|
|
3601
3388
|
this._mimeTypesMap[mimetype] = language.identifier;
|
|
3602
3389
|
});
|
|
3603
3390
|
});
|
|
3604
|
-
(
|
|
3391
|
+
( (Registry.as(Extensions$2.Configuration))).registerOverrideIdentifiers(this.getRegisteredLanguageIds());
|
|
3605
3392
|
this._onDidChange.fire();
|
|
3606
3393
|
}
|
|
3607
3394
|
_registerLanguage(lang) {
|
|
@@ -3639,7 +3426,6 @@ class LanguagesRegistry extends Disposable {
|
|
|
3639
3426
|
}
|
|
3640
3427
|
if (Array.isArray(lang.extensions)) {
|
|
3641
3428
|
if (lang.configuration) {
|
|
3642
|
-
// insert first as this appears to be the 'primary' language definition
|
|
3643
3429
|
resolvedLanguage.extensions = lang.extensions.concat(resolvedLanguage.extensions);
|
|
3644
3430
|
}
|
|
3645
3431
|
else {
|
|
@@ -3666,13 +3452,12 @@ class LanguagesRegistry extends Disposable {
|
|
|
3666
3452
|
firstLineRegexStr = '^' + firstLineRegexStr;
|
|
3667
3453
|
}
|
|
3668
3454
|
try {
|
|
3669
|
-
const firstLineRegex = (
|
|
3455
|
+
const firstLineRegex = ( (new RegExp(firstLineRegexStr)));
|
|
3670
3456
|
if (!regExpLeadsToEndlessLoop(firstLineRegex)) {
|
|
3671
3457
|
registerPlatformLanguageAssociation({ id: langId, mime: primaryMime, firstline: firstLineRegex }, this._warnOnOverwrite);
|
|
3672
3458
|
}
|
|
3673
3459
|
}
|
|
3674
3460
|
catch (err) {
|
|
3675
|
-
// Most likely, the regex was bad
|
|
3676
3461
|
onUnexpectedError(err);
|
|
3677
3462
|
}
|
|
3678
3463
|
}
|
|
@@ -3680,7 +3465,6 @@ class LanguagesRegistry extends Disposable {
|
|
|
3680
3465
|
let langAliases = null;
|
|
3681
3466
|
if (typeof lang.aliases !== 'undefined' && Array.isArray(lang.aliases)) {
|
|
3682
3467
|
if (lang.aliases.length === 0) {
|
|
3683
|
-
// signal that this language should not get a name
|
|
3684
3468
|
langAliases = [null];
|
|
3685
3469
|
}
|
|
3686
3470
|
else {
|
|
@@ -3717,7 +3501,9 @@ class LanguagesRegistry extends Disposable {
|
|
|
3717
3501
|
return hasOwnProperty.call(this._languages, languageId);
|
|
3718
3502
|
}
|
|
3719
3503
|
getRegisteredLanguageIds() {
|
|
3720
|
-
return (
|
|
3504
|
+
return (
|
|
3505
|
+
(Object.keys(this._languages))
|
|
3506
|
+
);
|
|
3721
3507
|
}
|
|
3722
3508
|
getSortedRegisteredLanguageNames() {
|
|
3723
3509
|
const result = [];
|
|
@@ -3794,11 +3580,6 @@ class LanguagesRegistry extends Disposable {
|
|
|
3794
3580
|
}
|
|
3795
3581
|
}
|
|
3796
3582
|
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
3583
|
class TraitRenderer {
|
|
3803
3584
|
constructor(trait) {
|
|
3804
3585
|
this.trait = trait;
|
|
@@ -3859,12 +3640,14 @@ class Trait {
|
|
|
3859
3640
|
this.length = 0;
|
|
3860
3641
|
this.indexes = [];
|
|
3861
3642
|
this.sortedIndexes = [];
|
|
3862
|
-
this._onChange = (
|
|
3643
|
+
this._onChange = ( (new Emitter()));
|
|
3863
3644
|
this.onChange = this._onChange.event;
|
|
3864
3645
|
}
|
|
3865
3646
|
get name() { return this._trait; }
|
|
3866
3647
|
get renderer() {
|
|
3867
|
-
return (
|
|
3648
|
+
return (
|
|
3649
|
+
(new TraitRenderer(this))
|
|
3650
|
+
);
|
|
3868
3651
|
}
|
|
3869
3652
|
splice(start, deleteCount, elements) {
|
|
3870
3653
|
deleteCount = Math.max(0, Math.min(deleteCount, this.length - start));
|
|
@@ -3890,12 +3673,6 @@ class Trait {
|
|
|
3890
3673
|
unrender(container) {
|
|
3891
3674
|
container.classList.remove(this._trait);
|
|
3892
3675
|
}
|
|
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
3676
|
set(indexes, browserEvent) {
|
|
3900
3677
|
return this._set(indexes, [...indexes].sort(numericSort), browserEvent);
|
|
3901
3678
|
}
|
|
@@ -3936,11 +3713,6 @@ class SelectionTrait extends Trait {
|
|
|
3936
3713
|
}
|
|
3937
3714
|
}
|
|
3938
3715
|
}
|
|
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
3716
|
class TraitSpliceable {
|
|
3945
3717
|
constructor(trait, view, identityProvider) {
|
|
3946
3718
|
this.trait = trait;
|
|
@@ -3951,8 +3723,8 @@ class TraitSpliceable {
|
|
|
3951
3723
|
if (!this.identityProvider) {
|
|
3952
3724
|
return this.trait.splice(start, deleteCount, elements.map(() => false));
|
|
3953
3725
|
}
|
|
3954
|
-
const pastElementsWithTrait = this.trait.get().map(i => (
|
|
3955
|
-
const elementsWithTrait = elements.map(e => pastElementsWithTrait.indexOf((
|
|
3726
|
+
const pastElementsWithTrait = this.trait.get().map(i => ( (this.identityProvider.getId(this.view.element(i)).toString())));
|
|
3727
|
+
const elementsWithTrait = elements.map(e => pastElementsWithTrait.indexOf(( (this.identityProvider.getId(e).toString()))) > -1);
|
|
3956
3728
|
this.trait.splice(start, deleteCount, elementsWithTrait);
|
|
3957
3729
|
}
|
|
3958
3730
|
}
|
|
@@ -3975,28 +3747,28 @@ class KeyboardController {
|
|
|
3975
3747
|
constructor(list, view, options) {
|
|
3976
3748
|
this.list = list;
|
|
3977
3749
|
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
|
|
3750
|
+
this.disposables = ( (new DisposableStore()));
|
|
3751
|
+
this.multipleSelectionDisposables = ( (new DisposableStore()));
|
|
3752
|
+
this.onKeyDown.filter(e => e.keyCode === 3 ).on(this.onEnter, this, this.disposables);
|
|
3753
|
+
this.onKeyDown.filter(e => e.keyCode === 16 ).on(this.onUpArrow, this, this.disposables);
|
|
3754
|
+
this.onKeyDown.filter(e => e.keyCode === 18 ).on(this.onDownArrow, this, this.disposables);
|
|
3755
|
+
this.onKeyDown.filter(e => e.keyCode === 11 ).on(this.onPageUpArrow, this, this.disposables);
|
|
3756
|
+
this.onKeyDown.filter(e => e.keyCode === 12 ).on(this.onPageDownArrow, this, this.disposables);
|
|
3757
|
+
this.onKeyDown.filter(e => e.keyCode === 9 ).on(this.onEscape, this, this.disposables);
|
|
3986
3758
|
if (options.multipleSelectionSupport !== false) {
|
|
3987
|
-
this.onKeyDown.filter(e => (isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === 31
|
|
3759
|
+
this.onKeyDown.filter(e => (isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === 31 ).on(this.onCtrlA, this, this.multipleSelectionDisposables);
|
|
3988
3760
|
}
|
|
3989
3761
|
}
|
|
3990
3762
|
get onKeyDown() {
|
|
3991
|
-
return this.disposables.add(Event.chain(this.disposables.add((
|
|
3763
|
+
return this.disposables.add(Event.chain(this.disposables.add(( (new DomEmitter(this.view.domNode, 'keydown')))).event)
|
|
3992
3764
|
.filter(e => !isInputElement(e.target))
|
|
3993
|
-
.map(e => (
|
|
3765
|
+
.map(e => ( (new StandardKeyboardEvent(e)))));
|
|
3994
3766
|
}
|
|
3995
3767
|
updateOptions(optionsUpdate) {
|
|
3996
3768
|
if (optionsUpdate.multipleSelectionSupport !== undefined) {
|
|
3997
3769
|
this.multipleSelectionDisposables.clear();
|
|
3998
3770
|
if (optionsUpdate.multipleSelectionSupport) {
|
|
3999
|
-
this.onKeyDown.filter(e => (isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === 31
|
|
3771
|
+
this.onKeyDown.filter(e => (isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === 31 ).on(this.onCtrlA, this, this.multipleSelectionDisposables);
|
|
4000
3772
|
}
|
|
4001
3773
|
}
|
|
4002
3774
|
}
|
|
@@ -4063,24 +3835,24 @@ class KeyboardController {
|
|
|
4063
3835
|
}
|
|
4064
3836
|
}
|
|
4065
3837
|
var TypeNavigationMode;
|
|
4066
|
-
(
|
|
3838
|
+
( ((function(TypeNavigationMode) {
|
|
4067
3839
|
TypeNavigationMode[TypeNavigationMode["Automatic"] = 0] = "Automatic";
|
|
4068
3840
|
TypeNavigationMode[TypeNavigationMode["Trigger"] = 1] = "Trigger";
|
|
4069
|
-
})(TypeNavigationMode || (TypeNavigationMode = {})));
|
|
3841
|
+
})(TypeNavigationMode || (TypeNavigationMode = {}))));
|
|
4070
3842
|
var TypeNavigationControllerState;
|
|
4071
|
-
(
|
|
3843
|
+
( ((function(TypeNavigationControllerState) {
|
|
4072
3844
|
TypeNavigationControllerState[TypeNavigationControllerState["Idle"] = 0] = "Idle";
|
|
4073
3845
|
TypeNavigationControllerState[TypeNavigationControllerState["Typing"] = 1] = "Typing";
|
|
4074
|
-
})(TypeNavigationControllerState || (TypeNavigationControllerState = {})));
|
|
3846
|
+
})(TypeNavigationControllerState || (TypeNavigationControllerState = {}))));
|
|
4075
3847
|
const DefaultKeyboardNavigationDelegate = new class {
|
|
4076
3848
|
mightProducePrintableCharacter(event) {
|
|
4077
3849
|
if (event.ctrlKey || event.metaKey || event.altKey) {
|
|
4078
3850
|
return false;
|
|
4079
3851
|
}
|
|
4080
|
-
return ((event.keyCode >= 31
|
|
4081
|
-
|| ((event.keyCode >= 21
|
|
4082
|
-
|| ((event.keyCode >= 93
|
|
4083
|
-
|| ((event.keyCode >= 80
|
|
3852
|
+
return ((event.keyCode >= 31 && event.keyCode <= 56) )
|
|
3853
|
+
|| ((event.keyCode >= 21 && event.keyCode <= 30) )
|
|
3854
|
+
|| ((event.keyCode >= 93 && event.keyCode <= 102) )
|
|
3855
|
+
|| ((event.keyCode >= 80 && event.keyCode <= 90) );
|
|
4084
3856
|
}
|
|
4085
3857
|
};
|
|
4086
3858
|
class TypeNavigationController {
|
|
@@ -4095,8 +3867,8 @@ class TypeNavigationController {
|
|
|
4095
3867
|
this.mode = TypeNavigationMode.Automatic;
|
|
4096
3868
|
this.triggered = false;
|
|
4097
3869
|
this.previouslyFocused = -1;
|
|
4098
|
-
this.enabledDisposables = (
|
|
4099
|
-
this.disposables = (
|
|
3870
|
+
this.enabledDisposables = ( (new DisposableStore()));
|
|
3871
|
+
this.disposables = ( (new DisposableStore()));
|
|
4100
3872
|
this.updateOptions(list.options);
|
|
4101
3873
|
}
|
|
4102
3874
|
updateOptions(options) {
|
|
@@ -4116,10 +3888,10 @@ class TypeNavigationController {
|
|
|
4116
3888
|
return;
|
|
4117
3889
|
}
|
|
4118
3890
|
let typing = false;
|
|
4119
|
-
const onChar = this.enabledDisposables.add(Event.chain(this.enabledDisposables.add((
|
|
3891
|
+
const onChar = this.enabledDisposables.add(Event.chain(this.enabledDisposables.add(( (new DomEmitter(this.view.domNode, 'keydown')))).event))
|
|
4120
3892
|
.filter(e => !isInputElement(e.target))
|
|
4121
3893
|
.filter(() => this.mode === TypeNavigationMode.Automatic || this.triggered)
|
|
4122
|
-
.map(event => (
|
|
3894
|
+
.map(event => ( (new StandardKeyboardEvent(event))))
|
|
4123
3895
|
.filter(e => typing || this.keyboardNavigationEventFilter(e))
|
|
4124
3896
|
.filter(e => this.delegate.mightProducePrintableCharacter(e))
|
|
4125
3897
|
.forEach(stopEvent)
|
|
@@ -4145,8 +3917,6 @@ class TypeNavigationController {
|
|
|
4145
3917
|
onClear() {
|
|
4146
3918
|
const focus = this.list.getFocus();
|
|
4147
3919
|
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
3920
|
const ariaLabel = this.list.options.accessibilityProvider?.getAriaLabel(this.list.element(focus[0]));
|
|
4151
3921
|
if (ariaLabel) {
|
|
4152
3922
|
alert(ariaLabel);
|
|
@@ -4167,7 +3937,7 @@ class TypeNavigationController {
|
|
|
4167
3937
|
for (let i = 0; i < this.list.length; i++) {
|
|
4168
3938
|
const index = (start + i + delta) % this.list.length;
|
|
4169
3939
|
const label = this.keyboardNavigationLabelProvider.getKeyboardNavigationLabel(this.view.element(index));
|
|
4170
|
-
const labelStr = label && (
|
|
3940
|
+
const labelStr = label && ( (label.toString()));
|
|
4171
3941
|
if (typeof labelStr === 'undefined' || matchesPrefix(word, labelStr)) {
|
|
4172
3942
|
this.previouslyFocused = start;
|
|
4173
3943
|
this.list.setFocus([index]);
|
|
@@ -4186,11 +3956,11 @@ class DOMFocusController {
|
|
|
4186
3956
|
constructor(list, view) {
|
|
4187
3957
|
this.list = list;
|
|
4188
3958
|
this.view = view;
|
|
4189
|
-
this.disposables = (
|
|
4190
|
-
const onKeyDown = this.disposables.add(Event.chain(this.disposables.add((
|
|
3959
|
+
this.disposables = ( (new DisposableStore()));
|
|
3960
|
+
const onKeyDown = this.disposables.add(Event.chain(this.disposables.add(( (new DomEmitter(view.domNode, 'keydown')))).event))
|
|
4191
3961
|
.filter(e => !isInputElement(e.target))
|
|
4192
|
-
.map(e => (
|
|
4193
|
-
onKeyDown.filter(e => e.keyCode === 2
|
|
3962
|
+
.map(e => ( (new StandardKeyboardEvent(e))));
|
|
3963
|
+
onKeyDown.filter(e => e.keyCode === 2 && !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey)
|
|
4194
3964
|
.on(this.onTab, this, this.disposables);
|
|
4195
3965
|
}
|
|
4196
3966
|
onTab(e) {
|
|
@@ -4237,8 +4007,8 @@ const DefaultMultipleSelectionController = {
|
|
|
4237
4007
|
class MouseController {
|
|
4238
4008
|
constructor(list) {
|
|
4239
4009
|
this.list = list;
|
|
4240
|
-
this.disposables = (
|
|
4241
|
-
this._onPointer = (
|
|
4010
|
+
this.disposables = ( (new DisposableStore()));
|
|
4011
|
+
this._onPointer = ( (new Emitter()));
|
|
4242
4012
|
this.onPointer = this._onPointer.event;
|
|
4243
4013
|
if (list.options.multipleSelectionSupport !== false) {
|
|
4244
4014
|
this.multipleSelectionController = this.list.options.multipleSelectionController || DefaultMultipleSelectionController;
|
|
@@ -4378,20 +4148,20 @@ class DefaultStyleController {
|
|
|
4378
4148
|
if (styles.listBackground.isOpaque()) {
|
|
4379
4149
|
content.push(`.monaco-list${suffix} .monaco-list-rows { background: ${styles.listBackground}; }`);
|
|
4380
4150
|
}
|
|
4381
|
-
else if (!isMacintosh) {
|
|
4151
|
+
else if (!isMacintosh) {
|
|
4382
4152
|
console.warn(`List with id '${this.selectorSuffix}' was styled with a non-opaque background color. This will break sub-pixel antialiasing.`);
|
|
4383
4153
|
}
|
|
4384
4154
|
}
|
|
4385
4155
|
if (styles.listFocusBackground) {
|
|
4386
4156
|
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}; }`);
|
|
4157
|
+
content.push(`.monaco-list${suffix}:focus .monaco-list-row.focused:hover { background-color: ${styles.listFocusBackground}; }`);
|
|
4388
4158
|
}
|
|
4389
4159
|
if (styles.listFocusForeground) {
|
|
4390
4160
|
content.push(`.monaco-list${suffix}:focus .monaco-list-row.focused { color: ${styles.listFocusForeground}; }`);
|
|
4391
4161
|
}
|
|
4392
4162
|
if (styles.listActiveSelectionBackground) {
|
|
4393
4163
|
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}; }`);
|
|
4164
|
+
content.push(`.monaco-list${suffix}:focus .monaco-list-row.selected:hover { background-color: ${styles.listActiveSelectionBackground}; }`);
|
|
4395
4165
|
}
|
|
4396
4166
|
if (styles.listActiveSelectionForeground) {
|
|
4397
4167
|
content.push(`.monaco-list${suffix}:focus .monaco-list-row.selected { color: ${styles.listActiveSelectionForeground}; }`);
|
|
@@ -4416,18 +4186,18 @@ class DefaultStyleController {
|
|
|
4416
4186
|
}
|
|
4417
4187
|
if (styles.listInactiveFocusForeground) {
|
|
4418
4188
|
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}; }`);
|
|
4189
|
+
content.push(`.monaco-list${suffix} .monaco-list-row.focused:hover { color: ${styles.listInactiveFocusForeground}; }`);
|
|
4420
4190
|
}
|
|
4421
4191
|
if (styles.listInactiveSelectionIconForeground) {
|
|
4422
4192
|
content.push(`.monaco-list${suffix} .monaco-list-row.focused .codicon { color: ${styles.listInactiveSelectionIconForeground}; }`);
|
|
4423
4193
|
}
|
|
4424
4194
|
if (styles.listInactiveFocusBackground) {
|
|
4425
4195
|
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}; }`);
|
|
4196
|
+
content.push(`.monaco-list${suffix} .monaco-list-row.focused:hover { background-color: ${styles.listInactiveFocusBackground}; }`);
|
|
4427
4197
|
}
|
|
4428
4198
|
if (styles.listInactiveSelectionBackground) {
|
|
4429
4199
|
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}; }`);
|
|
4200
|
+
content.push(`.monaco-list${suffix} .monaco-list-row.selected:hover { background-color: ${styles.listInactiveSelectionBackground}; }`);
|
|
4431
4201
|
}
|
|
4432
4202
|
if (styles.listInactiveSelectionForeground) {
|
|
4433
4203
|
content.push(`.monaco-list${suffix} .monaco-list-row.selected { color: ${styles.listInactiveSelectionForeground}; }`);
|
|
@@ -4481,20 +4251,20 @@ class DefaultStyleController {
|
|
|
4481
4251
|
}
|
|
4482
4252
|
}
|
|
4483
4253
|
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: (
|
|
4254
|
+
listFocusBackground: ( (Color$1.fromHex('#7FB0D0'))),
|
|
4255
|
+
listActiveSelectionBackground: ( (Color$1.fromHex('#0E639C'))),
|
|
4256
|
+
listActiveSelectionForeground: ( (Color$1.fromHex('#FFFFFF'))),
|
|
4257
|
+
listActiveSelectionIconForeground: ( (Color$1.fromHex('#FFFFFF'))),
|
|
4258
|
+
listFocusAndSelectionOutline: ( (Color$1.fromHex('#90C2F9'))),
|
|
4259
|
+
listFocusAndSelectionBackground: ( (Color$1.fromHex('#094771'))),
|
|
4260
|
+
listFocusAndSelectionForeground: ( (Color$1.fromHex('#FFFFFF'))),
|
|
4261
|
+
listInactiveSelectionBackground: ( (Color$1.fromHex('#3F3F46'))),
|
|
4262
|
+
listInactiveSelectionIconForeground: ( (Color$1.fromHex('#FFFFFF'))),
|
|
4263
|
+
listHoverBackground: ( (Color$1.fromHex('#2A2D2E'))),
|
|
4264
|
+
listDropBackground: ( (Color$1.fromHex('#383B3D'))),
|
|
4265
|
+
treeIndentGuidesStroke: ( (Color$1.fromHex('#a9a9a9'))),
|
|
4266
|
+
tableColumnsBorder: ( (( (Color$1.fromHex('#cccccc'))).transparent(0.2))),
|
|
4267
|
+
tableOddRowsBackgroundColor: ( (( (Color$1.fromHex('#cccccc'))).transparent(0.04)))
|
|
4498
4268
|
};
|
|
4499
4269
|
const DefaultOptions = {
|
|
4500
4270
|
keyboardSupport: true,
|
|
@@ -4507,7 +4277,6 @@ const DefaultOptions = {
|
|
|
4507
4277
|
drop() { }
|
|
4508
4278
|
}
|
|
4509
4279
|
};
|
|
4510
|
-
// TODO@Joao: move these utils into a SortedArray class
|
|
4511
4280
|
function getContiguousRangeContaining(range, value) {
|
|
4512
4281
|
const index = range.indexOf(value);
|
|
4513
4282
|
if (index === -1) {
|
|
@@ -4525,10 +4294,6 @@ function getContiguousRangeContaining(range, value) {
|
|
|
4525
4294
|
}
|
|
4526
4295
|
return result;
|
|
4527
4296
|
}
|
|
4528
|
-
/**
|
|
4529
|
-
* Given two sorted collections of numbers, returns the intersection
|
|
4530
|
-
* between them (OR).
|
|
4531
|
-
*/
|
|
4532
4297
|
function disjunction(one, other) {
|
|
4533
4298
|
const result = [];
|
|
4534
4299
|
let i = 0, j = 0;
|
|
@@ -4554,10 +4319,6 @@ function disjunction(one, other) {
|
|
|
4554
4319
|
}
|
|
4555
4320
|
return result;
|
|
4556
4321
|
}
|
|
4557
|
-
/**
|
|
4558
|
-
* Given two sorted collections of numbers, returns the relative
|
|
4559
|
-
* complement between them (XOR).
|
|
4560
|
-
*/
|
|
4561
4322
|
function relativeComplement(one, other) {
|
|
4562
4323
|
const result = [];
|
|
4563
4324
|
let i = 0, j = 0;
|
|
@@ -4639,7 +4400,6 @@ class AccessibiltyRenderer {
|
|
|
4639
4400
|
}
|
|
4640
4401
|
}
|
|
4641
4402
|
disposeTemplate(templateData) {
|
|
4642
|
-
// noop
|
|
4643
4403
|
}
|
|
4644
4404
|
}
|
|
4645
4405
|
class ListViewDragAndDrop {
|
|
@@ -4677,80 +4437,65 @@ class ListViewDragAndDrop {
|
|
|
4677
4437
|
this.dnd.drop(data, targetElement, targetIndex, originalEvent);
|
|
4678
4438
|
}
|
|
4679
4439
|
}
|
|
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
4440
|
class List {
|
|
4696
4441
|
constructor(user, container, virtualDelegate, renderers, _options = DefaultOptions) {
|
|
4697
4442
|
this.user = user;
|
|
4698
4443
|
this._options = _options;
|
|
4699
|
-
this.focus = (
|
|
4700
|
-
this.anchor = (
|
|
4701
|
-
this.eventBufferer = (
|
|
4444
|
+
this.focus = ( (new Trait('focused')));
|
|
4445
|
+
this.anchor = ( (new Trait('anchor')));
|
|
4446
|
+
this.eventBufferer = ( (new EventBufferer()));
|
|
4702
4447
|
this._ariaLabel = '';
|
|
4703
|
-
this.disposables = (
|
|
4704
|
-
this._onDidDispose = (
|
|
4448
|
+
this.disposables = ( (new DisposableStore()));
|
|
4449
|
+
this._onDidDispose = ( (new Emitter()));
|
|
4705
4450
|
this.onDidDispose = this._onDidDispose.event;
|
|
4706
4451
|
const role = this._options.accessibilityProvider && this._options.accessibilityProvider.getWidgetRole ? this._options.accessibilityProvider?.getWidgetRole() : 'list';
|
|
4707
|
-
this.selection = (
|
|
4452
|
+
this.selection = ( (new SelectionTrait(role !== 'listbox')));
|
|
4708
4453
|
mixin(_options, defaultStyles, false);
|
|
4709
4454
|
const baseRenderers = [this.focus.renderer, this.selection.renderer];
|
|
4710
4455
|
this.accessibilityProvider = _options.accessibilityProvider;
|
|
4711
4456
|
if (this.accessibilityProvider) {
|
|
4712
|
-
baseRenderers.push((
|
|
4457
|
+
baseRenderers.push(( (new AccessibiltyRenderer(this.accessibilityProvider))));
|
|
4713
4458
|
this.accessibilityProvider.onDidChangeActiveDescendant?.(this.onDidChangeActiveDescendant, this, this.disposables);
|
|
4714
4459
|
}
|
|
4715
|
-
renderers = renderers.map(r => (
|
|
4460
|
+
renderers = renderers.map(r => ( (new PipelineRenderer(r.templateId, [...baseRenderers, r]))));
|
|
4716
4461
|
const viewOptions = {
|
|
4717
4462
|
..._options,
|
|
4718
|
-
dnd: _options.dnd && (
|
|
4463
|
+
dnd: _options.dnd && ( (new ListViewDragAndDrop(this, _options.dnd)))
|
|
4719
4464
|
};
|
|
4720
|
-
this.view = (
|
|
4465
|
+
this.view = ( (new ListView(container, virtualDelegate, renderers, viewOptions)));
|
|
4721
4466
|
this.view.domNode.setAttribute('role', role);
|
|
4722
4467
|
if (_options.styleController) {
|
|
4723
4468
|
this.styleController = _options.styleController(this.view.domId);
|
|
4724
4469
|
}
|
|
4725
4470
|
else {
|
|
4726
4471
|
const styleElement = createStyleSheet(this.view.domNode);
|
|
4727
|
-
this.styleController = (
|
|
4472
|
+
this.styleController = ( (new DefaultStyleController(styleElement, this.view.domId)));
|
|
4728
4473
|
}
|
|
4729
|
-
this.spliceable = (
|
|
4730
|
-
(
|
|
4731
|
-
(
|
|
4732
|
-
(
|
|
4474
|
+
this.spliceable = ( (new CombinedSpliceable([
|
|
4475
|
+
( (new TraitSpliceable(this.focus, this.view, _options.identityProvider))),
|
|
4476
|
+
( (new TraitSpliceable(this.selection, this.view, _options.identityProvider))),
|
|
4477
|
+
( (new TraitSpliceable(this.anchor, this.view, _options.identityProvider))),
|
|
4733
4478
|
this.view
|
|
4734
|
-
]));
|
|
4479
|
+
])));
|
|
4735
4480
|
this.disposables.add(this.focus);
|
|
4736
4481
|
this.disposables.add(this.selection);
|
|
4737
4482
|
this.disposables.add(this.anchor);
|
|
4738
4483
|
this.disposables.add(this.view);
|
|
4739
4484
|
this.disposables.add(this._onDidDispose);
|
|
4740
|
-
this.disposables.add((
|
|
4485
|
+
this.disposables.add(( (new DOMFocusController(this, this.view))));
|
|
4741
4486
|
if (typeof _options.keyboardSupport !== 'boolean' || _options.keyboardSupport) {
|
|
4742
|
-
this.keyboardController = (
|
|
4487
|
+
this.keyboardController = ( (new KeyboardController(this, this.view, _options)));
|
|
4743
4488
|
this.disposables.add(this.keyboardController);
|
|
4744
4489
|
}
|
|
4745
4490
|
if (_options.keyboardNavigationLabelProvider) {
|
|
4746
4491
|
const delegate = _options.keyboardNavigationDelegate || DefaultKeyboardNavigationDelegate;
|
|
4747
|
-
this.typeNavigationController = (
|
|
4492
|
+
this.typeNavigationController = ( (new TypeNavigationController(
|
|
4748
4493
|
this,
|
|
4749
4494
|
this.view,
|
|
4750
4495
|
_options.keyboardNavigationLabelProvider,
|
|
4751
4496
|
_options.keyboardNavigationEventFilter ?? (() => true),
|
|
4752
4497
|
delegate
|
|
4753
|
-
));
|
|
4498
|
+
)));
|
|
4754
4499
|
this.disposables.add(this.typeNavigationController);
|
|
4755
4500
|
}
|
|
4756
4501
|
this.mouseController = this.createMouseController(_options);
|
|
@@ -4783,25 +4528,18 @@ class List {
|
|
|
4783
4528
|
get onMouseOut() { return this.view.onMouseOut; }
|
|
4784
4529
|
get onTouchStart() { return this.view.onTouchStart; }
|
|
4785
4530
|
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
4531
|
get onContextMenu() {
|
|
4794
4532
|
let didJustPressContextMenuKey = false;
|
|
4795
|
-
const fromKeyDown = this.disposables.add(Event.chain(this.disposables.add((
|
|
4796
|
-
.map(e => (
|
|
4797
|
-
.filter(e => didJustPressContextMenuKey = e.keyCode === 58
|
|
4533
|
+
const fromKeyDown = this.disposables.add(Event.chain(this.disposables.add(( (new DomEmitter(this.view.domNode, 'keydown')))).event))
|
|
4534
|
+
.map(e => ( (new StandardKeyboardEvent(e))))
|
|
4535
|
+
.filter(e => didJustPressContextMenuKey = e.keyCode === 58 || ((e.shiftKey && e.keyCode === 68) ))
|
|
4798
4536
|
.map(stopEvent)
|
|
4799
4537
|
.filter(() => false)
|
|
4800
4538
|
.event;
|
|
4801
|
-
const fromKeyUp = this.disposables.add(Event.chain(this.disposables.add((
|
|
4539
|
+
const fromKeyUp = this.disposables.add(Event.chain(this.disposables.add(( (new DomEmitter(this.view.domNode, 'keyup')))).event))
|
|
4802
4540
|
.forEach(() => didJustPressContextMenuKey = false)
|
|
4803
|
-
.map(e => (
|
|
4804
|
-
.filter(e => e.keyCode === 58
|
|
4541
|
+
.map(e => ( (new StandardKeyboardEvent(e))))
|
|
4542
|
+
.filter(e => e.keyCode === 58 || ((e.shiftKey && e.keyCode === 68) ))
|
|
4805
4543
|
.map(stopEvent)
|
|
4806
4544
|
.map(({ browserEvent }) => {
|
|
4807
4545
|
const focus = this.getFocus();
|
|
@@ -4817,13 +4555,15 @@ class List {
|
|
|
4817
4555
|
.event;
|
|
4818
4556
|
return Event.any(fromKeyDown, fromKeyUp, fromMouse);
|
|
4819
4557
|
}
|
|
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((
|
|
4558
|
+
get onKeyDown() { return this.disposables.add(( (new DomEmitter(this.view.domNode, 'keydown')))).event; }
|
|
4559
|
+
get onKeyUp() { return this.disposables.add(( (new DomEmitter(this.view.domNode, 'keyup')))).event; }
|
|
4560
|
+
get onKeyPress() { return this.disposables.add(( (new DomEmitter(this.view.domNode, 'keypress')))).event; }
|
|
4561
|
+
get onDidFocus() { return Event.signal(this.disposables.add(( (new DomEmitter(this.view.domNode, 'focus', true)))).event); }
|
|
4562
|
+
get onDidBlur() { return Event.signal(this.disposables.add(( (new DomEmitter(this.view.domNode, 'blur', true)))).event); }
|
|
4825
4563
|
createMouseController(options) {
|
|
4826
|
-
return (
|
|
4564
|
+
return (
|
|
4565
|
+
(new MouseController(this))
|
|
4566
|
+
);
|
|
4827
4567
|
}
|
|
4828
4568
|
updateOptions(optionsUpdate = {}) {
|
|
4829
4569
|
this._options = { ...this._options, ...optionsUpdate };
|
|
@@ -4997,13 +4737,11 @@ class List {
|
|
|
4997
4737
|
const previousScrollTop = this.view.getScrollTop();
|
|
4998
4738
|
let nextpageScrollTop = previousScrollTop + this.view.renderHeight;
|
|
4999
4739
|
if (lastPageIndex > currentlyFocusedElementIndex) {
|
|
5000
|
-
// scroll last page element to the top only if the last page element is below the focused element
|
|
5001
4740
|
nextpageScrollTop -= this.view.elementHeight(lastPageIndex);
|
|
5002
4741
|
}
|
|
5003
4742
|
this.view.setScrollTop(nextpageScrollTop);
|
|
5004
4743
|
if (this.view.getScrollTop() !== previousScrollTop) {
|
|
5005
4744
|
this.setFocus([]);
|
|
5006
|
-
// Let the scroll event listener run
|
|
5007
4745
|
await timeout(0);
|
|
5008
4746
|
await this.focusNextPage(browserEvent, filter);
|
|
5009
4747
|
}
|
|
@@ -5033,7 +4771,6 @@ class List {
|
|
|
5033
4771
|
this.view.setScrollTop(scrollTop - this.view.renderHeight);
|
|
5034
4772
|
if (this.view.getScrollTop() !== previousScrollTop) {
|
|
5035
4773
|
this.setFocus([]);
|
|
5036
|
-
// Let the scroll event listener run
|
|
5037
4774
|
await timeout(0);
|
|
5038
4775
|
await this.focusPreviousPage(browserEvent, filter);
|
|
5039
4776
|
}
|
|
@@ -5100,7 +4837,6 @@ class List {
|
|
|
5100
4837
|
const elementTop = this.view.elementTop(index);
|
|
5101
4838
|
const elementHeight = this.view.elementHeight(index);
|
|
5102
4839
|
if (isNumber(relativeTop)) {
|
|
5103
|
-
// y = mx + b
|
|
5104
4840
|
const m = elementHeight - this.view.renderHeight;
|
|
5105
4841
|
this.view.setScrollTop(m * clamp(relativeTop, 0, 1) + elementTop);
|
|
5106
4842
|
}
|
|
@@ -5116,10 +4852,6 @@ class List {
|
|
|
5116
4852
|
}
|
|
5117
4853
|
}
|
|
5118
4854
|
}
|
|
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
4855
|
getRelativeTop(index) {
|
|
5124
4856
|
if (index < 0 || index >= this.length) {
|
|
5125
4857
|
throw new ListError(this.user, `Invalid index ${index}`);
|
|
@@ -5130,7 +4862,6 @@ class List {
|
|
|
5130
4862
|
if (elementTop < scrollTop || elementTop + elementHeight > scrollTop + this.view.renderHeight) {
|
|
5131
4863
|
return null;
|
|
5132
4864
|
}
|
|
5133
|
-
// y = mx + b
|
|
5134
4865
|
const m = elementHeight - this.view.renderHeight;
|
|
5135
4866
|
return Math.abs((scrollTop - elementTop) / m);
|
|
5136
4867
|
}
|
|
@@ -5179,11 +4910,6 @@ class List {
|
|
|
5179
4910
|
this._onDidDispose.dispose();
|
|
5180
4911
|
}
|
|
5181
4912
|
}
|
|
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
4913
|
function roundFloat(number, decimalPoints) {
|
|
5188
4914
|
const decimal = Math.pow(10, decimalPoints);
|
|
5189
4915
|
return Math.round(number * decimal) / decimal;
|
|
@@ -5211,12 +4937,6 @@ class HSLA {
|
|
|
5211
4937
|
static equals(a, b) {
|
|
5212
4938
|
return a.h === b.h && a.s === b.s && a.l === b.l && a.a === b.a;
|
|
5213
4939
|
}
|
|
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
4940
|
static fromRGBA(rgba) {
|
|
5221
4941
|
const r = rgba.r / 255;
|
|
5222
4942
|
const g = rgba.g / 255;
|
|
@@ -5244,7 +4964,9 @@ class HSLA {
|
|
|
5244
4964
|
h *= 60;
|
|
5245
4965
|
h = Math.round(h);
|
|
5246
4966
|
}
|
|
5247
|
-
return (
|
|
4967
|
+
return (
|
|
4968
|
+
(new HSLA(h, s, l, a))
|
|
4969
|
+
);
|
|
5248
4970
|
}
|
|
5249
4971
|
static _hue2rgb(p, q, t) {
|
|
5250
4972
|
if (t < 0) {
|
|
@@ -5264,18 +4986,12 @@ class HSLA {
|
|
|
5264
4986
|
}
|
|
5265
4987
|
return p;
|
|
5266
4988
|
}
|
|
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
4989
|
static toRGBA(hsla) {
|
|
5274
4990
|
const h = hsla.h / 360;
|
|
5275
4991
|
const { s, l, a } = hsla;
|
|
5276
4992
|
let r, g, b;
|
|
5277
4993
|
if (s === 0) {
|
|
5278
|
-
r = g = b = l;
|
|
4994
|
+
r = g = b = l;
|
|
5279
4995
|
}
|
|
5280
4996
|
else {
|
|
5281
4997
|
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
@@ -5284,7 +5000,9 @@ class HSLA {
|
|
|
5284
5000
|
g = HSLA._hue2rgb(p, q, h);
|
|
5285
5001
|
b = HSLA._hue2rgb(p, q, h - 1 / 3);
|
|
5286
5002
|
}
|
|
5287
|
-
return (
|
|
5003
|
+
return (
|
|
5004
|
+
(new RGBA(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255), a))
|
|
5005
|
+
);
|
|
5288
5006
|
}
|
|
5289
5007
|
}
|
|
5290
5008
|
class HSVA {
|
|
@@ -5298,7 +5016,6 @@ class HSVA {
|
|
|
5298
5016
|
static equals(a, b) {
|
|
5299
5017
|
return a.h === b.h && a.s === b.s && a.v === b.v && a.a === b.a;
|
|
5300
5018
|
}
|
|
5301
|
-
// from http://www.rapidtables.com/convert/color/rgb-to-hsv.htm
|
|
5302
5019
|
static fromRGBA(rgba) {
|
|
5303
5020
|
const r = rgba.r / 255;
|
|
5304
5021
|
const g = rgba.g / 255;
|
|
@@ -5320,9 +5037,10 @@ class HSVA {
|
|
|
5320
5037
|
else {
|
|
5321
5038
|
m = ((r - g) / delta) + 4;
|
|
5322
5039
|
}
|
|
5323
|
-
return (
|
|
5040
|
+
return (
|
|
5041
|
+
(new HSVA(Math.round(m * 60), s, cmax, rgba.a))
|
|
5042
|
+
);
|
|
5324
5043
|
}
|
|
5325
|
-
// from http://www.rapidtables.com/convert/color/hsv-to-rgb.htm
|
|
5326
5044
|
static toRGBA(hsva) {
|
|
5327
5045
|
const { h, s, v, a } = hsva;
|
|
5328
5046
|
const c = v * s;
|
|
@@ -5356,7 +5074,9 @@ class HSVA {
|
|
|
5356
5074
|
r = Math.round((r + m) * 255);
|
|
5357
5075
|
g = Math.round((g + m) * 255);
|
|
5358
5076
|
b = Math.round((b + m) * 255);
|
|
5359
|
-
return (
|
|
5077
|
+
return (
|
|
5078
|
+
(new RGBA(r, g, b, a))
|
|
5079
|
+
);
|
|
5360
5080
|
}
|
|
5361
5081
|
}
|
|
5362
5082
|
class Color {
|
|
@@ -5399,10 +5119,6 @@ class Color {
|
|
|
5399
5119
|
equals(other) {
|
|
5400
5120
|
return !!other && RGBA.equals(this.rgba, other.rgba) && HSLA.equals(this.hsla, other.hsla) && HSVA.equals(this.hsva, other.hsva);
|
|
5401
5121
|
}
|
|
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
5122
|
getRelativeLuminance() {
|
|
5407
5123
|
const R = Color._relativeLuminanceForComponent(this.rgba.r);
|
|
5408
5124
|
const G = Color._relativeLuminanceForComponent(this.rgba.g);
|
|
@@ -5414,27 +5130,15 @@ class Color {
|
|
|
5414
5130
|
const c = color / 255;
|
|
5415
5131
|
return (c <= 0.03928) ? c / 12.92 : Math.pow(((c + 0.055) / 1.055), 2.4);
|
|
5416
5132
|
}
|
|
5417
|
-
/**
|
|
5418
|
-
* http://www.w3.org/TR/WCAG20/#contrast-ratiodef
|
|
5419
|
-
* Returns the contrast ration number in the set [1, 21].
|
|
5420
|
-
*/
|
|
5421
5133
|
getContrastRatio(another) {
|
|
5422
5134
|
const lum1 = this.getRelativeLuminance();
|
|
5423
5135
|
const lum2 = another.getRelativeLuminance();
|
|
5424
5136
|
return lum1 > lum2 ? (lum1 + 0.05) / (lum2 + 0.05) : (lum2 + 0.05) / (lum1 + 0.05);
|
|
5425
5137
|
}
|
|
5426
|
-
/**
|
|
5427
|
-
* http://24ways.org/2010/calculating-color-contrast
|
|
5428
|
-
* Return 'true' if darker color otherwise 'false'
|
|
5429
|
-
*/
|
|
5430
5138
|
isDarker() {
|
|
5431
5139
|
const yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1000;
|
|
5432
5140
|
return yiq < 128;
|
|
5433
5141
|
}
|
|
5434
|
-
/**
|
|
5435
|
-
* http://24ways.org/2010/calculating-color-contrast
|
|
5436
|
-
* Return 'true' if lighter color otherwise 'false'
|
|
5437
|
-
*/
|
|
5438
5142
|
isLighter() {
|
|
5439
5143
|
const yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1000;
|
|
5440
5144
|
return yiq >= 128;
|
|
@@ -5450,14 +5154,24 @@ class Color {
|
|
|
5450
5154
|
return lum1 < lum2;
|
|
5451
5155
|
}
|
|
5452
5156
|
lighten(factor) {
|
|
5453
|
-
return (
|
|
5157
|
+
return (
|
|
5158
|
+
(new Color(
|
|
5159
|
+
(new HSLA(this.hsla.h, this.hsla.s, this.hsla.l + this.hsla.l * factor, this.hsla.a))
|
|
5160
|
+
))
|
|
5161
|
+
);
|
|
5454
5162
|
}
|
|
5455
5163
|
darken(factor) {
|
|
5456
|
-
return (
|
|
5164
|
+
return (
|
|
5165
|
+
(new Color(
|
|
5166
|
+
(new HSLA(this.hsla.h, this.hsla.s, this.hsla.l - this.hsla.l * factor, this.hsla.a))
|
|
5167
|
+
))
|
|
5168
|
+
);
|
|
5457
5169
|
}
|
|
5458
5170
|
transparent(factor) {
|
|
5459
5171
|
const { r, g, b, a } = this.rgba;
|
|
5460
|
-
return (
|
|
5172
|
+
return (
|
|
5173
|
+
(new Color( (new RGBA(r, g, b, a * factor))))
|
|
5174
|
+
);
|
|
5461
5175
|
}
|
|
5462
5176
|
isTransparent() {
|
|
5463
5177
|
return this.rgba.a === 0;
|
|
@@ -5466,11 +5180,14 @@ class Color {
|
|
|
5466
5180
|
return this.rgba.a === 1;
|
|
5467
5181
|
}
|
|
5468
5182
|
opposite() {
|
|
5469
|
-
return (
|
|
5183
|
+
return (
|
|
5184
|
+
(new Color(
|
|
5185
|
+
(new RGBA(255 - this.rgba.r, 255 - this.rgba.g, 255 - this.rgba.b, this.rgba.a))
|
|
5186
|
+
))
|
|
5187
|
+
);
|
|
5470
5188
|
}
|
|
5471
5189
|
blend(c) {
|
|
5472
5190
|
const rgba = c.rgba;
|
|
5473
|
-
// Convert to 0..1 opacity
|
|
5474
5191
|
const thisA = this.rgba.a;
|
|
5475
5192
|
const colorA = rgba.a;
|
|
5476
5193
|
const a = thisA + colorA * (1 - thisA);
|
|
@@ -5480,21 +5197,23 @@ class Color {
|
|
|
5480
5197
|
const r = this.rgba.r * thisA / a + rgba.r * colorA * (1 - thisA) / a;
|
|
5481
5198
|
const g = this.rgba.g * thisA / a + rgba.g * colorA * (1 - thisA) / a;
|
|
5482
5199
|
const b = this.rgba.b * thisA / a + rgba.b * colorA * (1 - thisA) / a;
|
|
5483
|
-
return (
|
|
5200
|
+
return (
|
|
5201
|
+
(new Color( (new RGBA(r, g, b, a))))
|
|
5202
|
+
);
|
|
5484
5203
|
}
|
|
5485
5204
|
makeOpaque(opaqueBackground) {
|
|
5486
5205
|
if (this.isOpaque() || opaqueBackground.rgba.a !== 1) {
|
|
5487
|
-
// only allow to blend onto a non-opaque color onto a opaque color
|
|
5488
5206
|
return this;
|
|
5489
5207
|
}
|
|
5490
5208
|
const { r, g, b, a } = this.rgba;
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5209
|
+
return (
|
|
5210
|
+
(new Color( (new RGBA(
|
|
5211
|
+
opaqueBackground.rgba.r - a * (opaqueBackground.rgba.r - r),
|
|
5212
|
+
opaqueBackground.rgba.g - a * (opaqueBackground.rgba.g - g),
|
|
5213
|
+
opaqueBackground.rgba.b - a * (opaqueBackground.rgba.b - b),
|
|
5214
|
+
1
|
|
5215
|
+
))))
|
|
5216
|
+
);
|
|
5498
5217
|
}
|
|
5499
5218
|
flatten(...backgrounds) {
|
|
5500
5219
|
const background = backgrounds.reduceRight((accumulator, color) => {
|
|
@@ -5504,11 +5223,13 @@ class Color {
|
|
|
5504
5223
|
}
|
|
5505
5224
|
static _flatten(foreground, background) {
|
|
5506
5225
|
const backgroundAlpha = 1 - foreground.rgba.a;
|
|
5507
|
-
return (
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5226
|
+
return (
|
|
5227
|
+
(new Color( (new RGBA(
|
|
5228
|
+
backgroundAlpha * background.rgba.r + foreground.rgba.a * foreground.rgba.r,
|
|
5229
|
+
backgroundAlpha * background.rgba.g + foreground.rgba.a * foreground.rgba.g,
|
|
5230
|
+
backgroundAlpha * background.rgba.b + foreground.rgba.a * foreground.rgba.b
|
|
5231
|
+
))))
|
|
5232
|
+
);
|
|
5512
5233
|
}
|
|
5513
5234
|
toString() {
|
|
5514
5235
|
if (!this._toString) {
|
|
@@ -5524,7 +5245,9 @@ class Color {
|
|
|
5524
5245
|
const lum1 = of.getRelativeLuminance();
|
|
5525
5246
|
const lum2 = relative.getRelativeLuminance();
|
|
5526
5247
|
factor = factor * (lum2 - lum1) / lum2;
|
|
5527
|
-
return (
|
|
5248
|
+
return (
|
|
5249
|
+
(of.lighten(factor))
|
|
5250
|
+
);
|
|
5528
5251
|
}
|
|
5529
5252
|
static getDarkerColor(of, relative, factor) {
|
|
5530
5253
|
if (of.isDarkerThan(relative)) {
|
|
@@ -5534,20 +5257,22 @@ class Color {
|
|
|
5534
5257
|
const lum1 = of.getRelativeLuminance();
|
|
5535
5258
|
const lum2 = relative.getRelativeLuminance();
|
|
5536
5259
|
factor = factor * (lum1 - lum2) / lum1;
|
|
5537
|
-
return (
|
|
5260
|
+
return (
|
|
5261
|
+
(of.darken(factor))
|
|
5262
|
+
);
|
|
5538
5263
|
}
|
|
5539
5264
|
}
|
|
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
|
-
(
|
|
5265
|
+
Color.white = ( (new Color( (new RGBA(255, 255, 255, 1)))));
|
|
5266
|
+
Color.black = ( (new Color( (new RGBA(0, 0, 0, 1)))));
|
|
5267
|
+
Color.red = ( (new Color( (new RGBA(255, 0, 0, 1)))));
|
|
5268
|
+
Color.blue = ( (new Color( (new RGBA(0, 0, 255, 1)))));
|
|
5269
|
+
Color.green = ( (new Color( (new RGBA(0, 255, 0, 1)))));
|
|
5270
|
+
Color.cyan = ( (new Color( (new RGBA(0, 255, 255, 1)))));
|
|
5271
|
+
Color.lightgrey = ( (new Color( (new RGBA(211, 211, 211, 1)))));
|
|
5272
|
+
Color.transparent = ( (new Color( (new RGBA(0, 0, 0, 0)))));
|
|
5273
|
+
( ((function(Color) {
|
|
5274
|
+
( ((function(Format) {
|
|
5275
|
+
( ((function(CSS) {
|
|
5551
5276
|
function formatRGB(color) {
|
|
5552
5277
|
if (color.rgba.a === 1) {
|
|
5553
5278
|
return `rgb(${color.rgba.r}, ${color.rgba.g}, ${color.rgba.b})`;
|
|
@@ -5571,20 +5296,13 @@ Color.transparent = (/*#__PURE__*/ new Color((/*#__PURE__*/ new RGBA(0, 0, 0, 0)
|
|
|
5571
5296
|
}
|
|
5572
5297
|
CSS.formatHSLA = formatHSLA;
|
|
5573
5298
|
function _toTwoDigitHex(n) {
|
|
5574
|
-
const r = (
|
|
5299
|
+
const r = ( (n.toString(16)));
|
|
5575
5300
|
return r.length !== 2 ? '0' + r : r;
|
|
5576
5301
|
}
|
|
5577
|
-
/**
|
|
5578
|
-
* Formats the color as #RRGGBB
|
|
5579
|
-
*/
|
|
5580
5302
|
function formatHex(color) {
|
|
5581
5303
|
return `#${_toTwoDigitHex(color.rgba.r)}${_toTwoDigitHex(color.rgba.g)}${_toTwoDigitHex(color.rgba.b)}`;
|
|
5582
5304
|
}
|
|
5583
5305
|
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
5306
|
function formatHexA(color, compact = false) {
|
|
5589
5307
|
if (compact && color.rgba.a === 1) {
|
|
5590
5308
|
return Color.Format.CSS.formatHex(color);
|
|
@@ -5592,9 +5310,6 @@ Color.transparent = (/*#__PURE__*/ new Color((/*#__PURE__*/ new RGBA(0, 0, 0, 0)
|
|
|
5592
5310
|
return `#${_toTwoDigitHex(color.rgba.r)}${_toTwoDigitHex(color.rgba.g)}${_toTwoDigitHex(color.rgba.b)}${_toTwoDigitHex(Math.round(color.rgba.a * 255))}`;
|
|
5593
5311
|
}
|
|
5594
5312
|
CSS.formatHexA = formatHexA;
|
|
5595
|
-
/**
|
|
5596
|
-
* The default format will use HEX if opaque and RGBA otherwise.
|
|
5597
|
-
*/
|
|
5598
5313
|
function format(color) {
|
|
5599
5314
|
if (color.isOpaque()) {
|
|
5600
5315
|
return Color.Format.CSS.formatHex(color);
|
|
@@ -5602,120 +5317,105 @@ Color.transparent = (/*#__PURE__*/ new Color((/*#__PURE__*/ new RGBA(0, 0, 0, 0)
|
|
|
5602
5317
|
return Color.Format.CSS.formatRGBA(color);
|
|
5603
5318
|
}
|
|
5604
5319
|
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
5320
|
function parseHex(hex) {
|
|
5611
5321
|
const length = hex.length;
|
|
5612
5322
|
if (length === 0) {
|
|
5613
|
-
// Invalid color
|
|
5614
5323
|
return null;
|
|
5615
5324
|
}
|
|
5616
|
-
if (hex.charCodeAt(0) !== 35
|
|
5617
|
-
// Does not begin with a #
|
|
5325
|
+
if (hex.charCodeAt(0) !== 35 ) {
|
|
5618
5326
|
return null;
|
|
5619
5327
|
}
|
|
5620
5328
|
if (length === 7) {
|
|
5621
|
-
// #RRGGBB format
|
|
5622
5329
|
const r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
|
|
5623
5330
|
const g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
|
|
5624
5331
|
const b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
|
|
5625
|
-
return (
|
|
5332
|
+
return (
|
|
5333
|
+
(new Color( (new RGBA(r, g, b, 1))))
|
|
5334
|
+
);
|
|
5626
5335
|
}
|
|
5627
5336
|
if (length === 9) {
|
|
5628
|
-
// #RRGGBBAA format
|
|
5629
5337
|
const r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
|
|
5630
5338
|
const g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
|
|
5631
5339
|
const b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
|
|
5632
5340
|
const a = 16 * _parseHexDigit(hex.charCodeAt(7)) + _parseHexDigit(hex.charCodeAt(8));
|
|
5633
|
-
return (
|
|
5341
|
+
return (
|
|
5342
|
+
(new Color( (new RGBA(r, g, b, a / 255))))
|
|
5343
|
+
);
|
|
5634
5344
|
}
|
|
5635
5345
|
if (length === 4) {
|
|
5636
|
-
// #RGB format
|
|
5637
5346
|
const r = _parseHexDigit(hex.charCodeAt(1));
|
|
5638
5347
|
const g = _parseHexDigit(hex.charCodeAt(2));
|
|
5639
5348
|
const b = _parseHexDigit(hex.charCodeAt(3));
|
|
5640
|
-
return (
|
|
5349
|
+
return (
|
|
5350
|
+
(new Color( (new RGBA(16 * r + r, 16 * g + g, 16 * b + b))))
|
|
5351
|
+
);
|
|
5641
5352
|
}
|
|
5642
5353
|
if (length === 5) {
|
|
5643
|
-
// #RGBA format
|
|
5644
5354
|
const r = _parseHexDigit(hex.charCodeAt(1));
|
|
5645
5355
|
const g = _parseHexDigit(hex.charCodeAt(2));
|
|
5646
5356
|
const b = _parseHexDigit(hex.charCodeAt(3));
|
|
5647
5357
|
const a = _parseHexDigit(hex.charCodeAt(4));
|
|
5648
|
-
return (
|
|
5358
|
+
return (
|
|
5359
|
+
(new Color(
|
|
5360
|
+
(new RGBA(16 * r + r, 16 * g + g, 16 * b + b, (16 * a + a) / 255))
|
|
5361
|
+
))
|
|
5362
|
+
);
|
|
5649
5363
|
}
|
|
5650
|
-
// Invalid color
|
|
5651
5364
|
return null;
|
|
5652
5365
|
}
|
|
5653
5366
|
CSS.parseHex = parseHex;
|
|
5654
5367
|
function _parseHexDigit(charCode) {
|
|
5655
5368
|
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
|
|
5369
|
+
case 48 : return 0;
|
|
5370
|
+
case 49 : return 1;
|
|
5371
|
+
case 50 : return 2;
|
|
5372
|
+
case 51 : return 3;
|
|
5373
|
+
case 52 : return 4;
|
|
5374
|
+
case 53 : return 5;
|
|
5375
|
+
case 54 : return 6;
|
|
5376
|
+
case 55 : return 7;
|
|
5377
|
+
case 56 : return 8;
|
|
5378
|
+
case 57 : return 9;
|
|
5379
|
+
case 97 : return 10;
|
|
5380
|
+
case 65 : return 10;
|
|
5381
|
+
case 98 : return 11;
|
|
5382
|
+
case 66 : return 11;
|
|
5383
|
+
case 99 : return 12;
|
|
5384
|
+
case 67 : return 12;
|
|
5385
|
+
case 100 : return 13;
|
|
5386
|
+
case 68 : return 13;
|
|
5387
|
+
case 101 : return 14;
|
|
5388
|
+
case 69 : return 14;
|
|
5389
|
+
case 102 : return 15;
|
|
5390
|
+
case 70 : return 15;
|
|
5678
5391
|
}
|
|
5679
5392
|
return 0;
|
|
5680
5393
|
}
|
|
5681
|
-
})(Format.CSS || (Format.CSS = {})));
|
|
5682
|
-
})(Color.Format || (Color.Format = {})));
|
|
5683
|
-
})(Color || (Color = {})));
|
|
5684
|
-
|
|
5394
|
+
})(Format.CSS || (Format.CSS = {}))));
|
|
5395
|
+
})(Color.Format || (Color.Format = {}))));
|
|
5396
|
+
})(Color || (Color = {}))));
|
|
5685
5397
|
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
5398
|
if (SnippetParser.prototype.text == null) {
|
|
5690
5399
|
SnippetParser.prototype.text = function (value) {
|
|
5691
|
-
return this.parse(value).toString();
|
|
5400
|
+
return ( this.parse(value).toString());
|
|
5692
5401
|
};
|
|
5693
5402
|
}
|
|
5694
5403
|
else {
|
|
5695
5404
|
console.warn('Useless polyfill: SnippetParser');
|
|
5696
5405
|
}
|
|
5697
|
-
/**
|
|
5698
|
-
* Assign all properties of b to A
|
|
5699
|
-
*/
|
|
5700
5406
|
function polyfillPrototypeSimple(a, b) {
|
|
5701
5407
|
Object.defineProperties(a, Object.getOwnPropertyDescriptors(b));
|
|
5702
5408
|
}
|
|
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
5409
|
function polyfillPrototype(a, b, toA, toB) {
|
|
5709
5410
|
for (const key of Object.getOwnPropertyNames(b)) {
|
|
5710
5411
|
if (!Object.hasOwnProperty.call(a, key)) {
|
|
5711
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5712
5412
|
a[key] = function (...args) {
|
|
5713
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5714
5413
|
return toA(b[key].call(this, ...args.map(toB)));
|
|
5715
5414
|
};
|
|
5716
5415
|
}
|
|
5717
5416
|
}
|
|
5718
5417
|
}
|
|
5418
|
+
polyfillPrototypeSimple(LogService$1.prototype, LogService.prototype);
|
|
5719
5419
|
polyfillPrototypeSimple(List$1.prototype, List.prototype);
|
|
5720
5420
|
polyfillPrototypeSimple(WorkspaceFolder$1.prototype, WorkspaceFolder.prototype);
|
|
5721
5421
|
polyfillPrototypeSimple(LanguagesRegistry$1.prototype, LanguagesRegistry.prototype);
|
|
@@ -5725,54 +5425,36 @@ polyfillPrototypeSimple(Configuration$1.prototype, Configuration.prototype);
|
|
|
5725
5425
|
polyfillPrototypeSimple(TernarySearchTree$1.prototype, TernarySearchTree.prototype);
|
|
5726
5426
|
polyfillPrototypeSimple(StandaloneConfigurationService$1.prototype, StandaloneConfigurationService.prototype);
|
|
5727
5427
|
polyfillPrototypeSimple(LanguageService$1.prototype, LanguageService.prototype);
|
|
5728
|
-
polyfillPrototypeSimple(NoOpNotification
|
|
5428
|
+
polyfillPrototypeSimple(NoOpNotification.prototype, NoOpNotification$1.prototype);
|
|
5729
5429
|
polyfillPrototypeSimple(Themable$1.prototype, Themable.prototype);
|
|
5730
5430
|
polyfillPrototypeSimple(ProgressBar$1.prototype, ProgressBar.prototype);
|
|
5731
|
-
const jsonContributionRegistry = Registry.as(Extensions.JSONContribution);
|
|
5431
|
+
const jsonContributionRegistry = ( Registry.as(Extensions.JSONContribution));
|
|
5732
5432
|
jsonContributionRegistry.getSchemaContributions ?? (jsonContributionRegistry.getSchemaContributions = () => ({
|
|
5733
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5734
5433
|
schemas: jsonContributionRegistry.schemasById
|
|
5735
5434
|
}));
|
|
5736
|
-
// @ts-ignore Override of a readonly property
|
|
5737
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5738
5435
|
jsonContributionRegistry.onDidChangeSchema ?? (jsonContributionRegistry.onDidChangeSchema = jsonContributionRegistry._onDidChangeSchema.event);
|
|
5739
|
-
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
|
|
5436
|
+
const themeRegistry = ( Registry.as(Extensions$1.ThemingContribution));
|
|
5742
5437
|
themeRegistry.onThemingParticipantAdded ?? (themeRegistry.onThemingParticipantAdded = themeRegistry.onThemingParticipantAddedEmitter.event);
|
|
5743
|
-
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
|
|
5438
|
+
const configurationRegistry = ( Registry.as(Extensions$2.Configuration));
|
|
5746
5439
|
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
5440
|
configurationRegistry.onDidSchemaChange ?? (configurationRegistry.onDidSchemaChange = configurationRegistry._onDidSchemaChange.event);
|
|
5750
5441
|
configurationRegistry.notifyConfigurationSchemaUpdated ?? (configurationRegistry.notifyConfigurationSchemaUpdated = () => {
|
|
5751
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5752
5442
|
configurationRegistry._onDidSchemaChange.fire();
|
|
5753
5443
|
});
|
|
5754
|
-
|
|
5755
|
-
(_a = NoOpNotification$1.prototype).onDidClose ?? (_a.onDidClose = Event.None);
|
|
5444
|
+
(_a = NoOpNotification.prototype).onDidClose ?? (_a.onDidClose = Event.None);
|
|
5756
5445
|
function polyfillQuickInput(fn) {
|
|
5757
5446
|
return function () {
|
|
5758
5447
|
const quickInput = fn.call(this);
|
|
5759
|
-
// @ts-ignore Override of a readonly property
|
|
5760
5448
|
quickInput.onDidTriggerButton ?? (quickInput.onDidTriggerButton = quickInput.onDidTriggerButtonEmitter.event);
|
|
5761
5449
|
return quickInput;
|
|
5762
5450
|
};
|
|
5763
5451
|
}
|
|
5764
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5765
5452
|
QuickInputController.prototype.createQuickPick = polyfillQuickInput(QuickInputController.prototype.createQuickPick);
|
|
5766
5453
|
QuickInputController.prototype.createInputBox = polyfillQuickInput(QuickInputController.prototype.createInputBox);
|
|
5767
5454
|
const StandaloneUriLabelService = getSingletonServiceDescriptors().find(([id]) => id === ILabelService)[1].ctor;
|
|
5768
5455
|
(_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
5456
|
function toVSCodeVSBuffer(value) {
|
|
5774
5457
|
if (value instanceof VSBuffer$1) {
|
|
5775
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5776
5458
|
return VSBuffer.wrap(value.buffer);
|
|
5777
5459
|
}
|
|
5778
5460
|
return value;
|
|
@@ -5785,18 +5467,13 @@ function toMonacoVSBuffer(value) {
|
|
|
5785
5467
|
}
|
|
5786
5468
|
for (const key of Object.getOwnPropertyNames(VSBuffer)) {
|
|
5787
5469
|
if (!Object.hasOwnProperty.call(VSBuffer$1, key)) {
|
|
5788
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5789
5470
|
const method = VSBuffer[key];
|
|
5790
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5791
5471
|
VSBuffer[key] = VSBuffer$1[key] = function (...args) {
|
|
5792
5472
|
return toMonacoVSBuffer(method.call(VSBuffer$1, ...args.map(toVSCodeVSBuffer)));
|
|
5793
5473
|
};
|
|
5794
5474
|
}
|
|
5795
5475
|
}
|
|
5796
5476
|
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
5477
|
function toMonacoColor(value) {
|
|
5801
5478
|
if (value instanceof Color) {
|
|
5802
5479
|
return new Color$1(value.rgba);
|
|
@@ -5805,11 +5482,9 @@ function toMonacoColor(value) {
|
|
|
5805
5482
|
}
|
|
5806
5483
|
function toVSCodeColor(value) {
|
|
5807
5484
|
if (value instanceof Color$1) {
|
|
5808
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5809
5485
|
return new Color(value.rgba);
|
|
5810
5486
|
}
|
|
5811
5487
|
return value;
|
|
5812
5488
|
}
|
|
5813
5489
|
polyfillPrototype(Color$1.prototype, Color.prototype, toMonacoColor, toVSCodeColor);
|
|
5814
|
-
|
|
5815
|
-
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 };
|
|
5490
|
+
export { ConsoleMainLogger as C, Emitter as E, NotImplementedError as N, ResourceSet as R, UserSettings as U, isReadableStream as a, peekReadable as b, bufferToReadable as c, disposed as d, consumeStream as e, isReadableBufferedStream as f, bufferedStreamToBuffer as g, readableToBuffer as h, isWorkspaceIdentifier as i, newWriteableStream as j, parse as k, listenStream as l, getNodeType as m, newWriteableBufferStream as n, peekStream as p, readonly as r, streamToBuffer as s, transform as t };
|