src/vs/platform/configuration/common/configurationRegistry.ts

1089 LOC · 974 covered · 115 uncovered · 195 ranges · 7450 concepts · 58 introducers · 3913 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- configurationRegistry.ts ×40
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { distinct } from '../../../base/common/arrays.js';
7 > import { IStringDictionary } from '../../../base/common/collections.js';
8 > import { Emitter, Event } from '../../../base/common/event.js';
9 > import { IJSONSchema } from '../../../base/common/jsonSchema.js';
10 > import * as types from '../../../base/common/types.js';
11 > import * as nls from '../../../nls.js';
12 > import { getLanguageTagSettingPlainKey } from './configuration.js';
13 > import { Extensions as JSONExtensions, IJSONContributionRegistry } from '../../jsonschemas/common/jsonContributionRegistry.js';
14 > import { Registry } from '../../registry/common/platform.js';
15 > import { IPolicy, IPolicyReference, PolicyName } from '../../../base/common/policy.js';
16 > import { Disposable } from '../../../base/common/lifecycle.js';
17 > import product from '../../product/common/product.js';
18 >
19 > export enum EditPresentationTypes {
20 > Multiline = 'multilineText',
21 > Singleline = 'singlelineText'
22 > }
23 >
24 > export const Extensions = {
25 > Configuration: 'base.contributions.configuration'
26 > };
27 >
28 > export interface IConfigurationDelta {
29 > removedDefaults?: IConfigurationDefaults[];
30 > removedConfigurations?: IConfigurationNode[];
31 > addedDefaults?: IConfigurationDefaults[];
32 > addedConfigurations?: IConfigurationNode[];
33 > }
34 >
35 > export interface IConfigurationRegistry {
36 >
37 > /**
38 > * Register a configuration to the registry.
39 > */
40 > registerConfiguration(configuration: IConfigurationNode): IConfigurationNode;
41 >
42 > /**
43 > * Register multiple configurations to the registry.
44 > */
45 > registerConfigurations(configurations: IConfigurationNode[], validate?: boolean): void;
46 >
47 > /**
48 > * Deregister multiple configurations from the registry.
49 > */
50 > deregisterConfigurations(configurations: IConfigurationNode[]): void;
51 >
52 > /**
53 > * update the configuration registry by
54 > * - registering the configurations to add
55 > * - dereigstering the configurations to remove
56 > */
57 > updateConfigurations(configurations: { add: IConfigurationNode[]; remove: IConfigurationNode[] }): void;
58 >
59 > /**
60 > * Register multiple default configurations to the registry.
61 > */
62 > registerDefaultConfigurations(defaultConfigurations: IConfigurationDefaults[]): void;
63 >
64 > /**
65 > * Deregister multiple default configurations from the registry.
66 > */
67 > deregisterDefaultConfigurations(defaultConfigurations: IConfigurationDefaults[]): void;
68 >
69 > /**
70 > * Bulk update of the configuration registry (default and configurations, remove and add)
71 > * @param delta
72 > */
73 > deltaConfiguration(delta: IConfigurationDelta): void;
74 >
75 > /**
76 > * Return the registered default configurations
77 > */
78 > getRegisteredDefaultConfigurations(): IConfigurationDefaults[];
79 >
80 > /**
81 > * Return the registered configuration defaults overrides
82 > */
83 > getConfigurationDefaultsOverrides(): Map<string, IConfigurationDefaultOverrideValue>;
84 >
85 > /**
86 > * Signal that the schema of a configuration setting has changes. It is currently only supported to change enumeration values.
87 > * Property or default value changes are not allowed.
88 > */
89 > notifyConfigurationSchemaUpdated(...configurations: IConfigurationNode[]): void;
90 >
91 > /**
92 > * Event that fires whenever a configuration has been
93 > * registered.
94 > */
95 > readonly onDidSchemaChange: Event<void>;
96 >
97 > /**
98 > * Event that fires whenever a configuration has been
99 > * registered.
100 > */
101 > readonly onDidUpdateConfiguration: Event<{ properties: ReadonlySet<string>; defaultsOverrides?: boolean }>;
102 >
103 > /**
104 > * Returns all configuration nodes contributed to this registry.
105 > */
106 > getConfigurations(): IConfigurationNode[];
107 >
108 > /**
109 > * Returns all configurations settings of all configuration nodes contributed to this registry.
110 > */
111 > getConfigurationProperties(): IStringDictionary<IRegisteredConfigurationPropertySchema>;
112 >
113 > /**
114 > * Returns the owning setting key per policy name (at most one owner per name).
115 > */
116 > getPolicyConfigurations(): Map<PolicyName, string>;
117 >
118 > /**
119 > * Returns the referencing setting keys per policy name.
120 > */
121 > getPolicyReferenceConfigurations(): Map<PolicyName, Set<string>>;
122 >
123 > /**
124 > * Returns all excluded configurations settings of all configuration nodes contributed to this registry.
125 > */
126 > getExcludedConfigurationProperties(): IStringDictionary<IRegisteredConfigurationPropertySchema>;
127 >
128 > /**
129 > * Register the identifiers for editor configurations
130 > */
131 > registerOverrideIdentifiers(identifiers: string[]): void;
132 > }
133 >
134 > export const enum ConfigurationScope {
135 > /**
136 > * Application specific configuration, which can be configured only in default profile user settings.
137 > */
138 > APPLICATION = 1,
139 > /**
140 > * Machine specific configuration, which can be configured only in local and remote user settings.
141 > */
142 > MACHINE,
143 > /**
144 > * An application machine specific configuration, which can be configured only in default profile user settings and remote user settings.
145 > */
146 > APPLICATION_MACHINE,
147 > /**
148 > * Window specific configuration, which can be configured in the user or workspace settings.
149 > */
150 > WINDOW,
151 > /**
152 > * Resource specific configuration, which can be configured in the user, workspace or folder settings.
153 > */
154 > RESOURCE,
155 > /**
156 > * Resource specific configuration that can be configured in language specific settings
157 > */
158 > LANGUAGE_OVERRIDABLE,
159 > /**
160 > * Machine specific configuration that can also be configured in workspace or folder settings.
161 > */
162 > MACHINE_OVERRIDABLE,
163 > }
164 >
165 >
166 > export interface IConfigurationPropertySchema extends IJSONSchema {
167 >
168 > scope?: ConfigurationScope;
169 >
170 > /**
171 > * When restricted, value of this configuration will be read only from trusted sources.
172 > * For eg., If the workspace is not trusted, then the value of this configuration is not read from workspace settings file.
173 > */
174 > restricted?: boolean;
175 >
176 > /**
177 > * When `false` this property is excluded from the registry. Default is to include.
178 > */
179 > included?: boolean;
180 >
181 > /**
182 > * List of tags associated to the property.
183 > * - A tag can be used for filtering
184 > * - Use `experimental` tag for marking the setting as experimental.
185 > */
186 > tags?: string[];
187 >
188 > /**
189 > * When enabled this setting is ignored during sync and user can override this.
190 > */
191 > ignoreSync?: boolean;
192 >
193 > /**
194 > * When enabled this setting is ignored during sync and user cannot override this.
195 > */
196 > disallowSyncIgnore?: boolean;
197 >
198 > /**
199 > * Disallow extensions to contribute configuration default value for this setting.
200 > */
201 > disallowConfigurationDefault?: boolean;
202 >
203 > /**
204 > * Labels for enumeration items
205 > */
206 > enumItemLabels?: string[];
207 >
208 > /**
209 > * Optional keywords used for search purposes.
210 > */
211 > keywords?: string[];
212 >
213 > /**
214 > * When specified, controls the presentation format of string settings.
215 > * Otherwise, the presentation format defaults to `singleline`.
216 > */
217 > editPresentation?: EditPresentationTypes;
218 >
219 > /**
220 > * When specified, gives an order number for the setting
221 > * within the settings editor. Otherwise, the setting is placed at the end.
222 > */
223 > order?: number;
224 >
225 > /**
226 > * When specified, this setting's value can always be overwritten by
227 > * a system-wide policy. Exactly one setting may *own* a given policy name.
228 > */
229 > policy?: IPolicy;
230 >
231 > /**
232 > * When specified, this setting is governed by a policy owned by another setting.
233 > * A setting must not declare both `policy` and `policyReference`.
234 > * The type must match the owning setting (enforced when exporting the policy catalog).
235 > */
236 > policyReference?: IPolicyReference;
237 >
238 > /**
239 > * When specified, this setting's default value can always be overwritten by
240 > * an experiment.
241 > */
242 > experiment?: {
243 > /**
244 > * The mode of the experiment.
245 > * - `startup`: The setting value is updated to the experiment value only on startup.
246 > * - `auto`: The setting value is updated to the experiment value automatically (whenever the experiment value changes).
247 > */
248 > mode: 'startup' | 'auto';
249 >
250 > /**
251 > * The name of the experiment. By default, this is `config.${settingId}`
252 > */
253 > name?: string;
254 > };
255 >
256 > /**
257 > * When specified, provides configuration overrides for the Agents window.
258 > */
259 > agentsWindow?: {
260 > /**
261 > * Override default value for this setting in the Agents window.
262 > */
263 > default?: unknown;
264 >
265 > /**
266 > * When `true`, this setting is read-only in the Agents window
267 > * and cannot be changed by the user.
268 > */
269 > readOnly?: boolean;
270 > };
271 > }
272 >
273 > export interface IExtensionInfo {
274 > id: string;
275 > displayName?: string;
276 > }
277 >
278 > export interface IConfigurationNode {
279 > id?: string;
280 > order?: number;
281 > type?: string | string[];
282 > title?: string;
283 > description?: string;
284 > properties?: IStringDictionary<IConfigurationPropertySchema>;
285 > allOf?: IConfigurationNode[];
286 > scope?: ConfigurationScope;
287 > extensionInfo?: IExtensionInfo;
288 > restrictedProperties?: string[];
289 > }
290 >
291 > export type ConfigurationDefaultSource = IExtensionInfo | string;
292 >
293 > export function isConfigurationDefaultSourceEquals(a: ConfigurationDefaultSource | undefined, b: ConfigurationDefaultSource | undefined): boolean {
294 > if (a === b) { configurationRegistry.ts ×3
295 > return true; configurationRegistry.ts ×1
296 > }
297 > if (!a || !b) { configurationRegistry.ts ×3
298 > return false; configurationRegistry.ts ×1
299 > }
300 > if (typeof a === 'string' || typeof b === 'string') { configurationRegistry.ts ×3
301 > return a === b; configurationRegistry.ts ×1
302 > }
303 > return a.id === b.id; configurationRegistry.ts ×1
304 > }
306 > export type ConfigurationDefaultValueSource = ConfigurationDefaultSource | Map<string, ConfigurationDefaultSource>;
307 >
308 > export interface IConfigurationDefaults {
309 > overrides: IStringDictionary<unknown>;
310 > source?: ConfigurationDefaultSource;
311 > donotCache?: boolean;
312 > preventExperimentOverride?: boolean;
313 > }
314 >
315 > export type IRegisteredConfigurationPropertySchema = IConfigurationPropertySchema & {
316 > section?: {
317 > id?: string;
318 > title?: string;
319 > order?: number;
320 > extensionInfo?: IExtensionInfo;
321 > };
322 > defaultDefaultValue?: unknown;
323 > source?: ConfigurationDefaultSource; // Source of the Property
324 > defaultValueSource?: ConfigurationDefaultValueSource; // Source of the Default Value
325 > };
326 >
327 > export interface IConfigurationDefaultOverride {
328 > readonly value: unknown;
329 > readonly source?: ConfigurationDefaultSource; // Source of the default override
330 > }
331 >
332 > export interface IConfigurationDefaultOverrideValue {
333 > readonly value: unknown;
334 > readonly source?: ConfigurationDefaultValueSource;
335 > }
336 >
337 > export const allSettings: { properties: IStringDictionary<IConfigurationPropertySchema>; patternProperties: IStringDictionary<IConfigurationPropertySchema> } = { properties: {}, patternProperties: {} };
338 > export const applicationSettings: { properties: IStringDictionary<IConfigurationPropertySchema>; patternProperties: IStringDictionary<IConfigurationPropertySchema> } = { properties: {}, patternProperties: {} };
339 > export const applicationMachineSettings: { properties: IStringDictionary<IConfigurationPropertySchema>; patternProperties: IStringDictionary<IConfigurationPropertySchema> } = { properties: {}, patternProperties: {} };
340 > export const machineSettings: { properties: IStringDictionary<IConfigurationPropertySchema>; patternProperties: IStringDictionary<IConfigurationPropertySchema> } = { properties: {}, patternProperties: {} };
341 > export const machineOverridableSettings: { properties: IStringDictionary<IConfigurationPropertySchema>; patternProperties: IStringDictionary<IConfigurationPropertySchema> } = { properties: {}, patternProperties: {} };
342 > export const windowSettings: { properties: IStringDictionary<IConfigurationPropertySchema>; patternProperties: IStringDictionary<IConfigurationPropertySchema> } = { properties: {}, patternProperties: {} };
343 > export const resourceSettings: { properties: IStringDictionary<IConfigurationPropertySchema>; patternProperties: IStringDictionary<IConfigurationPropertySchema> } = { properties: {}, patternProperties: {} };
344 >
345 > export const resourceLanguageSettingsSchemaId = 'vscode://schemas/settings/resourceLanguage';
346 > export const configurationDefaultsSchemaId = 'vscode://schemas/settings/configurationDefaults';
347 >
348 > const contributionRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
349 >
350 > class ConfigurationRegistry extends Disposable implements IConfigurationRegistry {
351 >
352 > private readonly registeredConfigurationDefaults: IConfigurationDefaults[] = [];
353 > private readonly configurationDefaultsOverrides: Map<string, { configurationDefaultOverrides: IConfigurationDefaultOverride[]; configurationDefaultOverrideValue?: IConfigurationDefaultOverrideValue }>;
354 > private readonly defaultLanguageConfigurationOverridesNode: IConfigurationNode;
355 > private readonly configurationContributors: IConfigurationNode[];
356 > private readonly configurationProperties: IStringDictionary<IRegisteredConfigurationPropertySchema>;
357 > private readonly policyConfigurations: Map<PolicyName, string>;
358 > private readonly policyReferenceConfigurations: Map<PolicyName, Set<string>>;
359 > private readonly excludedConfigurationProperties: IStringDictionary<IRegisteredConfigurationPropertySchema>;
360 > private readonly resourceLanguageSettingsSchema: IJSONSchema;
361 > private readonly overrideIdentifiers = new Set<string>();
362 >
363 > private readonly _onDidSchemaChange = this._register(new Emitter<void>());
364 > readonly onDidSchemaChange: Event<void> = this._onDidSchemaChange.event;
365 >
366 > private readonly _onDidUpdateConfiguration = this._register(new Emitter<{ properties: ReadonlySet<string>; defaultsOverrides?: boolean }>());
367 > readonly onDidUpdateConfiguration = this._onDidUpdateConfiguration.event;
368 >
369 > constructor() {
370 > super();
371 > this.configurationDefaultsOverrides = new Map();
372 > this.defaultLanguageConfigurationOverridesNode = {
373 > id: 'defaultOverrides',
374 > title: nls.localize('defaultLanguageConfigurationOverrides.title', "Default Language Configuration Overrides"),
375 > properties: {}
376 > };
377 > this.configurationContributors = [this.defaultLanguageConfigurationOverridesNode];
378 > this.resourceLanguageSettingsSchema = {
379 > properties: {},
380 > patternProperties: {},
381 > additionalProperties: true,
382 > allowTrailingCommas: true,
383 > allowComments: true
384 > };
385 > this.configurationProperties = {};
386 > this.policyConfigurations = new Map<PolicyName, string>();
387 > this.policyReferenceConfigurations = new Map<PolicyName, Set<string>>();
388 > this.excludedConfigurationProperties = {};
389 >
390 > contributionRegistry.registerSchema(resourceLanguageSettingsSchemaId, this.resourceLanguageSettingsSchema);
391 > this.registerOverridePropertyPatternKey();
392 > }
393 >
394 > public registerConfiguration(configuration: IConfigurationNode, validate: boolean = true): IConfigurationNode {
395 > this.registerConfigurations([configuration], validate); configurationRegistry.ts ×7
396 > return configuration;
397 > }
399 > public registerConfigurations(configurations: IConfigurationNode[], validate: boolean = true): void {
400 > const properties = new Set<string>(); configurationRegistry.ts ×7
401 > this.doRegisterConfigurations(configurations, validate, properties);
402 >
403 > contributionRegistry.registerSchema(resourceLanguageSettingsSchemaId, this.resourceLanguageSettingsSchema);
404 > this._onDidSchemaChange.fire();
405 > this._onDidUpdateConfiguration.fire({ properties });
406 > }
408 > public deregisterConfigurations(configurations: IConfigurationNode[]): void {
409 > const properties = new Set<string>(); configurationRegistry.ts ×4
410 > this.doDeregisterConfigurations(configurations, properties);
411 >
412 > contributionRegistry.registerSchema(resourceLanguageSettingsSchemaId, this.resourceLanguageSettingsSchema);
413 > this._onDidSchemaChange.fire();
414 > this._onDidUpdateConfiguration.fire({ properties });
415 > }
417 > public updateConfigurations({ add, remove }: { add: IConfigurationNode[]; remove: IConfigurationNode[] }): void {
418 > const properties = new Set<string>(); configurationRegistry.ts ×1
419 > this.doDeregisterConfigurations(remove, properties);
420 > this.doRegisterConfigurations(add, false, properties);
421 >
422 > contributionRegistry.registerSchema(resourceLanguageSettingsSchemaId, this.resourceLanguageSettingsSchema);
423 > this._onDidSchemaChange.fire();
424 > this._onDidUpdateConfiguration.fire({ properties });
425 > }
427 > public registerDefaultConfigurations(configurationDefaults: IConfigurationDefaults[]): void {
428 > const properties = new Set<string>(); configurationRegistry.ts ×6
429 > this.doRegisterDefaultConfigurations(configurationDefaults, properties);
430 > this._onDidSchemaChange.fire();
431 > this._onDidUpdateConfiguration.fire({ properties, defaultsOverrides: true });
432 > }
434 > private doRegisterDefaultConfigurations(configurationDefaults: IConfigurationDefaults[], bucket: Set<string>) {
436 > this.registeredConfigurationDefaults.push(...configurationDefaults);
437 >
438 > const overrideIdentifiers: string[] = [];
439 >
440 > for (const { overrides, source } of configurationDefaults) {
441 > for (const key in overrides) {
442 > bucket.add(key);
443 >
444 > const configurationDefaultOverridesForKey = this.configurationDefaultsOverrides.get(key)
445 > ?? this.configurationDefaultsOverrides.set(key, { configurationDefaultOverrides: [] }).get(key)!;
446 >
447 > const value = overrides[key];
448 > configurationDefaultOverridesForKey.configurationDefaultOverrides.push({ value, source });
449 >
450 > // Configuration defaults for Override Identifiers
451 > if (OVERRIDE_PROPERTY_REGEX.test(key)) {
452 > const newDefaultOverride = this.mergeDefaultConfigurationsForOverrideIdentifier(key, value as IStringDictionary<unknown>, source, configurationDefaultOverridesForKey.configurationDefaultOverrideValue); configurationRegistry.ts ×9
453 > if (!newDefaultOverride) {
454 continue;
455 }
457 > configurationDefaultOverridesForKey.configurationDefaultOverrideValue = newDefaultOverride;
458 > this.updateDefaultOverrideProperty(key, newDefaultOverride, source);
459 > overrideIdentifiers.push(...overrideIdentifiersFromKey(key));
460 > }
462 > // Configuration defaults for Configuration Properties
463 > else {
464 > const newDefaultOverride = this.mergeDefaultConfigurationsForConfigurationProperty(key, value, source, configurationDefaultOverridesForKey.configurationDefaultOverrideValue);
465 > if (!newDefaultOverride) {
466 continue;
467 }
469 > configurationDefaultOverridesForKey.configurationDefaultOverrideValue = newDefaultOverride;
470 > const property = this.configurationProperties[key];
471 > if (property) {
472 > this.updatePropertyDefaultValue(key, property);
473 > this.updateSchema(key, property);
474 > }
475 > }
477 > }
478 > }
479 >
480 > this.doRegisterOverrideIdentifiers(overrideIdentifiers);
481 > }
483 > public deregisterDefaultConfigurations(defaultConfigurations: IConfigurationDefaults[]): void {
484 > const properties = new Set<string>(); configurationRegistry.ts ×6
485 > this.doDeregisterDefaultConfigurations(defaultConfigurations, properties);
486 > this._onDidSchemaChange.fire();
487 > this._onDidUpdateConfiguration.fire({ properties, defaultsOverrides: true });
488 > }
490 > private doDeregisterDefaultConfigurations(defaultConfigurations: IConfigurationDefaults[], bucket: Set<string>): void {
491 > for (const defaultConfiguration of defaultConfigurations) { configurationRegistry.ts ×6
492 > const index = this.registeredConfigurationDefaults.indexOf(defaultConfiguration); configurationRegistry.ts ×6
493 > if (index !== -1) {
494 > this.registeredConfigurationDefaults.splice(index, 1);
495 > }
496 > }
498 > for (const { overrides, source } of defaultConfigurations) {
499 > for (const key in overrides) { configurationRegistry.ts ×6
500 > const configurationDefaultOverridesForKey = this.configurationDefaultsOverrides.get(key);
501 > if (!configurationDefaultOverridesForKey) {
502 continue;
503 }
505 > const index = configurationDefaultOverridesForKey.configurationDefaultOverrides
506 > .findIndex(configurationDefaultOverride => source ? isConfigurationDefaultSourceEquals(configurationDefaultOverride.source, source) : configurationDefaultOverride.value === overrides[key]);
507 > if (index === -1) {
508 continue;
509 }
511 > configurationDefaultOverridesForKey.configurationDefaultOverrides.splice(index, 1);
512 > if (configurationDefaultOverridesForKey.configurationDefaultOverrides.length === 0) {
513 > this.configurationDefaultsOverrides.delete(key);
514 > }
515 >
516 > if (OVERRIDE_PROPERTY_REGEX.test(key)) {
517 > let configurationDefaultOverrideValue: IConfigurationDefaultOverrideValue | undefined; configurationRegistry.ts ×3
518 > for (const configurationDefaultOverride of configurationDefaultOverridesForKey.configurationDefaultOverrides) {
519 > configurationDefaultOverrideValue = this.mergeDefaultConfigurationsForOverrideIdentifier(key, configurationDefaultOverride.value as IStringDictionary<unknown>, configurationDefaultOverride.source, configurationDefaultOverrideValue); configurationRegistry.ts ×2
520 > }
521 > if (configurationDefaultOverrideValue && !types.isEmptyObject(configurationDefaultOverrideValue.value)) { configurationRegistry.ts ×3
522 > configurationDefaultOverridesForKey.configurationDefaultOverrideValue = configurationDefaultOverrideValue; configurationRegistry.ts ×2
523 > this.updateDefaultOverrideProperty(key, configurationDefaultOverrideValue, source);
525 > this.configurationDefaultsOverrides.delete(key);
526 > delete this.configurationProperties[key];
527 > delete this.defaultLanguageConfigurationOverridesNode.properties![key];
528 > }
530 > let configurationDefaultOverrideValue: IConfigurationDefaultOverrideValue | undefined; configurationRegistry.ts ×9
531 > for (const configurationDefaultOverride of configurationDefaultOverridesForKey.configurationDefaultOverrides) {
532 > configurationDefaultOverrideValue = this.mergeDefaultConfigurationsForConfigurationProperty(key, configurationDefaultOverride.value, configurationDefaultOverride.source, configurationDefaultOverrideValue); configurationRegistry.ts ×1
533 > }
534 > configurationDefaultOverridesForKey.configurationDefaultOverrideValue = configurationDefaultOverrideValue; configurationRegistry.ts ×9
535 > const property = this.configurationProperties[key];
536 > if (property) {
537 > this.updatePropertyDefaultValue(key, property); configurationRegistry.ts ×1
538 > this.updateSchema(key, property);
539 > }
541 > bucket.add(key); configurationRegistry.ts ×6
542 > }
543 > }
544 > this.updateOverridePropertyPatternKey(); configurationRegistry.ts ×6
545 > }
547 > private updateDefaultOverrideProperty(key: string, newDefaultOverride: IConfigurationDefaultOverrideValue, source: ConfigurationDefaultSource | undefined): void {
548 > const property: IRegisteredConfigurationPropertySchema = { configurationRegistry.ts ×9
549 > section: {
550 > id: this.defaultLanguageConfigurationOverridesNode.id,
551 > title: this.defaultLanguageConfigurationOverridesNode.title,
552 > order: this.defaultLanguageConfigurationOverridesNode.order,
553 > extensionInfo: this.defaultLanguageConfigurationOverridesNode.extensionInfo
554 > },
555 > type: 'object',
556 > default: newDefaultOverride.value,
557 > description: nls.localize('defaultLanguageConfiguration.description', "Configure settings to be overridden for {0}.", getLanguageTagSettingPlainKey(key)),
558 > $ref: resourceLanguageSettingsSchemaId,
559 > defaultDefaultValue: newDefaultOverride.value,
560 > source,
561 > defaultValueSource: source
562 > };
563 > this.configurationProperties[key] = property;
564 > this.defaultLanguageConfigurationOverridesNode.properties![key] = property;
565 > }
567 > private mergeDefaultConfigurationsForOverrideIdentifier(overrideIdentifier: string, configurationValueObject: IStringDictionary<unknown>, valueSource: ConfigurationDefaultSource | undefined, existingDefaultOverride: IConfigurationDefaultOverrideValue | undefined): IConfigurationDefaultOverrideValue | undefined {
568 > const defaultValue = existingDefaultOverride?.value || {}; configurationRegistry.ts ×9
569 > const source = existingDefaultOverride?.source ?? new Map<string, ConfigurationDefaultSource>();
570 >
571 > // This should not happen
572 > if (!(source instanceof Map)) {
573 console.error('objectConfigurationSources is not a Map');
574 return undefined;
575 }
577 > for (const propertyKey of Object.keys(configurationValueObject)) {
578 > const propertyDefaultValue = configurationValueObject[propertyKey];
579 >
580 > const isObjectSetting = types.isObject(propertyDefaultValue) &&
581 > (types.isUndefined((defaultValue as IStringDictionary<unknown>)[propertyKey]) || types.isObject((defaultValue as IStringDictionary<unknown>)[propertyKey])); configurationRegistry.ts ×2
583 > // If the default value is an object, merge the objects and store the source of each keys
584 > if (isObjectSetting) {
585 > (defaultValue as IStringDictionary<unknown>)[propertyKey] = { ...((defaultValue as IStringDictionary<unknown>)[propertyKey] ?? {}), ...propertyDefaultValue }; configurationRegistry.ts ×2
586 > // Track the source of each value in the object
587 > if (valueSource) {
588 > for (const objectKey in propertyDefaultValue) {
589 > source.set(`${propertyKey}.${objectKey}`, valueSource);
590 > }
591 > }
592 > }
594 > // Primitive values are overridden
595 > else {
596 > (defaultValue as IStringDictionary<unknown>)[propertyKey] = propertyDefaultValue;
597 > if (valueSource) {
598 source.set(propertyKey, valueSource);
600 > source.delete(propertyKey);
601 > }
602 > }
604 >
605 > return { value: defaultValue, source };
606 > }
608 > private mergeDefaultConfigurationsForConfigurationProperty(propertyKey: string, value: unknown, valuesSource: ConfigurationDefaultSource | undefined, existingDefaultOverride: IConfigurationDefaultOverrideValue | undefined): IConfigurationDefaultOverrideValue | undefined {
609 > const property = this.configurationProperties[propertyKey]; configurationRegistry.ts ×9
610 > const existingDefaultValue = existingDefaultOverride?.value ?? property?.defaultDefaultValue;
611 > let source: ConfigurationDefaultValueSource | undefined = valuesSource;
612 >
613 > const isObjectSetting = types.isObject(value) &&
614 > (
615 > property !== undefined && property.type === 'object' ||
616 > property === undefined && (types.isUndefined(existingDefaultValue) || types.isObject(existingDefaultValue)) configurationRegistry.ts ×1
618 >
619 > // If the default value is an object, merge the objects and store the source of each keys
620 > if (isObjectSetting) {
621 > source = existingDefaultOverride?.source ?? new Map<string, ConfigurationDefaultSource>();
622 >
623 > // This should not happen
624 > if (!(source instanceof Map)) {
625 console.error('defaultValueSource is not a Map');
626 return undefined;
627 }
629 > for (const objectKey in (value as IStringDictionary<unknown>)) {
630 > if (valuesSource) {
631 > source.set(`${propertyKey}.${objectKey}`, valuesSource); configurationRegistry.ts ×1
632 > }
634 > value = { ...(types.isObject(existingDefaultValue) ? existingDefaultValue : {}), ...(value as IStringDictionary<unknown>) };
635 > }
636 >
637 > return { value, source };
638 > }
640 > public deltaConfiguration(delta: IConfigurationDelta): void {
641 // defaults: remove
642 let defaultsOverrides = false;
643 const properties = new Set<string>();
644 if (delta.removedDefaults) {
645 this.doDeregisterDefaultConfigurations(delta.removedDefaults, properties);
646 defaultsOverrides = true;
647 }
648 // defaults: add
649 if (delta.addedDefaults) {
650 this.doRegisterDefaultConfigurations(delta.addedDefaults, properties);
651 defaultsOverrides = true;
652 }
653 // configurations: remove
654 if (delta.removedConfigurations) {
655 this.doDeregisterConfigurations(delta.removedConfigurations, properties);
656 }
657 // configurations: add
658 if (delta.addedConfigurations) {
659 this.doRegisterConfigurations(delta.addedConfigurations, false, properties);
660 }
661 this._onDidSchemaChange.fire();
662 this._onDidUpdateConfiguration.fire({ properties, defaultsOverrides });
663 }
665 > public notifyConfigurationSchemaUpdated(...configurations: IConfigurationNode[]) {
666 this._onDidSchemaChange.fire();
667 }
669 > public registerOverrideIdentifiers(overrideIdentifiers: string[]): void {
670 > this.doRegisterOverrideIdentifiers(overrideIdentifiers); languagesRegistry.ts ×23
671 > this._onDidSchemaChange.fire();
672 > }
674 > private doRegisterOverrideIdentifiers(overrideIdentifiers: string[]) {
675 > for (const overrideIdentifier of overrideIdentifiers) { configurationRegistry.ts ×6
676 > this.overrideIdentifiers.add(overrideIdentifier); configurationRegistry.ts ×9
677 > }
678 > this.updateOverridePropertyPatternKey(); configurationRegistry.ts ×6
679 > }
681 > private doRegisterConfigurations(configurations: IConfigurationNode[], validate: boolean, bucket: Set<string>): void {
683 > configurations.forEach(configuration => {
684 >
685 > this.validateAndRegisterProperties(configuration, validate, configuration.extensionInfo, configuration.restrictedProperties, undefined, bucket);
686 >
687 > this.configurationContributors.push(configuration);
688 > this.registerJSONConfiguration(configuration);
689 > });
690 > }
692 > private doDeregisterConfigurations(configurations: IConfigurationNode[], bucket: Set<string>): void {
694 > const deregisterConfiguration = (configuration: IConfigurationNode) => {
695 > if (configuration.properties) { configurationRegistry.ts ×4
696 > for (const key in configuration.properties) {
697 > bucket.add(key); configurationRegistry.ts ×9
698 > const property = this.configurationProperties[key];
699 > if (property?.policy?.name) {
700 > this.policyConfigurations.delete(property.policy.name); configurationRegistry.ts ×1
701 > }
702 > if (property?.policyReference?.name) { configurationRegistry.ts ×9
703 > const refs = this.policyReferenceConfigurations.get(property.policyReference.name); configurationRegistry.ts ×3
704 > if (refs) {
705 > refs.delete(key);
706 > if (refs.size === 0) {
707 > this.policyReferenceConfigurations.delete(property.policyReference.name);
708 > }
709 > }
710 > }
711 > delete this.configurationProperties[key]; configurationRegistry.ts ×9
712 > this.removeFromSchema(key, configuration.properties[key]);
713 > }
715 > configuration.allOf?.forEach(node => deregisterConfiguration(node));
716 > };
717 > for (const configuration of configurations) { configurationRegistry.ts ×3
718 > deregisterConfiguration(configuration); configurationRegistry.ts ×4
719 > const index = this.configurationContributors.indexOf(configuration);
720 > if (index !== -1) {
721 > this.configurationContributors.splice(index, 1);
722 > }
723 > }
726 > private validateAndRegisterProperties(configuration: IConfigurationNode, validate: boolean = true, extensionInfo: IExtensionInfo | undefined, restrictedProperties: string[] | undefined, scope: ConfigurationScope = ConfigurationScope.WINDOW, bucket: Set<string>): void {
727 > scope = types.isUndefinedOrNull(configuration.scope) ? scope : configuration.scope; configurationRegistry.ts ×7
728 > const properties = configuration.properties;
729 > if (properties) {
730 > for (const key in properties) {
731 > const property: IRegisteredConfigurationPropertySchema = properties[key];
732 > property.section = {
733 > id: configuration.id,
734 > title: configuration.title,
735 > order: configuration.order,
736 > extensionInfo: configuration.extensionInfo
737 > };
738 > if (validate && validateProperty(key, property, extensionInfo?.id)) {
739 > delete properties[key]; configurationRegistry.ts ×1
740 > continue;
741 > }
743 > property.source = extensionInfo;
744 >
745 > // update default value
746 > property.defaultDefaultValue = properties[key].default;
747 > this.updatePropertyDefaultValue(key, property);
748 >
749 > // update scope
750 > if (OVERRIDE_PROPERTY_REGEX.test(key)) {
751 property.scope = undefined; // No scope for overridable properties `[${identifier}]`
753 > property.scope = types.isUndefinedOrNull(property.scope) ? scope : property.scope;
754 > property.restricted = types.isUndefinedOrNull(property.restricted) ? !!restrictedProperties?.includes(key) : property.restricted;
755 > }
756 >
757 > if (property.experiment) {
758 > if (!property.tags?.some(tag => tag.toLowerCase() === 'onexp')) { request.ts ×15
759 > property.tags = property.tags ?? [];
760 > property.tags.push('onExP');
761 > }
762 > } else if (property.tags?.some(tag => tag.toLowerCase() === 'onexp')) { configurationRegistry.ts ×17
763 console.error(`Invalid tag 'onExP' found for property '${key}'. Please use 'experiment' property instead.`);
764 property.experiment = { mode: 'startup' };
765 }
767 > const excluded = properties[key].hasOwnProperty('included') && !properties[key].included;
768 > const policyName = properties[key].policy?.name; configurationRegistry.ts ×7
769 > const policyReferenceName = properties[key].policyReference?.name;
770 >
771 > if (excluded) {
772 > this.excludedConfigurationProperties[key] = properties[key]; configurationRegistry.ts ×3
773 > if (policyName) {
774 > this.policyConfigurations.set(policyName, key); configurations.ts ×2
775 > bucket.add(key);
776 > }
777 > if (policyReferenceName) { configurationRegistry.ts ×3
778 this.addPolicyReferenceConfiguration(policyReferenceName, key);
779 bucket.add(key);
780 }
781 > delete properties[key]; configurationRegistry.ts ×3
783 > bucket.add(key);
784 > if (policyName) {
785 > this.policyConfigurations.set(policyName, key); configurationRegistry.ts ×1
786 > }
787 > if (policyReferenceName) { configurationRegistry.ts ×17
788 > this.addPolicyReferenceConfiguration(policyReferenceName, key); configurationRegistry.ts ×3
789 > }
790 > this.configurationProperties[key] = properties[key]; configurationRegistry.ts ×17
791 > if (!properties[key].deprecationMessage && properties[key].markdownDeprecationMessage) {
792 > // If not set, default deprecationMessage to the markdown source agentHostTelemetryService.ts ×29
793 > properties[key].deprecationMessage = properties[key].markdownDeprecationMessage;
794 > }
797 >
798 > }
799 > }
800 > const subNodes = configuration.allOf;
801 > if (subNodes) {
802 for (const node of subNodes) {
803 this.validateAndRegisterProperties(node, validate, extensionInfo, restrictedProperties, scope, bucket);
804 }
805 }
808 > private addPolicyReferenceConfiguration(policyName: PolicyName, key: string): void {
809 > let keys = this.policyReferenceConfigurations.get(policyName); configurationRegistry.ts ×3
810 > if (!keys) {
811 > keys = new Set<string>();
812 > this.policyReferenceConfigurations.set(policyName, keys);
813 > }
814 > keys.add(key);
815 > }
817 > // Only for tests
818 > getConfigurations(): IConfigurationNode[] {
819 > return this.configurationContributors; configurationRegistry.ts ×6
820 > }
822 > getConfigurationProperties(): IStringDictionary<IRegisteredConfigurationPropertySchema> {
823 > return this.configurationProperties; configurationRegistry.ts ×1
824 > }
826 > getPolicyConfigurations(): Map<PolicyName, string> {
827 > return this.policyConfigurations; configurationRegistry.ts ×1
828 > }
830 > getPolicyReferenceConfigurations(): Map<PolicyName, Set<string>> {
831 > return this.policyReferenceConfigurations; configurationRegistry.ts ×1
832 > }
834 > getExcludedConfigurationProperties(): IStringDictionary<IRegisteredConfigurationPropertySchema> {
835 > return this.excludedConfigurationProperties; configurationRegistry.ts ×1
836 > }
838 > getRegisteredDefaultConfigurations(): IConfigurationDefaults[] {
839 > return [...this.registeredConfigurationDefaults]; configurationRegistry.ts ×6
840 > }
842 > getConfigurationDefaultsOverrides(): Map<string, IConfigurationDefaultOverrideValue> {
843 const configurationDefaultsOverrides = new Map<string, IConfigurationDefaultOverrideValue>();
844 for (const [key, value] of this.configurationDefaultsOverrides) {
845 if (value.configurationDefaultOverrideValue) {
846 configurationDefaultsOverrides.set(key, value.configurationDefaultOverrideValue);
847 }
848 }
849 return configurationDefaultsOverrides;
850 }
852 > private registerJSONConfiguration(configuration: IConfigurationNode) {
853 > const register = (configuration: IConfigurationNode) => { configurationRegistry.ts ×7
854 > const properties = configuration.properties;
855 > if (properties) {
856 > for (const key in properties) {
857 > this.updateSchema(key, properties[key]); configurationRegistry.ts ×17
858 > }
860 > const subNodes = configuration.allOf;
861 > subNodes?.forEach(register);
862 > };
863 > register(configuration);
864 > }
866 > private updateSchema(key: string, property: IConfigurationPropertySchema): void {
867 > allSettings.properties[key] = property; configurationRegistry.ts ×17
868 > switch (property.scope) {
869 > case ConfigurationScope.APPLICATION:
870 > applicationSettings.properties[key] = property; configurationRegistry.ts ×1
871 > break;
872 > case ConfigurationScope.MACHINE: configurationRegistry.ts ×17
873 > machineSettings.properties[key] = property; configurationRegistry.ts ×1
874 > break;
875 > case ConfigurationScope.APPLICATION_MACHINE: configurationRegistry.ts ×17
876 applicationMachineSettings.properties[key] = property;
877 break;
878 > case ConfigurationScope.MACHINE_OVERRIDABLE: configurationRegistry.ts ×17
879 > machineOverridableSettings.properties[key] = property; configurationRegistry.ts ×1
880 > break;
881 > case ConfigurationScope.WINDOW: configurationRegistry.ts ×17
882 > windowSettings.properties[key] = property; configurationRegistry.ts ×1
883 > break;
884 > case ConfigurationScope.RESOURCE: configurationRegistry.ts ×17
885 > resourceSettings.properties[key] = property; configurationRegistry.ts ×2
886 > break;
887 > case ConfigurationScope.LANGUAGE_OVERRIDABLE: configurationRegistry.ts ×17
888 > resourceSettings.properties[key] = property; configurationRegistry.ts ×2
889 > this.resourceLanguageSettingsSchema.properties![key] = property;
890 > break;
892 > }
894 > private removeFromSchema(key: string, property: IConfigurationPropertySchema): void {
895 > delete allSettings.properties[key]; configurationRegistry.ts ×9
896 > switch (property.scope) {
897 > case ConfigurationScope.APPLICATION:
898 > delete applicationSettings.properties[key]; configurationRegistry.ts ×1
899 > break;
900 > case ConfigurationScope.MACHINE: configurationRegistry.ts ×9
901 delete machineSettings.properties[key];
902 break;
903 > case ConfigurationScope.APPLICATION_MACHINE: configurationRegistry.ts ×9
904 delete applicationMachineSettings.properties[key];
905 break;
906 > case ConfigurationScope.MACHINE_OVERRIDABLE: configurationRegistry.ts ×9
907 delete machineOverridableSettings.properties[key];
908 break;
909 > case ConfigurationScope.WINDOW: configurationRegistry.ts ×9
910 > delete windowSettings.properties[key];
911 > break;
912 > case ConfigurationScope.RESOURCE:
913 > case ConfigurationScope.LANGUAGE_OVERRIDABLE:
914 delete resourceSettings.properties[key];
915 delete this.resourceLanguageSettingsSchema.properties![key];
916 break;
918 > }
920 > private updateOverridePropertyPatternKey(): void {
921 > for (const overrideIdentifier of this.overrideIdentifiers.values()) { configurationRegistry.ts ×2
922 > const overrideIdentifierProperty = `[${overrideIdentifier}]`; configurationRegistry.ts ×9
923 > const resourceLanguagePropertiesSchema: IJSONSchema = {
924 > type: 'object',
925 > description: nls.localize('overrideSettings.defaultDescription', "Configure editor settings to be overridden for a language."),
926 > errorMessage: nls.localize('overrideSettings.errorMessage', "This setting does not support per-language configuration."),
927 > $ref: resourceLanguageSettingsSchemaId,
928 > };
929 > this.updatePropertyDefaultValue(overrideIdentifierProperty, resourceLanguagePropertiesSchema);
930 > allSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
931 > applicationSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
932 > applicationMachineSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
933 > machineSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
934 > machineOverridableSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
935 > windowSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
936 > resourceSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
937 > }
940 > private registerOverridePropertyPatternKey(): void {
941 > const resourceLanguagePropertiesSchema: IJSONSchema = {
942 > type: 'object',
943 > description: nls.localize('overrideSettings.defaultDescription', "Configure editor settings to be overridden for a language."),
944 > errorMessage: nls.localize('overrideSettings.errorMessage', "This setting does not support per-language configuration."),
945 > $ref: resourceLanguageSettingsSchemaId,
946 > };
947 > allSettings.patternProperties[OVERRIDE_PROPERTY_PATTERN] = resourceLanguagePropertiesSchema;
948 > applicationSettings.patternProperties[OVERRIDE_PROPERTY_PATTERN] = resourceLanguagePropertiesSchema;
949 > applicationMachineSettings.patternProperties[OVERRIDE_PROPERTY_PATTERN] = resourceLanguagePropertiesSchema;
950 > machineSettings.patternProperties[OVERRIDE_PROPERTY_PATTERN] = resourceLanguagePropertiesSchema;
951 > machineOverridableSettings.patternProperties[OVERRIDE_PROPERTY_PATTERN] = resourceLanguagePropertiesSchema;
952 > windowSettings.patternProperties[OVERRIDE_PROPERTY_PATTERN] = resourceLanguagePropertiesSchema;
953 > resourceSettings.patternProperties[OVERRIDE_PROPERTY_PATTERN] = resourceLanguagePropertiesSchema;
954 > this._onDidSchemaChange.fire();
955 > }
956 >
957 > private updatePropertyDefaultValue(key: string, property: IRegisteredConfigurationPropertySchema): void {
958 > const configurationdefaultOverride = this.configurationDefaultsOverrides.get(key)?.configurationDefaultOverrideValue; configurationRegistry.ts ×5
959 > let defaultValue = undefined;
960 > let defaultSource = undefined;
961 > if (configurationdefaultOverride
962 > && (!property.disallowConfigurationDefault || !configurationdefaultOverride.source) // Prevent overriding the default value if the property is disallowed to be overridden by configuration defaults from extensions configurationRegistry.ts ×6
964 > defaultValue = configurationdefaultOverride.value; configurationRegistry.ts ×1
965 > defaultSource = configurationdefaultOverride.source;
966 > }
967 > if (types.isUndefined(defaultValue)) { configurationRegistry.ts ×5
968 > defaultValue = property.defaultDefaultValue; configurationRegistry.ts ×1
969 > defaultSource = undefined;
970 > }
971 > if (types.isUndefined(defaultValue)) { configurationRegistry.ts ×5
972 > defaultValue = getDefaultValue(property.type); configurationRegistry.ts ×8
973 > }
974 > property.default = defaultValue; configurationRegistry.ts ×5
975 > property.defaultValueSource = defaultSource;
976 > }
978 >
979 > const OVERRIDE_IDENTIFIER_PATTERN = `\\[([^\\]]+)\\]`;
980 > const OVERRIDE_IDENTIFIER_REGEX = new RegExp(OVERRIDE_IDENTIFIER_PATTERN, 'g');
981 > export const OVERRIDE_PROPERTY_PATTERN = `^(${OVERRIDE_IDENTIFIER_PATTERN})+$`;
982 > export const OVERRIDE_PROPERTY_REGEX = new RegExp(OVERRIDE_PROPERTY_PATTERN);
983 >
984 > export function overrideIdentifiersFromKey(key: string): string[] {
985 > const identifiers: string[] = []; configurationRegistry.ts ×1
986 > if (OVERRIDE_PROPERTY_REGEX.test(key)) {
987 > let matches = OVERRIDE_IDENTIFIER_REGEX.exec(key);
988 > while (matches?.length) {
989 > const identifier = matches[1].trim();
990 > if (identifier) {
991 > identifiers.push(identifier);
992 > }
993 > matches = OVERRIDE_IDENTIFIER_REGEX.exec(key);
994 > }
995 > }
996 > return distinct(identifiers);
997 > }
999 > export function keyFromOverrideIdentifiers(overrideIdentifiers: string[]): string {
1000 return overrideIdentifiers.reduce((result, overrideIdentifier) => `${result}[${overrideIdentifier}]`, '');
1001 }
1003 > export function getDefaultValue(type: string | string[] | undefined) {
1004 > const t = Array.isArray(type) ? type[0] : <string>type; configurationRegistry.ts ×8
1005 > switch (t) {
1006 > case 'boolean':
1007 > return false; configurationRegistry.ts ×1
1008 > case 'integer': configurationRegistry.ts ×8
1009 > case 'number':
1010 return 0;
1011 > case 'string': configurationRegistry.ts ×8
1012 > return ''; request.ts ×15
1013 > case 'array': configurationRegistry.ts ×8
1014 > return []; request.ts ×15
1015 > case 'object': configurationRegistry.ts ×8
1016 > return {}; configurationRegistry.ts ×1
1018 > return null; configurationRegistry.ts ×1
1020 > }
1022 > const configurationRegistry = new ConfigurationRegistry();
1023 > Registry.add(Extensions.Configuration, configurationRegistry);
1024 >
1025 > export function validateProperty(property: string, schema: IRegisteredConfigurationPropertySchema, extensionId?: string): string | null {
1026 > if (!property.trim()) { configurationRegistry.ts ×7
1027 return nls.localize('config.property.empty', "Cannot register an empty property");
1028 }
1029 > if (OVERRIDE_PROPERTY_REGEX.test(property)) { configurationRegistry.ts ×7
1030 return nls.localize('config.property.languageDefault', "Cannot register '{0}'. This matches property pattern '\\\\[.*\\\\]$' for describing language specific editor settings. Use 'configurationDefaults' contribution.", property);
1031 }
1032 > if (configurationRegistry.getConfigurationProperties()[property] !== undefined && (!extensionId || !EXTENSION_UNIFICATION_EXTENSION_IDS.has(extensionId.toLowerCase()))) { configurationRegistry.ts ×7
1033 > return nls.localize('config.property.duplicate', "Cannot register '{0}'. This property is already registered.", property); configurationRegistry.ts ×1
1034 > }
1035 > if (schema.policy && schema.policyReference) { configurationRegistry.ts ×7
1036 > return nls.localize('config.policy.bothPolicyAndReference', "Cannot register '{0}'. A setting must not declare both 'policy' and 'policyReference'.", property); configurationRegistry.ts ×1
1037 > }
1038 > if (schema.policy?.name && configurationRegistry.getPolicyConfigurations().get(schema.policy?.name) !== undefined) { configurationRegistry.ts ×7
1039 > return nls.localize('config.policy.duplicate', "Cannot register '{0}'. The associated policy {1} is already registered with {2}. To attach another setting to the same policy, use 'policyReference'.", property, schema.policy?.name, configurationRegistry.getPolicyConfigurations().get(schema.policy?.name)); configurationRegistry.ts ×1
1040 > }
1041 > return null; configurationRegistry.ts ×1
1042 > }
1044 > export function getScopes(): [string, ConfigurationScope | undefined][] {
1045 const scopes: [string, ConfigurationScope | undefined][] = [];
1046 const configurationProperties = configurationRegistry.getConfigurationProperties();
1047 for (const key of Object.keys(configurationProperties)) {
1048 scopes.push([key, configurationProperties[key].scope]);
1049 }
1050 scopes.push(['launch', ConfigurationScope.RESOURCE]);
1051 scopes.push(['task', ConfigurationScope.RESOURCE]);
1052 return scopes;
1053 }
1055 > export function getAllConfigurationProperties(configurationNode: IConfigurationNode[]): IStringDictionary<IRegisteredConfigurationPropertySchema> {
1056 const result: IStringDictionary<IRegisteredConfigurationPropertySchema> = {};
1057 for (const configuration of configurationNode) {
1058 const properties = configuration.properties;
1059 if (types.isObject(properties)) {
1060 for (const key in properties) {
1061 result[key] = properties[key];
1062 }
1063 }
1064 if (configuration.allOf) {
1065 Object.assign(result, getAllConfigurationProperties(configuration.allOf));
1066 }
1067 }
1068 return result;
1069 }
1071 > export function parseScope(scope: string): ConfigurationScope {
1072 switch (scope) {
1073 case 'application':
1074 return ConfigurationScope.APPLICATION;
1075 case 'machine':
1076 return ConfigurationScope.MACHINE;
1077 case 'resource':
1078 return ConfigurationScope.RESOURCE;
1079 case 'machine-overridable':
1080 return ConfigurationScope.MACHINE_OVERRIDABLE;
1081 case 'language-overridable':
1082 return ConfigurationScope.LANGUAGE_OVERRIDABLE;
1083 default:
1084 return ConfigurationScope.WINDOW;
1085 }
1086 }
1088 > // Used for extension unification. Should be removed when complete.
1089 > export const EXTENSION_UNIFICATION_EXTENSION_IDS: Set<string> = new Set(product.defaultChatAgent ? [product.defaultChatAgent.extensionId, product.defaultChatAgent.chatExtensionId].map(id => id.toLowerCase()) : []);