@codingame/monaco-vscode-api 1.67.17 → 1.67.20
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/README.md +15 -2
- package/dist/api.js +3 -3
- package/dist/{async-c7fd4178.js → async-088c7d8b.js} +1 -1
- package/dist/configuration.d.ts +248 -2
- package/dist/configuration.js +24 -931
- package/dist/messages.js +8 -7
- package/dist/missing-services-9c48c894.js +3177 -0
- package/dist/modelEditor.js +6 -5
- package/dist/{services-9299c4ca.js → services-a8445f52.js} +20 -1
- package/dist/services.js +1 -1
- package/package.json +1 -1
- package/dist/missing-services-597951f0.js +0 -1285
package/dist/configuration.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { E as Emitter, i as isReadableStream, p as peekStream, b as peekReadable, c as bufferToReadable, s as streamToBuffer, d as consumeStream, t as transform, e as isReadableBufferedStream, l as listenStream, f as bufferedStreamToBuffer, r as readableToBuffer, n as newWriteableBufferStream, g as newWriteableStream, u as unsupported } from './missing-services-
|
|
2
|
-
import { Disposable, toDisposable, dispose, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
3
|
-
import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
4
|
-
import { getConfigurationValue, addToValueTree, removeFromValueTree, toValuesTree, IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
5
|
-
import { distinct, equals, coalesce } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
6
|
-
import { deepClone, deepFreeze } from 'monaco-editor/esm/vs/base/common/objects.js';
|
|
7
|
-
import { isObject, isUndefinedOrNull } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
8
|
-
import { OVERRIDE_PROPERTY_REGEX, overrideIdentifiersFromKey, Extensions } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
|
|
9
|
-
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
1
|
+
import { E as Emitter, U as UserSettings, i as isReadableStream, p as peekStream, b as peekReadable, c as bufferToReadable, s as streamToBuffer, d as consumeStream, t as transform, e as isReadableBufferedStream, l as listenStream, f as bufferedStreamToBuffer, r as readableToBuffer, n as newWriteableBufferStream, g as newWriteableStream, u as unsupported } from './missing-services-9c48c894.js';
|
|
10
2
|
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
3
|
+
import { Disposable, toDisposable, dispose, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
11
4
|
import { extUriBiasedIgnorePathCase, isAbsolutePath, extUri, extUriIgnorePathCase } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
12
|
-
import { Configuration, DefaultConfigurationModel, ConfigurationModel
|
|
5
|
+
import { Configuration, DefaultConfigurationModel, ConfigurationModel, ConfigurationChangeEvent } from 'monaco-editor/esm/vs/platform/configuration/common/configurationModels.js';
|
|
13
6
|
import { RunOnceScheduler, Promises } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
7
|
+
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
8
|
+
import { Extensions } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
|
|
14
9
|
import { b as __decorate, c as __param } from './tslib.es6-16b40665.js';
|
|
15
|
-
import {
|
|
10
|
+
import { B as ensureFileSystemProviderError, D as createFileSystemProviderError, F as FileSystemProviderErrorCode, E as FileChangesEvent, G as FileOperationError, H as hasOpenReadWriteCloseCapability, J as hasReadWriteCapability, K as hasFileReadStreamCapability, L as toFileSystemProviderErrorCode, t as FileType, u as FilePermission, M as etag, O as FileOperationEvent, P as toFileOperationResult, Q as ETAG_DISABLED, R as hasFileAtomicReadCapability, T as NotModifiedSinceFileOperationError, U as hasFileFolderCopyCapability, C as CancellationTokenSource } from './services-a8445f52.js';
|
|
16
11
|
import { VSBuffer } from 'monaco-editor/esm/vs/base/common/buffer.js';
|
|
17
12
|
import { canceled } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
18
13
|
import { localize } from 'monaco-editor/esm/vs/nls.js';
|
|
19
|
-
import { R as ResourceQueue } from './async-
|
|
14
|
+
import { R as ResourceQueue } from './async-088c7d8b.js';
|
|
20
15
|
import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
|
|
21
16
|
import { TernarySearchTree } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
17
|
+
import { coalesce } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
22
18
|
import { hash } from 'monaco-editor/esm/vs/base/common/hash.js';
|
|
23
19
|
import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
|
|
24
20
|
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
25
21
|
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
26
22
|
import { P as Position } from './position-291dfe99.js';
|
|
23
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
27
24
|
import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
|
|
28
25
|
import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
|
|
29
26
|
import { StandaloneServices } from 'monaco-editor/esm/vs/editor/standalone/browser/standaloneServices.js';
|
|
30
27
|
import { ITextResourceConfigurationService } from 'monaco-editor/esm/vs/editor/common/services/textResourceConfiguration.js';
|
|
31
28
|
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
29
|
+
import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
32
30
|
import 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
|
|
33
31
|
import 'monaco-editor/esm/vs/base/browser/ui/progressbar/progressbar.js';
|
|
32
|
+
import 'monaco-editor/esm/vs/base/common/objects.js';
|
|
34
33
|
import 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
34
|
+
import 'monaco-editor/esm/vs/base/common/types.js';
|
|
35
35
|
import 'monaco-editor/esm/vs/base/common/color.js';
|
|
36
36
|
import 'monaco-editor/esm/vs/editor/common/services/languageService.js';
|
|
37
37
|
import 'monaco-editor/esm/vs/editor/common/services/languagesRegistry.js';
|
|
38
38
|
import 'monaco-editor/esm/vs/editor/common/languages/modesRegistry.js';
|
|
39
39
|
import 'monaco-editor/esm/vs/editor/common/languages.js';
|
|
40
40
|
import 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
41
|
+
import 'monaco-editor/esm/vs/base/common/strings.js';
|
|
41
42
|
import 'monaco-editor/esm/vs/base/parts/quickinput/browser/quickInput.js';
|
|
42
43
|
import 'monaco-editor/esm/vs/platform/instantiation/common/extensions.js';
|
|
43
44
|
import 'monaco-editor/esm/vs/platform/label/common/label.js';
|
|
44
45
|
import 'monaco-editor/esm/vs/editor/editor.api.js';
|
|
45
46
|
import 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
46
47
|
import 'monaco-editor/esm/vs/editor/common/languageFeatureRegistry.js';
|
|
47
|
-
import 'monaco-editor/esm/vs/base/common/strings.js';
|
|
48
48
|
import 'monaco-editor/esm/vs/base/browser/event.js';
|
|
49
49
|
import 'monaco-editor/esm/vs/platform/environment/common/environment.js';
|
|
50
50
|
import 'monaco-editor/esm/vs/base/common/platform.js';
|
|
@@ -72,920 +72,6 @@ function isConfigurationOverrides(thing) {
|
|
|
72
72
|
&& (!thing.overrideIdentifier || typeof thing.overrideIdentifier === 'string')
|
|
73
73
|
&& (!thing.resource || thing.resource instanceof URI);
|
|
74
74
|
}
|
|
75
|
-
var ParseOptions;
|
|
76
|
-
(function(ParseOptions) {
|
|
77
|
-
ParseOptions.DEFAULT = {
|
|
78
|
-
allowTrailingComma: true
|
|
79
|
-
};
|
|
80
|
-
})(ParseOptions || (ParseOptions = {}));
|
|
81
|
-
function createScanner(text, ignoreTrivia = false) {
|
|
82
|
-
let pos = 0, len = text.length, value = '', tokenOffset = 0, token = 16 , scanError = 0 ;
|
|
83
|
-
function scanHexDigits(count) {
|
|
84
|
-
let digits = 0;
|
|
85
|
-
let hexValue = 0;
|
|
86
|
-
while (digits < count) {
|
|
87
|
-
const ch = text.charCodeAt(pos);
|
|
88
|
-
if (ch >= 48 && ch <= 57 ) {
|
|
89
|
-
hexValue = hexValue * 16 + ch - 48 ;
|
|
90
|
-
}
|
|
91
|
-
else if (ch >= 65 && ch <= 70 ) {
|
|
92
|
-
hexValue = hexValue * 16 + ch - 65 + 10;
|
|
93
|
-
}
|
|
94
|
-
else if (ch >= 97 && ch <= 102 ) {
|
|
95
|
-
hexValue = hexValue * 16 + ch - 97 + 10;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
pos++;
|
|
101
|
-
digits++;
|
|
102
|
-
}
|
|
103
|
-
if (digits < count) {
|
|
104
|
-
hexValue = -1;
|
|
105
|
-
}
|
|
106
|
-
return hexValue;
|
|
107
|
-
}
|
|
108
|
-
function setPosition(newPosition) {
|
|
109
|
-
pos = newPosition;
|
|
110
|
-
value = '';
|
|
111
|
-
tokenOffset = 0;
|
|
112
|
-
token = 16 ;
|
|
113
|
-
scanError = 0 ;
|
|
114
|
-
}
|
|
115
|
-
function scanNumber() {
|
|
116
|
-
const start = pos;
|
|
117
|
-
if (text.charCodeAt(pos) === 48 ) {
|
|
118
|
-
pos++;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
pos++;
|
|
122
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
123
|
-
pos++;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (pos < text.length && text.charCodeAt(pos) === 46 ) {
|
|
127
|
-
pos++;
|
|
128
|
-
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
129
|
-
pos++;
|
|
130
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
131
|
-
pos++;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
scanError = 3 ;
|
|
136
|
-
return text.substring(start, pos);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
let end = pos;
|
|
140
|
-
if (pos < text.length && ((text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) )) {
|
|
141
|
-
pos++;
|
|
142
|
-
if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45 ) {
|
|
143
|
-
pos++;
|
|
144
|
-
}
|
|
145
|
-
if (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
146
|
-
pos++;
|
|
147
|
-
while (pos < text.length && isDigit(text.charCodeAt(pos))) {
|
|
148
|
-
pos++;
|
|
149
|
-
}
|
|
150
|
-
end = pos;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
scanError = 3 ;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return text.substring(start, end);
|
|
157
|
-
}
|
|
158
|
-
function scanString() {
|
|
159
|
-
let result = '', start = pos;
|
|
160
|
-
while (true) {
|
|
161
|
-
if (pos >= len) {
|
|
162
|
-
result += text.substring(start, pos);
|
|
163
|
-
scanError = 2 ;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
const ch = text.charCodeAt(pos);
|
|
167
|
-
if (ch === 34 ) {
|
|
168
|
-
result += text.substring(start, pos);
|
|
169
|
-
pos++;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
if (ch === 92 ) {
|
|
173
|
-
result += text.substring(start, pos);
|
|
174
|
-
pos++;
|
|
175
|
-
if (pos >= len) {
|
|
176
|
-
scanError = 2 ;
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
const ch2 = text.charCodeAt(pos++);
|
|
180
|
-
switch (ch2) {
|
|
181
|
-
case 34 :
|
|
182
|
-
result += '\"';
|
|
183
|
-
break;
|
|
184
|
-
case 92 :
|
|
185
|
-
result += '\\';
|
|
186
|
-
break;
|
|
187
|
-
case 47 :
|
|
188
|
-
result += '/';
|
|
189
|
-
break;
|
|
190
|
-
case 98 :
|
|
191
|
-
result += '\b';
|
|
192
|
-
break;
|
|
193
|
-
case 102 :
|
|
194
|
-
result += '\f';
|
|
195
|
-
break;
|
|
196
|
-
case 110 :
|
|
197
|
-
result += '\n';
|
|
198
|
-
break;
|
|
199
|
-
case 114 :
|
|
200
|
-
result += '\r';
|
|
201
|
-
break;
|
|
202
|
-
case 116 :
|
|
203
|
-
result += '\t';
|
|
204
|
-
break;
|
|
205
|
-
case 117 : {
|
|
206
|
-
const ch3 = scanHexDigits(4);
|
|
207
|
-
if (ch3 >= 0) {
|
|
208
|
-
result += String.fromCharCode(ch3);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
scanError = 4 ;
|
|
212
|
-
}
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
default:
|
|
216
|
-
scanError = 5 ;
|
|
217
|
-
}
|
|
218
|
-
start = pos;
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
if (ch >= 0 && ch <= 0x1F) {
|
|
222
|
-
if (isLineBreak(ch)) {
|
|
223
|
-
result += text.substring(start, pos);
|
|
224
|
-
scanError = 2 ;
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
scanError = 6 ;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
pos++;
|
|
232
|
-
}
|
|
233
|
-
return result;
|
|
234
|
-
}
|
|
235
|
-
function scanNext() {
|
|
236
|
-
value = '';
|
|
237
|
-
scanError = 0 ;
|
|
238
|
-
tokenOffset = pos;
|
|
239
|
-
if (pos >= len) {
|
|
240
|
-
tokenOffset = len;
|
|
241
|
-
return token = 17 ;
|
|
242
|
-
}
|
|
243
|
-
let code = text.charCodeAt(pos);
|
|
244
|
-
if (isWhitespace(code)) {
|
|
245
|
-
do {
|
|
246
|
-
pos++;
|
|
247
|
-
value += String.fromCharCode(code);
|
|
248
|
-
code = text.charCodeAt(pos);
|
|
249
|
-
} while (isWhitespace(code));
|
|
250
|
-
return token = 15 ;
|
|
251
|
-
}
|
|
252
|
-
if (isLineBreak(code)) {
|
|
253
|
-
pos++;
|
|
254
|
-
value += String.fromCharCode(code);
|
|
255
|
-
if (code === 13 && text.charCodeAt(pos) === 10 ) {
|
|
256
|
-
pos++;
|
|
257
|
-
value += '\n';
|
|
258
|
-
}
|
|
259
|
-
return token = 14 ;
|
|
260
|
-
}
|
|
261
|
-
switch (code) {
|
|
262
|
-
case 123 :
|
|
263
|
-
pos++;
|
|
264
|
-
return token = 1 ;
|
|
265
|
-
case 125 :
|
|
266
|
-
pos++;
|
|
267
|
-
return token = 2 ;
|
|
268
|
-
case 91 :
|
|
269
|
-
pos++;
|
|
270
|
-
return token = 3 ;
|
|
271
|
-
case 93 :
|
|
272
|
-
pos++;
|
|
273
|
-
return token = 4 ;
|
|
274
|
-
case 58 :
|
|
275
|
-
pos++;
|
|
276
|
-
return token = 6 ;
|
|
277
|
-
case 44 :
|
|
278
|
-
pos++;
|
|
279
|
-
return token = 5 ;
|
|
280
|
-
case 34 :
|
|
281
|
-
pos++;
|
|
282
|
-
value = scanString();
|
|
283
|
-
return token = 10 ;
|
|
284
|
-
case 47 : {
|
|
285
|
-
const start = pos - 1;
|
|
286
|
-
if (text.charCodeAt(pos + 1) === 47 ) {
|
|
287
|
-
pos += 2;
|
|
288
|
-
while (pos < len) {
|
|
289
|
-
if (isLineBreak(text.charCodeAt(pos))) {
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
pos++;
|
|
293
|
-
}
|
|
294
|
-
value = text.substring(start, pos);
|
|
295
|
-
return token = 12 ;
|
|
296
|
-
}
|
|
297
|
-
if (text.charCodeAt(pos + 1) === 42 ) {
|
|
298
|
-
pos += 2;
|
|
299
|
-
const safeLength = len - 1;
|
|
300
|
-
let commentClosed = false;
|
|
301
|
-
while (pos < safeLength) {
|
|
302
|
-
const ch = text.charCodeAt(pos);
|
|
303
|
-
if (ch === 42 && text.charCodeAt(pos + 1) === 47 ) {
|
|
304
|
-
pos += 2;
|
|
305
|
-
commentClosed = true;
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
pos++;
|
|
309
|
-
}
|
|
310
|
-
if (!commentClosed) {
|
|
311
|
-
pos++;
|
|
312
|
-
scanError = 1 ;
|
|
313
|
-
}
|
|
314
|
-
value = text.substring(start, pos);
|
|
315
|
-
return token = 13 ;
|
|
316
|
-
}
|
|
317
|
-
value += String.fromCharCode(code);
|
|
318
|
-
pos++;
|
|
319
|
-
return token = 16 ;
|
|
320
|
-
}
|
|
321
|
-
case 45 :
|
|
322
|
-
value += String.fromCharCode(code);
|
|
323
|
-
pos++;
|
|
324
|
-
if (pos === len || !isDigit(text.charCodeAt(pos))) {
|
|
325
|
-
return token = 16 ;
|
|
326
|
-
}
|
|
327
|
-
case 48 :
|
|
328
|
-
case 49 :
|
|
329
|
-
case 50 :
|
|
330
|
-
case 51 :
|
|
331
|
-
case 52 :
|
|
332
|
-
case 53 :
|
|
333
|
-
case 54 :
|
|
334
|
-
case 55 :
|
|
335
|
-
case 56 :
|
|
336
|
-
case 57 :
|
|
337
|
-
value += scanNumber();
|
|
338
|
-
return token = 11 ;
|
|
339
|
-
default:
|
|
340
|
-
while (pos < len && isUnknownContentCharacter(code)) {
|
|
341
|
-
pos++;
|
|
342
|
-
code = text.charCodeAt(pos);
|
|
343
|
-
}
|
|
344
|
-
if (tokenOffset !== pos) {
|
|
345
|
-
value = text.substring(tokenOffset, pos);
|
|
346
|
-
switch (value) {
|
|
347
|
-
case 'true': return token = 8 ;
|
|
348
|
-
case 'false': return token = 9 ;
|
|
349
|
-
case 'null': return token = 7 ;
|
|
350
|
-
}
|
|
351
|
-
return token = 16 ;
|
|
352
|
-
}
|
|
353
|
-
value += String.fromCharCode(code);
|
|
354
|
-
pos++;
|
|
355
|
-
return token = 16 ;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
function isUnknownContentCharacter(code) {
|
|
359
|
-
if (isWhitespace(code) || isLineBreak(code)) {
|
|
360
|
-
return false;
|
|
361
|
-
}
|
|
362
|
-
switch (code) {
|
|
363
|
-
case 125 :
|
|
364
|
-
case 93 :
|
|
365
|
-
case 123 :
|
|
366
|
-
case 91 :
|
|
367
|
-
case 34 :
|
|
368
|
-
case 58 :
|
|
369
|
-
case 44 :
|
|
370
|
-
case 47 :
|
|
371
|
-
return false;
|
|
372
|
-
}
|
|
373
|
-
return true;
|
|
374
|
-
}
|
|
375
|
-
function scanNextNonTrivia() {
|
|
376
|
-
let result;
|
|
377
|
-
do {
|
|
378
|
-
result = scanNext();
|
|
379
|
-
} while (result >= 12 && result <= 15 );
|
|
380
|
-
return result;
|
|
381
|
-
}
|
|
382
|
-
return {
|
|
383
|
-
setPosition: setPosition,
|
|
384
|
-
getPosition: () => pos,
|
|
385
|
-
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
386
|
-
getToken: () => token,
|
|
387
|
-
getTokenValue: () => value,
|
|
388
|
-
getTokenOffset: () => tokenOffset,
|
|
389
|
-
getTokenLength: () => pos - tokenOffset,
|
|
390
|
-
getTokenError: () => scanError
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
function isWhitespace(ch) {
|
|
394
|
-
return ch === 32 || ch === 9 || ch === 11 || ch === 12 ||
|
|
395
|
-
ch === 160 || ch === 5760 || ch >= 8192 && ch <= 8203 ||
|
|
396
|
-
ch === 8239 || ch === 8287 || ch === 12288 || ch === 65279 ;
|
|
397
|
-
}
|
|
398
|
-
function isLineBreak(ch) {
|
|
399
|
-
return ch === 10 || ch === 13 || ch === 8232 || ch === 8233 ;
|
|
400
|
-
}
|
|
401
|
-
function isDigit(ch) {
|
|
402
|
-
return ch >= 48 && ch <= 57 ;
|
|
403
|
-
}
|
|
404
|
-
function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
405
|
-
const _scanner = createScanner(text, false);
|
|
406
|
-
function toNoArgVisit(visitFunction) {
|
|
407
|
-
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength()) : () => true;
|
|
408
|
-
}
|
|
409
|
-
function toOneArgVisit(visitFunction) {
|
|
410
|
-
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength()) : () => true;
|
|
411
|
-
}
|
|
412
|
-
const onObjectBegin = toNoArgVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisit(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisit(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisit(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
413
|
-
const disallowComments = options && options.disallowComments;
|
|
414
|
-
const allowTrailingComma = options && options.allowTrailingComma;
|
|
415
|
-
function scanNext() {
|
|
416
|
-
while (true) {
|
|
417
|
-
const token = _scanner.scan();
|
|
418
|
-
switch (_scanner.getTokenError()) {
|
|
419
|
-
case 4 :
|
|
420
|
-
handleError(14 );
|
|
421
|
-
break;
|
|
422
|
-
case 5 :
|
|
423
|
-
handleError(15 );
|
|
424
|
-
break;
|
|
425
|
-
case 3 :
|
|
426
|
-
handleError(13 );
|
|
427
|
-
break;
|
|
428
|
-
case 1 :
|
|
429
|
-
if (!disallowComments) {
|
|
430
|
-
handleError(11 );
|
|
431
|
-
}
|
|
432
|
-
break;
|
|
433
|
-
case 2 :
|
|
434
|
-
handleError(12 );
|
|
435
|
-
break;
|
|
436
|
-
case 6 :
|
|
437
|
-
handleError(16 );
|
|
438
|
-
break;
|
|
439
|
-
}
|
|
440
|
-
switch (token) {
|
|
441
|
-
case 12 :
|
|
442
|
-
case 13 :
|
|
443
|
-
if (disallowComments) {
|
|
444
|
-
handleError(10 );
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
onComment();
|
|
448
|
-
}
|
|
449
|
-
break;
|
|
450
|
-
case 16 :
|
|
451
|
-
handleError(1 );
|
|
452
|
-
break;
|
|
453
|
-
case 15 :
|
|
454
|
-
case 14 :
|
|
455
|
-
break;
|
|
456
|
-
default:
|
|
457
|
-
return token;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
462
|
-
onError(error);
|
|
463
|
-
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
464
|
-
let token = _scanner.getToken();
|
|
465
|
-
while (token !== 17 ) {
|
|
466
|
-
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
467
|
-
scanNext();
|
|
468
|
-
break;
|
|
469
|
-
}
|
|
470
|
-
else if (skipUntil.indexOf(token) !== -1) {
|
|
471
|
-
break;
|
|
472
|
-
}
|
|
473
|
-
token = scanNext();
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
function parseString(isValue) {
|
|
478
|
-
const value = _scanner.getTokenValue();
|
|
479
|
-
if (isValue) {
|
|
480
|
-
onLiteralValue(value);
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
onObjectProperty(value);
|
|
484
|
-
}
|
|
485
|
-
scanNext();
|
|
486
|
-
return true;
|
|
487
|
-
}
|
|
488
|
-
function parseLiteral() {
|
|
489
|
-
switch (_scanner.getToken()) {
|
|
490
|
-
case 11 : {
|
|
491
|
-
let value = 0;
|
|
492
|
-
try {
|
|
493
|
-
value = JSON.parse(_scanner.getTokenValue());
|
|
494
|
-
if (typeof value !== 'number') {
|
|
495
|
-
handleError(2 );
|
|
496
|
-
value = 0;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
catch (e) {
|
|
500
|
-
handleError(2 );
|
|
501
|
-
}
|
|
502
|
-
onLiteralValue(value);
|
|
503
|
-
break;
|
|
504
|
-
}
|
|
505
|
-
case 7 :
|
|
506
|
-
onLiteralValue(null);
|
|
507
|
-
break;
|
|
508
|
-
case 8 :
|
|
509
|
-
onLiteralValue(true);
|
|
510
|
-
break;
|
|
511
|
-
case 9 :
|
|
512
|
-
onLiteralValue(false);
|
|
513
|
-
break;
|
|
514
|
-
default:
|
|
515
|
-
return false;
|
|
516
|
-
}
|
|
517
|
-
scanNext();
|
|
518
|
-
return true;
|
|
519
|
-
}
|
|
520
|
-
function parseProperty() {
|
|
521
|
-
if (_scanner.getToken() !== 10 ) {
|
|
522
|
-
handleError(3 , [], [2 , 5 ]);
|
|
523
|
-
return false;
|
|
524
|
-
}
|
|
525
|
-
parseString(false);
|
|
526
|
-
if (_scanner.getToken() === 6 ) {
|
|
527
|
-
onSeparator(':');
|
|
528
|
-
scanNext();
|
|
529
|
-
if (!parseValue()) {
|
|
530
|
-
handleError(4 , [], [2 , 5 ]);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
else {
|
|
534
|
-
handleError(5 , [], [2 , 5 ]);
|
|
535
|
-
}
|
|
536
|
-
return true;
|
|
537
|
-
}
|
|
538
|
-
function parseObject() {
|
|
539
|
-
onObjectBegin();
|
|
540
|
-
scanNext();
|
|
541
|
-
let needsComma = false;
|
|
542
|
-
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17 ) {
|
|
543
|
-
if (_scanner.getToken() === 5 ) {
|
|
544
|
-
if (!needsComma) {
|
|
545
|
-
handleError(4 , [], []);
|
|
546
|
-
}
|
|
547
|
-
onSeparator(',');
|
|
548
|
-
scanNext();
|
|
549
|
-
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
550
|
-
break;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
else if (needsComma) {
|
|
554
|
-
handleError(6 , [], []);
|
|
555
|
-
}
|
|
556
|
-
if (!parseProperty()) {
|
|
557
|
-
handleError(4 , [], [2 , 5 ]);
|
|
558
|
-
}
|
|
559
|
-
needsComma = true;
|
|
560
|
-
}
|
|
561
|
-
onObjectEnd();
|
|
562
|
-
if (_scanner.getToken() !== 2 ) {
|
|
563
|
-
handleError(7 , [2 ], []);
|
|
564
|
-
}
|
|
565
|
-
else {
|
|
566
|
-
scanNext();
|
|
567
|
-
}
|
|
568
|
-
return true;
|
|
569
|
-
}
|
|
570
|
-
function parseArray() {
|
|
571
|
-
onArrayBegin();
|
|
572
|
-
scanNext();
|
|
573
|
-
let needsComma = false;
|
|
574
|
-
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17 ) {
|
|
575
|
-
if (_scanner.getToken() === 5 ) {
|
|
576
|
-
if (!needsComma) {
|
|
577
|
-
handleError(4 , [], []);
|
|
578
|
-
}
|
|
579
|
-
onSeparator(',');
|
|
580
|
-
scanNext();
|
|
581
|
-
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
582
|
-
break;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
else if (needsComma) {
|
|
586
|
-
handleError(6 , [], []);
|
|
587
|
-
}
|
|
588
|
-
if (!parseValue()) {
|
|
589
|
-
handleError(4 , [], [4 , 5 ]);
|
|
590
|
-
}
|
|
591
|
-
needsComma = true;
|
|
592
|
-
}
|
|
593
|
-
onArrayEnd();
|
|
594
|
-
if (_scanner.getToken() !== 4 ) {
|
|
595
|
-
handleError(8 , [4 ], []);
|
|
596
|
-
}
|
|
597
|
-
else {
|
|
598
|
-
scanNext();
|
|
599
|
-
}
|
|
600
|
-
return true;
|
|
601
|
-
}
|
|
602
|
-
function parseValue() {
|
|
603
|
-
switch (_scanner.getToken()) {
|
|
604
|
-
case 3 :
|
|
605
|
-
return parseArray();
|
|
606
|
-
case 1 :
|
|
607
|
-
return parseObject();
|
|
608
|
-
case 10 :
|
|
609
|
-
return parseString(true);
|
|
610
|
-
default:
|
|
611
|
-
return parseLiteral();
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
scanNext();
|
|
615
|
-
if (_scanner.getToken() === 17 ) {
|
|
616
|
-
if (options.allowEmptyContent) {
|
|
617
|
-
return true;
|
|
618
|
-
}
|
|
619
|
-
handleError(4 , [], []);
|
|
620
|
-
return false;
|
|
621
|
-
}
|
|
622
|
-
if (!parseValue()) {
|
|
623
|
-
handleError(4 , [], []);
|
|
624
|
-
return false;
|
|
625
|
-
}
|
|
626
|
-
if (_scanner.getToken() !== 17 ) {
|
|
627
|
-
handleError(9 , [], []);
|
|
628
|
-
}
|
|
629
|
-
return true;
|
|
630
|
-
}
|
|
631
|
-
class ConfigurationModel {
|
|
632
|
-
constructor(_contents = {}, _keys = [], _overrides = []) {
|
|
633
|
-
this._contents = _contents;
|
|
634
|
-
this._keys = _keys;
|
|
635
|
-
this._overrides = _overrides;
|
|
636
|
-
this.isFrozen = false;
|
|
637
|
-
this.overrideConfigurations = new Map();
|
|
638
|
-
}
|
|
639
|
-
get contents() {
|
|
640
|
-
return this.checkAndFreeze(this._contents);
|
|
641
|
-
}
|
|
642
|
-
get overrides() {
|
|
643
|
-
return this.checkAndFreeze(this._overrides);
|
|
644
|
-
}
|
|
645
|
-
get keys() {
|
|
646
|
-
return this.checkAndFreeze(this._keys);
|
|
647
|
-
}
|
|
648
|
-
isEmpty() {
|
|
649
|
-
return this._keys.length === 0 && Object.keys(this._contents).length === 0 && this._overrides.length === 0;
|
|
650
|
-
}
|
|
651
|
-
getValue(section) {
|
|
652
|
-
return section ? getConfigurationValue(this.contents, section) : this.contents;
|
|
653
|
-
}
|
|
654
|
-
getOverrideValue(section, overrideIdentifier) {
|
|
655
|
-
const overrideContents = this.getContentsForOverrideIdentifer(overrideIdentifier);
|
|
656
|
-
return overrideContents
|
|
657
|
-
? section ? getConfigurationValue(overrideContents, section) : overrideContents
|
|
658
|
-
: undefined;
|
|
659
|
-
}
|
|
660
|
-
getKeysForOverrideIdentifier(identifier) {
|
|
661
|
-
const keys = [];
|
|
662
|
-
for (const override of this.overrides) {
|
|
663
|
-
if (override.identifiers.includes(identifier)) {
|
|
664
|
-
keys.push(...override.keys);
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
return distinct(keys);
|
|
668
|
-
}
|
|
669
|
-
getAllOverrideIdentifiers() {
|
|
670
|
-
const result = [];
|
|
671
|
-
for (const override of this.overrides) {
|
|
672
|
-
result.push(...override.identifiers);
|
|
673
|
-
}
|
|
674
|
-
return distinct(result);
|
|
675
|
-
}
|
|
676
|
-
override(identifier) {
|
|
677
|
-
let overrideConfigurationModel = this.overrideConfigurations.get(identifier);
|
|
678
|
-
if (!overrideConfigurationModel) {
|
|
679
|
-
overrideConfigurationModel = this.createOverrideConfigurationModel(identifier);
|
|
680
|
-
this.overrideConfigurations.set(identifier, overrideConfigurationModel);
|
|
681
|
-
}
|
|
682
|
-
return overrideConfigurationModel;
|
|
683
|
-
}
|
|
684
|
-
merge(...others) {
|
|
685
|
-
const contents = deepClone(this.contents);
|
|
686
|
-
const overrides = deepClone(this.overrides);
|
|
687
|
-
const keys = [...this.keys];
|
|
688
|
-
for (const other of others) {
|
|
689
|
-
this.mergeContents(contents, other.contents);
|
|
690
|
-
for (const otherOverride of other.overrides) {
|
|
691
|
-
const [override] = overrides.filter(o => equals(o.identifiers, otherOverride.identifiers));
|
|
692
|
-
if (override) {
|
|
693
|
-
this.mergeContents(override.contents, otherOverride.contents);
|
|
694
|
-
override.keys.push(...otherOverride.keys);
|
|
695
|
-
override.keys = distinct(override.keys);
|
|
696
|
-
}
|
|
697
|
-
else {
|
|
698
|
-
overrides.push(deepClone(otherOverride));
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
for (const key of other.keys) {
|
|
702
|
-
if (keys.indexOf(key) === -1) {
|
|
703
|
-
keys.push(key);
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
return (
|
|
708
|
-
new ConfigurationModel(contents, keys, overrides)
|
|
709
|
-
);
|
|
710
|
-
}
|
|
711
|
-
freeze() {
|
|
712
|
-
this.isFrozen = true;
|
|
713
|
-
return this;
|
|
714
|
-
}
|
|
715
|
-
createOverrideConfigurationModel(identifier) {
|
|
716
|
-
const overrideContents = this.getContentsForOverrideIdentifer(identifier);
|
|
717
|
-
if (!overrideContents || typeof overrideContents !== 'object' || !Object.keys(overrideContents).length) {
|
|
718
|
-
return this;
|
|
719
|
-
}
|
|
720
|
-
let contents = {};
|
|
721
|
-
for (const key of distinct([...Object.keys(this.contents), ...Object.keys(overrideContents)])) {
|
|
722
|
-
let contentsForKey = this.contents[key];
|
|
723
|
-
let overrideContentsForKey = overrideContents[key];
|
|
724
|
-
if (overrideContentsForKey) {
|
|
725
|
-
if (typeof contentsForKey === 'object' && typeof overrideContentsForKey === 'object') {
|
|
726
|
-
contentsForKey = deepClone(contentsForKey);
|
|
727
|
-
this.mergeContents(contentsForKey, overrideContentsForKey);
|
|
728
|
-
}
|
|
729
|
-
else {
|
|
730
|
-
contentsForKey = overrideContentsForKey;
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
contents[key] = contentsForKey;
|
|
734
|
-
}
|
|
735
|
-
return (
|
|
736
|
-
new ConfigurationModel(contents, this.keys, this.overrides)
|
|
737
|
-
);
|
|
738
|
-
}
|
|
739
|
-
mergeContents(source, target) {
|
|
740
|
-
for (const key of Object.keys(target)) {
|
|
741
|
-
if (key in source) {
|
|
742
|
-
if (isObject(source[key]) && isObject(target[key])) {
|
|
743
|
-
this.mergeContents(source[key], target[key]);
|
|
744
|
-
continue;
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
source[key] = deepClone(target[key]);
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
checkAndFreeze(data) {
|
|
751
|
-
if (this.isFrozen && !Object.isFrozen(data)) {
|
|
752
|
-
return deepFreeze(data);
|
|
753
|
-
}
|
|
754
|
-
return data;
|
|
755
|
-
}
|
|
756
|
-
getContentsForOverrideIdentifer(identifier) {
|
|
757
|
-
let contentsForIdentifierOnly = null;
|
|
758
|
-
let contents = null;
|
|
759
|
-
const mergeContents = (contentsToMerge) => {
|
|
760
|
-
if (contentsToMerge) {
|
|
761
|
-
if (contents) {
|
|
762
|
-
this.mergeContents(contents, contentsToMerge);
|
|
763
|
-
}
|
|
764
|
-
else {
|
|
765
|
-
contents = deepClone(contentsToMerge);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
for (const override of this.overrides) {
|
|
770
|
-
if (equals(override.identifiers, [identifier])) {
|
|
771
|
-
contentsForIdentifierOnly = override.contents;
|
|
772
|
-
}
|
|
773
|
-
else if (override.identifiers.includes(identifier)) {
|
|
774
|
-
mergeContents(override.contents);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
mergeContents(contentsForIdentifierOnly);
|
|
778
|
-
return contents;
|
|
779
|
-
}
|
|
780
|
-
toJSON() {
|
|
781
|
-
return {
|
|
782
|
-
contents: this.contents,
|
|
783
|
-
overrides: this.overrides,
|
|
784
|
-
keys: this.keys
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
|
-
setValue(key, value) {
|
|
788
|
-
this.addKey(key);
|
|
789
|
-
addToValueTree(this.contents, key, value, e => { throw new Error(e); });
|
|
790
|
-
}
|
|
791
|
-
removeValue(key) {
|
|
792
|
-
if (this.removeKey(key)) {
|
|
793
|
-
removeFromValueTree(this.contents, key);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
addKey(key) {
|
|
797
|
-
let index = this.keys.length;
|
|
798
|
-
for (let i = 0; i < index; i++) {
|
|
799
|
-
if (key.indexOf(this.keys[i]) === 0) {
|
|
800
|
-
index = i;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
this.keys.splice(index, 1, key);
|
|
804
|
-
}
|
|
805
|
-
removeKey(key) {
|
|
806
|
-
let index = this.keys.indexOf(key);
|
|
807
|
-
if (index !== -1) {
|
|
808
|
-
this.keys.splice(index, 1);
|
|
809
|
-
return true;
|
|
810
|
-
}
|
|
811
|
-
return false;
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
class ConfigurationModelParser {
|
|
815
|
-
constructor(_name) {
|
|
816
|
-
this._name = _name;
|
|
817
|
-
this._raw = null;
|
|
818
|
-
this._configurationModel = null;
|
|
819
|
-
this._restrictedConfigurations = [];
|
|
820
|
-
this._parseErrors = [];
|
|
821
|
-
}
|
|
822
|
-
get configurationModel() {
|
|
823
|
-
return this._configurationModel || new ConfigurationModel();
|
|
824
|
-
}
|
|
825
|
-
get restrictedConfigurations() {
|
|
826
|
-
return this._restrictedConfigurations;
|
|
827
|
-
}
|
|
828
|
-
get errors() {
|
|
829
|
-
return this._parseErrors;
|
|
830
|
-
}
|
|
831
|
-
parse(content, options) {
|
|
832
|
-
if (!isUndefinedOrNull(content)) {
|
|
833
|
-
const raw = this.doParseContent(content);
|
|
834
|
-
this.parseRaw(raw, options);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
reparse(options) {
|
|
838
|
-
if (this._raw) {
|
|
839
|
-
this.parseRaw(this._raw, options);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
parseRaw(raw, options) {
|
|
843
|
-
this._raw = raw;
|
|
844
|
-
const { contents, keys, overrides, restricted } = this.doParseRaw(raw, options);
|
|
845
|
-
this._configurationModel = new ConfigurationModel(contents, keys, overrides);
|
|
846
|
-
this._restrictedConfigurations = restricted || [];
|
|
847
|
-
}
|
|
848
|
-
doParseContent(content) {
|
|
849
|
-
let raw = {};
|
|
850
|
-
let currentProperty = null;
|
|
851
|
-
let currentParent = [];
|
|
852
|
-
let previousParents = [];
|
|
853
|
-
function onValue(value) {
|
|
854
|
-
if (Array.isArray(currentParent)) {
|
|
855
|
-
currentParent.push(value);
|
|
856
|
-
}
|
|
857
|
-
else if (currentProperty !== null) {
|
|
858
|
-
currentParent[currentProperty] = value;
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
let visitor = {
|
|
862
|
-
onObjectBegin: () => {
|
|
863
|
-
let object = {};
|
|
864
|
-
onValue(object);
|
|
865
|
-
previousParents.push(currentParent);
|
|
866
|
-
currentParent = object;
|
|
867
|
-
currentProperty = null;
|
|
868
|
-
},
|
|
869
|
-
onObjectProperty: (name) => {
|
|
870
|
-
currentProperty = name;
|
|
871
|
-
},
|
|
872
|
-
onObjectEnd: () => {
|
|
873
|
-
currentParent = previousParents.pop();
|
|
874
|
-
},
|
|
875
|
-
onArrayBegin: () => {
|
|
876
|
-
let array = [];
|
|
877
|
-
onValue(array);
|
|
878
|
-
previousParents.push(currentParent);
|
|
879
|
-
currentParent = array;
|
|
880
|
-
currentProperty = null;
|
|
881
|
-
},
|
|
882
|
-
onArrayEnd: () => {
|
|
883
|
-
currentParent = previousParents.pop();
|
|
884
|
-
},
|
|
885
|
-
onLiteralValue: onValue,
|
|
886
|
-
onError: (error, offset, length) => {
|
|
887
|
-
}
|
|
888
|
-
};
|
|
889
|
-
if (content) {
|
|
890
|
-
try {
|
|
891
|
-
visit(content, visitor);
|
|
892
|
-
raw = currentParent[0] || {};
|
|
893
|
-
}
|
|
894
|
-
catch (e) {
|
|
895
|
-
console.error(`Error while parsing settings file ${this._name}: ${e}`);
|
|
896
|
-
this._parseErrors = [e];
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
return raw;
|
|
900
|
-
}
|
|
901
|
-
doParseRaw(raw, options) {
|
|
902
|
-
const configurationProperties = Registry.as(Extensions.Configuration).getConfigurationProperties();
|
|
903
|
-
const filtered = this.filter(raw, configurationProperties, true, options);
|
|
904
|
-
raw = filtered.raw;
|
|
905
|
-
const contents = toValuesTree(raw, message => console.error(`Conflict in settings file ${this._name}: ${message}`));
|
|
906
|
-
const keys = Object.keys(raw);
|
|
907
|
-
const overrides = this.toOverrides(raw, message => console.error(`Conflict in settings file ${this._name}: ${message}`));
|
|
908
|
-
return { contents, keys, overrides, restricted: filtered.restricted };
|
|
909
|
-
}
|
|
910
|
-
filter(properties, configurationProperties, filterOverriddenProperties, options) {
|
|
911
|
-
if (!options?.scopes && !options?.skipRestricted) {
|
|
912
|
-
return { raw: properties, restricted: [] };
|
|
913
|
-
}
|
|
914
|
-
const raw = {};
|
|
915
|
-
const restricted = [];
|
|
916
|
-
for (let key in properties) {
|
|
917
|
-
if (OVERRIDE_PROPERTY_REGEX.test(key) && filterOverriddenProperties) {
|
|
918
|
-
const result = this.filter(properties[key], configurationProperties, false, options);
|
|
919
|
-
raw[key] = result.raw;
|
|
920
|
-
restricted.push(...result.restricted);
|
|
921
|
-
}
|
|
922
|
-
else {
|
|
923
|
-
const propertySchema = configurationProperties[key];
|
|
924
|
-
const scope = propertySchema ? typeof propertySchema.scope !== 'undefined' ? propertySchema.scope : 3 : undefined;
|
|
925
|
-
if (propertySchema?.restricted) {
|
|
926
|
-
restricted.push(key);
|
|
927
|
-
}
|
|
928
|
-
if (scope === undefined || options.scopes === undefined || options.scopes.includes(scope)) {
|
|
929
|
-
if (!(options.skipRestricted && propertySchema?.restricted)) {
|
|
930
|
-
raw[key] = properties[key];
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
return { raw, restricted };
|
|
936
|
-
}
|
|
937
|
-
toOverrides(raw, conflictReporter) {
|
|
938
|
-
const overrides = [];
|
|
939
|
-
for (const key of Object.keys(raw)) {
|
|
940
|
-
if (OVERRIDE_PROPERTY_REGEX.test(key)) {
|
|
941
|
-
const overrideRaw = {};
|
|
942
|
-
for (const keyInOverrideRaw in raw[key]) {
|
|
943
|
-
overrideRaw[keyInOverrideRaw] = raw[key][keyInOverrideRaw];
|
|
944
|
-
}
|
|
945
|
-
overrides.push({
|
|
946
|
-
identifiers: overrideIdentifiersFromKey(key),
|
|
947
|
-
keys: Object.keys(overrideRaw),
|
|
948
|
-
contents: toValuesTree(overrideRaw, conflictReporter)
|
|
949
|
-
});
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
return overrides;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
class UserSettings extends Disposable {
|
|
956
|
-
constructor(userSettingsResource, scopes, extUri, fileService) {
|
|
957
|
-
super();
|
|
958
|
-
this.userSettingsResource = userSettingsResource;
|
|
959
|
-
this.scopes = scopes;
|
|
960
|
-
this.fileService = fileService;
|
|
961
|
-
this._onDidChange = this._register( new Emitter());
|
|
962
|
-
this.onDidChange = this._onDidChange.event;
|
|
963
|
-
this.parser = new ConfigurationModelParser(this.userSettingsResource.toString());
|
|
964
|
-
this.parseOptions = { scopes: this.scopes };
|
|
965
|
-
this._register(this.fileService.watch(extUri.dirname(this.userSettingsResource)));
|
|
966
|
-
this._register(this.fileService.watch(this.userSettingsResource));
|
|
967
|
-
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(1 ) || e.isOperation(4 )) && extUri.isEqual(e.resource, userSettingsResource)))(() => this._onDidChange.fire()));
|
|
968
|
-
}
|
|
969
|
-
async loadConfiguration() {
|
|
970
|
-
try {
|
|
971
|
-
const content = await this.fileService.readFile(this.userSettingsResource);
|
|
972
|
-
this.parser.parse(content.value.toString() || '{}', this.parseOptions);
|
|
973
|
-
return this.parser.configurationModel;
|
|
974
|
-
}
|
|
975
|
-
catch (e) {
|
|
976
|
-
return (
|
|
977
|
-
new ConfigurationModel()
|
|
978
|
-
);
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
reparse() {
|
|
982
|
-
this.parser.reparse(this.parseOptions);
|
|
983
|
-
return this.parser.configurationModel;
|
|
984
|
-
}
|
|
985
|
-
getRestrictedSettings() {
|
|
986
|
-
return this.parser.restrictedConfigurations;
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
75
|
class ConfigurationService extends Disposable {
|
|
990
76
|
constructor(settingsResource, fileService) {
|
|
991
77
|
super();
|
|
@@ -993,7 +79,7 @@ class ConfigurationService extends Disposable {
|
|
|
993
79
|
this._onDidChangeConfiguration = this._register( new Emitter());
|
|
994
80
|
this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
|
|
995
81
|
this.userConfiguration = this._register( new UserSettings(this.settingsResource, undefined, extUriBiasedIgnorePathCase, fileService));
|
|
996
|
-
this.configuration = new Configuration( new DefaultConfigurationModel(), new ConfigurationModel
|
|
82
|
+
this.configuration = new Configuration( new DefaultConfigurationModel(), new ConfigurationModel());
|
|
997
83
|
this.reloadConfigurationScheduler = this._register( new RunOnceScheduler(() => this.reloadConfiguration(), 50));
|
|
998
84
|
this._register( Registry.as(Extensions.Configuration).onDidUpdateConfiguration(({ properties }) => this.onDidDefaultConfigurationChange(properties)));
|
|
999
85
|
this._register(this.userConfiguration.onDidChange(() => this.reloadConfigurationScheduler.schedule()));
|
|
@@ -2162,10 +1248,17 @@ function createConfigurationFileSystemProvider(settingsResource, readConfigurati
|
|
|
2162
1248
|
};
|
|
2163
1249
|
return provider;
|
|
2164
1250
|
}
|
|
2165
|
-
|
|
1251
|
+
let userConfigurationJson = '{}';
|
|
1252
|
+
const userConfigurationChangeEmitter = new Emitter();
|
|
1253
|
+
function updateUserConfiguration(configurationJson) {
|
|
1254
|
+
userConfigurationJson = configurationJson;
|
|
1255
|
+
userConfigurationChangeEmitter.fire(undefined);
|
|
1256
|
+
}
|
|
1257
|
+
const configurationRegistry = Registry.as(Extensions.Configuration);
|
|
1258
|
+
function getServiceOverride(settingsResource = URI.file('/userSettings.json')) {
|
|
2166
1259
|
const logService = StandaloneServices.get(ILogService);
|
|
2167
1260
|
const fileService = new FileService(logService);
|
|
2168
|
-
fileService.registerProvider(Schemas.file, createConfigurationFileSystemProvider(settingsResource,
|
|
1261
|
+
fileService.registerProvider(Schemas.file, createConfigurationFileSystemProvider(settingsResource, () => userConfigurationJson, userConfigurationChangeEmitter.event));
|
|
2169
1262
|
const configurationService = new ConfigurationService(settingsResource, fileService);
|
|
2170
1263
|
configurationService.initialize().catch(error => {
|
|
2171
1264
|
logService.error(error);
|
|
@@ -2175,4 +1268,4 @@ function getServiceOverride(readConfiguration, onChange, settingsResource = URI.
|
|
|
2175
1268
|
[ITextResourceConfigurationService.toString()]: new SyncDescriptor(TextResourceConfigurationService)
|
|
2176
1269
|
};
|
|
2177
1270
|
}
|
|
2178
|
-
export { getServiceOverride as default };
|
|
1271
|
+
export { configurationRegistry, getServiceOverride as default, updateUserConfiguration };
|