tokenClassificationRegistry.ts ×28

Frontier kind: Code frontier

unlabeled · c_2afedeaca979

11 tests · 12542 LOC · 59 files · introduces 0 tests · 983 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
33 ranges983 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1393 ranges12542 lines · 59 files · Browse complete extent
All tests (intent)
11 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: 983 introduced LOC across 33 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/themes/common/workbenchThemeService.ts 518 introduced LOC · 5 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- workbenchThemeService.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 { refineServiceDecorator } from '../../../../platform/instantiation/common/instantiation.js';
7 > import { Event } from '../../../../base/common/event.js';
8 > import { Color } from '../../../../base/common/color.js';
9 > import { IColorTheme, IThemeService, IFileIconTheme, IProductIconTheme } from '../../../../platform/theme/common/themeService.js';
10 > import { ConfigurationTarget } from '../../../../platform/configuration/common/configuration.js';
11 > import { isBoolean, isString } from '../../../../base/common/types.js';
12 > import { IconContribution, IconDefinition } from '../../../../platform/theme/common/iconRegistry.js';
13 > import { ColorScheme, ThemeTypeSelector } from '../../../../platform/theme/common/theme.js';
14 >
15 > export const IWorkbenchThemeService = refineServiceDecorator<IThemeService, IWorkbenchThemeService>(IThemeService);
16 >
17 > export const THEME_SCOPE_OPEN_PAREN = '[';
18 > export const THEME_SCOPE_CLOSE_PAREN = ']';
19 > export const THEME_SCOPE_WILDCARD = '*';
20 >
21 > export const themeScopeRegex = /\[(.+?)\]/g;
22 >
23 > export enum ThemeSettings {
24 > COLOR_THEME = 'workbench.colorTheme',
25 > FILE_ICON_THEME = 'workbench.iconTheme',
26 > PRODUCT_ICON_THEME = 'workbench.productIconTheme',
27 > COLOR_CUSTOMIZATIONS = 'workbench.colorCustomizations',
28 > TOKEN_COLOR_CUSTOMIZATIONS = 'editor.tokenColorCustomizations',
29 > SEMANTIC_TOKEN_COLOR_CUSTOMIZATIONS = 'editor.semanticTokenColorCustomizations',
30 >
31 > PREFERRED_DARK_THEME = 'workbench.preferredDarkColorTheme',
32 > PREFERRED_LIGHT_THEME = 'workbench.preferredLightColorTheme',
33 > PREFERRED_HC_DARK_THEME = 'workbench.preferredHighContrastColorTheme', /* id kept for compatibility reasons */
34 > PREFERRED_HC_LIGHT_THEME = 'workbench.preferredHighContrastLightColorTheme',
35 > DETECT_COLOR_SCHEME = 'window.autoDetectColorScheme',
36 > DETECT_HC = 'window.autoDetectHighContrast',
37 >
38 > SYSTEM_COLOR_THEME = 'window.systemColorTheme'
39 > }
40 >
41 > export namespace ThemeSettingDefaults {
42 > export const COLOR_THEME_DARK = 'Dark 2026';
43 > export const COLOR_THEME_LIGHT = 'Light 2026';
44 > export const COLOR_THEME_HC_DARK = 'Default High Contrast';
45 > export const COLOR_THEME_HC_LIGHT = 'Default High Contrast Light';
46 >
47 > export const FILE_ICON_THEME = 'vs-seti';
48 > export const PRODUCT_ICON_THEME = 'Default';
49 > }
50 >
51 > /**
52 > * Migrates legacy theme settings IDs to their current equivalents.
53 > * Theme IDs were simplified: "Default" prefix was removed from built-in themes,
54 > * and "Experimental" prefix was replaced when VS Code themes became GA.
55 > */
56 > export function migrateThemeSettingsId(settingsId: string): string {
57 switch (settingsId) {
58 case 'Default Dark Modern': return 'Dark Modern';
69 return settingsId;
70 }
72 > export const COLOR_THEME_DARK_INITIAL_COLORS = {
73 > 'actionBar.toggledBackground': '#383a49',
74 > 'activityBar.activeBorder': '#0078D4',
75 > 'activityBar.background': '#181818',
76 > 'activityBar.border': '#2B2B2B',
77 > 'activityBar.foreground': '#D7D7D7',
78 > 'activityBar.inactiveForeground': '#868686',
79 > 'activityBarBadge.background': '#0078D4',
80 > 'activityBarBadge.foreground': '#FFFFFF',
81 > 'badge.background': '#616161',
82 > 'badge.foreground': '#F8F8F8',
83 > 'button.background': '#0078D4',
84 > 'button.border': '#FFFFFF12',
85 > 'button.foreground': '#FFFFFF',
86 > 'button.hoverBackground': '#026EC1',
87 > 'button.secondaryBackground': '#313131',
88 > 'button.secondaryForeground': '#CCCCCC',
89 > 'button.secondaryHoverBackground': '#3C3C3C',
90 > 'chat.slashCommandBackground': '#26477866',
91 > 'chat.slashCommandForeground': '#85B6FF',
92 > 'chat.editedFileForeground': '#E2C08D',
93 > 'checkbox.background': '#313131',
94 > 'checkbox.border': '#3C3C3C',
95 > 'debugToolBar.background': '#181818',
96 > 'descriptionForeground': '#9D9D9D',
97 > 'dropdown.background': '#313131',
98 > 'dropdown.border': '#3C3C3C',
99 > 'dropdown.foreground': '#CCCCCC',
100 > 'dropdown.listBackground': '#1F1F1F',
101 > 'editor.background': '#1F1F1F',
102 > 'editor.findMatchBackground': '#9E6A03',
103 > 'editor.foreground': '#CCCCCC',
104 > 'editor.inactiveSelectionBackground': '#3A3D41',
105 > 'editor.selectionHighlightBackground': '#ADD6FF26',
106 > 'editorGroup.border': '#FFFFFF17',
107 > 'editorGroupHeader.tabsBackground': '#181818',
108 > 'editorGroupHeader.tabsBorder': '#2B2B2B',
109 > 'editorGutter.addedBackground': '#2EA043',
110 > 'editorGutter.deletedBackground': '#F85149',
111 > 'editorGutter.modifiedBackground': '#0078D4',
112 > 'editorIndentGuide.activeBackground1': '#707070',
113 > 'editorIndentGuide.background1': '#404040',
114 > 'editorLineNumber.activeForeground': '#CCCCCC',
115 > 'editorLineNumber.foreground': '#6E7681',
116 > 'editorOverviewRuler.border': '#010409',
117 > 'editorWidget.background': '#202020',
118 > 'errorForeground': '#F85149',
119 > 'focusBorder': '#0078D4',
120 > 'foreground': '#CCCCCC',
121 > 'icon.foreground': '#CCCCCC',
122 > 'input.background': '#313131',
123 > 'input.border': '#3C3C3C',
124 > 'input.foreground': '#CCCCCC',
125 > 'input.placeholderForeground': '#989898',
126 > 'inputOption.activeBackground': '#2489DB82',
127 > 'inputOption.activeBorder': '#2488DB',
128 > 'keybindingLabel.foreground': '#CCCCCC',
129 > 'list.activeSelectionIconForeground': '#FFF',
130 > 'list.dropBackground': '#383B3D',
131 > 'menu.background': '#1F1F1F',
132 > 'menu.border': '#454545',
133 > 'menu.foreground': '#CCCCCC',
134 > 'menu.selectionBackground': '#0078d4',
135 > 'menu.separatorBackground': '#454545',
136 > 'notificationCenterHeader.background': '#1F1F1F',
137 > 'notificationCenterHeader.foreground': '#CCCCCC',
138 > 'notifications.background': '#1F1F1F',
139 > 'notifications.border': '#2B2B2B',
140 > 'notifications.foreground': '#CCCCCC',
141 > 'panel.background': '#181818',
142 > 'panel.border': '#2B2B2B',
143 > 'panelInput.border': '#2B2B2B',
144 > 'panelTitle.activeBorder': '#0078D4',
145 > 'panelTitle.activeForeground': '#CCCCCC',
146 > 'panelTitle.inactiveForeground': '#9D9D9D',
147 > 'peekViewEditor.background': '#1F1F1F',
148 > 'peekViewEditor.matchHighlightBackground': '#BB800966',
149 > 'peekViewResult.background': '#1F1F1F',
150 > 'peekViewResult.matchHighlightBackground': '#BB800966',
151 > 'pickerGroup.border': '#3C3C3C',
152 > 'ports.iconRunningProcessForeground': '#369432',
153 > 'progressBar.background': '#0078D4',
154 > 'quickInput.background': '#222222',
155 > 'quickInput.foreground': '#CCCCCC',
156 > 'settings.dropdownBackground': '#313131',
157 > 'settings.dropdownBorder': '#3C3C3C',
158 > 'settings.headerForeground': '#FFFFFF',
159 > 'settings.modifiedItemIndicator': '#BB800966',
160 > 'sideBar.background': '#181818',
161 > 'sideBar.border': '#2B2B2B',
162 > 'sideBar.foreground': '#CCCCCC',
163 > 'sideBarSectionHeader.background': '#181818',
164 > 'sideBarSectionHeader.border': '#2B2B2B',
165 > 'sideBarSectionHeader.foreground': '#CCCCCC',
166 > 'sideBarTitle.foreground': '#CCCCCC',
167 > 'statusBar.background': '#181818',
168 > 'statusBar.border': '#2B2B2B',
169 > 'statusBar.debuggingBackground': '#0078D4',
170 > 'statusBar.debuggingForeground': '#FFFFFF',
171 > 'statusBar.focusBorder': '#0078D4',
172 > 'statusBar.foreground': '#CCCCCC',
173 > 'statusBar.noFolderBackground': '#1F1F1F',
174 > 'statusBarItem.focusBorder': '#0078D4',
175 > 'statusBarItem.prominentBackground': '#6E768166',
176 > 'statusBarItem.remoteBackground': '#0078D4',
177 > 'statusBarItem.remoteForeground': '#FFFFFF',
178 > 'tab.activeBackground': '#1F1F1F',
179 > 'tab.activeBorder': '#1F1F1F',
180 > 'tab.activeBorderTop': '#0078D4',
181 > 'tab.activeForeground': '#FFFFFF',
182 > 'tab.border': '#2B2B2B',
183 > 'tab.hoverBackground': '#1F1F1F',
184 > 'tab.inactiveBackground': '#181818',
185 > 'tab.inactiveForeground': '#9D9D9D',
186 > 'tab.lastPinnedBorder': '#ccc3',
187 > 'tab.selectedBackground': '#37373D',
188 > 'tab.selectedBorderTop': '#6caddf',
189 > 'tab.selectedForeground': '#FFFFFF',
190 > 'tab.unfocusedActiveBorder': '#1F1F1F',
191 > 'tab.unfocusedActiveBorderTop': '#2B2B2B',
192 > 'tab.unfocusedHoverBackground': '#1F1F1F',
193 > 'terminal.foreground': '#CCCCCC',
194 > 'terminal.inactiveSelectionBackground': '#3A3D41',
195 > 'terminal.tab.activeBorder': '#0078D4',
196 > 'textBlockQuote.background': '#2B2B2B',
197 > 'textBlockQuote.border': '#616161',
198 > 'textCodeBlock.background': '#2B2B2B',
199 > 'textLink.activeForeground': '#4daafc',
200 > 'textLink.foreground': '#4daafc',
201 > 'textPreformat.background': '#3C3C3C',
202 > 'textPreformat.foreground': '#D0D0D0',
203 > 'textSeparator.foreground': '#21262D',
204 > 'titleBar.activeBackground': '#181818',
205 > 'titleBar.activeForeground': '#CCCCCC',
206 > 'titleBar.border': '#2B2B2B',
207 > 'titleBar.inactiveBackground': '#1F1F1F',
208 > 'titleBar.inactiveForeground': '#9D9D9D',
209 > 'welcomePage.progress.foreground': '#0078D4',
210 > 'welcomePage.tileBackground': '#2B2B2B',
211 > 'widget.border': '#313131'
212 > };
213 >
214 > export const COLOR_THEME_LIGHT_INITIAL_COLORS = {
215 > 'actionBar.toggledBackground': '#dddddd',
216 > 'activityBar.activeBorder': '#005FB8',
217 > 'activityBar.background': '#F8F8F8',
218 > 'activityBar.border': '#E5E5E5',
219 > 'activityBar.foreground': '#1F1F1F',
220 > 'activityBar.inactiveForeground': '#616161',
221 > 'activityBarBadge.background': '#005FB8',
222 > 'activityBarBadge.foreground': '#FFFFFF',
223 > 'badge.background': '#CCCCCC',
224 > 'badge.foreground': '#3B3B3B',
225 > 'button.background': '#005FB8',
226 > 'button.border': '#0000001a',
227 > 'button.foreground': '#FFFFFF',
228 > 'button.hoverBackground': '#0258A8',
229 > 'button.secondaryBackground': '#E5E5E5',
230 > 'button.secondaryForeground': '#3B3B3B',
231 > 'button.secondaryHoverBackground': '#CCCCCC',
232 > 'chat.slashCommandBackground': '#ADCEFF7A',
233 > 'chat.slashCommandForeground': '#26569E',
234 > 'chat.editedFileForeground': '#895503',
235 > 'checkbox.background': '#F8F8F8',
236 > 'checkbox.border': '#CECECE',
237 > 'descriptionForeground': '#3B3B3B',
238 > 'diffEditor.unchangedRegionBackground': '#f8f8f8',
239 > 'dropdown.background': '#FFFFFF',
240 > 'dropdown.border': '#CECECE',
241 > 'dropdown.foreground': '#3B3B3B',
242 > 'dropdown.listBackground': '#FFFFFF',
243 > 'editor.background': '#FFFFFF',
244 > 'editor.foreground': '#3B3B3B',
245 > 'editor.inactiveSelectionBackground': '#E5EBF1',
246 > 'editor.selectionHighlightBackground': '#ADD6FF80',
247 > 'editorGroup.border': '#E5E5E5',
248 > 'editorGroupHeader.tabsBackground': '#F8F8F8',
249 > 'editorGroupHeader.tabsBorder': '#E5E5E5',
250 > 'editorGutter.addedBackground': '#2EA043',
251 > 'editorGutter.deletedBackground': '#F85149',
252 > 'editorGutter.modifiedBackground': '#005FB8',
253 > 'editorIndentGuide.activeBackground1': '#939393',
254 > 'editorIndentGuide.background1': '#D3D3D3',
255 > 'editorLineNumber.activeForeground': '#171184',
256 > 'editorLineNumber.foreground': '#6E7681',
257 > 'editorOverviewRuler.border': '#E5E5E5',
258 > 'editorSuggestWidget.background': '#F8F8F8',
259 > 'editorWidget.background': '#F8F8F8',
260 > 'errorForeground': '#F85149',
261 > 'focusBorder': '#005FB8',
262 > 'foreground': '#3B3B3B',
263 > 'icon.foreground': '#3B3B3B',
264 > 'input.background': '#FFFFFF',
265 > 'input.border': '#CECECE',
266 > 'input.foreground': '#3B3B3B',
267 > 'input.placeholderForeground': '#767676',
268 > 'inputOption.activeBackground': '#BED6ED',
269 > 'inputOption.activeBorder': '#005FB8',
270 > 'inputOption.activeForeground': '#000000',
271 > 'keybindingLabel.foreground': '#3B3B3B',
272 > 'list.activeSelectionBackground': '#E8E8E8',
273 > 'list.activeSelectionForeground': '#000000',
274 > 'list.activeSelectionIconForeground': '#000000',
275 > 'list.focusAndSelectionOutline': '#005FB8',
276 > 'list.hoverBackground': '#F2F2F2',
277 > 'menu.border': '#CECECE',
278 > 'menu.selectionBackground': '#005FB8',
279 > 'menu.selectionForeground': '#ffffff',
280 > 'notebook.cellBorderColor': '#E5E5E5',
281 > 'notebook.selectedCellBackground': '#C8DDF150',
282 > 'notificationCenterHeader.background': '#FFFFFF',
283 > 'notificationCenterHeader.foreground': '#3B3B3B',
284 > 'notifications.background': '#FFFFFF',
285 > 'notifications.border': '#E5E5E5',
286 > 'notifications.foreground': '#3B3B3B',
287 > 'panel.background': '#F8F8F8',
288 > 'panel.border': '#E5E5E5',
289 > 'panelInput.border': '#E5E5E5',
290 > 'panelTitle.activeBorder': '#005FB8',
291 > 'panelTitle.activeForeground': '#3B3B3B',
292 > 'panelTitle.inactiveForeground': '#3B3B3B',
293 > 'peekViewEditor.matchHighlightBackground': '#BB800966',
294 > 'peekViewResult.background': '#FFFFFF',
295 > 'peekViewResult.matchHighlightBackground': '#BB800966',
296 > 'pickerGroup.border': '#E5E5E5',
297 > 'pickerGroup.foreground': '#8B949E',
298 > 'ports.iconRunningProcessForeground': '#369432',
299 > 'progressBar.background': '#005FB8',
300 > 'quickInput.background': '#F8F8F8',
301 > 'quickInput.foreground': '#3B3B3B',
302 > 'searchEditor.textInputBorder': '#CECECE',
303 > 'settings.dropdownBackground': '#FFFFFF',
304 > 'settings.dropdownBorder': '#CECECE',
305 > 'settings.headerForeground': '#1F1F1F',
306 > 'settings.modifiedItemIndicator': '#BB800966',
307 > 'settings.numberInputBorder': '#CECECE',
308 > 'settings.textInputBorder': '#CECECE',
309 > 'sideBar.background': '#F8F8F8',
310 > 'sideBar.border': '#E5E5E5',
311 > 'sideBar.foreground': '#3B3B3B',
312 > 'sideBarSectionHeader.background': '#F8F8F8',
313 > 'sideBarSectionHeader.border': '#E5E5E5',
314 > 'sideBarSectionHeader.foreground': '#3B3B3B',
315 > 'sideBarTitle.foreground': '#3B3B3B',
316 > 'statusBar.background': '#F8F8F8',
317 > 'statusBar.border': '#E5E5E5',
318 > 'statusBar.debuggingBackground': '#FD716C',
319 > 'statusBar.debuggingForeground': '#000000',
320 > 'statusBar.focusBorder': '#005FB8',
321 > 'statusBar.foreground': '#3B3B3B',
322 > 'statusBar.noFolderBackground': '#F8F8F8',
323 > 'statusBarItem.compactHoverBackground': '#CCCCCC',
324 > 'statusBarItem.errorBackground': '#C72E0F',
325 > 'statusBarItem.focusBorder': '#005FB8',
326 > 'statusBarItem.hoverBackground': '#B8B8B850',
327 > 'statusBarItem.prominentBackground': '#6E768166',
328 > 'statusBarItem.remoteBackground': '#005FB8',
329 > 'statusBarItem.remoteForeground': '#FFFFFF',
330 > 'tab.activeBackground': '#FFFFFF',
331 > 'tab.activeBorder': '#F8F8F8',
332 > 'tab.activeBorderTop': '#005FB8',
333 > 'tab.activeForeground': '#3B3B3B',
334 > 'tab.border': '#E5E5E5',
335 > 'tab.hoverBackground': '#FFFFFF',
336 > 'tab.inactiveBackground': '#F8F8F8',
337 > 'tab.inactiveForeground': '#868686',
338 > 'tab.lastPinnedBorder': '#D4D4D4',
339 > 'tab.selectedBackground': '#E4E6F1',
340 > 'tab.selectedBorderTop': '#68a3da',
341 > 'tab.selectedForeground': '#333333',
342 > 'tab.unfocusedActiveBorder': '#F8F8F8',
343 > 'tab.unfocusedActiveBorderTop': '#E5E5E5',
344 > 'tab.unfocusedHoverBackground': '#F8F8F8',
345 > 'terminal.foreground': '#3B3B3B',
346 > 'terminal.inactiveSelectionBackground': '#E5EBF1',
347 > 'terminal.tab.activeBorder': '#005FB8',
348 > 'terminalCursor.foreground': '#005FB8',
349 > 'textBlockQuote.background': '#F8F8F8',
350 > 'textBlockQuote.border': '#E5E5E5',
351 > 'textCodeBlock.background': '#F8F8F8',
352 > 'textLink.activeForeground': '#005FB8',
353 > 'textLink.foreground': '#005FB8',
354 > 'textPreformat.background': '#0000001F',
355 > 'textPreformat.foreground': '#3B3B3B',
356 > 'textSeparator.foreground': '#21262D',
357 > 'titleBar.activeBackground': '#F8F8F8',
358 > 'titleBar.activeForeground': '#1E1E1E',
359 > 'titleBar.border': '#E5E5E5',
360 > 'titleBar.inactiveBackground': '#F8F8F8',
361 > 'titleBar.inactiveForeground': '#8B949E',
362 > 'welcomePage.tileBackground': '#F3F3F3',
363 > 'widget.border': '#E5E5E5'
364 > };
365 >
366 > export interface IWorkbenchTheme {
367 > readonly id: string;
368 > readonly label: string;
369 > readonly extensionData?: ExtensionData;
370 > readonly description?: string;
371 > readonly settingsId: string | null;
372 > }
373 >
374 > export interface IWorkbenchColorTheme extends IWorkbenchTheme, IColorTheme {
375 > readonly settingsId: string;
376 > readonly tokenColors: ITextMateThemingRule[];
377 > }
378 >
379 > export interface IColorMap {
380 > [id: string]: Color;
381 > }
382 >
383 > export interface IWorkbenchFileIconTheme extends IWorkbenchTheme, IFileIconTheme {
384 > }
385 >
386 > export interface IWorkbenchProductIconTheme extends IWorkbenchTheme, IProductIconTheme {
387 > readonly settingsId: string;
388 >
389 > getIcon(icon: IconContribution): IconDefinition | undefined;
390 > }
391 >
392 > export type ThemeSettingTarget = ConfigurationTarget | undefined | 'auto' | 'preview';
393 >
394 >
395 > export interface IWorkbenchThemeService extends IThemeService {
396 > readonly _serviceBrand: undefined;
397 > setColorTheme(themeId: string | undefined | IWorkbenchColorTheme, settingsTarget: ThemeSettingTarget): Promise<IWorkbenchColorTheme | null>;
398 > getColorTheme(): IWorkbenchColorTheme;
399 > getColorThemes(): Promise<IWorkbenchColorTheme[]>;
400 > getMarketplaceColorThemes(publisher: string, name: string, version: string): Promise<IWorkbenchColorTheme[]>;
401 > readonly onDidColorThemeChange: Event<IWorkbenchColorTheme>;
402 >
403 > getPreferredColorScheme(): ColorScheme | undefined;
404 >
405 > setFileIconTheme(iconThemeId: string | undefined | IWorkbenchFileIconTheme, settingsTarget: ThemeSettingTarget): Promise<IWorkbenchFileIconTheme>;
406 > getFileIconTheme(): IWorkbenchFileIconTheme;
407 > getFileIconThemes(): Promise<IWorkbenchFileIconTheme[]>;
408 > getMarketplaceFileIconThemes(publisher: string, name: string, version: string): Promise<IWorkbenchFileIconTheme[]>;
409 > readonly onDidFileIconThemeChange: Event<IWorkbenchFileIconTheme>;
410 >
411 > setProductIconTheme(iconThemeId: string | undefined | IWorkbenchProductIconTheme, settingsTarget: ThemeSettingTarget): Promise<IWorkbenchProductIconTheme>;
412 > getProductIconTheme(): IWorkbenchProductIconTheme;
413 > getProductIconThemes(): Promise<IWorkbenchProductIconTheme[]>;
414 > getMarketplaceProductIconThemes(publisher: string, name: string, version: string): Promise<IWorkbenchProductIconTheme[]>;
415 > readonly onDidProductIconThemeChange: Event<IWorkbenchProductIconTheme>;
416 > }
417 >
418 > export interface IThemeScopedColorCustomizations {
419 > [colorId: string]: string;
420 > }
421 >
422 > export interface IColorCustomizations {
423 > [colorIdOrThemeScope: string]: IThemeScopedColorCustomizations | string;
424 > }
425 >
426 > export interface IThemeScopedTokenColorCustomizations {
427 > [groupId: string]: ITextMateThemingRule[] | ITokenColorizationSetting | boolean | string | undefined;
428 > comments?: string | ITokenColorizationSetting;
429 > strings?: string | ITokenColorizationSetting;
430 > numbers?: string | ITokenColorizationSetting;
431 > keywords?: string | ITokenColorizationSetting;
432 > types?: string | ITokenColorizationSetting;
433 > functions?: string | ITokenColorizationSetting;
434 > variables?: string | ITokenColorizationSetting;
435 > textMateRules?: ITextMateThemingRule[];
436 > semanticHighlighting?: boolean; // deprecated, use ISemanticTokenColorCustomizations.enabled instead
437 > }
438 >
439 > export interface ITokenColorCustomizations {
440 > [groupIdOrThemeScope: string]: IThemeScopedTokenColorCustomizations | ITextMateThemingRule[] | ITokenColorizationSetting | boolean | string | undefined;
441 > comments?: string | ITokenColorizationSetting;
442 > strings?: string | ITokenColorizationSetting;
443 > numbers?: string | ITokenColorizationSetting;
444 > keywords?: string | ITokenColorizationSetting;
445 > types?: string | ITokenColorizationSetting;
446 > functions?: string | ITokenColorizationSetting;
447 > variables?: string | ITokenColorizationSetting;
448 > textMateRules?: ITextMateThemingRule[];
449 > semanticHighlighting?: boolean; // deprecated, use ISemanticTokenColorCustomizations.enabled instead
450 > }
451 >
452 > export interface IThemeScopedSemanticTokenColorCustomizations {
453 > [styleRule: string]: ISemanticTokenRules | boolean | undefined;
454 > enabled?: boolean;
455 > rules?: ISemanticTokenRules;
456 > }
457 >
458 > export interface ISemanticTokenColorCustomizations {
459 > [styleRuleOrThemeScope: string]: IThemeScopedSemanticTokenColorCustomizations | ISemanticTokenRules | boolean | undefined;
460 > enabled?: boolean;
461 > rules?: ISemanticTokenRules;
462 > }
463 >
464 > export interface IThemeScopedExperimentalSemanticTokenColorCustomizations {
465 > [themeScope: string]: ISemanticTokenRules | undefined;
466 > }
467 >
468 > export interface IExperimentalSemanticTokenColorCustomizations {
469 > [styleRuleOrThemeScope: string]: IThemeScopedExperimentalSemanticTokenColorCustomizations | ISemanticTokenRules | undefined;
470 > }
471 >
472 > export type IThemeScopedCustomizations =
473 > IThemeScopedColorCustomizations
474 > | IThemeScopedTokenColorCustomizations
475 > | IThemeScopedExperimentalSemanticTokenColorCustomizations
476 > | IThemeScopedSemanticTokenColorCustomizations;
477 >
478 > export type IThemeScopableCustomizations =
479 > IColorCustomizations
480 > | ITokenColorCustomizations
481 > | IExperimentalSemanticTokenColorCustomizations
482 > | ISemanticTokenColorCustomizations;
483 >
484 > export interface ISemanticTokenRules {
485 > [selector: string]: string | ISemanticTokenColorizationSetting | undefined;
486 > }
487 >
488 > export interface ITextMateThemingRule {
489 > name?: string;
490 > scope?: string | string[];
491 > settings: ITokenColorizationSetting;
492 > }
493 >
494 > export interface ITokenColorizationSetting {
495 > foreground?: string;
496 > background?: string;
497 > fontStyle?: string; /* [italic|bold|underline|strikethrough] */
498 > fontFamily?: string;
499 > fontSize?: number;
500 > lineHeight?: number;
501 > }
502 >
503 > export interface ISemanticTokenColorizationSetting {
504 > foreground?: string;
505 > fontStyle?: string; /* [italic|bold|underline|strikethrough] */
506 > bold?: boolean;
507 > underline?: boolean;
508 > strikethrough?: boolean;
509 > italic?: boolean;
510 > }
511 >
512 > export interface ExtensionData {
513 > extensionId: string;
514 > extensionPublisher: string;
515 > extensionName: string;
516 > extensionIsBuiltin: boolean;
517 > }
518 >
519 > export namespace ExtensionData {
520 > export function toJSONObject(d: ExtensionData | undefined): any {
521 return d && { _extensionId: d.extensionId, _extensionIsBuiltin: d.extensionIsBuiltin, _extensionName: d.extensionName, _extensionPublisher: d.extensionPublisher };
522 }
523 > export function fromJSONObject(o: any): ExtensionData | undefined { workbenchThemeService.ts
524 if (o && isString(o._extensionId) && isBoolean(o._extensionIsBuiltin) && isString(o._extensionName) && isString(o._extensionPublisher)) {
525 return { extensionId: o._extensionId, extensionIsBuiltin: o._extensionIsBuiltin, extensionName: o._extensionName, extensionPublisher: o._extensionPublisher };
527 return undefined;
528 }
529 > export function fromName(publisher: string, name: string, isBuiltin = false): ExtensionData { workbenchThemeService.ts
530 return { extensionPublisher: publisher, extensionId: `${publisher}.${name}`, extensionName: name, extensionIsBuiltin: isBuiltin };
531 }
533 >
534 > export interface IThemeExtensionPoint {
535 > id: string;
536 > label?: string;
537 > description?: string;
538 > path: string;
539 > uiTheme?: ThemeTypeSelector;
540 > _watch: boolean; // unsupported options to watch location
541 > }
src/vs/platform/theme/common/tokenClassificationRegistry.ts 465 introduced LOC · 28 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- tokenClassificationRegistry.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 { RunOnceScheduler } from '../../../base/common/async.js';
7 > import { Color } from '../../../base/common/color.js';
8 > import { Emitter, Event } from '../../../base/common/event.js';
9 > import { IJSONSchema, IJSONSchemaMap } from '../../../base/common/jsonSchema.js';
10 > import { Disposable } from '../../../base/common/lifecycle.js';
11 > import * as nls from '../../../nls.js';
12 > import { Extensions as JSONExtensions, IJSONContributionRegistry } from '../../jsonschemas/common/jsonContributionRegistry.js';
13 > import * as platform from '../../registry/common/platform.js';
14 > import { IColorTheme } from './themeService.js';
15 >
16 > const TOKEN_TYPE_WILDCARD = '*';
17 > const TOKEN_CLASSIFIER_LANGUAGE_SEPARATOR = ':';
18 > const CLASSIFIER_MODIFIER_SEPARATOR = '.';
19 >
20 > // qualified string [type|*](.modifier)*(/language)!
21 > type TokenClassificationString = string;
22 >
23 > const idPattern = '\\w+[-_\\w+]*';
24 > export const typeAndModifierIdPattern = `^${idPattern}$`;
25 >
26 > const selectorPattern = `^(${idPattern}|\\*)(\\${CLASSIFIER_MODIFIER_SEPARATOR}${idPattern})*(${TOKEN_CLASSIFIER_LANGUAGE_SEPARATOR}${idPattern})?$`;
27 >
28 > const fontStylePattern = '^(\\s*(italic|bold|underline|strikethrough))*\\s*$';
29 >
30 > export interface TokenSelector {
31 > match(type: string, modifiers: string[], language: string): number;
32 > readonly id: string;
33 > }
34 >
35 > export interface TokenTypeOrModifierContribution {
36 > readonly num: number;
37 > readonly id: string;
38 > readonly superType?: string;
39 > readonly description: string;
40 > readonly deprecationMessage?: string;
41 > }
42 >
43 >
44 > export interface TokenStyleData {
45 > foreground: Color | undefined;
46 > bold: boolean | undefined;
47 > underline: boolean | undefined;
48 > strikethrough: boolean | undefined;
49 > italic: boolean | undefined;
50 > }
51 >
52 > export class TokenStyle implements Readonly<TokenStyleData> {
53 > constructor(
54 public readonly foreground: Color | undefined,
55 public readonly bold: boolean | undefined,
59 ) {
60 }
62 >
63 > export namespace TokenStyle {
64 > export function toJSONObject(style: TokenStyle): any {
65 return {
66 _foreground: style.foreground === undefined ? null : Color.Format.CSS.formatHexA(style.foreground, true),
71 };
72 }
73 > export function fromJSONObject(obj: any): TokenStyle | undefined { tokenClassificationRegistry.ts
74 if (obj) {
75 const boolOrUndef = (b: any) => (typeof b === 'boolean') ? b : undefined;
85 return undefined;
86 }
87 > export function equals(s1: any, s2: any): boolean { tokenClassificationRegistry.ts
88 if (s1 === s2) {
89 return true;
96 && s1.italic === s2.italic;
97 }
98 > export function is(s: any): s is TokenStyle { tokenClassificationRegistry.ts
99 return s instanceof TokenStyle;
100 }
101 > export function fromData(data: { foreground: Color | undefined; bold: boolean | undefined; underline: boolean | undefined; strikethrough: boolean | undefined; italic: boolean | undefined }): TokenStyle { tokenClassificationRegistry.ts
102 return new TokenStyle(data.foreground, data.bold, data.underline, data.strikethrough, data.italic);
103 }
104 > export function fromSettings(foreground: string | undefined, fontStyle: string | undefined): TokenStyle; tokenClassificationRegistry.ts
105 > export function fromSettings(foreground: string | undefined, fontStyle: string | undefined, bold: boolean | undefined, underline: boolean | undefined, strikethrough: boolean | undefined, italic: boolean | undefined): TokenStyle;
106 > export function fromSettings(foreground: string | undefined, fontStyle: string | undefined, bold?: boolean, underline?: boolean, strikethrough?: boolean, italic?: boolean): TokenStyle {
107 let foregroundColor = undefined;
108 if (foreground !== undefined) {
124 return new TokenStyle(foregroundColor, bold, underline, strikethrough, italic);
125 }
127 >
128 > export type ProbeScope = string[];
129 >
130 > export interface TokenStyleFunction {
131 > (theme: IColorTheme): TokenStyle | undefined;
132 > }
133 >
134 > export interface TokenStyleDefaults {
135 > scopesToProbe?: ProbeScope[];
136 > light?: TokenStyleValue;
137 > dark?: TokenStyleValue;
138 > hcDark?: TokenStyleValue;
139 > hcLight?: TokenStyleValue;
140 > }
141 >
142 > export interface SemanticTokenDefaultRule {
143 > selector: TokenSelector;
144 > defaults: TokenStyleDefaults;
145 > }
146 >
147 > export interface SemanticTokenRule {
148 > style: TokenStyle;
149 > selector: TokenSelector;
150 > }
151 >
152 > export namespace SemanticTokenRule {
153 > export function fromJSONObject(registry: ITokenClassificationRegistry, o: any): SemanticTokenRule | undefined {
154 if (o && typeof o._selector === 'string' && o._style) {
155 const style = TokenStyle.fromJSONObject(o._style);
163 return undefined;
164 }
165 > export function toJSONObject(rule: SemanticTokenRule): any { tokenClassificationRegistry.ts
166 return {
167 _selector: rule.selector.id,
169 };
170 }
171 > export function equals(r1: SemanticTokenRule | undefined, r2: SemanticTokenRule | undefined) { tokenClassificationRegistry.ts
172 if (r1 === r2) {
173 return true;
177 && TokenStyle.equals(r1.style, r2.style);
178 }
179 > export function is(r: any): r is SemanticTokenRule { tokenClassificationRegistry.ts
180 return r && r.selector && typeof r.selector.id === 'string' && TokenStyle.is(r.style);
181 }
183 >
184 > /**
185 > * A TokenStyle Value is either a token style literal, or a TokenClassificationString
186 > */
187 > export type TokenStyleValue = TokenStyle | TokenClassificationString;
188 >
189 > // TokenStyle registry
190 > const Extensions = {
191 > TokenClassificationContribution: 'base.contributions.tokenClassification'
192 > };
193 >
194 > export interface ITokenClassificationRegistry {
195 >
196 > readonly onDidChangeSchema: Event<void>;
197 >
198 > /**
199 > * Register a token type to the registry.
200 > * @param id The TokenType id as used in theme description files
201 > * @param description the description
202 > */
203 > registerTokenType(id: string, description: string, superType?: string, deprecationMessage?: string): void;
204 >
205 > /**
206 > * Register a token modifier to the registry.
207 > * @param id The TokenModifier id as used in theme description files
208 > * @param description the description
209 > */
210 > registerTokenModifier(id: string, description: string): void;
211 >
212 > /**
213 > * Parses a token selector from a selector string.
214 > * @param selectorString selector string in the form (*|type)(.modifier)*
215 > * @param language language to which the selector applies or undefined if the selector is for all languafe
216 > * @returns the parsesd selector
217 > * @throws an error if the string is not a valid selector
218 > */
219 > parseTokenSelector(selectorString: string, language?: string): TokenSelector;
220 >
221 > /**
222 > * Register a TokenStyle default to the registry.
223 > * @param selector The rule selector
224 > * @param defaults The default values
225 > */
226 > registerTokenStyleDefault(selector: TokenSelector, defaults: TokenStyleDefaults): void;
227 >
228 > /**
229 > * Deregister a TokenStyle default to the registry.
230 > * @param selector The rule selector
231 > */
232 > deregisterTokenStyleDefault(selector: TokenSelector): void;
233 >
234 > /**
235 > * Deregister a TokenType from the registry.
236 > */
237 > deregisterTokenType(id: string): void;
238 >
239 > /**
240 > * Deregister a TokenModifier from the registry.
241 > */
242 > deregisterTokenModifier(id: string): void;
243 >
244 > /**
245 > * Get all TokenType contributions
246 > */
247 > getTokenTypes(): TokenTypeOrModifierContribution[];
248 >
249 > /**
250 > * Get all TokenModifier contributions
251 > */
252 > getTokenModifiers(): TokenTypeOrModifierContribution[];
253 >
254 > /**
255 > * The styling rules to used when a schema does not define any styling rules.
256 > */
257 > getTokenStylingDefaultRules(): SemanticTokenDefaultRule[];
258 >
259 > /**
260 > * JSON schema for an object to assign styling to token classifications
261 > */
262 > getTokenStylingSchema(): IJSONSchema;
263 > }
264 >
265 > class TokenClassificationRegistry extends Disposable implements ITokenClassificationRegistry {
266 >
267 > private readonly _onDidChangeSchema = this._register(new Emitter<void>());
268 > readonly onDidChangeSchema: Event<void> = this._onDidChangeSchema.event;
269 >
270 > private currentTypeNumber = 0;
271 > private currentModifierBit = 1;
272 >
273 > private tokenTypeById: { [key: string]: TokenTypeOrModifierContribution };
274 > private tokenModifierById: { [key: string]: TokenTypeOrModifierContribution };
275 >
276 > private tokenStylingDefaultRules: SemanticTokenDefaultRule[] = [];
277 >
278 > private typeHierarchy: { [id: string]: string[] };
279 >
280 > private tokenStylingSchema: IJSONSchema & { properties: IJSONSchemaMap; patternProperties: IJSONSchemaMap } = {
281 > type: 'object',
282 > properties: {},
283 > patternProperties: {
284 > [selectorPattern]: getStylingSchemeEntry()
285 > },
286 > //errorMessage: nls.localize('schema.token.errors', 'Valid token selectors have the form (*|tokenType)(.tokenModifier)*(:tokenLanguage)?.'),
287 > additionalProperties: false,
288 > definitions: {
289 > style: {
290 > type: 'object',
291 > description: nls.localize('schema.token.settings', 'Colors and styles for the token.'),
292 > properties: {
293 > foreground: {
294 > type: 'string',
295 > description: nls.localize('schema.token.foreground', 'Foreground color for the token.'),
296 > format: 'color-hex',
297 > default: '#ff0000'
298 > },
299 > background: {
300 > type: 'string',
301 > deprecationMessage: nls.localize('schema.token.background.warning', 'Token background colors are currently not supported.')
302 > },
303 > fontStyle: {
304 > type: 'string',
305 > description: nls.localize('schema.token.fontStyle', 'Sets the all font styles of the rule: \'italic\', \'bold\', \'underline\' or \'strikethrough\' or a combination. All styles that are not listed are unset. The empty string unsets all styles.'),
306 > pattern: fontStylePattern,
307 > patternErrorMessage: nls.localize('schema.fontStyle.error', 'Font style must be \'italic\', \'bold\', \'underline\' or \'strikethrough\' or a combination. The empty string unsets all styles.'),
308 > defaultSnippets: [
309 > { label: nls.localize('schema.token.fontStyle.none', 'None (clear inherited style)'), bodyText: '""' },
310 > { body: 'italic' },
311 > { body: 'bold' },
312 > { body: 'underline' },
313 > { body: 'strikethrough' },
314 > { body: 'italic bold' },
315 > { body: 'italic underline' },
316 > { body: 'italic strikethrough' },
317 > { body: 'bold underline' },
318 > { body: 'bold strikethrough' },
319 > { body: 'underline strikethrough' },
320 > { body: 'italic bold underline' },
321 > { body: 'italic bold strikethrough' },
322 > { body: 'italic underline strikethrough' },
323 > { body: 'bold underline strikethrough' },
324 > { body: 'italic bold underline strikethrough' }
325 > ]
326 > },
327 > bold: {
328 > type: 'boolean',
329 > description: nls.localize('schema.token.bold', 'Sets or unsets the font style to bold. Note, the presence of \'fontStyle\' overrides this setting.'),
330 > },
331 > italic: {
332 > type: 'boolean',
333 > description: nls.localize('schema.token.italic', 'Sets or unsets the font style to italic. Note, the presence of \'fontStyle\' overrides this setting.'),
334 > },
335 > underline: {
336 > type: 'boolean',
337 > description: nls.localize('schema.token.underline', 'Sets or unsets the font style to underline. Note, the presence of \'fontStyle\' overrides this setting.'),
338 > },
339 > strikethrough: {
340 > type: 'boolean',
341 > description: nls.localize('schema.token.strikethrough', 'Sets or unsets the font style to strikethrough. Note, the presence of \'fontStyle\' overrides this setting.'),
342 > }
343 >
344 > },
345 > defaultSnippets: [{ body: { foreground: '${1:#FF0000}', fontStyle: '${2:bold}' } }]
346 > }
347 > }
348 > };
349 >
350 > constructor() {
351 > super();
352 > this.tokenTypeById = Object.create(null);
353 > this.tokenModifierById = Object.create(null);
354 > this.typeHierarchy = Object.create(null);
355 > }
356 >
357 > public registerTokenType(id: string, description: string, superType?: string, deprecationMessage?: string): void {
358 > if (!id.match(typeAndModifierIdPattern)) {
359 throw new Error('Invalid token type id.');
360 }
361 > if (superType && !superType.match(typeAndModifierIdPattern)) { tokenClassificationRegistry.ts
362 throw new Error('Invalid token super type id.');
363 }
365 > const num = this.currentTypeNumber++;
366 > const tokenStyleContribution: TokenTypeOrModifierContribution = { num, id, superType, description, deprecationMessage };
367 > this.tokenTypeById[id] = tokenStyleContribution;
368 >
369 > const stylingSchemeEntry = getStylingSchemeEntry(description, deprecationMessage);
370 > this.tokenStylingSchema.properties[id] = stylingSchemeEntry;
371 > this.typeHierarchy = Object.create(null);
372 > }
373 >
374 > public registerTokenModifier(id: string, description: string, deprecationMessage?: string): void {
375 > if (!id.match(typeAndModifierIdPattern)) {
376 throw new Error('Invalid token modifier id.');
377 }
379 > const num = this.currentModifierBit;
380 > this.currentModifierBit = this.currentModifierBit * 2;
381 > const tokenStyleContribution: TokenTypeOrModifierContribution = { num, id, description, deprecationMessage };
382 > this.tokenModifierById[id] = tokenStyleContribution;
383 >
384 > this.tokenStylingSchema.properties[`*.${id}`] = getStylingSchemeEntry(description, deprecationMessage);
385 > }
386 >
387 > public parseTokenSelector(selectorString: string, language?: string): TokenSelector {
388 > const selector = parseClassifierString(selectorString, language);
389 >
390 > if (!selector.type) {
391 return {
392 match: () => -1,
394 };
395 }
397 > return {
398 > match: (type: string, modifiers: string[], language: string) => {
399 let score = 0;
400 if (selector.language !== undefined) {
420 return score + selector.modifiers.length * 100;
421 },
422 > id: `${[selector.type, ...selector.modifiers.sort()].join('.')}${selector.language !== undefined ? ':' + selector.language : ''}` tokenClassificationRegistry.ts
423 > };
424 > }
425 >
426 > public registerTokenStyleDefault(selector: TokenSelector, defaults: TokenStyleDefaults): void {
427 > this.tokenStylingDefaultRules.push({ selector, defaults });
428 > }
429 >
430 > public deregisterTokenStyleDefault(selector: TokenSelector): void {
431 const selectorString = selector.id;
432 this.tokenStylingDefaultRules = this.tokenStylingDefaultRules.filter(r => r.selector.id !== selectorString);
433 }
435 > public deregisterTokenType(id: string): void {
436 delete this.tokenTypeById[id];
437 delete this.tokenStylingSchema.properties[id];
438 this.typeHierarchy = Object.create(null);
439 }
441 > public deregisterTokenModifier(id: string): void {
442 delete this.tokenModifierById[id];
443 delete this.tokenStylingSchema.properties[`*.${id}`];
444 }
446 > public getTokenTypes(): TokenTypeOrModifierContribution[] {
447 return Object.keys(this.tokenTypeById).map(id => this.tokenTypeById[id]);
448 }
450 > public getTokenModifiers(): TokenTypeOrModifierContribution[] {
451 return Object.keys(this.tokenModifierById).map(id => this.tokenModifierById[id]);
452 }
454 > public getTokenStylingSchema(): IJSONSchema {
455 > return this.tokenStylingSchema;
456 > }
457 >
458 > public getTokenStylingDefaultRules(): SemanticTokenDefaultRule[] {
459 return this.tokenStylingDefaultRules;
460 }
462 > private getTypeHierarchy(typeId: string): string[] {
463 let hierarchy = this.typeHierarchy[typeId];
464 if (!hierarchy) {
472 return hierarchy;
473 }
475 >
476 > public override toString() {
477 const sorter = (a: string, b: string) => {
478 const cat1 = a.indexOf('.') === -1 ? 0 : 1;
486 return Object.keys(this.tokenTypeById).sort(sorter).map(k => `- \`${k}\`: ${this.tokenTypeById[k].description}`).join('\n');
487 }
489 > }
490 >
491 > const CHAR_LANGUAGE = TOKEN_CLASSIFIER_LANGUAGE_SEPARATOR.charCodeAt(0);
492 > const CHAR_MODIFIER = CLASSIFIER_MODIFIER_SEPARATOR.charCodeAt(0);
493 >
494 > export function parseClassifierString(s: string, defaultLanguage: string): { type: string; modifiers: string[]; language: string };
495 > export function parseClassifierString(s: string, defaultLanguage?: string): { type: string; modifiers: string[]; language: string | undefined };
496 > export function parseClassifierString(s: string, defaultLanguage: string | undefined): { type: string; modifiers: string[]; language: string | undefined } {
497 > let k = s.length;
498 > let language: string | undefined = defaultLanguage;
499 > const modifiers = [];
500 >
501 > for (let i = k - 1; i >= 0; i--) {
502 > const ch = s.charCodeAt(i);
503 > if (ch === CHAR_LANGUAGE || ch === CHAR_MODIFIER) {
504 > const segment = s.substring(i + 1, k);
505 > k = i;
506 > if (ch === CHAR_LANGUAGE) {
507 language = segment;
509 > modifiers.push(segment);
510 > }
511 > }
512 > }
513 > const type = s.substring(0, k);
514 > return { type, modifiers, language };
515 > }
516 >
517 >
518 > const tokenClassificationRegistry = createDefaultTokenClassificationRegistry();
519 > platform.Registry.add(Extensions.TokenClassificationContribution, tokenClassificationRegistry);
520 >
521 >
522 > function createDefaultTokenClassificationRegistry(): TokenClassificationRegistry {
523 >
524 > const registry = new TokenClassificationRegistry();
525 >
526 > function registerTokenType(id: string, description: string, scopesToProbe: ProbeScope[] = [], superType?: string, deprecationMessage?: string): string {
527 > registry.registerTokenType(id, description, superType, deprecationMessage);
528 > if (scopesToProbe) {
529 > registerTokenStyleDefault(id, scopesToProbe);
530 > }
531 > return id;
532 > }
533 >
534 > function registerTokenStyleDefault(selectorString: string, scopesToProbe: ProbeScope[]) {
535 > try {
536 > const selector = registry.parseTokenSelector(selectorString);
537 > registry.registerTokenStyleDefault(selector, { scopesToProbe });
538 > } catch (e) {
539 console.log(e);
540 }
542 >
543 > // default token types
544 >
545 > registerTokenType('comment', nls.localize('comment', "Style for comments."), [['comment']]);
546 > registerTokenType('string', nls.localize('string', "Style for strings."), [['string']]);
547 > registerTokenType('keyword', nls.localize('keyword', "Style for keywords."), [['keyword.control']]);
548 > registerTokenType('number', nls.localize('number', "Style for numbers."), [['constant.numeric']]);
549 > registerTokenType('regexp', nls.localize('regexp', "Style for expressions."), [['constant.regexp']]);
550 > registerTokenType('operator', nls.localize('operator', "Style for operators."), [['keyword.operator']]);
551 >
552 > registerTokenType('namespace', nls.localize('namespace', "Style for namespaces."), [['entity.name.namespace']]);
553 >
554 > registerTokenType('type', nls.localize('type', "Style for types."), [['entity.name.type'], ['support.type']]);
555 > registerTokenType('struct', nls.localize('struct', "Style for structs."), [['entity.name.type.struct']]);
556 > registerTokenType('class', nls.localize('class', "Style for classes."), [['entity.name.type.class'], ['support.class']]);
557 > registerTokenType('interface', nls.localize('interface', "Style for interfaces."), [['entity.name.type.interface']]);
558 > registerTokenType('enum', nls.localize('enum', "Style for enums."), [['entity.name.type.enum']]);
559 > registerTokenType('typeParameter', nls.localize('typeParameter', "Style for type parameters."), [['entity.name.type.parameter']]);
560 >
561 > registerTokenType('function', nls.localize('function', "Style for functions"), [['entity.name.function'], ['support.function']]);
562 > registerTokenType('member', nls.localize('member', "Style for member functions"), [], 'method', 'Deprecated use `method` instead');
563 > registerTokenType('method', nls.localize('method', "Style for method (member functions)"), [['entity.name.function.member'], ['support.function']]);
564 > registerTokenType('macro', nls.localize('macro', "Style for macros."), [['entity.name.function.preprocessor']]);
565 >
566 > registerTokenType('variable', nls.localize('variable', "Style for variables."), [['variable.other.readwrite'], ['entity.name.variable']]);
567 > registerTokenType('parameter', nls.localize('parameter', "Style for parameters."), [['variable.parameter']]);
568 > registerTokenType('property', nls.localize('property', "Style for properties."), [['variable.other.property']]);
569 > registerTokenType('enumMember', nls.localize('enumMember', "Style for enum members."), [['variable.other.enummember']]);
570 > registerTokenType('event', nls.localize('event', "Style for events."), [['variable.other.event']]);
571 > registerTokenType('decorator', nls.localize('decorator', "Style for decorators & annotations."), [['entity.name.decorator'], ['entity.name.function']]);
572 >
573 > registerTokenType('label', nls.localize('labels', "Style for labels. "), undefined);
574 >
575 > // default token modifiers
576 >
577 > registry.registerTokenModifier('declaration', nls.localize('declaration', "Style for all symbol declarations."), undefined);
578 > registry.registerTokenModifier('documentation', nls.localize('documentation', "Style to use for references in documentation."), undefined);
579 > registry.registerTokenModifier('static', nls.localize('static', "Style to use for symbols that are static."), undefined);
580 > registry.registerTokenModifier('abstract', nls.localize('abstract', "Style to use for symbols that are abstract."), undefined);
581 > registry.registerTokenModifier('deprecated', nls.localize('deprecated', "Style to use for symbols that are deprecated."), undefined);
582 > registry.registerTokenModifier('modification', nls.localize('modification', "Style to use for write accesses."), undefined);
583 > registry.registerTokenModifier('async', nls.localize('async', "Style to use for symbols that are async."), undefined);
584 > registry.registerTokenModifier('readonly', nls.localize('readonly', "Style to use for symbols that are read-only."), undefined);
585 >
586 >
587 > registerTokenStyleDefault('variable.readonly', [['variable.other.constant']]);
588 > registerTokenStyleDefault('property.readonly', [['variable.other.constant.property']]);
589 > registerTokenStyleDefault('type.defaultLibrary', [['support.type']]);
590 > registerTokenStyleDefault('class.defaultLibrary', [['support.class']]);
591 > registerTokenStyleDefault('interface.defaultLibrary', [['support.class']]);
592 > registerTokenStyleDefault('variable.defaultLibrary', [['support.variable'], ['support.other.variable']]);
593 > registerTokenStyleDefault('variable.defaultLibrary.readonly', [['support.constant']]);
594 > registerTokenStyleDefault('property.defaultLibrary', [['support.variable.property']]);
595 > registerTokenStyleDefault('property.defaultLibrary.readonly', [['support.constant.property']]);
596 > registerTokenStyleDefault('function.defaultLibrary', [['support.function']]);
597 > registerTokenStyleDefault('member.defaultLibrary', [['support.function']]);
598 > return registry;
599 > }
600 >
601 > export function getTokenClassificationRegistry(): ITokenClassificationRegistry {
602 return tokenClassificationRegistry;
603 }
605 > function getStylingSchemeEntry(description?: string, deprecationMessage?: string): IJSONSchema {
606 > return {
607 > description,
608 > deprecationMessage,
609 > defaultSnippets: [{ body: '${1:#ff0000}' }],
610 > anyOf: [
611 > {
612 > type: 'string',
613 > format: 'color-hex'
614 > },
615 > {
616 > $ref: '#/definitions/style'
617 > }
618 > ]
619 > };
620 > }
621 >
622 > export const tokenStylingSchemaId = 'vscode://schemas/token-styling';
623 >
624 > const schemaRegistry = platform.Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
625 > schemaRegistry.registerSchema(tokenStylingSchemaId, tokenClassificationRegistry.getTokenStylingSchema());
626 >
627 > const delayer = new RunOnceScheduler(() => schemaRegistry.notifySchemaChanged(tokenStylingSchemaId), 200);
628 > tokenClassificationRegistry.onDidChangeSchema(() => {
629 if (!delayer.isScheduled()) {
630 delayer.schedule();