Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/services/configuration/common/configuration.ts
3296 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 { ConfigurationScope } from '../../../../platform/configuration/common/configurationRegistry.js';
7
import { URI } from '../../../../base/common/uri.js';
8
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
9
import { refineServiceDecorator } from '../../../../platform/instantiation/common/instantiation.js';
10
import { Event } from '../../../../base/common/event.js';
11
import { ResourceMap } from '../../../../base/common/map.js';
12
import { IAnyWorkspaceIdentifier } from '../../../../platform/workspace/common/workspace.js';
13
14
export const FOLDER_CONFIG_FOLDER_NAME = '.vscode';
15
export const FOLDER_SETTINGS_NAME = 'settings';
16
export const FOLDER_SETTINGS_PATH = `${FOLDER_CONFIG_FOLDER_NAME}/${FOLDER_SETTINGS_NAME}.json`;
17
18
export const defaultSettingsSchemaId = 'vscode://schemas/settings/default';
19
export const userSettingsSchemaId = 'vscode://schemas/settings/user';
20
export const profileSettingsSchemaId = 'vscode://schemas/settings/profile';
21
export const machineSettingsSchemaId = 'vscode://schemas/settings/machine';
22
export const workspaceSettingsSchemaId = 'vscode://schemas/settings/workspace';
23
export const folderSettingsSchemaId = 'vscode://schemas/settings/folder';
24
export const launchSchemaId = 'vscode://schemas/launch';
25
export const tasksSchemaId = 'vscode://schemas/tasks';
26
export const mcpSchemaId = 'vscode://schemas/mcp';
27
28
export const APPLICATION_SCOPES = [ConfigurationScope.APPLICATION, ConfigurationScope.APPLICATION_MACHINE];
29
export const PROFILE_SCOPES = [ConfigurationScope.MACHINE, ConfigurationScope.WINDOW, ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE, ConfigurationScope.MACHINE_OVERRIDABLE];
30
export const LOCAL_MACHINE_PROFILE_SCOPES = [ConfigurationScope.WINDOW, ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE];
31
export const LOCAL_MACHINE_SCOPES = [ConfigurationScope.APPLICATION, ...LOCAL_MACHINE_PROFILE_SCOPES];
32
export const REMOTE_MACHINE_SCOPES = [ConfigurationScope.MACHINE, ConfigurationScope.APPLICATION_MACHINE, ConfigurationScope.WINDOW, ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE, ConfigurationScope.MACHINE_OVERRIDABLE];
33
export const WORKSPACE_SCOPES = [ConfigurationScope.WINDOW, ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE, ConfigurationScope.MACHINE_OVERRIDABLE];
34
export const FOLDER_SCOPES = [ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE, ConfigurationScope.MACHINE_OVERRIDABLE];
35
36
export const TASKS_CONFIGURATION_KEY = 'tasks';
37
export const LAUNCH_CONFIGURATION_KEY = 'launch';
38
export const MCP_CONFIGURATION_KEY = 'mcp';
39
40
export const WORKSPACE_STANDALONE_CONFIGURATIONS = Object.create(null);
41
WORKSPACE_STANDALONE_CONFIGURATIONS[TASKS_CONFIGURATION_KEY] = `${FOLDER_CONFIG_FOLDER_NAME}/${TASKS_CONFIGURATION_KEY}.json`;
42
WORKSPACE_STANDALONE_CONFIGURATIONS[LAUNCH_CONFIGURATION_KEY] = `${FOLDER_CONFIG_FOLDER_NAME}/${LAUNCH_CONFIGURATION_KEY}.json`;
43
WORKSPACE_STANDALONE_CONFIGURATIONS[MCP_CONFIGURATION_KEY] = `${FOLDER_CONFIG_FOLDER_NAME}/${MCP_CONFIGURATION_KEY}.json`;
44
export const USER_STANDALONE_CONFIGURATIONS = Object.create(null);
45
USER_STANDALONE_CONFIGURATIONS[TASKS_CONFIGURATION_KEY] = `${TASKS_CONFIGURATION_KEY}.json`;
46
USER_STANDALONE_CONFIGURATIONS[MCP_CONFIGURATION_KEY] = `${MCP_CONFIGURATION_KEY}.json`;
47
48
export type ConfigurationKey = { type: 'defaults' | 'user' | 'workspaces' | 'folder'; key: string };
49
50
export interface IConfigurationCache {
51
52
needsCaching(resource: URI): boolean;
53
read(key: ConfigurationKey): Promise<string>;
54
write(key: ConfigurationKey, content: string): Promise<void>;
55
remove(key: ConfigurationKey): Promise<void>;
56
57
}
58
59
export type RestrictedSettings = {
60
default: ReadonlyArray<string>;
61
application?: ReadonlyArray<string>;
62
userLocal?: ReadonlyArray<string>;
63
userRemote?: ReadonlyArray<string>;
64
workspace?: ReadonlyArray<string>;
65
workspaceFolder?: ResourceMap<ReadonlyArray<string>>;
66
};
67
68
export const IWorkbenchConfigurationService = refineServiceDecorator<IConfigurationService, IWorkbenchConfigurationService>(IConfigurationService);
69
export interface IWorkbenchConfigurationService extends IConfigurationService {
70
/**
71
* Restricted settings defined in each configuration target
72
*/
73
readonly restrictedSettings: RestrictedSettings;
74
75
/**
76
* Event that triggers when the restricted settings changes
77
*/
78
readonly onDidChangeRestrictedSettings: Event<RestrictedSettings>;
79
80
/**
81
* A promise that resolves when the remote configuration is loaded in a remote window.
82
* The promise is resolved immediately if the window is not remote.
83
*/
84
whenRemoteConfigurationLoaded(): Promise<void>;
85
86
/**
87
* Initialize configuration service for the given workspace
88
* @param arg workspace Identifier
89
*/
90
initialize(arg: IAnyWorkspaceIdentifier): Promise<void>;
91
92
/**
93
* Returns true if the setting can be applied for all profiles otherwise false.
94
* @param setting
95
*/
96
isSettingAppliedForAllProfiles(setting: string): boolean;
97
}
98
99
export const TASKS_DEFAULT = '{\n\t\"version\": \"2.0.0\",\n\t\"tasks\": []\n}';
100
101
export const APPLY_ALL_PROFILES_SETTING = 'workbench.settings.applyToAllProfiles';
102
103