1
>
/*---------------------------------------------------------------------------------------------
configurationRegistry.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 { 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) {
295
return true;