Path: blob/main/src/vs/editor/common/services/textResourceConfiguration.ts
3294 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Event } from '../../../base/common/event.js';6import { URI } from '../../../base/common/uri.js';7import { IPosition } from '../core/position.js';8import { ConfigurationTarget, IConfigurationValue } from '../../../platform/configuration/common/configuration.js';9import { createDecorator } from '../../../platform/instantiation/common/instantiation.js';1011export const ITextResourceConfigurationService = createDecorator<ITextResourceConfigurationService>('textResourceConfigurationService');1213export interface ITextResourceConfigurationChangeEvent {1415/**16* All affected keys. Also includes language overrides and keys changed under language overrides.17*/18readonly affectedKeys: ReadonlySet<string>;1920/**21* Returns `true` if the given section has changed for the given resource.22*23* Example: To check if the configuration section has changed for a given resource use `e.affectsConfiguration(resource, section)`.24*25* @param resource Resource for which the configuration has to be checked.26* @param section Section of the configuration27*/28affectsConfiguration(resource: URI | undefined, section: string): boolean;29}3031export interface ITextResourceConfigurationService {3233readonly _serviceBrand: undefined;3435/**36* Event that fires when the configuration changes.37*/38onDidChangeConfiguration: Event<ITextResourceConfigurationChangeEvent>;3940/**41* Fetches the value of the section for the given resource by applying language overrides.42* Value can be of native type or an object keyed off the section name.43*44* @param resource - Resource for which the configuration has to be fetched.45* @param position - Position in the resource for which configuration has to be fetched.46* @param section - Section of the configuration.47*48*/49getValue<T>(resource: URI | undefined, section?: string): T;50getValue<T>(resource: URI | undefined, position?: IPosition, section?: string): T;5152/**53* Inspects the values of the section for the given resource by applying language overrides.54*55* @param resource - Resource for which the configuration has to be fetched.56* @param position - Position in the resource for which configuration has to be fetched.57* @param section - Section of the configuration.58*59*/60inspect<T>(resource: URI | undefined, position: IPosition | null, section: string): IConfigurationValue<Readonly<T>>;6162/**63* Update the configuration value for the given resource at the effective location.64*65* - If configurationTarget is not specified, target will be derived by checking where the configuration is defined.66* - If the language overrides for the give resource contains the configuration, then it is updated.67*68* @param resource Resource for which the configuration has to be updated69* @param key Configuration key70* @param value Configuration value71* @param configurationTarget Optional target into which the configuration has to be updated.72* If not specified, target will be derived by checking where the configuration is defined.73*/74updateValue(resource: URI | undefined, key: string, value: unknown, configurationTarget?: ConfigurationTarget): Promise<void>;7576}7778export const ITextResourcePropertiesService = createDecorator<ITextResourcePropertiesService>('textResourcePropertiesService');7980export interface ITextResourcePropertiesService {8182readonly _serviceBrand: undefined;8384/**85* Returns the End of Line characters for the given resource86*/87getEOL(resource: URI, language?: string): string;88}899091