configurationService.ts ×13

Frontier kind: Code frontier

unlabeled · c_7f29d42602fe

5 tests · 17063 LOC · 74 files · introduces 0 tests · 45 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges45 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2923 ranges17063 lines · 74 files · Browse complete extent
All tests (intent)
5 testsBrowse complete intent

Neighbourhood graph

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

Introduced files, introduced tests, and structurally relevant concept specialization

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

Graph controls are ready.

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

Native relationship evidence

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

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

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

Introduced code

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

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

src/vs/platform/configuration/common/configurationService.ts 45 introduced LOC · 13 ranges

Open complete file

124 throw new Error(`Unable to write ${key} because it is configured in system policy.`);
125 }
127 > // Remove the setting, if the value is same as default value
128 > if (equals(value, inspect.defaultValue)) {
129 value = undefined;
130 }
132 if (overrides?.overrideIdentifiers?.length && overrides.overrideIdentifiers.length > 1) {
133 const overrideIdentifiers = overrides.overrideIdentifiers.sort();
137 }
138 }
140 const path = overrides?.overrideIdentifiers?.length ? [keyFromOverrideIdentifiers(overrides.overrideIdentifiers), key] : [key];
141
142 await this.configurationEditing.write(path, value);
143 > await this.reloadConfiguration(); configurationService.ts
144 }
145
201
202 write(path: JSONPath, value: unknown): Promise<void> {
203 > return this.queue.queue(() => this.doWriteConfiguration(path, value)); // queue up writes to prevent race conditions configurationService.ts
204 > }
205
206 private async doWriteConfiguration(path: JSONPath, value: unknown): Promise<void> {
207 > let content: string; configurationService.ts
208 > try {
209 > const fileContent = await this.fileService.readFile(this.settingsResource);
210 content = fileContent.value.toString();
211 > } catch (error) { configurationService.ts
212 > if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
213 > content = '{}';
214 > } else {
215 throw error;
216 }
218 >
219 > const parseErrors: ParseError[] = [];
220 > parse(content, parseErrors, { allowTrailingComma: true, allowEmptyContent: true });
221 > if (parseErrors.length > 0) {
222 throw new Error('Unable to write into the settings file. Please open the file to correct errors/warnings in the file and try again.');
223 }
225 > const edits = this.getEdits(content, path, value);
226 > content = applyEdits(content, edits);
227 >
228 > await this.fileService.writeFile(this.settingsResource, VSBuffer.fromString(content));
229 > }
230
231 private getEdits(content: string, path: JSONPath, value: unknown): Edit[] {
232 > const { tabSize, insertSpaces, eol } = this.formattingOptions; configurationService.ts
233 >
234 > // With empty path the entire file is being replaced, so we just use JSON.stringify
235 > if (!path.length) {
236 const content = JSON.stringify(value, null, insertSpaces ? ' '.repeat(tabSize) : '\t');
237 return [{
241 }];
242 }
244 > return setProperty(content, path, value, { tabSize, insertSpaces, eol });
245 > }
246
247 private _formattingOptions: Required<FormattingOptions> | undefined;
248 private get formattingOptions(): Required<FormattingOptions> {
249 > if (!this._formattingOptions) { configurationService.ts
250 > let eol = OS === OperatingSystem.Linux || OS === OperatingSystem.Macintosh ? '\n' : '\r\n';
251 > const configuredEol = this.configurationService.getValue('files.eol', { overrideIdentifier: 'jsonc' });
252 > if (configuredEol && typeof configuredEol === 'string' && configuredEol !== 'auto') {
253 eol = configuredEol;
254 }
255 > this._formattingOptions = { configurationService.ts
256 > eol,
257 > insertSpaces: !!this.configurationService.getValue('editor.insertSpaces', { overrideIdentifier: 'jsonc' }),
258 > tabSize: this.configurationService.getValue('editor.tabSize', { overrideIdentifier: 'jsonc' })
259 > };
260 > }
261 > return this._formattingOptions;
262 > }
263 }