@codingame/monaco-vscode-configuration-service-override 4.1.0 → 4.1.2
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/override/vs/platform/dialogs/common/dialogs.js +10 -0
- package/package.json +9 -9
- package/vscode/src/vs/editor/common/services/textResourceConfigurationService.js +118 -0
- package/vscode/src/vs/workbench/api/common/configurationExtensionPoint.js +595 -0
- package/vscode/src/vs/workbench/contrib/workspaces/browser/workspaces.contribution.js +134 -0
- package/vscode/src/vs/workbench/services/configuration/browser/configuration.js +852 -0
- package/vscode/src/vs/workbench/services/configuration/browser/configurationService.js +1201 -0
- package/vscode/src/vs/workbench/services/configuration/common/configurationEditing.js +668 -0
- package/vscode/src/vs/workbench/services/configuration/common/configurationModels.js +121 -0
- package/vscode/src/vs/workbench/services/label/common/labelService.js +437 -0
- package/vscode/src/vs/workbench/services/textresourceProperties/common/textResourcePropertiesService.js +46 -0
- package/vscode/src/vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService.js +337 -0
- package/vscode/src/vs/workbench/services/workspaces/browser/workspacesService.js +153 -0
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
+
import { parse } from 'vscode/vscode/vs/base/common/json';
|
|
4
|
+
import { setProperty } from 'vscode/vscode/vs/base/common/jsonEdit';
|
|
5
|
+
import { Queue } from 'vscode/vscode/vs/base/common/async';
|
|
6
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
7
|
+
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
8
|
+
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
9
|
+
import { TASKS_CONFIGURATION_KEY, LAUNCH_CONFIGURATION_KEY, TASKS_DEFAULT, FOLDER_SCOPES, FOLDER_SETTINGS_PATH, IWorkbenchConfigurationService, USER_STANDALONE_CONFIGURATIONS, WORKSPACE_STANDALONE_CONFIGURATIONS } from 'vscode/vscode/vs/workbench/services/configuration/common/configuration';
|
|
10
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
|
|
11
|
+
import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
|
|
12
|
+
import { Extensions, OVERRIDE_PROPERTY_REGEX, keyFromOverrideIdentifiers } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
13
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
14
|
+
import { Severity, INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
15
|
+
import { IPreferencesService } from 'vscode/vscode/vs/workbench/services/preferences/common/preferences';
|
|
16
|
+
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
|
|
17
|
+
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
18
|
+
import { EditOperation } from 'vscode/vscode/vs/editor/common/core/editOperation';
|
|
19
|
+
import { Selection } from 'vscode/vscode/vs/editor/common/core/selection';
|
|
20
|
+
import { IUserDataProfileService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile';
|
|
21
|
+
import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile';
|
|
22
|
+
import { ErrorNoTelemetry } from 'vscode/vscode/vs/base/common/errors';
|
|
23
|
+
|
|
24
|
+
class ConfigurationEditingError extends ErrorNoTelemetry {
|
|
25
|
+
constructor(message, code) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.code = code;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
let ConfigurationEditing = class ConfigurationEditing {
|
|
31
|
+
constructor(remoteSettingsResource, configurationService, contextService, userDataProfileService, userDataProfilesService, fileService, textModelResolverService, textFileService, notificationService, preferencesService, editorService, uriIdentityService) {
|
|
32
|
+
this.remoteSettingsResource = remoteSettingsResource;
|
|
33
|
+
this.configurationService = configurationService;
|
|
34
|
+
this.contextService = contextService;
|
|
35
|
+
this.userDataProfileService = userDataProfileService;
|
|
36
|
+
this.userDataProfilesService = userDataProfilesService;
|
|
37
|
+
this.fileService = fileService;
|
|
38
|
+
this.textModelResolverService = textModelResolverService;
|
|
39
|
+
this.textFileService = textFileService;
|
|
40
|
+
this.notificationService = notificationService;
|
|
41
|
+
this.preferencesService = preferencesService;
|
|
42
|
+
this.editorService = editorService;
|
|
43
|
+
this.uriIdentityService = uriIdentityService;
|
|
44
|
+
this.queue = ( new Queue());
|
|
45
|
+
}
|
|
46
|
+
async writeConfiguration(target, value, options = {}) {
|
|
47
|
+
const operation = this.getConfigurationEditOperation(target, value, options.scopes || {});
|
|
48
|
+
return this.queue.queue(async () => {
|
|
49
|
+
try {
|
|
50
|
+
await this.doWriteConfiguration(operation, options);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (options.donotNotifyError) {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
await this.onError(error, operation, options.scopes);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async doWriteConfiguration(operation, options) {
|
|
61
|
+
await this.validate(operation.target, operation, !options.handleDirtyFile, options.scopes || {});
|
|
62
|
+
const resource = operation.resource;
|
|
63
|
+
const reference = await this.resolveModelReference(resource);
|
|
64
|
+
try {
|
|
65
|
+
const formattingOptions = this.getFormattingOptions(reference.object.textEditorModel);
|
|
66
|
+
await this.updateConfiguration(operation, reference.object.textEditorModel, formattingOptions, options);
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
reference.dispose();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async updateConfiguration(operation, model, formattingOptions, options) {
|
|
73
|
+
if (this.hasParseErrors(model.getValue(), operation)) {
|
|
74
|
+
throw this.toConfigurationEditingError(11 , operation.target, operation);
|
|
75
|
+
}
|
|
76
|
+
if (this.textFileService.isDirty(model.uri) && options.handleDirtyFile) {
|
|
77
|
+
switch (options.handleDirtyFile) {
|
|
78
|
+
case 'save':
|
|
79
|
+
await this.save(model, operation);
|
|
80
|
+
break;
|
|
81
|
+
case 'revert':
|
|
82
|
+
await this.textFileService.revert(model.uri);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const edit = this.getEdits(operation, model.getValue(), formattingOptions)[0];
|
|
87
|
+
if (edit && this.applyEditsToBuffer(edit, model)) {
|
|
88
|
+
await this.save(model, operation);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async save(model, operation) {
|
|
92
|
+
try {
|
|
93
|
+
await this.textFileService.save(model.uri, { ignoreErrorHandler: true });
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (error.fileOperationResult === 3 ) {
|
|
97
|
+
throw this.toConfigurationEditingError(10 , operation.target, operation);
|
|
98
|
+
}
|
|
99
|
+
throw new ConfigurationEditingError(localizeWithPath('vs/workbench/services/configuration/common/configurationEditing', 'fsError', "Error while writing to {0}. {1}", this.stringifyTarget(operation.target), error.message), 13 );
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
applyEditsToBuffer(edit, model) {
|
|
103
|
+
const startPosition = model.getPositionAt(edit.offset);
|
|
104
|
+
const endPosition = model.getPositionAt(edit.offset + edit.length);
|
|
105
|
+
const range = ( new Range(
|
|
106
|
+
startPosition.lineNumber,
|
|
107
|
+
startPosition.column,
|
|
108
|
+
endPosition.lineNumber,
|
|
109
|
+
endPosition.column
|
|
110
|
+
));
|
|
111
|
+
const currentText = model.getValueInRange(range);
|
|
112
|
+
if (edit.content !== currentText) {
|
|
113
|
+
const editOperation = currentText ? EditOperation.replace(range, edit.content) : EditOperation.insert(startPosition, edit.content);
|
|
114
|
+
model.pushEditOperations([( new Selection(
|
|
115
|
+
startPosition.lineNumber,
|
|
116
|
+
startPosition.column,
|
|
117
|
+
startPosition.lineNumber,
|
|
118
|
+
startPosition.column
|
|
119
|
+
))], [editOperation], () => []);
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
getEdits({ value, jsonPath }, modelContent, formattingOptions) {
|
|
125
|
+
if (jsonPath.length) {
|
|
126
|
+
return setProperty(modelContent, jsonPath, value, formattingOptions);
|
|
127
|
+
}
|
|
128
|
+
const content = JSON.stringify(value, null, formattingOptions.insertSpaces && formattingOptions.tabSize ? ' '.repeat(formattingOptions.tabSize) : '\t');
|
|
129
|
+
return [{
|
|
130
|
+
content,
|
|
131
|
+
length: modelContent.length,
|
|
132
|
+
offset: 0
|
|
133
|
+
}];
|
|
134
|
+
}
|
|
135
|
+
getFormattingOptions(model) {
|
|
136
|
+
const { insertSpaces, tabSize } = model.getOptions();
|
|
137
|
+
const eol = model.getEOL();
|
|
138
|
+
return { insertSpaces, tabSize, eol };
|
|
139
|
+
}
|
|
140
|
+
async onError(error, operation, scopes) {
|
|
141
|
+
switch (error.code) {
|
|
142
|
+
case 11 :
|
|
143
|
+
this.onInvalidConfigurationError(error, operation);
|
|
144
|
+
break;
|
|
145
|
+
case 9 :
|
|
146
|
+
this.onConfigurationFileDirtyError(error, operation, scopes);
|
|
147
|
+
break;
|
|
148
|
+
case 10 :
|
|
149
|
+
return this.doWriteConfiguration(operation, { scopes, handleDirtyFile: 'revert' });
|
|
150
|
+
default:
|
|
151
|
+
this.notificationService.error(error.message);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
onInvalidConfigurationError(error, operation) {
|
|
155
|
+
const openStandAloneConfigurationActionLabel = operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY ? ( localizeWithPath(
|
|
156
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
157
|
+
'openTasksConfiguration',
|
|
158
|
+
"Open Tasks Configuration"
|
|
159
|
+
))
|
|
160
|
+
: operation.workspaceStandAloneConfigurationKey === LAUNCH_CONFIGURATION_KEY ? ( localizeWithPath(
|
|
161
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
162
|
+
'openLaunchConfiguration',
|
|
163
|
+
"Open Launch Configuration"
|
|
164
|
+
))
|
|
165
|
+
: null;
|
|
166
|
+
if (openStandAloneConfigurationActionLabel) {
|
|
167
|
+
this.notificationService.prompt(Severity.Error, error.message, [{
|
|
168
|
+
label: openStandAloneConfigurationActionLabel,
|
|
169
|
+
run: () => this.openFile(operation.resource)
|
|
170
|
+
}]);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
this.notificationService.prompt(Severity.Error, error.message, [{
|
|
174
|
+
label: ( localizeWithPath(
|
|
175
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
176
|
+
'open',
|
|
177
|
+
"Open Settings"
|
|
178
|
+
)),
|
|
179
|
+
run: () => this.openSettings(operation)
|
|
180
|
+
}]);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
onConfigurationFileDirtyError(error, operation, scopes) {
|
|
184
|
+
const openStandAloneConfigurationActionLabel = operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY ? ( localizeWithPath(
|
|
185
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
186
|
+
'openTasksConfiguration',
|
|
187
|
+
"Open Tasks Configuration"
|
|
188
|
+
))
|
|
189
|
+
: operation.workspaceStandAloneConfigurationKey === LAUNCH_CONFIGURATION_KEY ? ( localizeWithPath(
|
|
190
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
191
|
+
'openLaunchConfiguration',
|
|
192
|
+
"Open Launch Configuration"
|
|
193
|
+
))
|
|
194
|
+
: null;
|
|
195
|
+
if (openStandAloneConfigurationActionLabel) {
|
|
196
|
+
this.notificationService.prompt(Severity.Error, error.message, [{
|
|
197
|
+
label: ( localizeWithPath(
|
|
198
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
199
|
+
'saveAndRetry',
|
|
200
|
+
"Save and Retry"
|
|
201
|
+
)),
|
|
202
|
+
run: () => {
|
|
203
|
+
const key = operation.key ? `${operation.workspaceStandAloneConfigurationKey}.${operation.key}` : operation.workspaceStandAloneConfigurationKey;
|
|
204
|
+
this.writeConfiguration(operation.target, { key, value: operation.value }, { handleDirtyFile: 'save', scopes });
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
label: openStandAloneConfigurationActionLabel,
|
|
209
|
+
run: () => this.openFile(operation.resource)
|
|
210
|
+
}]);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
this.notificationService.prompt(Severity.Error, error.message, [{
|
|
214
|
+
label: ( localizeWithPath(
|
|
215
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
216
|
+
'saveAndRetry',
|
|
217
|
+
"Save and Retry"
|
|
218
|
+
)),
|
|
219
|
+
run: () => this.writeConfiguration(operation.target, { key: operation.key, value: operation.value }, { handleDirtyFile: 'save', scopes })
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
label: ( localizeWithPath(
|
|
223
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
224
|
+
'open',
|
|
225
|
+
"Open Settings"
|
|
226
|
+
)),
|
|
227
|
+
run: () => this.openSettings(operation)
|
|
228
|
+
}]);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
openSettings(operation) {
|
|
232
|
+
const options = { jsonEditor: true };
|
|
233
|
+
switch (operation.target) {
|
|
234
|
+
case 1 :
|
|
235
|
+
this.preferencesService.openUserSettings(options);
|
|
236
|
+
break;
|
|
237
|
+
case 2 :
|
|
238
|
+
this.preferencesService.openRemoteSettings(options);
|
|
239
|
+
break;
|
|
240
|
+
case 3 :
|
|
241
|
+
this.preferencesService.openWorkspaceSettings(options);
|
|
242
|
+
break;
|
|
243
|
+
case 4 :
|
|
244
|
+
if (operation.resource) {
|
|
245
|
+
const workspaceFolder = this.contextService.getWorkspaceFolder(operation.resource);
|
|
246
|
+
if (workspaceFolder) {
|
|
247
|
+
this.preferencesService.openFolderSettings({ folderUri: workspaceFolder.uri, jsonEditor: true });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
openFile(resource) {
|
|
254
|
+
this.editorService.openEditor({ resource, options: { pinned: true } });
|
|
255
|
+
}
|
|
256
|
+
toConfigurationEditingError(code, target, operation) {
|
|
257
|
+
const message = this.toErrorMessage(code, target, operation);
|
|
258
|
+
return ( new ConfigurationEditingError(message, code));
|
|
259
|
+
}
|
|
260
|
+
toErrorMessage(error, target, operation) {
|
|
261
|
+
switch (error) {
|
|
262
|
+
case 12 : return ( localizeWithPath(
|
|
263
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
264
|
+
'errorPolicyConfiguration',
|
|
265
|
+
"Unable to write {0} because it is configured in system policy.",
|
|
266
|
+
operation.key
|
|
267
|
+
));
|
|
268
|
+
case 0 : return ( localizeWithPath(
|
|
269
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
270
|
+
'errorUnknownKey',
|
|
271
|
+
"Unable to write to {0} because {1} is not a registered configuration.",
|
|
272
|
+
this.stringifyTarget(target),
|
|
273
|
+
operation.key
|
|
274
|
+
));
|
|
275
|
+
case 1 : return ( localizeWithPath(
|
|
276
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
277
|
+
'errorInvalidWorkspaceConfigurationApplication',
|
|
278
|
+
"Unable to write {0} to Workspace Settings. This setting can be written only into User settings.",
|
|
279
|
+
operation.key
|
|
280
|
+
));
|
|
281
|
+
case 2 : return ( localizeWithPath(
|
|
282
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
283
|
+
'errorInvalidWorkspaceConfigurationMachine',
|
|
284
|
+
"Unable to write {0} to Workspace Settings. This setting can be written only into User settings.",
|
|
285
|
+
operation.key
|
|
286
|
+
));
|
|
287
|
+
case 3 : return ( localizeWithPath(
|
|
288
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
289
|
+
'errorInvalidFolderConfiguration',
|
|
290
|
+
"Unable to write to Folder Settings because {0} does not support the folder resource scope.",
|
|
291
|
+
operation.key
|
|
292
|
+
));
|
|
293
|
+
case 4 : return ( localizeWithPath(
|
|
294
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
295
|
+
'errorInvalidUserTarget',
|
|
296
|
+
"Unable to write to User Settings because {0} does not support for global scope.",
|
|
297
|
+
operation.key
|
|
298
|
+
));
|
|
299
|
+
case 5 : return ( localizeWithPath(
|
|
300
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
301
|
+
'errorInvalidWorkspaceTarget',
|
|
302
|
+
"Unable to write to Workspace Settings because {0} does not support for workspace scope in a multi folder workspace.",
|
|
303
|
+
operation.key
|
|
304
|
+
));
|
|
305
|
+
case 6 : return ( localizeWithPath(
|
|
306
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
307
|
+
'errorInvalidFolderTarget',
|
|
308
|
+
"Unable to write to Folder Settings because no resource is provided."
|
|
309
|
+
));
|
|
310
|
+
case 7 : return ( localizeWithPath(
|
|
311
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
312
|
+
'errorInvalidResourceLanguageConfiguration',
|
|
313
|
+
"Unable to write to Language Settings because {0} is not a resource language setting.",
|
|
314
|
+
operation.key
|
|
315
|
+
));
|
|
316
|
+
case 8 : return ( localizeWithPath(
|
|
317
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
318
|
+
'errorNoWorkspaceOpened',
|
|
319
|
+
"Unable to write to {0} because no workspace is opened. Please open a workspace first and try again.",
|
|
320
|
+
this.stringifyTarget(target)
|
|
321
|
+
));
|
|
322
|
+
case 11 : {
|
|
323
|
+
if (operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY) {
|
|
324
|
+
return ( localizeWithPath(
|
|
325
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
326
|
+
'errorInvalidTaskConfiguration',
|
|
327
|
+
"Unable to write into the tasks configuration file. Please open it to correct errors/warnings in it and try again."
|
|
328
|
+
));
|
|
329
|
+
}
|
|
330
|
+
if (operation.workspaceStandAloneConfigurationKey === LAUNCH_CONFIGURATION_KEY) {
|
|
331
|
+
return ( localizeWithPath(
|
|
332
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
333
|
+
'errorInvalidLaunchConfiguration',
|
|
334
|
+
"Unable to write into the launch configuration file. Please open it to correct errors/warnings in it and try again."
|
|
335
|
+
));
|
|
336
|
+
}
|
|
337
|
+
switch (target) {
|
|
338
|
+
case 1 :
|
|
339
|
+
return ( localizeWithPath(
|
|
340
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
341
|
+
'errorInvalidConfiguration',
|
|
342
|
+
"Unable to write into user settings. Please open the user settings to correct errors/warnings in it and try again."
|
|
343
|
+
));
|
|
344
|
+
case 2 :
|
|
345
|
+
return ( localizeWithPath(
|
|
346
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
347
|
+
'errorInvalidRemoteConfiguration',
|
|
348
|
+
"Unable to write into remote user settings. Please open the remote user settings to correct errors/warnings in it and try again."
|
|
349
|
+
));
|
|
350
|
+
case 3 :
|
|
351
|
+
return ( localizeWithPath(
|
|
352
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
353
|
+
'errorInvalidConfigurationWorkspace',
|
|
354
|
+
"Unable to write into workspace settings. Please open the workspace settings to correct errors/warnings in the file and try again."
|
|
355
|
+
));
|
|
356
|
+
case 4 : {
|
|
357
|
+
let workspaceFolderName = '<<unknown>>';
|
|
358
|
+
if (operation.resource) {
|
|
359
|
+
const folder = this.contextService.getWorkspaceFolder(operation.resource);
|
|
360
|
+
if (folder) {
|
|
361
|
+
workspaceFolderName = folder.name;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return ( localizeWithPath(
|
|
365
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
366
|
+
'errorInvalidConfigurationFolder',
|
|
367
|
+
"Unable to write into folder settings. Please open the '{0}' folder settings to correct errors/warnings in it and try again.",
|
|
368
|
+
workspaceFolderName
|
|
369
|
+
));
|
|
370
|
+
}
|
|
371
|
+
default:
|
|
372
|
+
return '';
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
case 9 : {
|
|
376
|
+
if (operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY) {
|
|
377
|
+
return ( localizeWithPath(
|
|
378
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
379
|
+
'errorTasksConfigurationFileDirty',
|
|
380
|
+
"Unable to write into tasks configuration file because the file has unsaved changes. Please save it first and then try again."
|
|
381
|
+
));
|
|
382
|
+
}
|
|
383
|
+
if (operation.workspaceStandAloneConfigurationKey === LAUNCH_CONFIGURATION_KEY) {
|
|
384
|
+
return ( localizeWithPath(
|
|
385
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
386
|
+
'errorLaunchConfigurationFileDirty',
|
|
387
|
+
"Unable to write into launch configuration file because the file has unsaved changes. Please save it first and then try again."
|
|
388
|
+
));
|
|
389
|
+
}
|
|
390
|
+
switch (target) {
|
|
391
|
+
case 1 :
|
|
392
|
+
return ( localizeWithPath(
|
|
393
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
394
|
+
'errorConfigurationFileDirty',
|
|
395
|
+
"Unable to write into user settings because the file has unsaved changes. Please save the user settings file first and then try again."
|
|
396
|
+
));
|
|
397
|
+
case 2 :
|
|
398
|
+
return ( localizeWithPath(
|
|
399
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
400
|
+
'errorRemoteConfigurationFileDirty',
|
|
401
|
+
"Unable to write into remote user settings because the file has unsaved changes. Please save the remote user settings file first and then try again."
|
|
402
|
+
));
|
|
403
|
+
case 3 :
|
|
404
|
+
return ( localizeWithPath(
|
|
405
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
406
|
+
'errorConfigurationFileDirtyWorkspace',
|
|
407
|
+
"Unable to write into workspace settings because the file has unsaved changes. Please save the workspace settings file first and then try again."
|
|
408
|
+
));
|
|
409
|
+
case 4 : {
|
|
410
|
+
let workspaceFolderName = '<<unknown>>';
|
|
411
|
+
if (operation.resource) {
|
|
412
|
+
const folder = this.contextService.getWorkspaceFolder(operation.resource);
|
|
413
|
+
if (folder) {
|
|
414
|
+
workspaceFolderName = folder.name;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return ( localizeWithPath(
|
|
418
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
419
|
+
'errorConfigurationFileDirtyFolder',
|
|
420
|
+
"Unable to write into folder settings because the file has unsaved changes. Please save the '{0}' folder settings file first and then try again.",
|
|
421
|
+
workspaceFolderName
|
|
422
|
+
));
|
|
423
|
+
}
|
|
424
|
+
default:
|
|
425
|
+
return '';
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
case 10 :
|
|
429
|
+
if (operation.workspaceStandAloneConfigurationKey === TASKS_CONFIGURATION_KEY) {
|
|
430
|
+
return ( localizeWithPath(
|
|
431
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
432
|
+
'errorTasksConfigurationFileModifiedSince',
|
|
433
|
+
"Unable to write into tasks configuration file because the content of the file is newer."
|
|
434
|
+
));
|
|
435
|
+
}
|
|
436
|
+
if (operation.workspaceStandAloneConfigurationKey === LAUNCH_CONFIGURATION_KEY) {
|
|
437
|
+
return ( localizeWithPath(
|
|
438
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
439
|
+
'errorLaunchConfigurationFileModifiedSince',
|
|
440
|
+
"Unable to write into launch configuration file because the content of the file is newer."
|
|
441
|
+
));
|
|
442
|
+
}
|
|
443
|
+
switch (target) {
|
|
444
|
+
case 1 :
|
|
445
|
+
return ( localizeWithPath(
|
|
446
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
447
|
+
'errorConfigurationFileModifiedSince',
|
|
448
|
+
"Unable to write into user settings because the content of the file is newer."
|
|
449
|
+
));
|
|
450
|
+
case 2 :
|
|
451
|
+
return ( localizeWithPath(
|
|
452
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
453
|
+
'errorRemoteConfigurationFileModifiedSince',
|
|
454
|
+
"Unable to write into remote user settings because the content of the file is newer."
|
|
455
|
+
));
|
|
456
|
+
case 3 :
|
|
457
|
+
return ( localizeWithPath(
|
|
458
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
459
|
+
'errorConfigurationFileModifiedSinceWorkspace',
|
|
460
|
+
"Unable to write into workspace settings because the content of the file is newer."
|
|
461
|
+
));
|
|
462
|
+
case 4 :
|
|
463
|
+
return ( localizeWithPath(
|
|
464
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
465
|
+
'errorConfigurationFileModifiedSinceFolder',
|
|
466
|
+
"Unable to write into folder settings because the content of the file is newer."
|
|
467
|
+
));
|
|
468
|
+
}
|
|
469
|
+
case 13 : return ( localizeWithPath(
|
|
470
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
471
|
+
'errorUnknown',
|
|
472
|
+
"Unable to write to {0} because of an internal error.",
|
|
473
|
+
this.stringifyTarget(target)
|
|
474
|
+
));
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
stringifyTarget(target) {
|
|
478
|
+
switch (target) {
|
|
479
|
+
case 1 :
|
|
480
|
+
return ( localizeWithPath(
|
|
481
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
482
|
+
'userTarget',
|
|
483
|
+
"User Settings"
|
|
484
|
+
));
|
|
485
|
+
case 2 :
|
|
486
|
+
return ( localizeWithPath(
|
|
487
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
488
|
+
'remoteUserTarget',
|
|
489
|
+
"Remote User Settings"
|
|
490
|
+
));
|
|
491
|
+
case 3 :
|
|
492
|
+
return ( localizeWithPath(
|
|
493
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
494
|
+
'workspaceTarget',
|
|
495
|
+
"Workspace Settings"
|
|
496
|
+
));
|
|
497
|
+
case 4 :
|
|
498
|
+
return ( localizeWithPath(
|
|
499
|
+
'vs/workbench/services/configuration/common/configurationEditing',
|
|
500
|
+
'folderTarget',
|
|
501
|
+
"Folder Settings"
|
|
502
|
+
));
|
|
503
|
+
default:
|
|
504
|
+
return '';
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
defaultResourceValue(resource) {
|
|
508
|
+
const basename = this.uriIdentityService.extUri.basename(resource);
|
|
509
|
+
const configurationValue = basename.substr(0, basename.length - this.uriIdentityService.extUri.extname(resource).length);
|
|
510
|
+
switch (configurationValue) {
|
|
511
|
+
case TASKS_CONFIGURATION_KEY: return TASKS_DEFAULT;
|
|
512
|
+
default: return '{}';
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
async resolveModelReference(resource) {
|
|
516
|
+
const exists = await this.fileService.exists(resource);
|
|
517
|
+
if (!exists) {
|
|
518
|
+
await this.textFileService.write(resource, this.defaultResourceValue(resource), { encoding: 'utf8' });
|
|
519
|
+
}
|
|
520
|
+
return this.textModelResolverService.createModelReference(resource);
|
|
521
|
+
}
|
|
522
|
+
hasParseErrors(content, operation) {
|
|
523
|
+
if (operation.workspaceStandAloneConfigurationKey && !operation.key) {
|
|
524
|
+
return false;
|
|
525
|
+
}
|
|
526
|
+
const parseErrors = [];
|
|
527
|
+
parse(content, parseErrors, { allowTrailingComma: true, allowEmptyContent: true });
|
|
528
|
+
return parseErrors.length > 0;
|
|
529
|
+
}
|
|
530
|
+
async validate(target, operation, checkDirty, overrides) {
|
|
531
|
+
if (this.configurationService.inspect(operation.key).policyValue !== undefined) {
|
|
532
|
+
throw this.toConfigurationEditingError(12 , target, operation);
|
|
533
|
+
}
|
|
534
|
+
const configurationProperties = ( Registry.as(Extensions.Configuration)).getConfigurationProperties();
|
|
535
|
+
const configurationScope = configurationProperties[operation.key]?.scope;
|
|
536
|
+
if (!operation.workspaceStandAloneConfigurationKey) {
|
|
537
|
+
const validKeys = ( this.configurationService.keys()).default;
|
|
538
|
+
if (validKeys.indexOf(operation.key) < 0 && !OVERRIDE_PROPERTY_REGEX.test(operation.key) && operation.value !== undefined) {
|
|
539
|
+
throw this.toConfigurationEditingError(0 , target, operation);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (operation.workspaceStandAloneConfigurationKey) {
|
|
543
|
+
if ((operation.workspaceStandAloneConfigurationKey !== TASKS_CONFIGURATION_KEY) && ((target === 1 || target === 2) )) {
|
|
544
|
+
throw this.toConfigurationEditingError(4 , target, operation);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (((target === 3 || target === 4) ) && this.contextService.getWorkbenchState() === 1 ) {
|
|
548
|
+
throw this.toConfigurationEditingError(8 , target, operation);
|
|
549
|
+
}
|
|
550
|
+
if (target === 3 ) {
|
|
551
|
+
if (!operation.workspaceStandAloneConfigurationKey && !OVERRIDE_PROPERTY_REGEX.test(operation.key)) {
|
|
552
|
+
if (configurationScope === 1 ) {
|
|
553
|
+
throw this.toConfigurationEditingError(1 , target, operation);
|
|
554
|
+
}
|
|
555
|
+
if (configurationScope === 2 ) {
|
|
556
|
+
throw this.toConfigurationEditingError(2 , target, operation);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (target === 4 ) {
|
|
561
|
+
if (!operation.resource) {
|
|
562
|
+
throw this.toConfigurationEditingError(6 , target, operation);
|
|
563
|
+
}
|
|
564
|
+
if (!operation.workspaceStandAloneConfigurationKey && !OVERRIDE_PROPERTY_REGEX.test(operation.key)) {
|
|
565
|
+
if (configurationScope !== undefined && !FOLDER_SCOPES.includes(configurationScope)) {
|
|
566
|
+
throw this.toConfigurationEditingError(3 , target, operation);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
if (overrides.overrideIdentifiers?.length) {
|
|
571
|
+
if (configurationScope !== 5 ) {
|
|
572
|
+
throw this.toConfigurationEditingError(7 , target, operation);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
if (!operation.resource) {
|
|
576
|
+
throw this.toConfigurationEditingError(6 , target, operation);
|
|
577
|
+
}
|
|
578
|
+
if (checkDirty && this.textFileService.isDirty(operation.resource)) {
|
|
579
|
+
throw this.toConfigurationEditingError(9 , target, operation);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
getConfigurationEditOperation(target, config, overrides) {
|
|
583
|
+
if (config.key) {
|
|
584
|
+
const standaloneConfigurationMap = target === 1 ? USER_STANDALONE_CONFIGURATIONS : WORKSPACE_STANDALONE_CONFIGURATIONS;
|
|
585
|
+
const standaloneConfigurationKeys = ( Object.keys(standaloneConfigurationMap));
|
|
586
|
+
for (const key of standaloneConfigurationKeys) {
|
|
587
|
+
const resource = this.getConfigurationFileResource(target, key, standaloneConfigurationMap[key], overrides.resource, undefined);
|
|
588
|
+
if (config.key === key) {
|
|
589
|
+
const jsonPath = this.isWorkspaceConfigurationResource(resource) ? [key] : [];
|
|
590
|
+
return { key: jsonPath[jsonPath.length - 1], jsonPath, value: config.value, resource: resource ?? undefined, workspaceStandAloneConfigurationKey: key, target };
|
|
591
|
+
}
|
|
592
|
+
const keyPrefix = `${key}.`;
|
|
593
|
+
if (config.key.indexOf(keyPrefix) === 0) {
|
|
594
|
+
const jsonPath = this.isWorkspaceConfigurationResource(resource) ? [key, config.key.substr(keyPrefix.length)] : [config.key.substr(keyPrefix.length)];
|
|
595
|
+
return { key: jsonPath[jsonPath.length - 1], jsonPath, value: config.value, resource: resource ?? undefined, workspaceStandAloneConfigurationKey: key, target };
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
const key = config.key;
|
|
600
|
+
const configurationProperties = ( Registry.as(Extensions.Configuration)).getConfigurationProperties();
|
|
601
|
+
const configurationScope = configurationProperties[key]?.scope;
|
|
602
|
+
let jsonPath = overrides.overrideIdentifiers?.length ? [keyFromOverrideIdentifiers(overrides.overrideIdentifiers), key] : [key];
|
|
603
|
+
if (target === 1 || target === 2 ) {
|
|
604
|
+
return { key, jsonPath, value: config.value, resource: this.getConfigurationFileResource(target, key, '', null, configurationScope) ?? undefined, target };
|
|
605
|
+
}
|
|
606
|
+
const resource = this.getConfigurationFileResource(target, key, FOLDER_SETTINGS_PATH, overrides.resource, configurationScope);
|
|
607
|
+
if (this.isWorkspaceConfigurationResource(resource)) {
|
|
608
|
+
jsonPath = ['settings', ...jsonPath];
|
|
609
|
+
}
|
|
610
|
+
return { key, jsonPath, value: config.value, resource: resource ?? undefined, target };
|
|
611
|
+
}
|
|
612
|
+
isWorkspaceConfigurationResource(resource) {
|
|
613
|
+
const workspace = this.contextService.getWorkspace();
|
|
614
|
+
return !!(workspace.configuration && resource && workspace.configuration.fsPath === resource.fsPath);
|
|
615
|
+
}
|
|
616
|
+
getConfigurationFileResource(target, key, relativePath, resource, scope) {
|
|
617
|
+
if (target === 1 ) {
|
|
618
|
+
if (key === TASKS_CONFIGURATION_KEY) {
|
|
619
|
+
return this.userDataProfileService.currentProfile.tasksResource;
|
|
620
|
+
}
|
|
621
|
+
else {
|
|
622
|
+
if (!this.userDataProfileService.currentProfile.isDefault && this.configurationService.isSettingAppliedForAllProfiles(key)) {
|
|
623
|
+
return this.userDataProfilesService.defaultProfile.settingsResource;
|
|
624
|
+
}
|
|
625
|
+
return this.userDataProfileService.currentProfile.settingsResource;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (target === 2 ) {
|
|
629
|
+
return this.remoteSettingsResource;
|
|
630
|
+
}
|
|
631
|
+
const workbenchState = this.contextService.getWorkbenchState();
|
|
632
|
+
if (workbenchState !== 1 ) {
|
|
633
|
+
const workspace = this.contextService.getWorkspace();
|
|
634
|
+
if (target === 3 ) {
|
|
635
|
+
if (workbenchState === 3 ) {
|
|
636
|
+
return workspace.configuration ?? null;
|
|
637
|
+
}
|
|
638
|
+
if (workbenchState === 2 ) {
|
|
639
|
+
return workspace.folders[0].toResource(relativePath);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
if (target === 4 ) {
|
|
643
|
+
if (resource) {
|
|
644
|
+
const folder = this.contextService.getWorkspaceFolder(resource);
|
|
645
|
+
if (folder) {
|
|
646
|
+
return folder.toResource(relativePath);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return null;
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
ConfigurationEditing = ( __decorate([
|
|
655
|
+
( __param(1, IWorkbenchConfigurationService)),
|
|
656
|
+
( __param(2, IWorkspaceContextService)),
|
|
657
|
+
( __param(3, IUserDataProfileService)),
|
|
658
|
+
( __param(4, IUserDataProfilesService)),
|
|
659
|
+
( __param(5, IFileService)),
|
|
660
|
+
( __param(6, ITextModelService)),
|
|
661
|
+
( __param(7, ITextFileService)),
|
|
662
|
+
( __param(8, INotificationService)),
|
|
663
|
+
( __param(9, IPreferencesService)),
|
|
664
|
+
( __param(10, IEditorService)),
|
|
665
|
+
( __param(11, IUriIdentityService))
|
|
666
|
+
], ConfigurationEditing));
|
|
667
|
+
|
|
668
|
+
export { ConfigurationEditing, ConfigurationEditingError };
|