themeConfiguration.ts ×22

Frontier kind: Code frontier

unlabeled · c_69d06748c346

4 tests · 13134 LOC · 62 files · introduces 0 tests · 550 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
23 ranges550 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1427 ranges13134 lines · 62 files · Browse complete extent
All tests (intent)
4 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.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

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

2 files ranked by introduced lines: 550 introduced LOC across 23 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/themes/common/themeConfiguration.ts 281 introduced LOC · 22 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- themeConfiguration.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 * as nls from '../../../../nls.js';
7 > import * as types from '../../../../base/common/types.js';
8 > import { Registry } from '../../../../platform/registry/common/platform.js';
9 > import { IConfigurationRegistry, Extensions as ConfigurationExtensions, IConfigurationPropertySchema, IConfigurationNode, ConfigurationScope } from '../../../../platform/configuration/common/configurationRegistry.js';
10 >
11 > import { IJSONSchema } from '../../../../base/common/jsonSchema.js';
12 > import { textmateColorsSchemaId, textmateColorGroupSchemaId } from './colorThemeSchema.js';
13 > import { workbenchColorsSchemaId } from '../../../../platform/theme/common/colorRegistry.js';
14 > import { tokenStylingSchemaId } from '../../../../platform/theme/common/tokenClassificationRegistry.js';
15 > import { ThemeSettings, IWorkbenchColorTheme, IWorkbenchFileIconTheme, IColorCustomizations, ITokenColorCustomizations, IWorkbenchProductIconTheme, ISemanticTokenColorCustomizations, ThemeSettingTarget, ThemeSettingDefaults } from './workbenchThemeService.js';
16 > import { IConfigurationService, ConfigurationTarget } from '../../../../platform/configuration/common/configuration.js';
17 > import { isWeb } from '../../../../base/common/platform.js';
18 > import { ColorScheme } from '../../../../platform/theme/common/theme.js';
19 > import { IHostColorSchemeService } from './hostColorSchemeService.js';
20 > import { IColorScheme } from '../../../../platform/window/common/window.js';
21 >
22 > // Configuration: Themes
23 > const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
24 >
25 > const colorThemeSettingEnum: string[] = [];
26 > const colorThemeSettingEnumItemLabels: string[] = [];
27 > const colorThemeSettingEnumDescriptions: string[] = [];
28 >
29 > export function formatSettingAsLink(str: string) {
30 > return `\`#${str}#\``;
31 > }
32 >
33 > export const COLOR_THEME_CONFIGURATION_SETTINGS_TAG = 'colorThemeConfiguration';
34 >
35 > const colorThemeSettingSchema: IConfigurationPropertySchema = {
36 > type: 'string',
37 > markdownDescription: nls.localize({ key: 'colorTheme', comment: ['{0} will become a link to another setting.'] }, "Specifies the color theme used in the workbench when {0} is not enabled.", formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)),
38 > default: isWeb ? ThemeSettingDefaults.COLOR_THEME_LIGHT : ThemeSettingDefaults.COLOR_THEME_DARK,
39 > tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG],
40 > enum: colorThemeSettingEnum,
41 > enumDescriptions: colorThemeSettingEnumDescriptions,
42 > enumItemLabels: colorThemeSettingEnumItemLabels,
43 > errorMessage: nls.localize('colorThemeError', "Theme is unknown or not installed."),
44 > };
45 > const preferredDarkThemeSettingSchema: IConfigurationPropertySchema = {
46 > type: 'string', //
47 > markdownDescription: nls.localize({ key: 'preferredDarkColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme when system color mode is dark and {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)),
48 > default: ThemeSettingDefaults.COLOR_THEME_DARK,
49 > tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG],
50 > enum: colorThemeSettingEnum,
51 > enumDescriptions: colorThemeSettingEnumDescriptions,
52 > enumItemLabels: colorThemeSettingEnumItemLabels,
53 > errorMessage: nls.localize('colorThemeError', "Theme is unknown or not installed."),
54 > };
55 > const preferredLightThemeSettingSchema: IConfigurationPropertySchema = {
56 > type: 'string',
57 > markdownDescription: nls.localize({ key: 'preferredLightColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme when system color mode is light and {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)),
58 > default: ThemeSettingDefaults.COLOR_THEME_LIGHT,
59 > tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG],
60 > enum: colorThemeSettingEnum,
61 > enumDescriptions: colorThemeSettingEnumDescriptions,
62 > enumItemLabels: colorThemeSettingEnumItemLabels,
63 > errorMessage: nls.localize('colorThemeError', "Theme is unknown or not installed."),
64 > };
65 > const preferredHCDarkThemeSettingSchema: IConfigurationPropertySchema = {
66 > type: 'string',
67 > markdownDescription: nls.localize({ key: 'preferredHCDarkColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme when in high contrast dark mode and {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_HC)),
68 > default: ThemeSettingDefaults.COLOR_THEME_HC_DARK,
69 > tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG],
70 > enum: colorThemeSettingEnum,
71 > enumDescriptions: colorThemeSettingEnumDescriptions,
72 > enumItemLabels: colorThemeSettingEnumItemLabels,
73 > errorMessage: nls.localize('colorThemeError', "Theme is unknown or not installed."),
74 > };
75 > const preferredHCLightThemeSettingSchema: IConfigurationPropertySchema = {
76 > type: 'string',
77 > markdownDescription: nls.localize({ key: 'preferredHCLightColorTheme', comment: ['{0} will become a link to another setting.'] }, 'Specifies the color theme when in high contrast light mode and {0} is enabled.', formatSettingAsLink(ThemeSettings.DETECT_HC)),
78 > default: ThemeSettingDefaults.COLOR_THEME_HC_LIGHT,
79 > tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG],
80 > enum: colorThemeSettingEnum,
81 > enumDescriptions: colorThemeSettingEnumDescriptions,
82 > enumItemLabels: colorThemeSettingEnumItemLabels,
83 > errorMessage: nls.localize('colorThemeError', "Theme is unknown or not installed."),
84 > };
85 > const detectColorSchemeSettingSchema: IConfigurationPropertySchema = {
86 > type: 'boolean',
87 > markdownDescription: nls.localize({ key: 'detectColorScheme', comment: ['{0} and {1} will become links to other settings.'] }, 'If enabled, will automatically select a color theme based on the system color mode. If the system color mode is dark, {0} is used, else {1}.', formatSettingAsLink(ThemeSettings.PREFERRED_DARK_THEME), formatSettingAsLink(ThemeSettings.PREFERRED_LIGHT_THEME)),
88 > default: false,
89 > ...(isWeb ? { agentsWindow: { default: true } } : {}),
90 > tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG],
91 > };
92 >
93 > const colorCustomizationsSchema: IConfigurationPropertySchema = {
94 > type: 'object',
95 > description: nls.localize('workbenchColors', "Overrides colors from the currently selected color theme."),
96 > allOf: [{ $ref: workbenchColorsSchemaId }],
97 > default: {},
98 > defaultSnippets: [{
99 > body: {
100 > }
101 > }]
102 > };
103 > const fileIconThemeSettingSchema: IConfigurationPropertySchema = {
104 > type: ['string', 'null'],
105 > default: ThemeSettingDefaults.FILE_ICON_THEME,
106 > description: nls.localize('iconTheme', "Specifies the file icon theme used in the workbench or 'null' to not show any file icons."),
107 > enum: [null],
108 > enumItemLabels: [nls.localize('noIconThemeLabel', 'None')],
109 > enumDescriptions: [nls.localize('noIconThemeDesc', 'No file icons')],
110 > errorMessage: nls.localize('iconThemeError', "File icon theme is unknown or not installed.")
111 > };
112 > const productIconThemeSettingSchema: IConfigurationPropertySchema = {
113 > type: ['string', 'null'],
114 > default: ThemeSettingDefaults.PRODUCT_ICON_THEME,
115 > description: nls.localize('productIconTheme', "Specifies the product icon theme used."),
116 > enum: [ThemeSettingDefaults.PRODUCT_ICON_THEME],
117 > enumItemLabels: [nls.localize('defaultProductIconThemeLabel', 'Default')],
118 > enumDescriptions: [nls.localize('defaultProductIconThemeDesc', 'Default')],
119 > errorMessage: nls.localize('productIconThemeError', "Product icon theme is unknown or not installed.")
120 > };
121 >
122 > const detectHCSchemeSettingSchema: IConfigurationPropertySchema = {
123 > type: 'boolean',
124 > default: true,
125 > markdownDescription: nls.localize({ key: 'autoDetectHighContrast', comment: ['{0} and {1} will become links to other settings.'] }, "If enabled, will automatically change to high contrast theme if the OS is using a high contrast theme. The high contrast theme to use is specified by {0} and {1}.", formatSettingAsLink(ThemeSettings.PREFERRED_HC_DARK_THEME), formatSettingAsLink(ThemeSettings.PREFERRED_HC_LIGHT_THEME)),
126 > scope: ConfigurationScope.APPLICATION,
127 > tags: [COLOR_THEME_CONFIGURATION_SETTINGS_TAG],
128 > };
129 >
130 > const themeSettingsConfiguration: IConfigurationNode = {
131 > id: 'workbench',
132 > order: 7.1,
133 > type: 'object',
134 > properties: {
135 > [ThemeSettings.COLOR_THEME]: colorThemeSettingSchema,
136 > [ThemeSettings.PREFERRED_DARK_THEME]: preferredDarkThemeSettingSchema,
137 > [ThemeSettings.PREFERRED_LIGHT_THEME]: preferredLightThemeSettingSchema,
138 > [ThemeSettings.PREFERRED_HC_DARK_THEME]: preferredHCDarkThemeSettingSchema,
139 > [ThemeSettings.PREFERRED_HC_LIGHT_THEME]: preferredHCLightThemeSettingSchema,
140 > [ThemeSettings.FILE_ICON_THEME]: fileIconThemeSettingSchema,
141 > [ThemeSettings.COLOR_CUSTOMIZATIONS]: colorCustomizationsSchema,
142 > [ThemeSettings.PRODUCT_ICON_THEME]: productIconThemeSettingSchema
143 > }
144 > };
145 > configurationRegistry.registerConfiguration(themeSettingsConfiguration);
146 >
147 > const themeSettingsWindowConfiguration: IConfigurationNode = {
148 > id: 'window',
149 > order: 8.1,
150 > type: 'object',
151 > properties: {
152 > [ThemeSettings.DETECT_HC]: detectHCSchemeSettingSchema,
153 > [ThemeSettings.DETECT_COLOR_SCHEME]: detectColorSchemeSettingSchema,
154 > }
155 > };
156 > configurationRegistry.registerConfiguration(themeSettingsWindowConfiguration);
157 >
158 > function tokenGroupSettings(description: string): IJSONSchema {
159 > return {
160 > description,
161 > $ref: textmateColorGroupSchemaId
162 > };
163 > }
164 >
165 > const themeSpecificSettingKey = '^\\[[^\\]]*(\\]\\s*\\[[^\\]]*)*\\]$';
166 >
167 > const tokenColorSchema: IJSONSchema = {
168 > type: 'object',
169 > properties: {
170 > comments: tokenGroupSettings(nls.localize('editorColors.comments', "Sets the colors and styles for comments")),
171 > strings: tokenGroupSettings(nls.localize('editorColors.strings', "Sets the colors and styles for strings literals.")),
172 > keywords: tokenGroupSettings(nls.localize('editorColors.keywords', "Sets the colors and styles for keywords.")),
173 > numbers: tokenGroupSettings(nls.localize('editorColors.numbers', "Sets the colors and styles for number literals.")),
174 > types: tokenGroupSettings(nls.localize('editorColors.types', "Sets the colors and styles for type declarations and references.")),
175 > functions: tokenGroupSettings(nls.localize('editorColors.functions', "Sets the colors and styles for functions declarations and references.")),
176 > variables: tokenGroupSettings(nls.localize('editorColors.variables', "Sets the colors and styles for variables declarations and references.")),
177 > textMateRules: {
178 > description: nls.localize('editorColors.textMateRules', 'Sets colors and styles using textmate theming rules (advanced).'),
179 > $ref: textmateColorsSchemaId
180 > },
181 > semanticHighlighting: {
182 > description: nls.localize('editorColors.semanticHighlighting', 'Whether semantic highlighting should be enabled for this theme.'),
183 > deprecationMessage: nls.localize('editorColors.semanticHighlighting.deprecationMessage', 'Use `enabled` in `editor.semanticTokenColorCustomizations` setting instead.'),
184 > markdownDeprecationMessage: nls.localize({ key: 'editorColors.semanticHighlighting.deprecationMessageMarkdown', comment: ['{0} will become a link to another setting.'] }, 'Use `enabled` in {0} setting instead.', formatSettingAsLink('editor.semanticTokenColorCustomizations')),
185 > type: 'boolean'
186 > }
187 > },
188 > additionalProperties: false
189 > };
190 >
191 > const tokenColorCustomizationSchema: IConfigurationPropertySchema = {
192 > description: nls.localize('editorColors', "Overrides editor syntax colors and font style from the currently selected color theme."),
193 > default: {},
194 > allOf: [{ ...tokenColorSchema, patternProperties: { '^\\[': {} } }]
195 > };
196 >
197 > const semanticTokenColorSchema: IJSONSchema = {
198 > type: 'object',
199 > properties: {
200 > enabled: {
201 > type: 'boolean',
202 > description: nls.localize('editorColors.semanticHighlighting.enabled', 'Whether semantic highlighting is enabled or disabled for this theme'),
203 > suggestSortText: '0_enabled'
204 > },
205 > rules: {
206 > $ref: tokenStylingSchemaId,
207 > description: nls.localize('editorColors.semanticHighlighting.rules', 'Semantic token styling rules for this theme.'),
208 > suggestSortText: '0_rules'
209 > }
210 > },
211 > additionalProperties: false
212 > };
213 >
214 > const semanticTokenColorCustomizationSchema: IConfigurationPropertySchema = {
215 > description: nls.localize('semanticTokenColors', "Overrides editor semantic token color and styles from the currently selected color theme."),
216 > default: {},
217 > allOf: [{ ...semanticTokenColorSchema, patternProperties: { '^\\[': {} } }]
218 > };
219 >
220 > const tokenColorCustomizationConfiguration: IConfigurationNode = {
221 > id: 'editor',
222 > order: 7.2,
223 > type: 'object',
224 > properties: {
225 > [ThemeSettings.TOKEN_COLOR_CUSTOMIZATIONS]: tokenColorCustomizationSchema,
226 > [ThemeSettings.SEMANTIC_TOKEN_COLOR_CUSTOMIZATIONS]: semanticTokenColorCustomizationSchema
227 > }
228 > };
229 >
230 > configurationRegistry.registerConfiguration(tokenColorCustomizationConfiguration);
231 >
232 > export function updateColorThemeConfigurationSchemas(themes: IWorkbenchColorTheme[]) {
233 // updates enum for the 'workbench.colorTheme` setting
234 themes.sort((a, b) => a.label.localeCompare(b.label));
260 configurationRegistry.notifyConfigurationSchemaUpdated(themeSettingsConfiguration, tokenColorCustomizationConfiguration);
261 }
263 > export function updateFileIconThemeConfigurationSchemas(themes: IWorkbenchFileIconTheme[]) {
264 fileIconThemeSettingSchema.enum!.splice(1, Number.MAX_VALUE, ...themes.map(t => t.settingsId));
265 fileIconThemeSettingSchema.enumItemLabels!.splice(1, Number.MAX_VALUE, ...themes.map(t => t.label));
268 configurationRegistry.notifyConfigurationSchemaUpdated(themeSettingsConfiguration);
269 }
271 > export function updateProductIconThemeConfigurationSchemas(themes: IWorkbenchProductIconTheme[]) {
272 productIconThemeSettingSchema.enum!.splice(1, Number.MAX_VALUE, ...themes.map(t => t.settingsId));
273 productIconThemeSettingSchema.enumItemLabels!.splice(1, Number.MAX_VALUE, ...themes.map(t => t.label));
276 configurationRegistry.notifyConfigurationSchemaUpdated(themeSettingsConfiguration);
277 }
279 > const colorSchemeToPreferred = {
280 > [ColorScheme.DARK]: ThemeSettings.PREFERRED_DARK_THEME,
281 > [ColorScheme.LIGHT]: ThemeSettings.PREFERRED_LIGHT_THEME,
282 > [ColorScheme.HIGH_CONTRAST_DARK]: ThemeSettings.PREFERRED_HC_DARK_THEME,
283 > [ColorScheme.HIGH_CONTRAST_LIGHT]: ThemeSettings.PREFERRED_HC_LIGHT_THEME
284 > };
285 >
286 > export class ThemeConfiguration {
287 > constructor(private configurationService: IConfigurationService, private hostColorService: IHostColorSchemeService) {
288 }
290 > public get colorTheme(): string {
291 return this.configurationService.getValue<string>(this.getColorThemeSettingId());
292 }
294 > public get fileIconTheme(): string | null {
295 return this.configurationService.getValue<string | null>(ThemeSettings.FILE_ICON_THEME);
296 }
298 > public get productIconTheme(): string {
299 return this.configurationService.getValue<string>(ThemeSettings.PRODUCT_ICON_THEME);
300 }
302 > public get colorCustomizations(): IColorCustomizations {
303 return this.configurationService.getValue<IColorCustomizations>(ThemeSettings.COLOR_CUSTOMIZATIONS) || {};
304 }
306 > public get tokenColorCustomizations(): ITokenColorCustomizations {
307 const tokenColorCustomization = this.configurationService.getValue<ITokenColorCustomizations>(ThemeSettings.TOKEN_COLOR_CUSTOMIZATIONS) || {};
308 const textMateRules = tokenColorCustomization.textMateRules;
330 return updatedTokenColorCustomization;
331 }
333 > public get semanticTokenColorCustomizations(): ISemanticTokenColorCustomizations | undefined {
334 return this.configurationService.getValue<ISemanticTokenColorCustomizations>(ThemeSettings.SEMANTIC_TOKEN_COLOR_CUSTOMIZATIONS);
335 }
337 > public getPreferredColorScheme(): ColorScheme | undefined {
338 if (this.configurationService.getValue(ThemeSettings.DETECT_HC) && this.hostColorService.highContrast) {
339 return this.hostColorService.dark ? ColorScheme.HIGH_CONTRAST_DARK : ColorScheme.HIGH_CONTRAST_LIGHT;
344 return undefined;
345 }
347 > public isDetectingHighContrast(): boolean {
348 return this.configurationService.getValue(ThemeSettings.DETECT_HC);
349 }
351 > public isDetectingColorScheme(): boolean {
352 return this.configurationService.getValue(ThemeSettings.DETECT_COLOR_SCHEME);
353 }
355 > public isPreferredColorSchemeChange(previous: IColorScheme): boolean {
356 const darkChanged = previous.dark !== this.hostColorService.dark;
357 if (this.isDetectingColorScheme() && darkChanged) {
363 return false;
364 }
366 > public getColorThemeSettingId(): ThemeSettings {
367 const preferredScheme = this.getPreferredColorScheme();
368 return preferredScheme ? colorSchemeToPreferred[preferredScheme] : ThemeSettings.COLOR_THEME;
369 }
371 > public async setColorTheme(theme: IWorkbenchColorTheme, settingsTarget: ThemeSettingTarget): Promise<IWorkbenchColorTheme> {
372 await this.writeConfiguration(this.getColorThemeSettingId(), theme.settingsId, settingsTarget);
373 return theme;
374 }
376 > public async setFileIconTheme(theme: IWorkbenchFileIconTheme, settingsTarget: ThemeSettingTarget): Promise<IWorkbenchFileIconTheme> {
377 await this.writeConfiguration(ThemeSettings.FILE_ICON_THEME, theme.settingsId, settingsTarget);
378 return theme;
379 }
381 > public async setProductIconTheme(theme: IWorkbenchProductIconTheme, settingsTarget: ThemeSettingTarget): Promise<IWorkbenchProductIconTheme> {
382 await this.writeConfiguration(ThemeSettings.PRODUCT_ICON_THEME, theme.settingsId, settingsTarget);
383 return theme;
384 }
386 > public isDefaultColorTheme(): boolean {
387 const settings = this.configurationService.inspect(this.getColorThemeSettingId());
388 return settings && settings.default?.value === settings.value;
389 }
391 > public findAutoConfigurationTarget(key: string) {
392 const settings = this.configurationService.inspect(key);
393 if (!types.isUndefined(settings.workspaceFolderValue)) {
400 return ConfigurationTarget.USER;
401 }
403 > private async writeConfiguration(key: string, value: unknown, settingsTarget: ThemeSettingTarget): Promise<void> {
404 if (settingsTarget === undefined || settingsTarget === 'preview') {
405 return;
427 return this.configurationService.updateValue(key, value, settingsTarget);
428 }
src/vs/workbench/services/themes/common/colorThemeSchema.ts 269 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- colorThemeSchema.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 > import * as nls from '../../../../nls.js';
6 >
7 > import { Registry } from '../../../../platform/registry/common/platform.js';
8 > import { Extensions as JSONExtensions, IJSONContributionRegistry } from '../../../../platform/jsonschemas/common/jsonContributionRegistry.js';
9 > import { IJSONSchema } from '../../../../base/common/jsonSchema.js';
10 >
11 > import { workbenchColorsSchemaId } from '../../../../platform/theme/common/colorRegistry.js';
12 > import { tokenStylingSchemaId } from '../../../../platform/theme/common/tokenClassificationRegistry.js';
13 >
14 > const textMateScopes = [
15 > 'comment',
16 > 'comment.block',
17 > 'comment.block.documentation',
18 > 'comment.line',
19 > 'constant',
20 > 'constant.character',
21 > 'constant.character.escape',
22 > 'constant.numeric',
23 > 'constant.numeric.integer',
24 > 'constant.numeric.float',
25 > 'constant.numeric.hex',
26 > 'constant.numeric.octal',
27 > 'constant.other',
28 > 'constant.regexp',
29 > 'constant.rgb-value',
30 > 'emphasis',
31 > 'entity',
32 > 'entity.name',
33 > 'entity.name.class',
34 > 'entity.name.function',
35 > 'entity.name.method',
36 > 'entity.name.section',
37 > 'entity.name.selector',
38 > 'entity.name.tag',
39 > 'entity.name.type',
40 > 'entity.other',
41 > 'entity.other.attribute-name',
42 > 'entity.other.inherited-class',
43 > 'invalid',
44 > 'invalid.deprecated',
45 > 'invalid.illegal',
46 > 'keyword',
47 > 'keyword.control',
48 > 'keyword.operator',
49 > 'keyword.operator.new',
50 > 'keyword.operator.assignment',
51 > 'keyword.operator.arithmetic',
52 > 'keyword.operator.logical',
53 > 'keyword.other',
54 > 'markup',
55 > 'markup.bold',
56 > 'markup.changed',
57 > 'markup.deleted',
58 > 'markup.heading',
59 > 'markup.inline.raw',
60 > 'markup.inserted',
61 > 'markup.italic',
62 > 'markup.list',
63 > 'markup.list.numbered',
64 > 'markup.list.unnumbered',
65 > 'markup.other',
66 > 'markup.quote',
67 > 'markup.raw',
68 > 'markup.underline',
69 > 'markup.underline.link',
70 > 'meta',
71 > 'meta.block',
72 > 'meta.cast',
73 > 'meta.class',
74 > 'meta.function',
75 > 'meta.function-call',
76 > 'meta.preprocessor',
77 > 'meta.return-type',
78 > 'meta.selector',
79 > 'meta.tag',
80 > 'meta.type.annotation',
81 > 'meta.type',
82 > 'punctuation.definition.string.begin',
83 > 'punctuation.definition.string.end',
84 > 'punctuation.separator',
85 > 'punctuation.separator.continuation',
86 > 'punctuation.terminator',
87 > 'storage',
88 > 'storage.modifier',
89 > 'storage.type',
90 > 'string',
91 > 'string.interpolated',
92 > 'string.other',
93 > 'string.quoted',
94 > 'string.quoted.double',
95 > 'string.quoted.other',
96 > 'string.quoted.single',
97 > 'string.quoted.triple',
98 > 'string.regexp',
99 > 'string.unquoted',
100 > 'strong',
101 > 'support',
102 > 'support.class',
103 > 'support.constant',
104 > 'support.function',
105 > 'support.other',
106 > 'support.type',
107 > 'support.type.property-name',
108 > 'support.variable',
109 > 'variable',
110 > 'variable.language',
111 > 'variable.name',
112 > 'variable.other',
113 > 'variable.other.readwrite',
114 > 'variable.parameter'
115 > ];
116 >
117 > export const textmateColorsSchemaId = 'vscode://schemas/textmate-colors';
118 > export const textmateColorGroupSchemaId = `${textmateColorsSchemaId}#/definitions/colorGroup`;
119 >
120 > const textmateColorSchema: IJSONSchema = {
121 > type: 'array',
122 > definitions: {
123 > colorGroup: {
124 > default: '#FF0000',
125 > anyOf: [
126 > {
127 > type: 'string',
128 > format: 'color-hex'
129 > },
130 > {
131 > $ref: '#/definitions/settings'
132 > }
133 > ]
134 > },
135 > settings: {
136 > type: 'object',
137 > description: nls.localize('schema.token.settings', 'Colors and styles for the token.'),
138 > properties: {
139 > foreground: {
140 > type: 'string',
141 > description: nls.localize('schema.token.foreground', 'Foreground color for the token.'),
142 > format: 'color-hex',
143 > default: '#ff0000'
144 > },
145 > background: {
146 > type: 'string',
147 > deprecationMessage: nls.localize('schema.token.background.warning', 'Token background colors are currently not supported.')
148 > },
149 > fontStyle: {
150 > type: 'string',
151 > description: nls.localize('schema.token.fontStyle', 'Font style of the rule: \'italic\', \'bold\', \'underline\', \'strikethrough\' or a combination. The empty string unsets inherited settings.'),
152 > pattern: '^(\\s*\\b(italic|bold|underline|strikethrough))*\\s*$',
153 > patternErrorMessage: nls.localize('schema.fontStyle.error', 'Font style must be \'italic\', \'bold\', \'underline\', \'strikethrough\' or a combination or the empty string.'),
154 > defaultSnippets: [
155 > { label: nls.localize('schema.token.fontStyle.none', 'None (clear inherited style)'), bodyText: '""' },
156 > { body: 'italic' },
157 > { body: 'bold' },
158 > { body: 'underline' },
159 > { body: 'strikethrough' },
160 > { body: 'italic bold' },
161 > { body: 'italic underline' },
162 > { body: 'italic strikethrough' },
163 > { body: 'bold underline' },
164 > { body: 'bold strikethrough' },
165 > { body: 'underline strikethrough' },
166 > { body: 'italic bold underline' },
167 > { body: 'italic bold strikethrough' },
168 > { body: 'italic underline strikethrough' },
169 > { body: 'bold underline strikethrough' },
170 > { body: 'italic bold underline strikethrough' }
171 > ]
172 > },
173 > fontFamily: {
174 > type: 'string',
175 > description: nls.localize('schema.token.fontFamily', 'Font family for the token (e.g., "Fira Code", "JetBrains Mono").')
176 > },
177 > fontSize: {
178 > type: 'number',
179 > description: nls.localize('schema.token.fontSize', 'Font size multiplier for the token (e.g., 1.2 will use 1.2 times the default font size).')
180 > },
181 > lineHeight: {
182 > type: 'number',
183 > description: nls.localize('schema.token.lineHeight', 'Line height multiplier for the token (e.g., 1.2 will use 1.2 times the default height). If the font size is set and the line height is not explicitly set, the line height will be computed based on the font size.')
184 > }
185 > },
186 > additionalProperties: false,
187 > defaultSnippets: [{ body: { foreground: '${1:#FF0000}', fontStyle: '${2:bold}' } }]
188 > }
189 > },
190 > items: {
191 > type: 'object',
192 > defaultSnippets: [{ body: { scope: '${1:keyword.operator}', settings: { foreground: '${2:#FF0000}' } } }],
193 > properties: {
194 > name: {
195 > type: 'string',
196 > description: nls.localize('schema.properties.name', 'Description of the rule.')
197 > },
198 > scope: {
199 > description: nls.localize('schema.properties.scope', 'Scope selector against which this rule matches.'),
200 > anyOf: [
201 > {
202 > enum: textMateScopes
203 > },
204 > {
205 > type: 'string'
206 > },
207 > {
208 > type: 'array',
209 > items: {
210 > enum: textMateScopes
211 > }
212 > },
213 > {
214 > type: 'array',
215 > items: {
216 > type: 'string'
217 > }
218 > }
219 > ]
220 > },
221 > settings: {
222 > $ref: '#/definitions/settings'
223 > }
224 > },
225 > required: [
226 > 'settings'
227 > ],
228 > additionalProperties: false
229 > }
230 > };
231 >
232 > export const colorThemeSchemaId = 'vscode://schemas/color-theme';
233 >
234 > const colorThemeSchema: IJSONSchema = {
235 > type: 'object',
236 > allowComments: true,
237 > allowTrailingCommas: true,
238 > properties: {
239 > colors: {
240 > description: nls.localize('schema.workbenchColors', 'Colors in the workbench'),
241 > $ref: workbenchColorsSchemaId,
242 > additionalProperties: false
243 > },
244 > tokenColors: {
245 > anyOf: [{
246 > type: 'string',
247 > description: nls.localize('schema.tokenColors.path', 'Path to a tmTheme file (relative to the current file).')
248 > },
249 > {
250 > description: nls.localize('schema.colors', 'Colors for syntax highlighting'),
251 > $ref: textmateColorsSchemaId
252 > }
253 > ]
254 > },
255 > semanticHighlighting: {
256 > type: 'boolean',
257 > description: nls.localize('schema.supportsSemanticHighlighting', 'Whether semantic highlighting should be enabled for this theme.')
258 > },
259 > semanticTokenColors: {
260 > type: 'object',
261 > description: nls.localize('schema.semanticTokenColors', 'Colors for semantic tokens'),
262 > $ref: tokenStylingSchemaId
263 > }
264 > }
265 > };
266 >
267 >
268 >
269 > export function registerColorThemeSchemas() {
270 const schemaRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
271 schemaRegistry.registerSchema(colorThemeSchemaId, colorThemeSchema);