colorThemeData.ts ×57

Frontier kind: Code frontier

unlabeled · c_859dd86982b0

7 tests · 31496 LOC · 176 files · introduces 0 tests · 483 LOC · 8 files

Introduces — evidence that enters the hierarchy at this concept

Code
76 ranges483 lines · 8 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3432 ranges31496 lines · 176 files · Browse complete extent
All tests (intent)
7 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.

8 files ranked by introduced lines: 483 introduced LOC across 76 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/themes/common/colorThemeData.ts 267 introduced LOC · 57 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- colorThemeData.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 { basename } from '../../../../base/common/path.js';
7 > import * as Json from '../../../../base/common/json.js';
8 > import { Color } from '../../../../base/common/color.js';
9 > import { ExtensionData, ITokenColorCustomizations, ITextMateThemingRule, IWorkbenchColorTheme, IColorMap, IThemeExtensionPoint, IColorCustomizations, ISemanticTokenRules, ISemanticTokenColorizationSetting, ISemanticTokenColorCustomizations, IThemeScopableCustomizations, IThemeScopedCustomizations, THEME_SCOPE_CLOSE_PAREN, THEME_SCOPE_OPEN_PAREN, themeScopeRegex, THEME_SCOPE_WILDCARD } from './workbenchThemeService.js';
10 > import { convertSettings } from './themeCompatibility.js';
11 > import * as nls from '../../../../nls.js';
12 > import * as types from '../../../../base/common/types.js';
13 > import * as resources from '../../../../base/common/resources.js';
14 > import { Extensions as ColorRegistryExtensions, IColorRegistry, ColorIdentifier, editorBackground, editorForeground, DEFAULT_COLOR_CONFIG_VALUE } from '../../../../platform/theme/common/colorRegistry.js';
15 > import { IFontTokenOptions, ITokenStyle, getThemeTypeSelector } from '../../../../platform/theme/common/themeService.js';
16 > import { Registry } from '../../../../platform/registry/common/platform.js';
17 > import { getParseErrorMessage } from '../../../../base/common/jsonErrorMessages.js';
18 > import { URI } from '../../../../base/common/uri.js';
19 > import { parse as parsePList } from './plistParser.js';
20 > import { TokenStyle, SemanticTokenRule, ProbeScope, getTokenClassificationRegistry, TokenStyleValue, TokenStyleData, parseClassifierString } from '../../../../platform/theme/common/tokenClassificationRegistry.js';
21 > import { MatcherWithPriority, Matcher, createMatchers } from './textMateScopeMatcher.js';
22 > import { IExtensionResourceLoaderService } from '../../../../platform/extensionResourceLoader/common/extensionResourceLoader.js';
23 > import { CharCode } from '../../../../base/common/charCode.js';
24 > import { StorageScope, IStorageService, StorageTarget } from '../../../../platform/storage/common/storage.js';
25 > import { ThemeConfiguration } from './themeConfiguration.js';
26 > import { ColorScheme, ThemeTypeSelector } from '../../../../platform/theme/common/theme.js';
27 > import { ColorId, FontStyle, MetadataConsts } from '../../../../editor/common/encodedTokenAttributes.js';
28 > import { toStandardTokenType } from '../../../../editor/common/languages/supports/tokenization.js';
29 >
30 > const colorRegistry = Registry.as<IColorRegistry>(ColorRegistryExtensions.ColorContribution);
31 >
32 > const tokenClassificationRegistry = getTokenClassificationRegistry();
33 >
34 > const tokenGroupToScopesMap = {
35 > comments: ['comment', 'punctuation.definition.comment'],
36 > strings: ['string', 'meta.embedded.assembly'],
37 > keywords: ['keyword - keyword.operator', 'keyword.control', 'storage', 'storage.type'],
38 > numbers: ['constant.numeric'],
39 > types: ['entity.name.type', 'entity.name.class', 'support.type', 'support.class'],
40 > functions: ['entity.name.function', 'support.function'],
41 > variables: ['variable', 'entity.name.variable']
42 > };
43 >
44 >
45 > export type TokenStyleDefinition = SemanticTokenRule | ProbeScope[] | TokenStyleValue;
46 > export type TokenStyleDefinitions = { [P in keyof TokenStyleData]?: TokenStyleDefinition | undefined };
47 >
48 > export type TextMateThemingRuleDefinitions = { [P in keyof TokenStyleData]?: ITextMateThemingRule | undefined; } & { scope?: ProbeScope };
49 >
50 > interface IColorOrDefaultMap {
51 > [id: string]: Color | typeof DEFAULT_COLOR_CONFIG_VALUE;
52 > }
53 >
54 > export class ColorThemeData implements IWorkbenchColorTheme {
55 >
56 > static readonly STORAGE_KEY = 'colorThemeData';
57 >
58 > id: string;
59 > label: string;
60 > settingsId: string;
61 > description?: string;
62 > isLoaded: boolean;
63 > location?: URI; // only set for extension from the registry, not for themes restored from the storage
64 > watch?: boolean;
65 > extensionData?: ExtensionData;
66 >
67 > private themeSemanticHighlighting: boolean | undefined;
68 > private customSemanticHighlighting: boolean | undefined;
69 > private customSemanticHighlightingDeprecated: boolean | undefined;
70 >
71 > private themeTokenColors: ITextMateThemingRule[] = [];
72 > private customTokenColors: ITextMateThemingRule[] = [];
73 > private colorMap: IColorMap = {};
74 > private customColorMap: IColorOrDefaultMap = {};
75 >
76 > private semanticTokenRules: SemanticTokenRule[] = [];
77 > private customSemanticTokenRules: SemanticTokenRule[] = [];
78 >
79 > private themeTokenScopeMatchers: Matcher<ProbeScope>[] | undefined;
80 > private customTokenScopeMatchers: Matcher<ProbeScope>[] | undefined;
81 >
82 > private textMateThemingRules: ITextMateThemingRule[] | undefined = undefined; // created on demand
83 > private tokenColorIndex: TokenColorIndex | undefined = undefined; // created on demand
84 > private tokenFontIndex: TokenFontIndex | undefined = undefined; // created on demand
85 >
86 > private constructor(id: string, label: string, settingsId: string) {
87 > this.id = id;
88 > this.label = label;
89 > this.settingsId = settingsId;
90 > this.isLoaded = false;
91 > }
92 >
93 > get semanticHighlighting(): boolean {
94 if (this.customSemanticHighlighting !== undefined) {
95 return this.customSemanticHighlighting;
100 return !!this.themeSemanticHighlighting;
101 }
103 > get tokenColors(): ITextMateThemingRule[] {
104 if (!this.textMateThemingRules) {
105 const result: ITextMateThemingRule[] = [];
148 return this.textMateThemingRules;
149 }
151 > public getColor(colorId: ColorIdentifier, useDefault?: boolean): Color | undefined {
152 const customColor = this.customColorMap[colorId];
153 if (customColor instanceof Color) {
165 return undefined;
166 }
168 > private getTokenStyle(type: string, modifiers: string[], language: string, useDefault = true, definitions: TokenStyleDefinitions = {}): TokenStyle | undefined {
169 const result: any = {
170 foreground: undefined,
246
247 }
249 > /**
250 > * @param tokenStyleValue Resolve a tokenStyleValue in the context of a theme
251 > */
252 > public resolveTokenStyleValue(tokenStyleValue: TokenStyleValue | undefined): TokenStyle | undefined {
253 if (tokenStyleValue === undefined) {
254 return undefined;
261 return undefined;
262 }
264 > public getTokenColorIndex(): TokenColorIndex {
265 // collect all colors that tokens can have
266 if (!this.tokenColorIndex) {
284 return this.tokenColorIndex;
285 }
287 >
288 > public getTokenFontIndex(): TokenFontIndex {
289 if (!this.tokenFontIndex) {
290 const index = new TokenFontIndex();
294 return this.tokenFontIndex;
295 }
297 > public get tokenColorMap(): string[] {
298 return this.getTokenColorIndex().asArray();
299 }
301 > public get tokenFontMap(): IFontTokenOptions[] {
302 return this.getTokenFontIndex().asArray();
303 }
305 > public getTokenStyleMetadata(typeWithLanguage: string, modifiers: string[], defaultLanguage: string, useDefault = true, definitions: TokenStyleDefinitions = {}): ITokenStyle | undefined {
306 const { type, language } = parseClassifierString(typeWithLanguage, defaultLanguage);
307 const style = this.getTokenStyle(type, modifiers, language, useDefault, definitions);
318 };
319 }
321 > public getTokenStylingRuleScope(rule: SemanticTokenRule): 'setting' | 'theme' | undefined {
322 if (this.customSemanticTokenRules.indexOf(rule) !== -1) {
323 return 'setting';
328 return undefined;
329 }
331 > public getDefault(colorId: ColorIdentifier): Color | undefined {
332 return colorRegistry.resolveDefaultColor(colorId, this);
333 }
335 >
336 > public resolveScopes(scopes: ProbeScope[], definitions?: TextMateThemingRuleDefinitions): TokenStyle | undefined {
337 >
338 > if (!this.themeTokenScopeMatchers) {
339 > this.themeTokenScopeMatchers = this.themeTokenColors.map(getScopeMatcher);
340 > }
341 > if (!this.customTokenScopeMatchers) {
342 > this.customTokenScopeMatchers = this.customTokenColors.map(getScopeMatcher);
343 > }
344 >
345 > for (const scope of scopes) {
346 > let foreground: string | undefined = undefined;
347 > let fontStyle: string | undefined = undefined;
348 > let foregroundScore = -1;
349 > let fontStyleScore = -1;
350 > let fontStyleThemingRule: ITextMateThemingRule | undefined = undefined;
351 > let foregroundThemingRule: ITextMateThemingRule | undefined = undefined;
352 >
353 > function findTokenStyleForScopeInScopes(scopeMatchers: Matcher<ProbeScope>[], themingRules: ITextMateThemingRule[]) {
354 > for (let i = 0; i < scopeMatchers.length; i++) {
355 const score = scopeMatchers[i](scope);
356 if (score >= 0) {
369 }
370 }
372 > findTokenStyleForScopeInScopes(this.themeTokenScopeMatchers, this.themeTokenColors);
373 > findTokenStyleForScopeInScopes(this.customTokenScopeMatchers, this.customTokenColors);
374 > if (foreground !== undefined || fontStyle !== undefined) {
375 if (definitions) {
376 definitions.foreground = foregroundThemingRule;
381 return TokenStyle.fromSettings(foreground, fontStyle);
382 }
384 return undefined;
386 >
387 > public defines(colorId: ColorIdentifier): boolean {
388 const customColor = this.customColorMap[colorId];
389 if (customColor instanceof Color) {
392 return customColor === undefined /* !== DEFAULT_COLOR_CONFIG_VALUE */ && this.colorMap.hasOwnProperty(colorId);
393 }
395 > public setCustomizations(settings: ThemeConfiguration) {
396 this.setCustomColors(settings.colorCustomizations);
397 this.setCustomTokenColors(settings.tokenColorCustomizations);
398 this.setCustomSemanticTokenColors(settings.semanticTokenColorCustomizations);
399 }
401 > public setCustomColors(colors: IColorCustomizations) {
402 this.customColorMap = {};
403 this.overwriteCustomColors(colors);
413 this.customTokenScopeMatchers = undefined;
414 }
416 > private overwriteCustomColors(colors: IColorCustomizations) {
417 for (const id in colors) {
418 const colorVal = colors[id];
424 }
425 }
427 > public setCustomTokenColors(customTokenColors: ITokenColorCustomizations) {
428 this.customTokenColors = [];
429 this.customSemanticHighlightingDeprecated = undefined;
443 this.customTokenScopeMatchers = undefined;
444 }
446 > public setCustomSemanticTokenColors(semanticTokenColors: ISemanticTokenColorCustomizations | undefined) {
447 this.customSemanticTokenRules = [];
448 this.customSemanticHighlighting = undefined;
468 this.textMateThemingRules = undefined;
469 }
471 > public isThemeScope(key: string): boolean {
472 return key.charAt(0) === THEME_SCOPE_OPEN_PAREN && key.charAt(key.length - 1) === THEME_SCOPE_CLOSE_PAREN;
473 }
475 > public isThemeScopeMatch(themeId: string): boolean {
476 const themeIdFirstChar = themeId.charAt(0);
477 const themeIdLastChar = themeId.charAt(themeId.length - 1);
484 || (this.settingsId.endsWith(themeIdSuffix) && themeIdFirstChar === THEME_SCOPE_WILDCARD);
485 }
487 > public getThemeSpecificColors(colors: IThemeScopableCustomizations): IThemeScopedCustomizations | undefined {
488 let themeSpecificColors: IThemeScopedCustomizations | undefined;
489 for (const key in colors) {
513 return themeSpecificColors;
514 }
516 > private readSemanticTokenRules(tokenStylingRuleSection: ISemanticTokenRules) {
517 for (const key in tokenStylingRuleSection) {
518 if (!this.isThemeScope(key)) { // still do this test until experimental settings are gone
528 }
529 }
531 > private addCustomTokenColors(customTokenColors: ITokenColorCustomizations) {
532 // Put the general customizations such as comments, strings, etc. first so that
533 // they can be overridden by specific customizations like "string.interpolated"
556 }
557 }
559 > public ensureLoaded(extensionResourceLoaderService: IExtensionResourceLoaderService): Promise<void> {
560 return !this.isLoaded ? this.load(extensionResourceLoaderService) : Promise.resolve(undefined);
561 }
563 > public reload(extensionResourceLoaderService: IExtensionResourceLoaderService): Promise<void> {
564 return this.load(extensionResourceLoaderService);
565 }
567 > private load(extensionResourceLoaderService: IExtensionResourceLoaderService): Promise<void> {
568 if (!this.location) {
569 return Promise.resolve(undefined);
586 });
587 }
589 > public clearCaches() {
590 this.tokenColorIndex = undefined;
591 this.tokenFontIndex = undefined;
594 this.customTokenScopeMatchers = undefined;
595 }
597 > toStorage(storageService: IStorageService) {
598 const colorMapData: { [key: string]: string } = {};
599 for (const key in this.colorMap) {
616 storageService.store(ColorThemeData.STORAGE_KEY, value, StorageScope.PROFILE, StorageTarget.USER);
617 }
619 > get themeTypeSelector(): ThemeTypeSelector {
620 return this.classNames[0] as ThemeTypeSelector;
621 }
623 > get classNames(): string[] {
624 return this.id.split(' ');
625 }
627 > get type(): ColorScheme {
628 switch (this.themeTypeSelector) {
629 case ThemeTypeSelector.VS: return ColorScheme.LIGHT;
633 }
634 }
636 > // constructors
637 >
638 > static createUnloadedThemeForThemeType(themeType: ColorScheme, colorMap?: { [id: string]: string }): ColorThemeData {
639 return ColorThemeData.createUnloadedTheme(getThemeTypeSelector(themeType), colorMap);
640 }
642 > static createUnloadedTheme(id: string, colorMap?: { [id: string]: string }): ColorThemeData {
643 const themeData = new ColorThemeData(id, '', '__' + id);
644 themeData.isLoaded = false;
652 return themeData;
653 }
655 > static createLoadedEmptyTheme(id: string, settingsId: string): ColorThemeData {
656 const themeData = new ColorThemeData(id, '', settingsId);
657 themeData.isLoaded = true;
660 return themeData;
661 }
663 > static fromStorageData(storageService: IStorageService): ColorThemeData | undefined {
664 const input = storageService.get(ColorThemeData.STORAGE_KEY, StorageScope.PROFILE);
665 if (!input) {
711 }
712 }
714 > static fromExtensionTheme(theme: IThemeExtensionPoint, colorThemeLocation: URI, extensionData: ExtensionData): ColorThemeData {
715 const baseTheme: string = theme['uiTheme'] || 'vs-dark';
716 const themeSelector = toCSSSelector(extensionData.extensionId, theme.path);
726 return themeData;
727 }
729 >
730 function toCSSSelector(extensionId: string, path: string) {
731 if (path.startsWith('./')) {
741 return str;
742 }
744 async function _loadColorTheme(extensionResourceLoaderService: IExtensionResourceLoaderService, themeLocation: URI, result: { textMateRules: ITextMateThemingRule[]; colors: IColorMap; semanticTokenRules: SemanticTokenRule[]; semanticHighlighting: boolean }): Promise<any> {
745 if (resources.extname(themeLocation) === '.json') {
802 }
803 }
805 function _loadSyntaxTokens(extensionResourceLoaderService: IExtensionResourceLoaderService, themeLocation: URI, result: { textMateRules: ITextMateThemingRule[]; colors: IColorMap }): Promise<any> {
806 return extensionResourceLoaderService.readExtensionResource(themeLocation).then(content => {
820 });
821 }
823 > const defaultThemeColors: { [baseTheme: string]: ITextMateThemingRule[] } = {
824 > 'light': [
825 > { scope: 'token.info-token', settings: { foreground: '#316bcd' } },
826 > { scope: 'token.warn-token', settings: { foreground: '#cd9731' } },
827 > { scope: 'token.error-token', settings: { foreground: '#cd3131' } },
828 > { scope: 'token.debug-token', settings: { foreground: '#800080' } }
829 > ],
830 > 'dark': [
831 > { scope: 'token.info-token', settings: { foreground: '#6796e6' } },
832 > { scope: 'token.warn-token', settings: { foreground: '#cd9731' } },
833 > { scope: 'token.error-token', settings: { foreground: '#f44747' } },
834 > { scope: 'token.debug-token', settings: { foreground: '#b267e6' } }
835 > ],
836 > 'hcLight': [
837 > { scope: 'token.info-token', settings: { foreground: '#316bcd' } },
838 > { scope: 'token.warn-token', settings: { foreground: '#cd9731' } },
839 > { scope: 'token.error-token', settings: { foreground: '#cd3131' } },
840 > { scope: 'token.debug-token', settings: { foreground: '#800080' } }
841 > ],
842 > 'hcDark': [
843 > { scope: 'token.info-token', settings: { foreground: '#6796e6' } },
844 > { scope: 'token.warn-token', settings: { foreground: '#008000' } },
845 > { scope: 'token.error-token', settings: { foreground: '#FF0000' } },
846 > { scope: 'token.debug-token', settings: { foreground: '#b267e6' } }
847 > ]
848 > };
849 >
850 > const noMatch = (_scope: ProbeScope) => -1;
851 >
852 function nameMatcher(identifiers: string[], scopes: ProbeScope): number {
853 if (scopes.length < identifiers.length) {
877 return thisScopeName.length > len && thisScopeName.substr(0, len) === scopeName && thisScopeName[len] === '.';
878 }
880 function getScopeMatcher(rule: ITextMateThemingRule): Matcher<ProbeScope> {
881 const ruleScope = rule.scope;
903 };
904 }
906 function readSemanticTokenRule(selectorString: string, settings: ISemanticTokenColorizationSetting | string | boolean | undefined): SemanticTokenRule | undefined {
907 const selector = tokenClassificationRegistry.parseTokenSelector(selectorString);
917 return undefined;
918 }
920 function isSemanticTokenColorizationSetting(style: any): style is ISemanticTokenColorizationSetting {
921 return style && (types.isString(style.foreground) || types.isString(style.fontStyle) || types.isBoolean(style.italic)
922 || types.isBoolean(style.underline) || types.isBoolean(style.strikethrough) || types.isBoolean(style.bold));
923 }
925 > export function findMetadata(colorThemeData: ColorThemeData, captureNames: string[], languageId: number, bracket: boolean): number {
926 let metadata = 0;
927
960 return metadata;
961 }
963 > class TokenColorIndex {
964 >
965 > private _lastColorId: number;
966 > private _id2color: string[];
967 > private _color2id: { [color: string]: number };
968 >
969 > constructor() {
970 this._lastColorId = 0;
971 this._id2color = [];
972 this._color2id = Object.create(null);
973 }
975 > public add(color: string | Color | undefined): number {
976 color = normalizeColor(color);
977 if (color === undefined) {
988 return value;
989 }
991 > public get(color: string | Color | undefined): number {
992 color = normalizeColor(color);
993 if (color === undefined) {
1001 return 0;
1002 }
1004 > public asArray(): string[] {
1005 return this._id2color.slice(0);
1006 }
1008 >
1009 > class TokenFontIndex {
1010 >
1011 > private _lastFontId: number;
1012 > private _id2font: IFontTokenOptions[];
1013 > private _font2id: Map<IFontTokenOptions, number>;
1014 >
1015 > constructor() {
1016 this._lastFontId = 0;
1017 this._id2font = [];
1018 this._font2id = new Map();
1019 }
1021 > public add(fontFamily: string | undefined, fontSizeMultiplier: number | undefined, lineHeightMultiplier: number | undefined): number {
1022 const font: IFontTokenOptions = { fontFamily, fontSizeMultiplier, lineHeightMultiplier };
1023 let value = this._font2id.get(font);
1030 return value;
1031 }
1033 > public get(font: IFontTokenOptions): number {
1034 const value = this._font2id.get(font);
1035 if (value) {
1038 return 0;
1039 }
1041 > public asArray(): IFontTokenOptions[] {
1042 return this._id2font.slice(0);
1043 }
1045 >
1046 function normalizeColor(color: string | Color | undefined | null): string | undefined {
1047 if (!color) {
1073 return String.fromCharCode(...result);
1074 }
1076 function hexUpper(charCode: CharCode): number {
1077 if (charCode >= CharCode.Digit0 && charCode <= CharCode.Digit9 || charCode >= CharCode.A && charCode <= CharCode.F) {
src/vs/workbench/services/themes/common/themeCompatibility.ts 49 introduced LOC · 2 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- themeCompatibility.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 { ITextMateThemingRule, IColorMap } from './workbenchThemeService.js';
7 > import { Color } from '../../../../base/common/color.js';
8 > import * as colorRegistry from '../../../../platform/theme/common/colorRegistry.js';
9 >
10 > import * as editorColorRegistry from '../../../../editor/common/core/editorColorRegistry.js';
11 >
12 > const settingToColorIdMapping: { [settingId: string]: string[] } = {};
13 > function addSettingMapping(settingId: string, colorId: string) {
14 > let colorIds = settingToColorIdMapping[settingId];
15 > if (!colorIds) {
16 > settingToColorIdMapping[settingId] = colorIds = [];
17 > }
18 > colorIds.push(colorId);
19 > }
20 >
21 > export function convertSettings(oldSettings: ITextMateThemingRule[], result: { textMateRules: ITextMateThemingRule[]; colors: IColorMap }): void {
22 for (const rule of oldSettings) {
23 result.textMateRules.push(rule);
47 }
48 }
50 > addSettingMapping('background', colorRegistry.editorBackground);
51 > addSettingMapping('foreground', colorRegistry.editorForeground);
52 > addSettingMapping('selection', colorRegistry.editorSelectionBackground);
53 > addSettingMapping('inactiveSelection', colorRegistry.editorInactiveSelection);
54 > addSettingMapping('selectionHighlightColor', colorRegistry.editorSelectionHighlight);
55 > addSettingMapping('findMatchHighlight', colorRegistry.editorFindMatchHighlight);
56 > addSettingMapping('currentFindMatchHighlight', colorRegistry.editorFindMatch);
57 > addSettingMapping('hoverHighlight', colorRegistry.editorHoverHighlight);
58 > addSettingMapping('wordHighlight', 'editor.wordHighlightBackground'); // inlined to avoid editor/contrib dependenies
59 > addSettingMapping('wordHighlightStrong', 'editor.wordHighlightStrongBackground');
60 > addSettingMapping('findRangeHighlight', colorRegistry.editorFindRangeHighlight);
61 > addSettingMapping('findMatchHighlight', 'peekViewResult.matchHighlightBackground');
62 > addSettingMapping('referenceHighlight', 'peekViewEditor.matchHighlightBackground');
63 > addSettingMapping('lineHighlight', editorColorRegistry.editorLineHighlight);
64 > addSettingMapping('rangeHighlight', editorColorRegistry.editorRangeHighlight);
65 > addSettingMapping('caret', editorColorRegistry.editorCursorForeground);
66 > addSettingMapping('invisibles', editorColorRegistry.editorWhitespaces);
67 > addSettingMapping('guide', editorColorRegistry.editorIndentGuide1);
68 > addSettingMapping('activeGuide', editorColorRegistry.editorActiveIndentGuide1);
69 >
70 > const ansiColorMap = ['ansiBlack', 'ansiRed', 'ansiGreen', 'ansiYellow', 'ansiBlue', 'ansiMagenta', 'ansiCyan', 'ansiWhite',
71 > 'ansiBrightBlack', 'ansiBrightRed', 'ansiBrightGreen', 'ansiBrightYellow', 'ansiBrightBlue', 'ansiBrightMagenta', 'ansiBrightCyan', 'ansiBrightWhite'
72 > ];
73 >
74 > for (const color of ansiColorMap) {
75 > addSettingMapping(color, 'terminal.' + color);
76 > }
src/vs/platform/extensionManagement/common/extensionGalleryManifestService.ts 44 introduced LOC · 2 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- extensionGalleryManifestService.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 { Event } from '../../../base/common/event.js';
7 > import { Disposable } from '../../../base/common/lifecycle.js';
8 > import { IProductService } from '../../product/common/productService.js';
9 > import { ExtensionGalleryResourceType, Flag, IExtensionGalleryManifest, IExtensionGalleryManifestService, ExtensionGalleryManifestStatus } from './extensionGalleryManifest.js';
10 > import { FilterType, SortBy } from './extensionManagement.js';
11 >
12 > type ExtensionGalleryConfig = {
13 > readonly serviceUrl: string;
14 > readonly itemUrl: string;
15 > readonly publisherUrl: string;
16 > readonly resourceUrlTemplate: string;
17 > readonly extensionUrlTemplate: string;
18 > readonly controlUrl: string;
19 > readonly nlsBaseUrl: string;
20 > };
21 >
22 > export class ExtensionGalleryManifestService extends Disposable implements IExtensionGalleryManifestService {
23 >
24 > readonly _serviceBrand: undefined;
25 > readonly onDidChangeExtensionGalleryManifest = Event.None;
26 > readonly onDidChangeExtensionGalleryManifestStatus = Event.None;
27 >
28 > get extensionGalleryManifestStatus(): ExtensionGalleryManifestStatus {
29 > return !!this.productService.extensionsGallery?.serviceUrl ? ExtensionGalleryManifestStatus.Available : ExtensionGalleryManifestStatus.Unavailable;
30 > }
31 >
32 > constructor(
33 > @IProductService protected readonly productService: IProductService,
34 > ) {
35 > super();
36 > }
37 >
38 > async getExtensionGalleryManifest(): Promise<IExtensionGalleryManifest | null> {
39 > const extensionsGallery = this.productService.extensionsGallery as ExtensionGalleryConfig | undefined;
40 > if (!extensionsGallery?.serviceUrl) {
41 > return null;
42 > }
43
44 const resources = [
src/vs/platform/extensionResourceLoader/common/extensionResourceLoaderService.ts 38 introduced LOC · 2 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- extensionResourceLoaderService.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 { URI } from '../../../base/common/uri.js';
7 > import { InstantiationType, registerSingleton } from '../../instantiation/common/extensions.js';
8 > import { IFileService } from '../../files/common/files.js';
9 > import { IProductService } from '../../product/common/productService.js';
10 > import { asTextOrError, IRequestService } from '../../request/common/request.js';
11 > import { IStorageService } from '../../storage/common/storage.js';
12 > import { IEnvironmentService } from '../../environment/common/environment.js';
13 > import { IConfigurationService } from '../../configuration/common/configuration.js';
14 > import { CancellationToken } from '../../../base/common/cancellation.js';
15 > import { AbstractExtensionResourceLoaderService, IExtensionResourceLoaderService } from './extensionResourceLoader.js';
16 > import { IExtensionGalleryManifestService } from '../../extensionManagement/common/extensionGalleryManifest.js';
17 > import { ILogService } from '../../log/common/log.js';
18 >
19 > export class ExtensionResourceLoaderService extends AbstractExtensionResourceLoaderService {
20 >
21 > constructor(
22 > @IFileService fileService: IFileService,
23 > @IStorageService storageService: IStorageService,
24 > @IProductService productService: IProductService,
25 > @IEnvironmentService environmentService: IEnvironmentService,
26 > @IConfigurationService configurationService: IConfigurationService,
27 > @IExtensionGalleryManifestService extensionGalleryManifestService: IExtensionGalleryManifestService,
28 > @IRequestService private readonly _requestService: IRequestService,
29 > @ILogService logService: ILogService,
30 > ) {
31 > super(fileService, storageService, productService, environmentService, configurationService, extensionGalleryManifestService, logService);
32 > }
33 >
34 > async readExtensionResource(uri: URI): Promise<string> {
35 if (await this.isExtensionGalleryResource(uri)) {
36 const headers = await this.getExtensionGalleryRequestHeaders();
41 return result.value.toString();
42 }
44 > }
45 >
46 > registerSingleton(IExtensionResourceLoaderService, ExtensionResourceLoaderService, InstantiationType.Delayed);
src/vs/workbench/services/themes/common/plistParser.ts 30 introduced LOC · 2 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- plistParser.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 > const enum ChCode {
7 > BOM = 65279,
8 >
9 > SPACE = 32,
10 > TAB = 9,
11 > CARRIAGE_RETURN = 13,
12 > LINE_FEED = 10,
13 >
14 > SLASH = 47,
15 >
16 > LESS_THAN = 60,
17 > QUESTION_MARK = 63,
18 > EXCLAMATION_MARK = 33,
19 > }
20 >
21 > const enum State {
22 > ROOT_STATE = 0,
23 > DICT_STATE = 1,
24 > ARR_STATE = 2
25 > }
26 > /**
27 > * A very fast plist parser
28 > */
29 > export function parse(content: string): any {
30 return _parse(content, null, null);
31 }
33 function _parse(content: string, filename: string | null, locationKeyName: string | null): any {
34 const len = content.length;
src/vs/platform/extensionResourceLoader/common/extensionResourceLoader.ts 20 introduced LOC · 4 ranges

Open complete file

75
76 constructor(
77 > protected readonly _fileService: IFileService, extensionResourceLoader.ts
78 > private readonly _storageService: IStorageService,
79 > private readonly _productService: IProductService,
80 > private readonly _environmentService: IEnvironmentService,
81 > private readonly _configurationService: IConfigurationService,
82 > private readonly _extensionGalleryManifestService: IExtensionGalleryManifestService,
83 > protected readonly _logService: ILogService,
84 > ) {
85 > super();
86 > this._initPromise = this._init();
87 > }
88
89 private async _init(): Promise<void> {
91 > const manifest = await this._extensionGalleryManifestService.getExtensionGalleryManifest();
92 > this.resolve(manifest);
93 > this._register(this._extensionGalleryManifestService.onDidChangeExtensionGalleryManifest(() => this.resolve(manifest)));
94 > } catch (error) {
95 this._logService.error(error);
96 }
98
99 private resolve(manifest: IExtensionGalleryManifest | null): void {
100 > this._extensionGalleryResourceUrlTemplate = manifest ? getExtensionGalleryManifestResourceUri(manifest, ExtensionGalleryResourceType.ExtensionResourceUri) : undefined; extensionResourceLoader.ts
101 > this._extensionGalleryAuthority = this._extensionGalleryResourceUrlTemplate ? this._getExtensionGalleryAuthority(URI.parse(this._extensionGalleryResourceUrlTemplate)) : undefined;
102 > }
103
104 public async supportsExtensionGalleryResources(): Promise<boolean> {
src/vs/workbench/services/themes/common/textMateScopeMatcher.ts 19 introduced LOC · 3 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- textMateScopeMatcher.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 > 'use strict';
7 >
8 > export interface MatcherWithPriority<T> {
9 > matcher: Matcher<T>;
10 > priority: -1 | 0 | 1;
11 > }
12 >
13 > export interface Matcher<T> {
14 > (matcherInput: T): number;
15 > }
16 >
17 > export function createMatchers<T>(selector: string, matchesName: (names: string[], matcherInput: T) => number, results: MatcherWithPriority<T>[]): void {
18 const tokenizer = newTokenizer(selector);
19 let token = tokenizer.next();
114 }
115 }
117 function isIdentifier(token: string | null): token is string {
118 return !!token && !!token.match(/[\w\.:]+/);
119 }
121 function newTokenizer(input: string): { next: () => string | null } {
122 const regex = /([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g;
src/vs/platform/theme/common/tokenClassificationRegistry.ts 16 introduced LOC · 4 ranges

Open complete file

52 export class TokenStyle implements Readonly<TokenStyleData> {
53 constructor(
54 > public readonly foreground: Color | undefined, tokenClassificationRegistry.ts
55 > public readonly bold: boolean | undefined,
56 > public readonly underline: boolean | undefined,
57 > public readonly strikethrough: boolean | undefined,
58 > public readonly italic: boolean | undefined,
59 > ) {
60 > }
61 }
62
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; tokenClassificationRegistry.ts
108 > if (foreground !== undefined) {
109 > foregroundColor = Color.fromHex(foreground);
110 > }
111 > if (fontStyle !== undefined) {
112 bold = italic = underline = strikethrough = false;
113 const expression = /italic|bold|underline|strikethrough/g;
600
601 export function getTokenClassificationRegistry(): ITokenClassificationRegistry {
602 > return tokenClassificationRegistry; tokenClassificationRegistry.ts
603 > }
604
605 function getStylingSchemeEntry(description?: string, deprecationMessage?: string): IJSONSchema {