configurations.ts ×19

Frontier kind: Code frontier

unlabeled · c_8251c1770991

1092 tests · 11391 LOC · 50 files · introduces 0 tests · 94 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
19 ranges94 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1590 ranges11391 lines · 50 files · Browse complete extent
All tests (intent)
1092 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

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 native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 94 introduced LOC across 19 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/configuration/common/configurations.ts 94 introduced LOC · 19 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- configurations.ts
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 { IStringDictionary } from '../../../base/common/collections.js';
7 > import { Emitter, Event } from '../../../base/common/event.js';
8 > import { Disposable } from '../../../base/common/lifecycle.js';
9 > import { deepClone, equals } from '../../../base/common/objects.js';
10 > import { isEmptyObject, isString } from '../../../base/common/types.js';
11 > import { ConfigurationModel } from './configurationModels.js';
12 > import { Extensions, IConfigurationRegistry, IRegisteredConfigurationPropertySchema } from './configurationRegistry.js';
13 > import { ILogService, NullLogService } from '../../log/common/log.js';
14 > import { IPolicyService, PolicyDefinition, PolicyValue } from '../../policy/common/policy.js';
15 > import { Registry } from '../../registry/common/platform.js';
16 > import { getErrorMessage } from '../../../base/common/errors.js';
17 > import * as json from '../../../base/common/json.js';
18 > import { PolicyName } from '../../../base/common/policy.js';
19 >
20 > export class DefaultConfiguration extends Disposable {
21 >
22 > private readonly _onDidChangeConfiguration = this._register(new Emitter<{ defaults: ConfigurationModel; properties: string[] }>());
23 > readonly onDidChangeConfiguration = this._onDidChangeConfiguration.event;
24 >
25 > private _configurationModel: ConfigurationModel;
26 > get configurationModel(): ConfigurationModel {
27 > return this._configurationModel;
28 > }
29 >
30 > constructor(private readonly logService: ILogService) {
31 super();
32 this._configurationModel = ConfigurationModel.createEmptyModel(logService);
33 }
35 > async initialize(): Promise<ConfigurationModel> {
36 this.resetConfigurationModel();
37 this._register(Registry.as<IConfigurationRegistry>(Extensions.Configuration).onDidUpdateConfiguration(({ properties, defaultsOverrides }) => this.onDidUpdateConfiguration(Array.from(properties), defaultsOverrides)));
38 return this.configurationModel;
39 }
41 > reload(): ConfigurationModel {
42 this.resetConfigurationModel();
43 return this.configurationModel;
44 }
46 > protected onDidUpdateConfiguration(properties: string[], defaultsOverrides?: boolean): void {
47 this.updateConfigurationModel(properties, Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurationProperties());
48 this._onDidChangeConfiguration.fire({ defaults: this.configurationModel, properties });
49 }
51 > protected getConfigurationDefaultOverrides(): IStringDictionary<unknown> {
52 return {};
53 }
55 > private resetConfigurationModel(): void {
56 this._configurationModel = ConfigurationModel.createEmptyModel(this.logService);
57 const properties = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurationProperties();
58 this.updateConfigurationModel(Object.keys(properties), properties);
59 }
61 > private updateConfigurationModel(properties: string[], configurationProperties: IStringDictionary<IRegisteredConfigurationPropertySchema>): void {
62 const configurationDefaultsOverrides = this.getConfigurationDefaultOverrides();
63 for (const key of properties) {
73 }
74 }
76 > protected getDefaultValue(_key: string, propertySchema: IRegisteredConfigurationPropertySchema): unknown {
77 return deepClone(propertySchema.default);
78 }
80 > }
81 >
82 > export interface IPolicyConfiguration {
83 > readonly onDidChangeConfiguration: Event<ConfigurationModel>;
84 > readonly configurationModel: ConfigurationModel;
85 > initialize(): Promise<ConfigurationModel>;
86 > }
87 >
88 > export class NullPolicyConfiguration implements IPolicyConfiguration {
89 readonly onDidChangeConfiguration = Event.None;
90 readonly configurationModel = ConfigurationModel.createEmptyModel(new NullLogService());
91 > async initialize() { return this.configurationModel; } configurations.ts
92 > }
93 >
94 > type ParsedType = IStringDictionary<unknown> | Array<unknown>;
95 >
96 > export class PolicyConfiguration extends Disposable implements IPolicyConfiguration {
97 >
98 > private readonly _onDidChangeConfiguration = this._register(new Emitter<ConfigurationModel>());
99 > readonly onDidChangeConfiguration = this._onDidChangeConfiguration.event;
100 >
101 > private readonly configurationRegistry: IConfigurationRegistry;
102 >
103 > private _configurationModel: ConfigurationModel;
104 > get configurationModel() { return this._configurationModel; }
105 >
106 > /** Last definition submitted per policy name; avoids redundant re-registration. */
107 > private readonly _submittedPolicyDefinitions = new Map<PolicyName, PolicyDefinition>();
108 >
109 > /** Maps each policy-controlled setting key to its policy name, so removed keys can be re-resolved. */
110 > private readonly _policyNameByKey = new Map<string, PolicyName>();
111 >
112 > constructor(
113 private readonly defaultConfiguration: DefaultConfiguration,
114 @IPolicyService private readonly policyService: IPolicyService,
119 this.configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
120 }
122 > async initialize(): Promise<ConfigurationModel> {
123 this.logService.trace('PolicyConfiguration#initialize');
124
129 return this._configurationModel;
130 }
132 > private toPolicyDefinitionType(configType: unknown, policyName: PolicyName): 'string' | 'number' | 'boolean' | undefined {
133 // `configType` may be a single type or a union (e.g. `['array', 'null']`).
134 // Normalize to an array and keep only the types we can represent as policies.
141 return supportedTypes.includes('number') ? 'number' : supportedTypes.includes('boolean') ? 'boolean' : 'string';
142 }
144 > private async updatePolicyDefinitions(properties: string[]): Promise<string[]> {
145 this.logService.trace('PolicyConfiguration#updatePolicyDefinitions', properties);
146 const keys: string[] = [];
183 return keys;
184 }
186 > private isSamePolicyDefinition(a: PolicyDefinition | undefined, b: PolicyDefinition): boolean {
187 return !!a && a.type === b.type && a.value === b.value && a.managedSettings === b.managedSettings && a.restrictedValue === b.restrictedValue;
188 }
190 > /** Resolve the authoritative definition: owner wins; references provide a bare type fallback. */
191 > private resolvePolicyDefinition(policyName: PolicyName): PolicyDefinition | undefined {
192 const configurationProperties = this.configurationRegistry.getConfigurationProperties();
193 const excludedConfigurationProperties = this.configurationRegistry.getExcludedConfigurationProperties();
214 return undefined;
215 }
217 > private onDidChangePolicies(policyNames: readonly PolicyName[]): void {
218 this.logService.trace('PolicyConfiguration#onDidChangePolicies', policyNames);
219 const policyConfigurations = this.configurationRegistry.getPolicyConfigurations();
232 this.update(keys, true);
233 }
235 > private update(keys: string[], trigger: boolean): void {
236 this.logService.trace('PolicyConfiguration#update', keys);
237 const configurationProperties = this.configurationRegistry.getConfigurationProperties();
286 }
287 }
289 > private parse(content: string): ParsedType {
290 let raw: ParsedType = {};
291 let currentProperty: string | null = null;