Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/common/services/textResourceConfiguration.ts
3294 views
1
/*---------------------------------------------------------------------------------------------
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 { Event } from '../../../base/common/event.js';
7
import { URI } from '../../../base/common/uri.js';
8
import { IPosition } from '../core/position.js';
9
import { ConfigurationTarget, IConfigurationValue } from '../../../platform/configuration/common/configuration.js';
10
import { createDecorator } from '../../../platform/instantiation/common/instantiation.js';
11
12
export const ITextResourceConfigurationService = createDecorator<ITextResourceConfigurationService>('textResourceConfigurationService');
13
14
export interface ITextResourceConfigurationChangeEvent {
15
16
/**
17
* All affected keys. Also includes language overrides and keys changed under language overrides.
18
*/
19
readonly affectedKeys: ReadonlySet<string>;
20
21
/**
22
* Returns `true` if the given section has changed for the given resource.
23
*
24
* Example: To check if the configuration section has changed for a given resource use `e.affectsConfiguration(resource, section)`.
25
*
26
* @param resource Resource for which the configuration has to be checked.
27
* @param section Section of the configuration
28
*/
29
affectsConfiguration(resource: URI | undefined, section: string): boolean;
30
}
31
32
export interface ITextResourceConfigurationService {
33
34
readonly _serviceBrand: undefined;
35
36
/**
37
* Event that fires when the configuration changes.
38
*/
39
onDidChangeConfiguration: Event<ITextResourceConfigurationChangeEvent>;
40
41
/**
42
* Fetches the value of the section for the given resource by applying language overrides.
43
* Value can be of native type or an object keyed off the section name.
44
*
45
* @param resource - Resource for which the configuration has to be fetched.
46
* @param position - Position in the resource for which configuration has to be fetched.
47
* @param section - Section of the configuration.
48
*
49
*/
50
getValue<T>(resource: URI | undefined, section?: string): T;
51
getValue<T>(resource: URI | undefined, position?: IPosition, section?: string): T;
52
53
/**
54
* Inspects the values of the section for the given resource by applying language overrides.
55
*
56
* @param resource - Resource for which the configuration has to be fetched.
57
* @param position - Position in the resource for which configuration has to be fetched.
58
* @param section - Section of the configuration.
59
*
60
*/
61
inspect<T>(resource: URI | undefined, position: IPosition | null, section: string): IConfigurationValue<Readonly<T>>;
62
63
/**
64
* Update the configuration value for the given resource at the effective location.
65
*
66
* - If configurationTarget is not specified, target will be derived by checking where the configuration is defined.
67
* - If the language overrides for the give resource contains the configuration, then it is updated.
68
*
69
* @param resource Resource for which the configuration has to be updated
70
* @param key Configuration key
71
* @param value Configuration value
72
* @param configurationTarget Optional target into which the configuration has to be updated.
73
* If not specified, target will be derived by checking where the configuration is defined.
74
*/
75
updateValue(resource: URI | undefined, key: string, value: unknown, configurationTarget?: ConfigurationTarget): Promise<void>;
76
77
}
78
79
export const ITextResourcePropertiesService = createDecorator<ITextResourcePropertiesService>('textResourcePropertiesService');
80
81
export interface ITextResourcePropertiesService {
82
83
readonly _serviceBrand: undefined;
84
85
/**
86
* Returns the End of Line characters for the given resource
87
*/
88
getEOL(resource: URI, language?: string): string;
89
}
90
91