textResourceConfigurationService.ts ×8

Frontier kind: Joint frontier

unlabeled · c_a27618e10825

22 tests · 9340 LOC · 49 files · introduces 5 tests · 56 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges56 lines · 1 files
Tests
5 tests

Contains — complete concept membership

All code (extent)
1367 ranges9340 lines · 49 files · Browse complete extent
All tests (intent)
22 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.

5 tests introduced at this concept.

Introduced code

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

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

src/vs/editor/common/services/textResourceConfigurationService.ts 56 introduced LOC · 8 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- textResourceConfigurationService.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 { Emitter, Event } from '../../../base/common/event.js';
7 > import { Disposable } from '../../../base/common/lifecycle.js';
8 > import { URI } from '../../../base/common/uri.js';
9 > import { IPosition, Position } from '../core/position.js';
10 > import { ILanguageService } from '../languages/language.js';
11 > import { IModelService } from './model.js';
12 > import { ITextResourceConfigurationService, ITextResourceConfigurationChangeEvent } from './textResourceConfiguration.js';
13 > import { IConfigurationService, ConfigurationTarget, IConfigurationValue, IConfigurationChangeEvent } from '../../../platform/configuration/common/configuration.js';
14 >
15 > export class TextResourceConfigurationService extends Disposable implements ITextResourceConfigurationService {
16 >
17 > public _serviceBrand: undefined;
18 >
19 > private readonly _onDidChangeConfiguration: Emitter<ITextResourceConfigurationChangeEvent> = this._register(new Emitter<ITextResourceConfigurationChangeEvent>());
20 > public readonly onDidChangeConfiguration: Event<ITextResourceConfigurationChangeEvent> = this._onDidChangeConfiguration.event;
21 >
22 > constructor(
23 > @IConfigurationService private readonly configurationService: IConfigurationService,
24 > @IModelService private readonly modelService: IModelService,
25 > @ILanguageService private readonly languageService: ILanguageService,
26 > ) {
27 > super();
28 > this._register(this.configurationService.onDidChangeConfiguration(e => this._onDidChangeConfiguration.fire(this.toResourceConfigurationChangeEvent(e))));
29 > }
30 >
31 > getValue<T>(resource: URI | undefined, section?: string): T;
32 > getValue<T>(resource: URI | undefined, at?: IPosition, section?: string): T;
33 > getValue<T>(resource: URI | undefined, arg2?: unknown, arg3?: unknown): T {
34 if (typeof arg3 === 'string') {
35 return this._getValue(resource, Position.isIPosition(arg2) ? arg2 : null, arg3);
37 return this._getValue(resource, null, typeof arg2 === 'string' ? arg2 : undefined);
38 }
40 > updateValue(resource: URI | undefined, key: string, value: unknown, configurationTarget?: ConfigurationTarget): Promise<void> {
41 > const language = resource ? this.getLanguage(resource, null) : null;
42 > const configurationValue = this.configurationService.inspect(key, { resource, overrideIdentifier: language });
43 > if (configurationTarget === undefined) {
44 configurationTarget = this.deriveConfigurationTarget(configurationValue, language);
45 }
46 > const overrideIdentifier = language && configurationValue.overrideIdentifiers?.includes(language) ? language : undefined; textResourceConfigurationService.ts
47 > return this.configurationService.updateValue(key, value, { resource, overrideIdentifier }, configurationTarget);
48 > }
49 >
50 > private deriveConfigurationTarget(configurationValue: IConfigurationValue<unknown>, language: string | null): ConfigurationTarget {
51 if (language) {
52 if (configurationValue.memory?.override !== undefined) {
80 return ConfigurationTarget.USER_LOCAL;
81 }
83 > private _getValue<T>(resource: URI | undefined, position: IPosition | null, section: string | undefined): T {
84 const language = resource ? this.getLanguage(resource, position) : undefined;
85 if (typeof section === 'undefined') {
88 return this.configurationService.getValue<T>(section, { resource, overrideIdentifier: language });
89 }
91 > inspect<T>(resource: URI | undefined, position: IPosition | null, section: string): IConfigurationValue<Readonly<T>> {
92 const language = resource ? this.getLanguage(resource, position) : undefined;
93 return this.configurationService.inspect<T>(section, { resource, overrideIdentifier: language });
94 }
96 > private getLanguage(resource: URI, position: IPosition | null): string | null {
97 > const model = this.modelService.getModel(resource);
98 > if (model) {
99 return position ? model.getLanguageIdAtPosition(position.lineNumber, position.column) : model.getLanguageId();
100 }
101 > return this.languageService.guessLanguageIdByFilepathOrFirstLine(resource); textResourceConfigurationService.ts
102 > }
103 >
104 > private toResourceConfigurationChangeEvent(configurationChangeEvent: IConfigurationChangeEvent): ITextResourceConfigurationChangeEvent {
105 return {
106 affectedKeys: configurationChangeEvent.affectedKeys,