colorThemeData.ts ×16

Frontier kind: Joint frontier

unlabeled · c_b42ccb22e924

1 test · 32953 LOC · 176 files · introduces 1 test · 64 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
19 ranges64 lines · 3 files
Tests
1 test

Contains — complete concept membership

All code (extent)
3875 ranges32953 lines · 176 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

1 test introduced at this concept.

Introduced code

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

3 files ranked by introduced lines: 64 introduced LOC across 19 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

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

Open complete file

558
559 public ensureLoaded(extensionResourceLoaderService: IExtensionResourceLoaderService): Promise<void> {
560 > return !this.isLoaded ? this.load(extensionResourceLoaderService) : Promise.resolve(undefined); colorThemeData.ts
561 > }
562
563 public reload(extensionResourceLoaderService: IExtensionResourceLoaderService): Promise<void> {
566
567 private load(extensionResourceLoaderService: IExtensionResourceLoaderService): Promise<void> {
568 > if (!this.location) { colorThemeData.ts
569 return Promise.resolve(undefined);
570 }
571 > this.themeTokenColors = []; colorThemeData.ts
572 > this.clearCaches();
573 >
574 > const result = {
575 > colors: {},
576 > textMateRules: [],
577 > semanticTokenRules: [],
578 > semanticHighlighting: false
579 > };
580 > return _loadColorTheme(extensionResourceLoaderService, this.location, result).then(_ => {
581 > this.isLoaded = true;
582 > this.semanticTokenRules = result.semanticTokenRules;
583 > this.colorMap = result.colors;
584 > this.themeTokenColors = result.textMateRules;
585 > this.themeSemanticHighlighting = result.semanticHighlighting;
586 > });
587 > }
588
589 public clearCaches() {
590 > this.tokenColorIndex = undefined; colorThemeData.ts
591 > this.tokenFontIndex = undefined;
592 > this.textMateThemingRules = undefined;
593 > this.themeTokenScopeMatchers = undefined;
594 > this.customTokenScopeMatchers = undefined;
595 > }
596
597 toStorage(storageService: IStorageService) {
641
642 static createUnloadedTheme(id: string, colorMap?: { [id: string]: string }): ColorThemeData {
643 > const themeData = new ColorThemeData(id, '', '__' + id); colorThemeData.ts
644 > themeData.isLoaded = false;
645 > themeData.themeTokenColors = [];
646 > themeData.watch = false;
647 > if (colorMap) {
648 for (const id in colorMap) {
649 themeData.colorMap[id] = Color.fromHex(colorMap[id]);
650 }
651 }
652 > return themeData; colorThemeData.ts
653 > }
654
655 static createLoadedEmptyTheme(id: string, settingsId: string): ColorThemeData {
742 }
743
744 > async function _loadColorTheme(extensionResourceLoaderService: IExtensionResourceLoaderService, themeLocation: URI, result: { textMateRules: ITextMateThemingRule[]; colors: IColorMap; semanticTokenRules: SemanticTokenRule[]; semanticHighlighting: boolean }): Promise<any> { colorThemeData.ts
745 > if (resources.extname(themeLocation) === '.json') {
746 > const content = await extensionResourceLoaderService.readExtensionResource(themeLocation);
747 > const errors: Json.ParseError[] = [];
748 > const contentValue = Json.parse(content, errors);
749 > if (errors.length > 0) {
750 return Promise.reject(new Error(nls.localize('error.cannotparsejson', "Problems parsing JSON theme file: {0}", errors.map(e => getParseErrorMessage(e.error)).join(', '))));
751 > } else if (Json.getNodeType(contentValue) !== 'object') { colorThemeData.ts
752 return Promise.reject(new Error(nls.localize('error.invalidformat', "Invalid format for JSON theme file: Object expected.")));
753 }
754 > if (contentValue.include) { colorThemeData.ts
755 await _loadColorTheme(extensionResourceLoaderService, resources.joinPath(resources.dirname(themeLocation), contentValue.include), result);
756 }
757 > if (Array.isArray(contentValue.settings)) { colorThemeData.ts
758 convertSettings(contentValue.settings, result);
759 return null;
760 }
761 > result.semanticHighlighting = result.semanticHighlighting || contentValue.semanticHighlighting; colorThemeData.ts
762 > const colors = contentValue.colors;
763 > if (colors) {
764 if (typeof colors !== 'object') {
765 return Promise.reject(new Error(nls.localize({ key: 'error.invalidformat.colors', comment: ['{0} will be replaced by a path. Values in quotes should not be translated.'] }, "Problem parsing color theme file: {0}. Property 'colors' is not of type 'object'.", themeLocation.toString())));
775 }
776 }
777 > const tokenColors = contentValue.tokenColors; colorThemeData.ts
778 > if (tokenColors) {
779 > if (Array.isArray(tokenColors)) {
780 > result.textMateRules.push(...tokenColors);
781 > } else if (typeof tokenColors === 'string') {
782 await _loadSyntaxTokens(extensionResourceLoaderService, resources.joinPath(resources.dirname(themeLocation), tokenColors), result);
783 } else {
784 return Promise.reject(new Error(nls.localize({ key: 'error.invalidformat.tokenColors', comment: ['{0} will be replaced by a path. Values in quotes should not be translated.'] }, "Problem parsing color theme file: {0}. Property 'tokenColors' should be either an array specifying colors or a path to a TextMate theme file", themeLocation.toString())));
785 }
787 > const semanticTokenColors = contentValue.semanticTokenColors;
788 > if (semanticTokenColors && typeof semanticTokenColors === 'object') {
789 for (const key in semanticTokenColors) {
790 try {
798 }
799 }
800 > } else { colorThemeData.ts
801 return _loadSyntaxTokens(extensionResourceLoaderService, themeLocation, result);
802 }
804
805 function _loadSyntaxTokens(extensionResourceLoaderService: IExtensionResourceLoaderService, themeLocation: URI, result: { textMateRules: ITextMateThemingRule[]; colors: IColorMap }): Promise<any> {
981 let value = this._color2id[color];
982 if (value) {
983 > return value; colorThemeData.ts
984 > }
985 value = ++this._lastColorId;
986 this._color2id[color] = value;
src/vs/platform/extensionResourceLoader/common/extensionResourceLoaderService.ts 4 introduced LOC · 2 ranges

Open complete file

33
34 async readExtensionResource(uri: URI): Promise<string> {
35 > if (await this.isExtensionGalleryResource(uri)) { extensionResourceLoaderService.ts
36 const headers = await this.getExtensionGalleryRequestHeaders();
37 const requestContext = await this._requestService.request({ url: uri.toString(), headers, callSite: 'extensionResourceLoader.readExtensionResource' }, CancellationToken.None);
38 return (await asTextOrError(requestContext)) || '';
39 }
40 > const result = await this._fileService.readFile(uri); extensionResourceLoaderService.ts
41 > return result.value.toString();
42 > }
43
44 }
src/vs/platform/extensionResourceLoader/common/extensionResourceLoader.ts 3 introduced LOC · 1 range

Open complete file

129
130 async isExtensionGalleryResource(uri: URI): Promise<boolean> {
131 > await this._initPromise; extensionResourceLoader.ts
132 > return !!this._extensionGalleryAuthority && this._extensionGalleryAuthority === this._getExtensionGalleryAuthority(uri);
133 > }
134
135 protected async getExtensionGalleryRequestHeaders(): Promise<Record<string, string>> {