Path: blob/main/src/vs/workbench/services/configuration/common/configuration.ts
3296 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 { ConfigurationScope } from '../../../../platform/configuration/common/configurationRegistry.js';6import { URI } from '../../../../base/common/uri.js';7import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';8import { refineServiceDecorator } from '../../../../platform/instantiation/common/instantiation.js';9import { Event } from '../../../../base/common/event.js';10import { ResourceMap } from '../../../../base/common/map.js';11import { IAnyWorkspaceIdentifier } from '../../../../platform/workspace/common/workspace.js';1213export const FOLDER_CONFIG_FOLDER_NAME = '.vscode';14export const FOLDER_SETTINGS_NAME = 'settings';15export const FOLDER_SETTINGS_PATH = `${FOLDER_CONFIG_FOLDER_NAME}/${FOLDER_SETTINGS_NAME}.json`;1617export const defaultSettingsSchemaId = 'vscode://schemas/settings/default';18export const userSettingsSchemaId = 'vscode://schemas/settings/user';19export const profileSettingsSchemaId = 'vscode://schemas/settings/profile';20export const machineSettingsSchemaId = 'vscode://schemas/settings/machine';21export const workspaceSettingsSchemaId = 'vscode://schemas/settings/workspace';22export const folderSettingsSchemaId = 'vscode://schemas/settings/folder';23export const launchSchemaId = 'vscode://schemas/launch';24export const tasksSchemaId = 'vscode://schemas/tasks';25export const mcpSchemaId = 'vscode://schemas/mcp';2627export const APPLICATION_SCOPES = [ConfigurationScope.APPLICATION, ConfigurationScope.APPLICATION_MACHINE];28export const PROFILE_SCOPES = [ConfigurationScope.MACHINE, ConfigurationScope.WINDOW, ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE, ConfigurationScope.MACHINE_OVERRIDABLE];29export const LOCAL_MACHINE_PROFILE_SCOPES = [ConfigurationScope.WINDOW, ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE];30export const LOCAL_MACHINE_SCOPES = [ConfigurationScope.APPLICATION, ...LOCAL_MACHINE_PROFILE_SCOPES];31export const REMOTE_MACHINE_SCOPES = [ConfigurationScope.MACHINE, ConfigurationScope.APPLICATION_MACHINE, ConfigurationScope.WINDOW, ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE, ConfigurationScope.MACHINE_OVERRIDABLE];32export const WORKSPACE_SCOPES = [ConfigurationScope.WINDOW, ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE, ConfigurationScope.MACHINE_OVERRIDABLE];33export const FOLDER_SCOPES = [ConfigurationScope.RESOURCE, ConfigurationScope.LANGUAGE_OVERRIDABLE, ConfigurationScope.MACHINE_OVERRIDABLE];3435export const TASKS_CONFIGURATION_KEY = 'tasks';36export const LAUNCH_CONFIGURATION_KEY = 'launch';37export const MCP_CONFIGURATION_KEY = 'mcp';3839export const WORKSPACE_STANDALONE_CONFIGURATIONS = Object.create(null);40WORKSPACE_STANDALONE_CONFIGURATIONS[TASKS_CONFIGURATION_KEY] = `${FOLDER_CONFIG_FOLDER_NAME}/${TASKS_CONFIGURATION_KEY}.json`;41WORKSPACE_STANDALONE_CONFIGURATIONS[LAUNCH_CONFIGURATION_KEY] = `${FOLDER_CONFIG_FOLDER_NAME}/${LAUNCH_CONFIGURATION_KEY}.json`;42WORKSPACE_STANDALONE_CONFIGURATIONS[MCP_CONFIGURATION_KEY] = `${FOLDER_CONFIG_FOLDER_NAME}/${MCP_CONFIGURATION_KEY}.json`;43export const USER_STANDALONE_CONFIGURATIONS = Object.create(null);44USER_STANDALONE_CONFIGURATIONS[TASKS_CONFIGURATION_KEY] = `${TASKS_CONFIGURATION_KEY}.json`;45USER_STANDALONE_CONFIGURATIONS[MCP_CONFIGURATION_KEY] = `${MCP_CONFIGURATION_KEY}.json`;4647export type ConfigurationKey = { type: 'defaults' | 'user' | 'workspaces' | 'folder'; key: string };4849export interface IConfigurationCache {5051needsCaching(resource: URI): boolean;52read(key: ConfigurationKey): Promise<string>;53write(key: ConfigurationKey, content: string): Promise<void>;54remove(key: ConfigurationKey): Promise<void>;5556}5758export type RestrictedSettings = {59default: ReadonlyArray<string>;60application?: ReadonlyArray<string>;61userLocal?: ReadonlyArray<string>;62userRemote?: ReadonlyArray<string>;63workspace?: ReadonlyArray<string>;64workspaceFolder?: ResourceMap<ReadonlyArray<string>>;65};6667export const IWorkbenchConfigurationService = refineServiceDecorator<IConfigurationService, IWorkbenchConfigurationService>(IConfigurationService);68export interface IWorkbenchConfigurationService extends IConfigurationService {69/**70* Restricted settings defined in each configuration target71*/72readonly restrictedSettings: RestrictedSettings;7374/**75* Event that triggers when the restricted settings changes76*/77readonly onDidChangeRestrictedSettings: Event<RestrictedSettings>;7879/**80* A promise that resolves when the remote configuration is loaded in a remote window.81* The promise is resolved immediately if the window is not remote.82*/83whenRemoteConfigurationLoaded(): Promise<void>;8485/**86* Initialize configuration service for the given workspace87* @param arg workspace Identifier88*/89initialize(arg: IAnyWorkspaceIdentifier): Promise<void>;9091/**92* Returns true if the setting can be applied for all profiles otherwise false.93* @param setting94*/95isSettingAppliedForAllProfiles(setting: string): boolean;96}9798export const TASKS_DEFAULT = '{\n\t\"version\": \"2.0.0\",\n\t\"tasks\": []\n}';99100export const APPLY_ALL_PROFILES_SETTING = 'workbench.settings.applyToAllProfiles';101102103