@codingame/monaco-vscode-configuration-service-override 3.2.3 → 4.1.0
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/configuration.js +8 -8
- package/package.json +9 -9
- package/override/vs/platform/dialogs/common/dialogs.js +0 -8
- package/vscode/src/vs/editor/common/services/textResourceConfigurationService.js +0 -118
- package/vscode/src/vs/workbench/api/common/configurationExtensionPoint.js +0 -595
- package/vscode/src/vs/workbench/contrib/workspaces/browser/workspaces.contribution.js +0 -134
- package/vscode/src/vs/workbench/services/configuration/browser/configuration.js +0 -852
- package/vscode/src/vs/workbench/services/configuration/browser/configurationService.js +0 -1201
- package/vscode/src/vs/workbench/services/configuration/common/configurationEditing.js +0 -668
- package/vscode/src/vs/workbench/services/configuration/common/configurationModels.js +0 -121
- package/vscode/src/vs/workbench/services/label/common/labelService.js +0 -437
- package/vscode/src/vs/workbench/services/textresourceProperties/common/textResourcePropertiesService.js +0 -45
- package/vscode/src/vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService.js +0 -337
- package/vscode/src/vs/workbench/services/workspaces/browser/workspacesService.js +0 -153
|
@@ -1,852 +0,0 @@
|
|
|
1
|
-
import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
|
|
2
|
-
import { getErrorMessage } from 'vscode/vscode/vs/base/common/errors';
|
|
3
|
-
import { Disposable, MutableDisposable, combinedDisposable, toDisposable, DisposableStore, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
-
import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
|
|
5
|
-
import { whenProviderRegistered } from 'vscode/vscode/vs/platform/files/common/files';
|
|
6
|
-
import { UserSettings, ConfigurationModelParser, ConfigurationModel } from 'vscode/vscode/vs/platform/configuration/common/configurationModels';
|
|
7
|
-
import { StandaloneConfigurationModelParser, WorkspaceConfigurationModelParser } from '../common/configurationModels.js';
|
|
8
|
-
import { APPLY_ALL_PROFILES_SETTING, TASKS_CONFIGURATION_KEY, REMOTE_MACHINE_SCOPES, WORKSPACE_SCOPES, FOLDER_SCOPES, FOLDER_SETTINGS_NAME, LAUNCH_CONFIGURATION_KEY } from 'vscode/vscode/vs/workbench/services/configuration/common/configuration';
|
|
9
|
-
import { Extensions, OVERRIDE_PROPERTY_REGEX } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
10
|
-
import { equals } from 'vscode/vscode/vs/base/common/objects';
|
|
11
|
-
import { hash } from 'vscode/vscode/vs/base/common/hash';
|
|
12
|
-
import { joinPath } from 'vscode/vscode/vs/base/common/resources';
|
|
13
|
-
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
14
|
-
import { isEmptyObject, isObject } from 'vscode/vscode/vs/base/common/types';
|
|
15
|
-
import { DefaultConfiguration as DefaultConfiguration$1 } from 'vscode/vscode/vs/platform/configuration/common/configurations';
|
|
16
|
-
|
|
17
|
-
class DefaultConfiguration extends DefaultConfiguration$1 {
|
|
18
|
-
static { this.DEFAULT_OVERRIDES_CACHE_EXISTS_KEY = 'DefaultOverridesCacheExists'; }
|
|
19
|
-
constructor(configurationCache, environmentService) {
|
|
20
|
-
super();
|
|
21
|
-
this.configurationCache = configurationCache;
|
|
22
|
-
this.configurationRegistry = ( Registry.as(Extensions.Configuration));
|
|
23
|
-
this.cachedConfigurationDefaultsOverrides = {};
|
|
24
|
-
this.cacheKey = { type: 'defaults', key: 'configurationDefaultsOverrides' };
|
|
25
|
-
this.updateCache = false;
|
|
26
|
-
if (environmentService.options?.configurationDefaults) {
|
|
27
|
-
this.configurationRegistry.registerDefaultConfigurations([{ overrides: environmentService.options.configurationDefaults }]);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
getConfigurationDefaultOverrides() {
|
|
31
|
-
return this.cachedConfigurationDefaultsOverrides;
|
|
32
|
-
}
|
|
33
|
-
async initialize() {
|
|
34
|
-
await this.initializeCachedConfigurationDefaultsOverrides();
|
|
35
|
-
return super.initialize();
|
|
36
|
-
}
|
|
37
|
-
reload() {
|
|
38
|
-
this.updateCache = true;
|
|
39
|
-
this.cachedConfigurationDefaultsOverrides = {};
|
|
40
|
-
this.updateCachedConfigurationDefaultsOverrides();
|
|
41
|
-
return super.reload();
|
|
42
|
-
}
|
|
43
|
-
hasCachedConfigurationDefaultsOverrides() {
|
|
44
|
-
return !isEmptyObject(this.cachedConfigurationDefaultsOverrides);
|
|
45
|
-
}
|
|
46
|
-
initializeCachedConfigurationDefaultsOverrides() {
|
|
47
|
-
if (!this.initiaizeCachedConfigurationDefaultsOverridesPromise) {
|
|
48
|
-
this.initiaizeCachedConfigurationDefaultsOverridesPromise = (async () => {
|
|
49
|
-
try {
|
|
50
|
-
if (localStorage.getItem(DefaultConfiguration.DEFAULT_OVERRIDES_CACHE_EXISTS_KEY)) {
|
|
51
|
-
const content = await this.configurationCache.read(this.cacheKey);
|
|
52
|
-
if (content) {
|
|
53
|
-
this.cachedConfigurationDefaultsOverrides = JSON.parse(content);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (error) { }
|
|
58
|
-
this.cachedConfigurationDefaultsOverrides = isObject(this.cachedConfigurationDefaultsOverrides) ? this.cachedConfigurationDefaultsOverrides : {};
|
|
59
|
-
})();
|
|
60
|
-
}
|
|
61
|
-
return this.initiaizeCachedConfigurationDefaultsOverridesPromise;
|
|
62
|
-
}
|
|
63
|
-
onDidUpdateConfiguration(properties, defaultsOverrides) {
|
|
64
|
-
super.onDidUpdateConfiguration(properties, defaultsOverrides);
|
|
65
|
-
if (defaultsOverrides) {
|
|
66
|
-
this.updateCachedConfigurationDefaultsOverrides();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
async updateCachedConfigurationDefaultsOverrides() {
|
|
70
|
-
if (!this.updateCache) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const cachedConfigurationDefaultsOverrides = {};
|
|
74
|
-
const configurationDefaultsOverrides = this.configurationRegistry.getConfigurationDefaultsOverrides();
|
|
75
|
-
for (const [key, value] of configurationDefaultsOverrides) {
|
|
76
|
-
if (!OVERRIDE_PROPERTY_REGEX.test(key) && value.value !== undefined) {
|
|
77
|
-
cachedConfigurationDefaultsOverrides[key] = value.value;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
if (( Object.keys(cachedConfigurationDefaultsOverrides)).length) {
|
|
82
|
-
localStorage.setItem(DefaultConfiguration.DEFAULT_OVERRIDES_CACHE_EXISTS_KEY, 'yes');
|
|
83
|
-
await this.configurationCache.write(this.cacheKey, JSON.stringify(cachedConfigurationDefaultsOverrides));
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
localStorage.removeItem(DefaultConfiguration.DEFAULT_OVERRIDES_CACHE_EXISTS_KEY);
|
|
87
|
-
await this.configurationCache.remove(this.cacheKey);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
catch (error) { }
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
class ApplicationConfiguration extends UserSettings {
|
|
94
|
-
constructor(userDataProfilesService, fileService, uriIdentityService) {
|
|
95
|
-
super(userDataProfilesService.defaultProfile.settingsResource, { scopes: [1 ] }, uriIdentityService.extUri, fileService);
|
|
96
|
-
this._onDidChangeConfiguration = this._register(( new Emitter()));
|
|
97
|
-
this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
|
|
98
|
-
this._register(this.onDidChange(() => this.reloadConfigurationScheduler.schedule()));
|
|
99
|
-
this.reloadConfigurationScheduler = this._register(( new RunOnceScheduler(
|
|
100
|
-
() => this.loadConfiguration().then(configurationModel => this._onDidChangeConfiguration.fire(configurationModel)),
|
|
101
|
-
50
|
|
102
|
-
)));
|
|
103
|
-
}
|
|
104
|
-
async initialize() {
|
|
105
|
-
return this.loadConfiguration();
|
|
106
|
-
}
|
|
107
|
-
async loadConfiguration() {
|
|
108
|
-
const model = await super.loadConfiguration();
|
|
109
|
-
const value = model.getValue(APPLY_ALL_PROFILES_SETTING);
|
|
110
|
-
const allProfilesSettings = Array.isArray(value) ? value : [];
|
|
111
|
-
return this.parseOptions.include || allProfilesSettings.length
|
|
112
|
-
? this.reparse({ ...this.parseOptions, include: allProfilesSettings })
|
|
113
|
-
: model;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
class UserConfiguration extends Disposable {
|
|
117
|
-
get hasTasksLoaded() { return this.userConfiguration.value instanceof FileServiceBasedConfiguration; }
|
|
118
|
-
constructor(settingsResource, tasksResource, configurationParseOptions, fileService, uriIdentityService, logService) {
|
|
119
|
-
super();
|
|
120
|
-
this.settingsResource = settingsResource;
|
|
121
|
-
this.tasksResource = tasksResource;
|
|
122
|
-
this.configurationParseOptions = configurationParseOptions;
|
|
123
|
-
this.fileService = fileService;
|
|
124
|
-
this.uriIdentityService = uriIdentityService;
|
|
125
|
-
this.logService = logService;
|
|
126
|
-
this._onDidChangeConfiguration = this._register(( new Emitter()));
|
|
127
|
-
this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
|
|
128
|
-
this.userConfiguration = this._register(( new MutableDisposable()));
|
|
129
|
-
this.userConfigurationChangeDisposable = this._register(( new MutableDisposable()));
|
|
130
|
-
this.userConfiguration.value = ( new UserSettings(
|
|
131
|
-
settingsResource,
|
|
132
|
-
this.configurationParseOptions,
|
|
133
|
-
uriIdentityService.extUri,
|
|
134
|
-
this.fileService
|
|
135
|
-
));
|
|
136
|
-
this.userConfigurationChangeDisposable.value = this.userConfiguration.value.onDidChange(() => this.reloadConfigurationScheduler.schedule());
|
|
137
|
-
this.reloadConfigurationScheduler = this._register(( new RunOnceScheduler(
|
|
138
|
-
() => this.userConfiguration.value.loadConfiguration().then(configurationModel => this._onDidChangeConfiguration.fire(configurationModel)),
|
|
139
|
-
50
|
|
140
|
-
)));
|
|
141
|
-
}
|
|
142
|
-
async reset(settingsResource, tasksResource, configurationParseOptions) {
|
|
143
|
-
this.settingsResource = settingsResource;
|
|
144
|
-
this.tasksResource = tasksResource;
|
|
145
|
-
this.configurationParseOptions = configurationParseOptions;
|
|
146
|
-
return this.doReset();
|
|
147
|
-
}
|
|
148
|
-
async doReset(settingsConfiguration) {
|
|
149
|
-
const folder = this.uriIdentityService.extUri.dirname(this.settingsResource);
|
|
150
|
-
const standAloneConfigurationResources = this.tasksResource ? [[TASKS_CONFIGURATION_KEY, this.tasksResource]] : [];
|
|
151
|
-
const fileServiceBasedConfiguration = ( new FileServiceBasedConfiguration(( folder.toString()), this.settingsResource, standAloneConfigurationResources, this.configurationParseOptions, this.fileService, this.uriIdentityService, this.logService));
|
|
152
|
-
const configurationModel = await fileServiceBasedConfiguration.loadConfiguration(settingsConfiguration);
|
|
153
|
-
this.userConfiguration.value = fileServiceBasedConfiguration;
|
|
154
|
-
if (this.userConfigurationChangeDisposable.value) {
|
|
155
|
-
this.userConfigurationChangeDisposable.value = this.userConfiguration.value.onDidChange(() => this.reloadConfigurationScheduler.schedule());
|
|
156
|
-
}
|
|
157
|
-
return configurationModel;
|
|
158
|
-
}
|
|
159
|
-
async initialize() {
|
|
160
|
-
return this.userConfiguration.value.loadConfiguration();
|
|
161
|
-
}
|
|
162
|
-
async reload(settingsConfiguration) {
|
|
163
|
-
if (this.hasTasksLoaded) {
|
|
164
|
-
return this.userConfiguration.value.loadConfiguration();
|
|
165
|
-
}
|
|
166
|
-
return this.doReset(settingsConfiguration);
|
|
167
|
-
}
|
|
168
|
-
reparse(parseOptions) {
|
|
169
|
-
this.configurationParseOptions = { ...this.configurationParseOptions, ...parseOptions };
|
|
170
|
-
return this.userConfiguration.value.reparse(this.configurationParseOptions);
|
|
171
|
-
}
|
|
172
|
-
getRestrictedSettings() {
|
|
173
|
-
return this.userConfiguration.value.getRestrictedSettings();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
class FileServiceBasedConfiguration extends Disposable {
|
|
177
|
-
constructor(name, settingsResource, standAloneConfigurationResources, configurationParseOptions, fileService, uriIdentityService, logService) {
|
|
178
|
-
super();
|
|
179
|
-
this.settingsResource = settingsResource;
|
|
180
|
-
this.standAloneConfigurationResources = standAloneConfigurationResources;
|
|
181
|
-
this.fileService = fileService;
|
|
182
|
-
this.uriIdentityService = uriIdentityService;
|
|
183
|
-
this.logService = logService;
|
|
184
|
-
this._onDidChange = this._register(( new Emitter()));
|
|
185
|
-
this.onDidChange = this._onDidChange.event;
|
|
186
|
-
this.allResources = [this.settingsResource, ...( this.standAloneConfigurationResources.map(([, resource]) => resource))];
|
|
187
|
-
this._register(combinedDisposable(...( this.allResources.map(
|
|
188
|
-
resource => combinedDisposable(this.fileService.watch(uriIdentityService.extUri.dirname(resource)),
|
|
189
|
-
this.fileService.watch(resource))
|
|
190
|
-
))));
|
|
191
|
-
this._folderSettingsModelParser = ( new ConfigurationModelParser(name));
|
|
192
|
-
this._folderSettingsParseOptions = configurationParseOptions;
|
|
193
|
-
this._standAloneConfigurations = [];
|
|
194
|
-
this._cache = ( new ConfigurationModel());
|
|
195
|
-
this._register(Event.debounce(Event.any(Event.filter(this.fileService.onDidFilesChange, e => this.handleFileChangesEvent(e)), Event.filter(this.fileService.onDidRunOperation, e => this.handleFileOperationEvent(e))), () => undefined, 100)(() => this._onDidChange.fire()));
|
|
196
|
-
}
|
|
197
|
-
async resolveContents(donotResolveSettings) {
|
|
198
|
-
const resolveContents = async (resources) => {
|
|
199
|
-
return Promise.all(( resources.map(async (resource) => {
|
|
200
|
-
try {
|
|
201
|
-
const content = await this.fileService.readFile(resource, { atomic: true });
|
|
202
|
-
return ( content.value.toString());
|
|
203
|
-
}
|
|
204
|
-
catch (error) {
|
|
205
|
-
this.logService.trace(`Error while resolving configuration file '${( resource.toString())}': ${getErrorMessage(error)}`);
|
|
206
|
-
if (error.fileOperationResult !== 1
|
|
207
|
-
&& error.fileOperationResult !== 9 ) {
|
|
208
|
-
this.logService.error(error);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return '{}';
|
|
212
|
-
})));
|
|
213
|
-
};
|
|
214
|
-
const [[settingsContent], standAloneConfigurationContents] = await Promise.all([
|
|
215
|
-
donotResolveSettings ? Promise.resolve([undefined]) : resolveContents([this.settingsResource]),
|
|
216
|
-
resolveContents(( this.standAloneConfigurationResources.map(([, resource]) => resource))),
|
|
217
|
-
]);
|
|
218
|
-
return [settingsContent, ( standAloneConfigurationContents.map(
|
|
219
|
-
(content, index) => ([this.standAloneConfigurationResources[index][0], content])
|
|
220
|
-
))];
|
|
221
|
-
}
|
|
222
|
-
async loadConfiguration(settingsConfiguration) {
|
|
223
|
-
const [settingsContent, standAloneConfigurationContents] = await this.resolveContents(!!settingsConfiguration);
|
|
224
|
-
this._standAloneConfigurations = [];
|
|
225
|
-
this._folderSettingsModelParser.parse('', this._folderSettingsParseOptions);
|
|
226
|
-
if (settingsContent !== undefined) {
|
|
227
|
-
this._folderSettingsModelParser.parse(settingsContent, this._folderSettingsParseOptions);
|
|
228
|
-
}
|
|
229
|
-
for (let index = 0; index < standAloneConfigurationContents.length; index++) {
|
|
230
|
-
const contents = standAloneConfigurationContents[index][1];
|
|
231
|
-
if (contents !== undefined) {
|
|
232
|
-
const standAloneConfigurationModelParser = ( new StandaloneConfigurationModelParser(( this.standAloneConfigurationResources[index][1].toString()), this.standAloneConfigurationResources[index][0]));
|
|
233
|
-
standAloneConfigurationModelParser.parse(contents);
|
|
234
|
-
this._standAloneConfigurations.push(standAloneConfigurationModelParser.configurationModel);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
this.consolidate(settingsConfiguration);
|
|
238
|
-
return this._cache;
|
|
239
|
-
}
|
|
240
|
-
getRestrictedSettings() {
|
|
241
|
-
return this._folderSettingsModelParser.restrictedConfigurations;
|
|
242
|
-
}
|
|
243
|
-
reparse(configurationParseOptions) {
|
|
244
|
-
const oldContents = this._folderSettingsModelParser.configurationModel.contents;
|
|
245
|
-
this._folderSettingsParseOptions = configurationParseOptions;
|
|
246
|
-
this._folderSettingsModelParser.reparse(this._folderSettingsParseOptions);
|
|
247
|
-
if (!equals(oldContents, this._folderSettingsModelParser.configurationModel.contents)) {
|
|
248
|
-
this.consolidate();
|
|
249
|
-
}
|
|
250
|
-
return this._cache;
|
|
251
|
-
}
|
|
252
|
-
consolidate(settingsConfiguration) {
|
|
253
|
-
this._cache = (settingsConfiguration ?? this._folderSettingsModelParser.configurationModel).merge(...this._standAloneConfigurations);
|
|
254
|
-
}
|
|
255
|
-
handleFileChangesEvent(event) {
|
|
256
|
-
if (( this.allResources.some(resource => event.contains(resource)))) {
|
|
257
|
-
return true;
|
|
258
|
-
}
|
|
259
|
-
if (( this.allResources.some(
|
|
260
|
-
resource => event.contains(this.uriIdentityService.extUri.dirname(resource), 2 )
|
|
261
|
-
))) {
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
return false;
|
|
265
|
-
}
|
|
266
|
-
handleFileOperationEvent(event) {
|
|
267
|
-
if ((event.isOperation(0 ) || event.isOperation(3 ) || event.isOperation(1 ) || event.isOperation(4 ))
|
|
268
|
-
&& ( this.allResources.some(
|
|
269
|
-
resource => this.uriIdentityService.extUri.isEqual(event.resource, resource)
|
|
270
|
-
))) {
|
|
271
|
-
return true;
|
|
272
|
-
}
|
|
273
|
-
if (event.isOperation(1 ) && ( this.allResources.some(
|
|
274
|
-
resource => this.uriIdentityService.extUri.isEqual(event.resource, this.uriIdentityService.extUri.dirname(resource))
|
|
275
|
-
))) {
|
|
276
|
-
return true;
|
|
277
|
-
}
|
|
278
|
-
return false;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
class RemoteUserConfiguration extends Disposable {
|
|
282
|
-
constructor(remoteAuthority, configurationCache, fileService, uriIdentityService, remoteAgentService) {
|
|
283
|
-
super();
|
|
284
|
-
this._userConfigurationInitializationPromise = null;
|
|
285
|
-
this._onDidChangeConfiguration = this._register(( new Emitter()));
|
|
286
|
-
this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
|
|
287
|
-
this._onDidInitialize = this._register(( new Emitter()));
|
|
288
|
-
this.onDidInitialize = this._onDidInitialize.event;
|
|
289
|
-
this._fileService = fileService;
|
|
290
|
-
this._userConfiguration = this._cachedConfiguration = ( new CachedRemoteUserConfiguration(remoteAuthority, configurationCache, { scopes: REMOTE_MACHINE_SCOPES }));
|
|
291
|
-
remoteAgentService.getEnvironment().then(async (environment) => {
|
|
292
|
-
if (environment) {
|
|
293
|
-
const userConfiguration = this._register(( new FileServiceBasedRemoteUserConfiguration(
|
|
294
|
-
environment.settingsPath,
|
|
295
|
-
{ scopes: REMOTE_MACHINE_SCOPES },
|
|
296
|
-
this._fileService,
|
|
297
|
-
uriIdentityService
|
|
298
|
-
)));
|
|
299
|
-
this._register(userConfiguration.onDidChangeConfiguration(configurationModel => this.onDidUserConfigurationChange(configurationModel)));
|
|
300
|
-
this._userConfigurationInitializationPromise = userConfiguration.initialize();
|
|
301
|
-
const configurationModel = await this._userConfigurationInitializationPromise;
|
|
302
|
-
this._userConfiguration.dispose();
|
|
303
|
-
this._userConfiguration = userConfiguration;
|
|
304
|
-
this.onDidUserConfigurationChange(configurationModel);
|
|
305
|
-
this._onDidInitialize.fire(configurationModel);
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
async initialize() {
|
|
310
|
-
if (this._userConfiguration instanceof FileServiceBasedRemoteUserConfiguration) {
|
|
311
|
-
return this._userConfiguration.initialize();
|
|
312
|
-
}
|
|
313
|
-
let configurationModel = await this._userConfiguration.initialize();
|
|
314
|
-
if (this._userConfigurationInitializationPromise) {
|
|
315
|
-
configurationModel = await this._userConfigurationInitializationPromise;
|
|
316
|
-
this._userConfigurationInitializationPromise = null;
|
|
317
|
-
}
|
|
318
|
-
return configurationModel;
|
|
319
|
-
}
|
|
320
|
-
reload() {
|
|
321
|
-
return this._userConfiguration.reload();
|
|
322
|
-
}
|
|
323
|
-
reparse() {
|
|
324
|
-
return this._userConfiguration.reparse({ scopes: REMOTE_MACHINE_SCOPES });
|
|
325
|
-
}
|
|
326
|
-
getRestrictedSettings() {
|
|
327
|
-
return this._userConfiguration.getRestrictedSettings();
|
|
328
|
-
}
|
|
329
|
-
onDidUserConfigurationChange(configurationModel) {
|
|
330
|
-
this.updateCache();
|
|
331
|
-
this._onDidChangeConfiguration.fire(configurationModel);
|
|
332
|
-
}
|
|
333
|
-
async updateCache() {
|
|
334
|
-
if (this._userConfiguration instanceof FileServiceBasedRemoteUserConfiguration) {
|
|
335
|
-
let content;
|
|
336
|
-
try {
|
|
337
|
-
content = await this._userConfiguration.resolveContent();
|
|
338
|
-
}
|
|
339
|
-
catch (error) {
|
|
340
|
-
if (error.fileOperationResult !== 1 ) {
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
await this._cachedConfiguration.updateConfiguration(content);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
class FileServiceBasedRemoteUserConfiguration extends Disposable {
|
|
349
|
-
constructor(configurationResource, configurationParseOptions, fileService, uriIdentityService) {
|
|
350
|
-
super();
|
|
351
|
-
this.configurationResource = configurationResource;
|
|
352
|
-
this.fileService = fileService;
|
|
353
|
-
this.uriIdentityService = uriIdentityService;
|
|
354
|
-
this._onDidChangeConfiguration = this._register(( new Emitter()));
|
|
355
|
-
this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
|
|
356
|
-
this.fileWatcherDisposable = this._register(( new MutableDisposable()));
|
|
357
|
-
this.directoryWatcherDisposable = this._register(( new MutableDisposable()));
|
|
358
|
-
this.parser = ( new ConfigurationModelParser(( this.configurationResource.toString())));
|
|
359
|
-
this.parseOptions = configurationParseOptions;
|
|
360
|
-
this._register(fileService.onDidFilesChange(e => this.handleFileChangesEvent(e)));
|
|
361
|
-
this._register(fileService.onDidRunOperation(e => this.handleFileOperationEvent(e)));
|
|
362
|
-
this.reloadConfigurationScheduler = this._register(( new RunOnceScheduler(
|
|
363
|
-
() => this.reload().then(configurationModel => this._onDidChangeConfiguration.fire(configurationModel)),
|
|
364
|
-
50
|
|
365
|
-
)));
|
|
366
|
-
this._register(toDisposable(() => {
|
|
367
|
-
this.stopWatchingResource();
|
|
368
|
-
this.stopWatchingDirectory();
|
|
369
|
-
}));
|
|
370
|
-
}
|
|
371
|
-
watchResource() {
|
|
372
|
-
this.fileWatcherDisposable.value = this.fileService.watch(this.configurationResource);
|
|
373
|
-
}
|
|
374
|
-
stopWatchingResource() {
|
|
375
|
-
this.fileWatcherDisposable.value = undefined;
|
|
376
|
-
}
|
|
377
|
-
watchDirectory() {
|
|
378
|
-
const directory = this.uriIdentityService.extUri.dirname(this.configurationResource);
|
|
379
|
-
this.directoryWatcherDisposable.value = this.fileService.watch(directory);
|
|
380
|
-
}
|
|
381
|
-
stopWatchingDirectory() {
|
|
382
|
-
this.directoryWatcherDisposable.value = undefined;
|
|
383
|
-
}
|
|
384
|
-
async initialize() {
|
|
385
|
-
const exists = await this.fileService.exists(this.configurationResource);
|
|
386
|
-
this.onResourceExists(exists);
|
|
387
|
-
return this.reload();
|
|
388
|
-
}
|
|
389
|
-
async resolveContent() {
|
|
390
|
-
const content = await this.fileService.readFile(this.configurationResource, { atomic: true });
|
|
391
|
-
return ( content.value.toString());
|
|
392
|
-
}
|
|
393
|
-
async reload() {
|
|
394
|
-
try {
|
|
395
|
-
const content = await this.resolveContent();
|
|
396
|
-
this.parser.parse(content, this.parseOptions);
|
|
397
|
-
return this.parser.configurationModel;
|
|
398
|
-
}
|
|
399
|
-
catch (e) {
|
|
400
|
-
return ( new ConfigurationModel());
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
reparse(configurationParseOptions) {
|
|
404
|
-
this.parseOptions = configurationParseOptions;
|
|
405
|
-
this.parser.reparse(this.parseOptions);
|
|
406
|
-
return this.parser.configurationModel;
|
|
407
|
-
}
|
|
408
|
-
getRestrictedSettings() {
|
|
409
|
-
return this.parser.restrictedConfigurations;
|
|
410
|
-
}
|
|
411
|
-
handleFileChangesEvent(event) {
|
|
412
|
-
let affectedByChanges = event.contains(this.configurationResource, 0 );
|
|
413
|
-
if (event.contains(this.configurationResource, 1 )) {
|
|
414
|
-
affectedByChanges = true;
|
|
415
|
-
this.onResourceExists(true);
|
|
416
|
-
}
|
|
417
|
-
else if (event.contains(this.configurationResource, 2 )) {
|
|
418
|
-
affectedByChanges = true;
|
|
419
|
-
this.onResourceExists(false);
|
|
420
|
-
}
|
|
421
|
-
if (affectedByChanges) {
|
|
422
|
-
this.reloadConfigurationScheduler.schedule();
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
handleFileOperationEvent(event) {
|
|
426
|
-
if ((event.isOperation(0 ) || event.isOperation(3 ) || event.isOperation(1 ) || event.isOperation(4 ))
|
|
427
|
-
&& this.uriIdentityService.extUri.isEqual(event.resource, this.configurationResource)) {
|
|
428
|
-
this.reloadConfigurationScheduler.schedule();
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
onResourceExists(exists) {
|
|
432
|
-
if (exists) {
|
|
433
|
-
this.stopWatchingDirectory();
|
|
434
|
-
this.watchResource();
|
|
435
|
-
}
|
|
436
|
-
else {
|
|
437
|
-
this.stopWatchingResource();
|
|
438
|
-
this.watchDirectory();
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
class CachedRemoteUserConfiguration extends Disposable {
|
|
443
|
-
constructor(remoteAuthority, configurationCache, configurationParseOptions) {
|
|
444
|
-
super();
|
|
445
|
-
this.configurationCache = configurationCache;
|
|
446
|
-
this._onDidChange = this._register(( new Emitter()));
|
|
447
|
-
this.onDidChange = this._onDidChange.event;
|
|
448
|
-
this.key = { type: 'user', key: remoteAuthority };
|
|
449
|
-
this.parser = ( new ConfigurationModelParser('CachedRemoteUserConfiguration'));
|
|
450
|
-
this.parseOptions = configurationParseOptions;
|
|
451
|
-
this.configurationModel = ( new ConfigurationModel());
|
|
452
|
-
}
|
|
453
|
-
getConfigurationModel() {
|
|
454
|
-
return this.configurationModel;
|
|
455
|
-
}
|
|
456
|
-
initialize() {
|
|
457
|
-
return this.reload();
|
|
458
|
-
}
|
|
459
|
-
reparse(configurationParseOptions) {
|
|
460
|
-
this.parseOptions = configurationParseOptions;
|
|
461
|
-
this.parser.reparse(this.parseOptions);
|
|
462
|
-
this.configurationModel = this.parser.configurationModel;
|
|
463
|
-
return this.configurationModel;
|
|
464
|
-
}
|
|
465
|
-
getRestrictedSettings() {
|
|
466
|
-
return this.parser.restrictedConfigurations;
|
|
467
|
-
}
|
|
468
|
-
async reload() {
|
|
469
|
-
try {
|
|
470
|
-
const content = await this.configurationCache.read(this.key);
|
|
471
|
-
const parsed = JSON.parse(content);
|
|
472
|
-
if (parsed.content) {
|
|
473
|
-
this.parser.parse(parsed.content, this.parseOptions);
|
|
474
|
-
this.configurationModel = this.parser.configurationModel;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
catch (e) { }
|
|
478
|
-
return this.configurationModel;
|
|
479
|
-
}
|
|
480
|
-
async updateConfiguration(content) {
|
|
481
|
-
if (content) {
|
|
482
|
-
return this.configurationCache.write(this.key, JSON.stringify({ content }));
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
return this.configurationCache.remove(this.key);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
class WorkspaceConfiguration extends Disposable {
|
|
490
|
-
get initialized() { return this._initialized; }
|
|
491
|
-
constructor(configurationCache, fileService, uriIdentityService, logService) {
|
|
492
|
-
super();
|
|
493
|
-
this.configurationCache = configurationCache;
|
|
494
|
-
this.fileService = fileService;
|
|
495
|
-
this.uriIdentityService = uriIdentityService;
|
|
496
|
-
this.logService = logService;
|
|
497
|
-
this._workspaceConfigurationDisposables = this._register(( new DisposableStore()));
|
|
498
|
-
this._workspaceIdentifier = null;
|
|
499
|
-
this._isWorkspaceTrusted = false;
|
|
500
|
-
this._onDidUpdateConfiguration = this._register(( new Emitter()));
|
|
501
|
-
this.onDidUpdateConfiguration = this._onDidUpdateConfiguration.event;
|
|
502
|
-
this._initialized = false;
|
|
503
|
-
this.fileService = fileService;
|
|
504
|
-
this._workspaceConfiguration = this._cachedConfiguration = ( new CachedWorkspaceConfiguration(configurationCache));
|
|
505
|
-
}
|
|
506
|
-
async initialize(workspaceIdentifier, workspaceTrusted) {
|
|
507
|
-
this._workspaceIdentifier = workspaceIdentifier;
|
|
508
|
-
this._isWorkspaceTrusted = workspaceTrusted;
|
|
509
|
-
if (!this._initialized) {
|
|
510
|
-
if (this.configurationCache.needsCaching(this._workspaceIdentifier.configPath)) {
|
|
511
|
-
this._workspaceConfiguration = this._cachedConfiguration;
|
|
512
|
-
this.waitAndInitialize(this._workspaceIdentifier);
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
this.doInitialize(( new FileServiceBasedWorkspaceConfiguration(this.fileService, this.uriIdentityService, this.logService)));
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
await this.reload();
|
|
519
|
-
}
|
|
520
|
-
async reload() {
|
|
521
|
-
if (this._workspaceIdentifier) {
|
|
522
|
-
await this._workspaceConfiguration.load(this._workspaceIdentifier, { scopes: WORKSPACE_SCOPES, skipRestricted: this.isUntrusted() });
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
getFolders() {
|
|
526
|
-
return this._workspaceConfiguration.getFolders();
|
|
527
|
-
}
|
|
528
|
-
setFolders(folders, jsonEditingService) {
|
|
529
|
-
if (this._workspaceIdentifier) {
|
|
530
|
-
return jsonEditingService.write(this._workspaceIdentifier.configPath, [{ path: ['folders'], value: folders }], true)
|
|
531
|
-
.then(() => this.reload());
|
|
532
|
-
}
|
|
533
|
-
return Promise.resolve();
|
|
534
|
-
}
|
|
535
|
-
isTransient() {
|
|
536
|
-
return this._workspaceConfiguration.isTransient();
|
|
537
|
-
}
|
|
538
|
-
getConfiguration() {
|
|
539
|
-
return this._workspaceConfiguration.getWorkspaceSettings();
|
|
540
|
-
}
|
|
541
|
-
updateWorkspaceTrust(trusted) {
|
|
542
|
-
this._isWorkspaceTrusted = trusted;
|
|
543
|
-
return this.reparseWorkspaceSettings();
|
|
544
|
-
}
|
|
545
|
-
reparseWorkspaceSettings() {
|
|
546
|
-
this._workspaceConfiguration.reparseWorkspaceSettings({ scopes: WORKSPACE_SCOPES, skipRestricted: this.isUntrusted() });
|
|
547
|
-
return this.getConfiguration();
|
|
548
|
-
}
|
|
549
|
-
getRestrictedSettings() {
|
|
550
|
-
return this._workspaceConfiguration.getRestrictedSettings();
|
|
551
|
-
}
|
|
552
|
-
async waitAndInitialize(workspaceIdentifier) {
|
|
553
|
-
await whenProviderRegistered(workspaceIdentifier.configPath, this.fileService);
|
|
554
|
-
if (!(this._workspaceConfiguration instanceof FileServiceBasedWorkspaceConfiguration)) {
|
|
555
|
-
const fileServiceBasedWorkspaceConfiguration = this._register(( new FileServiceBasedWorkspaceConfiguration(this.fileService, this.uriIdentityService, this.logService)));
|
|
556
|
-
await fileServiceBasedWorkspaceConfiguration.load(workspaceIdentifier, { scopes: WORKSPACE_SCOPES, skipRestricted: this.isUntrusted() });
|
|
557
|
-
this.doInitialize(fileServiceBasedWorkspaceConfiguration);
|
|
558
|
-
this.onDidWorkspaceConfigurationChange(false, true);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
doInitialize(fileServiceBasedWorkspaceConfiguration) {
|
|
562
|
-
this._workspaceConfigurationDisposables.clear();
|
|
563
|
-
this._workspaceConfiguration = this._workspaceConfigurationDisposables.add(fileServiceBasedWorkspaceConfiguration);
|
|
564
|
-
this._workspaceConfigurationDisposables.add(this._workspaceConfiguration.onDidChange(e => this.onDidWorkspaceConfigurationChange(true, false)));
|
|
565
|
-
this._initialized = true;
|
|
566
|
-
}
|
|
567
|
-
isUntrusted() {
|
|
568
|
-
return !this._isWorkspaceTrusted;
|
|
569
|
-
}
|
|
570
|
-
async onDidWorkspaceConfigurationChange(reload, fromCache) {
|
|
571
|
-
if (reload) {
|
|
572
|
-
await this.reload();
|
|
573
|
-
}
|
|
574
|
-
this.updateCache();
|
|
575
|
-
this._onDidUpdateConfiguration.fire(fromCache);
|
|
576
|
-
}
|
|
577
|
-
async updateCache() {
|
|
578
|
-
if (this._workspaceIdentifier && this.configurationCache.needsCaching(this._workspaceIdentifier.configPath) && this._workspaceConfiguration instanceof FileServiceBasedWorkspaceConfiguration) {
|
|
579
|
-
const content = await this._workspaceConfiguration.resolveContent(this._workspaceIdentifier);
|
|
580
|
-
await this._cachedConfiguration.updateWorkspace(this._workspaceIdentifier, content);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
class FileServiceBasedWorkspaceConfiguration extends Disposable {
|
|
585
|
-
constructor(fileService, uriIdentityService, logService) {
|
|
586
|
-
super();
|
|
587
|
-
this.fileService = fileService;
|
|
588
|
-
this.logService = logService;
|
|
589
|
-
this._workspaceIdentifier = null;
|
|
590
|
-
this._onDidChange = this._register(( new Emitter()));
|
|
591
|
-
this.onDidChange = this._onDidChange.event;
|
|
592
|
-
this.workspaceConfigurationModelParser = ( new WorkspaceConfigurationModelParser(''));
|
|
593
|
-
this.workspaceSettings = ( new ConfigurationModel());
|
|
594
|
-
this._register(Event.any(Event.filter(this.fileService.onDidFilesChange, e => !!this._workspaceIdentifier && e.contains(this._workspaceIdentifier.configPath)), Event.filter(this.fileService.onDidRunOperation, e => !!this._workspaceIdentifier && (e.isOperation(0 ) || e.isOperation(3 ) || e.isOperation(1 ) || e.isOperation(4 )) && uriIdentityService.extUri.isEqual(e.resource, this._workspaceIdentifier.configPath)))(() => this.reloadConfigurationScheduler.schedule()));
|
|
595
|
-
this.reloadConfigurationScheduler = this._register(( new RunOnceScheduler(() => this._onDidChange.fire(), 50)));
|
|
596
|
-
this.workspaceConfigWatcher = this._register(this.watchWorkspaceConfigurationFile());
|
|
597
|
-
}
|
|
598
|
-
get workspaceIdentifier() {
|
|
599
|
-
return this._workspaceIdentifier;
|
|
600
|
-
}
|
|
601
|
-
async resolveContent(workspaceIdentifier) {
|
|
602
|
-
const content = await this.fileService.readFile(workspaceIdentifier.configPath, { atomic: true });
|
|
603
|
-
return ( content.value.toString());
|
|
604
|
-
}
|
|
605
|
-
async load(workspaceIdentifier, configurationParseOptions) {
|
|
606
|
-
if (!this._workspaceIdentifier || this._workspaceIdentifier.id !== workspaceIdentifier.id) {
|
|
607
|
-
this._workspaceIdentifier = workspaceIdentifier;
|
|
608
|
-
this.workspaceConfigurationModelParser = ( new WorkspaceConfigurationModelParser(this._workspaceIdentifier.id));
|
|
609
|
-
dispose(this.workspaceConfigWatcher);
|
|
610
|
-
this.workspaceConfigWatcher = this._register(this.watchWorkspaceConfigurationFile());
|
|
611
|
-
}
|
|
612
|
-
let contents = '';
|
|
613
|
-
try {
|
|
614
|
-
contents = await this.resolveContent(this._workspaceIdentifier);
|
|
615
|
-
}
|
|
616
|
-
catch (error) {
|
|
617
|
-
const exists = await this.fileService.exists(this._workspaceIdentifier.configPath);
|
|
618
|
-
if (exists) {
|
|
619
|
-
this.logService.error(error);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
this.workspaceConfigurationModelParser.parse(contents, configurationParseOptions);
|
|
623
|
-
this.consolidate();
|
|
624
|
-
}
|
|
625
|
-
getConfigurationModel() {
|
|
626
|
-
return this.workspaceConfigurationModelParser.configurationModel;
|
|
627
|
-
}
|
|
628
|
-
getFolders() {
|
|
629
|
-
return this.workspaceConfigurationModelParser.folders;
|
|
630
|
-
}
|
|
631
|
-
isTransient() {
|
|
632
|
-
return this.workspaceConfigurationModelParser.transient;
|
|
633
|
-
}
|
|
634
|
-
getWorkspaceSettings() {
|
|
635
|
-
return this.workspaceSettings;
|
|
636
|
-
}
|
|
637
|
-
reparseWorkspaceSettings(configurationParseOptions) {
|
|
638
|
-
this.workspaceConfigurationModelParser.reparseWorkspaceSettings(configurationParseOptions);
|
|
639
|
-
this.consolidate();
|
|
640
|
-
return this.getWorkspaceSettings();
|
|
641
|
-
}
|
|
642
|
-
getRestrictedSettings() {
|
|
643
|
-
return this.workspaceConfigurationModelParser.getRestrictedWorkspaceSettings();
|
|
644
|
-
}
|
|
645
|
-
consolidate() {
|
|
646
|
-
this.workspaceSettings = this.workspaceConfigurationModelParser.settingsModel.merge(this.workspaceConfigurationModelParser.launchModel, this.workspaceConfigurationModelParser.tasksModel);
|
|
647
|
-
}
|
|
648
|
-
watchWorkspaceConfigurationFile() {
|
|
649
|
-
return this._workspaceIdentifier ? this.fileService.watch(this._workspaceIdentifier.configPath) : Disposable.None;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
class CachedWorkspaceConfiguration {
|
|
653
|
-
constructor(configurationCache) {
|
|
654
|
-
this.configurationCache = configurationCache;
|
|
655
|
-
this.onDidChange = Event.None;
|
|
656
|
-
this.workspaceConfigurationModelParser = ( new WorkspaceConfigurationModelParser(''));
|
|
657
|
-
this.workspaceSettings = ( new ConfigurationModel());
|
|
658
|
-
}
|
|
659
|
-
async load(workspaceIdentifier, configurationParseOptions) {
|
|
660
|
-
try {
|
|
661
|
-
const key = this.getKey(workspaceIdentifier);
|
|
662
|
-
const contents = await this.configurationCache.read(key);
|
|
663
|
-
const parsed = JSON.parse(contents);
|
|
664
|
-
if (parsed.content) {
|
|
665
|
-
this.workspaceConfigurationModelParser = ( new WorkspaceConfigurationModelParser(key.key));
|
|
666
|
-
this.workspaceConfigurationModelParser.parse(parsed.content, configurationParseOptions);
|
|
667
|
-
this.consolidate();
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
catch (e) {
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
get workspaceIdentifier() {
|
|
674
|
-
return null;
|
|
675
|
-
}
|
|
676
|
-
getConfigurationModel() {
|
|
677
|
-
return this.workspaceConfigurationModelParser.configurationModel;
|
|
678
|
-
}
|
|
679
|
-
getFolders() {
|
|
680
|
-
return this.workspaceConfigurationModelParser.folders;
|
|
681
|
-
}
|
|
682
|
-
isTransient() {
|
|
683
|
-
return this.workspaceConfigurationModelParser.transient;
|
|
684
|
-
}
|
|
685
|
-
getWorkspaceSettings() {
|
|
686
|
-
return this.workspaceSettings;
|
|
687
|
-
}
|
|
688
|
-
reparseWorkspaceSettings(configurationParseOptions) {
|
|
689
|
-
this.workspaceConfigurationModelParser.reparseWorkspaceSettings(configurationParseOptions);
|
|
690
|
-
this.consolidate();
|
|
691
|
-
return this.getWorkspaceSettings();
|
|
692
|
-
}
|
|
693
|
-
getRestrictedSettings() {
|
|
694
|
-
return this.workspaceConfigurationModelParser.getRestrictedWorkspaceSettings();
|
|
695
|
-
}
|
|
696
|
-
consolidate() {
|
|
697
|
-
this.workspaceSettings = this.workspaceConfigurationModelParser.settingsModel.merge(this.workspaceConfigurationModelParser.launchModel, this.workspaceConfigurationModelParser.tasksModel);
|
|
698
|
-
}
|
|
699
|
-
async updateWorkspace(workspaceIdentifier, content) {
|
|
700
|
-
try {
|
|
701
|
-
const key = this.getKey(workspaceIdentifier);
|
|
702
|
-
if (content) {
|
|
703
|
-
await this.configurationCache.write(key, JSON.stringify({ content }));
|
|
704
|
-
}
|
|
705
|
-
else {
|
|
706
|
-
await this.configurationCache.remove(key);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
catch (error) {
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
getKey(workspaceIdentifier) {
|
|
713
|
-
return {
|
|
714
|
-
type: 'workspaces',
|
|
715
|
-
key: workspaceIdentifier.id
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
class CachedFolderConfiguration {
|
|
720
|
-
constructor(folder, configFolderRelativePath, configurationParseOptions, configurationCache) {
|
|
721
|
-
this.configurationCache = configurationCache;
|
|
722
|
-
this.onDidChange = Event.None;
|
|
723
|
-
this.key = { type: 'folder', key: ( hash(( joinPath(folder, configFolderRelativePath).toString())).toString(16)) };
|
|
724
|
-
this._folderSettingsModelParser = ( new ConfigurationModelParser('CachedFolderConfiguration'));
|
|
725
|
-
this._folderSettingsParseOptions = configurationParseOptions;
|
|
726
|
-
this._standAloneConfigurations = [];
|
|
727
|
-
this.configurationModel = ( new ConfigurationModel());
|
|
728
|
-
}
|
|
729
|
-
async loadConfiguration() {
|
|
730
|
-
try {
|
|
731
|
-
const contents = await this.configurationCache.read(this.key);
|
|
732
|
-
const { content: configurationContents } = JSON.parse(( contents.toString()));
|
|
733
|
-
if (configurationContents) {
|
|
734
|
-
for (const key of ( Object.keys(configurationContents))) {
|
|
735
|
-
if (key === FOLDER_SETTINGS_NAME) {
|
|
736
|
-
this._folderSettingsModelParser.parse(configurationContents[key], this._folderSettingsParseOptions);
|
|
737
|
-
}
|
|
738
|
-
else {
|
|
739
|
-
const standAloneConfigurationModelParser = ( new StandaloneConfigurationModelParser(key, key));
|
|
740
|
-
standAloneConfigurationModelParser.parse(configurationContents[key]);
|
|
741
|
-
this._standAloneConfigurations.push(standAloneConfigurationModelParser.configurationModel);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
this.consolidate();
|
|
746
|
-
}
|
|
747
|
-
catch (e) {
|
|
748
|
-
}
|
|
749
|
-
return this.configurationModel;
|
|
750
|
-
}
|
|
751
|
-
async updateConfiguration(settingsContent, standAloneConfigurationContents) {
|
|
752
|
-
const content = {};
|
|
753
|
-
if (settingsContent) {
|
|
754
|
-
content[FOLDER_SETTINGS_NAME] = settingsContent;
|
|
755
|
-
}
|
|
756
|
-
standAloneConfigurationContents.forEach(([key, contents]) => {
|
|
757
|
-
if (contents) {
|
|
758
|
-
content[key] = contents;
|
|
759
|
-
}
|
|
760
|
-
});
|
|
761
|
-
if (( Object.keys(content)).length) {
|
|
762
|
-
await this.configurationCache.write(this.key, JSON.stringify({ content }));
|
|
763
|
-
}
|
|
764
|
-
else {
|
|
765
|
-
await this.configurationCache.remove(this.key);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
getRestrictedSettings() {
|
|
769
|
-
return this._folderSettingsModelParser.restrictedConfigurations;
|
|
770
|
-
}
|
|
771
|
-
reparse(configurationParseOptions) {
|
|
772
|
-
this._folderSettingsParseOptions = configurationParseOptions;
|
|
773
|
-
this._folderSettingsModelParser.reparse(this._folderSettingsParseOptions);
|
|
774
|
-
this.consolidate();
|
|
775
|
-
return this.configurationModel;
|
|
776
|
-
}
|
|
777
|
-
consolidate() {
|
|
778
|
-
this.configurationModel = this._folderSettingsModelParser.configurationModel.merge(...this._standAloneConfigurations);
|
|
779
|
-
}
|
|
780
|
-
getUnsupportedKeys() {
|
|
781
|
-
return [];
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
class FolderConfiguration extends Disposable {
|
|
785
|
-
constructor(useCache, workspaceFolder, configFolderRelativePath, workbenchState, workspaceTrusted, fileService, uriIdentityService, logService, configurationCache) {
|
|
786
|
-
super();
|
|
787
|
-
this.workspaceFolder = workspaceFolder;
|
|
788
|
-
this.workbenchState = workbenchState;
|
|
789
|
-
this.workspaceTrusted = workspaceTrusted;
|
|
790
|
-
this.configurationCache = configurationCache;
|
|
791
|
-
this._onDidChange = this._register(( new Emitter()));
|
|
792
|
-
this.onDidChange = this._onDidChange.event;
|
|
793
|
-
this.scopes = 3 === this.workbenchState ? FOLDER_SCOPES : WORKSPACE_SCOPES;
|
|
794
|
-
this.configurationFolder = uriIdentityService.extUri.joinPath(workspaceFolder.uri, configFolderRelativePath);
|
|
795
|
-
this.cachedFolderConfiguration = ( new CachedFolderConfiguration(
|
|
796
|
-
workspaceFolder.uri,
|
|
797
|
-
configFolderRelativePath,
|
|
798
|
-
{ scopes: this.scopes, skipRestricted: this.isUntrusted() },
|
|
799
|
-
configurationCache
|
|
800
|
-
));
|
|
801
|
-
if (useCache && this.configurationCache.needsCaching(workspaceFolder.uri)) {
|
|
802
|
-
this.folderConfiguration = this.cachedFolderConfiguration;
|
|
803
|
-
whenProviderRegistered(workspaceFolder.uri, fileService)
|
|
804
|
-
.then(() => {
|
|
805
|
-
this.folderConfiguration = this._register(this.createFileServiceBasedConfiguration(fileService, uriIdentityService, logService));
|
|
806
|
-
this._register(this.folderConfiguration.onDidChange(e => this.onDidFolderConfigurationChange()));
|
|
807
|
-
this.onDidFolderConfigurationChange();
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
else {
|
|
811
|
-
this.folderConfiguration = this._register(this.createFileServiceBasedConfiguration(fileService, uriIdentityService, logService));
|
|
812
|
-
this._register(this.folderConfiguration.onDidChange(e => this.onDidFolderConfigurationChange()));
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
loadConfiguration() {
|
|
816
|
-
return this.folderConfiguration.loadConfiguration();
|
|
817
|
-
}
|
|
818
|
-
updateWorkspaceTrust(trusted) {
|
|
819
|
-
this.workspaceTrusted = trusted;
|
|
820
|
-
return this.reparse();
|
|
821
|
-
}
|
|
822
|
-
reparse() {
|
|
823
|
-
const configurationModel = this.folderConfiguration.reparse({ scopes: this.scopes, skipRestricted: this.isUntrusted() });
|
|
824
|
-
this.updateCache();
|
|
825
|
-
return configurationModel;
|
|
826
|
-
}
|
|
827
|
-
getRestrictedSettings() {
|
|
828
|
-
return this.folderConfiguration.getRestrictedSettings();
|
|
829
|
-
}
|
|
830
|
-
isUntrusted() {
|
|
831
|
-
return !this.workspaceTrusted;
|
|
832
|
-
}
|
|
833
|
-
onDidFolderConfigurationChange() {
|
|
834
|
-
this.updateCache();
|
|
835
|
-
this._onDidChange.fire();
|
|
836
|
-
}
|
|
837
|
-
createFileServiceBasedConfiguration(fileService, uriIdentityService, logService) {
|
|
838
|
-
const settingsResource = uriIdentityService.extUri.joinPath(this.configurationFolder, `${FOLDER_SETTINGS_NAME}.json`);
|
|
839
|
-
const standAloneConfigurationResources = ( [TASKS_CONFIGURATION_KEY, LAUNCH_CONFIGURATION_KEY].map(
|
|
840
|
-
name => ([name, uriIdentityService.extUri.joinPath(this.configurationFolder, `${name}.json`)])
|
|
841
|
-
));
|
|
842
|
-
return ( new FileServiceBasedConfiguration(( this.configurationFolder.toString()), settingsResource, standAloneConfigurationResources, { scopes: this.scopes, skipRestricted: this.isUntrusted() }, fileService, uriIdentityService, logService));
|
|
843
|
-
}
|
|
844
|
-
async updateCache() {
|
|
845
|
-
if (this.configurationCache.needsCaching(this.configurationFolder) && this.folderConfiguration instanceof FileServiceBasedConfiguration) {
|
|
846
|
-
const [settingsContent, standAloneConfigurationContents] = await this.folderConfiguration.resolveContents();
|
|
847
|
-
this.cachedFolderConfiguration.updateConfiguration(settingsContent, standAloneConfigurationContents);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
export { ApplicationConfiguration, DefaultConfiguration, FolderConfiguration, RemoteUserConfiguration, UserConfiguration, WorkspaceConfiguration };
|