@@ -8,6 +8,8 @@ import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema';
88import { ThemeIcon } from 'vs/platform/theme/common/themeService' ;
99import { Event , Emitter } from 'vs/base/common/event' ;
1010import { localize } from 'vs/nls' ;
11+ import { Extensions as JSONExtensions , IJSONContributionRegistry } from 'vs/platform/jsonschemas/common/jsonContributionRegistry' ;
12+ import { RunOnceScheduler } from 'vs/base/common/async' ;
1113
1214// ------ API types
1315
@@ -18,7 +20,7 @@ export const Extensions = {
1820} ;
1921
2022export interface IconDefaults {
21- font ?: string ;
23+ fontId ?: string ;
2224 character : string ;
2325}
2426
@@ -69,7 +71,21 @@ class IconRegistry implements IIconRegistry {
6971 readonly onDidChangeSchema : Event < void > = this . _onDidChangeSchema . event ;
7072
7173 private iconsById : { [ key : string ] : IconContribution } ;
72- private iconSchema : IJSONSchema & { properties : IJSONSchemaMap } = { type : 'object' , properties : { } } ;
74+ private iconSchema : IJSONSchema & { properties : IJSONSchemaMap } = {
75+ definitions : {
76+ icons : {
77+ type : 'object' ,
78+ properties : {
79+ fontId : { type : 'string' , description : localize ( 'iconDefintion.fontId' , 'The id of the font to use. If not set, the font that is defined first is used.' ) } ,
80+ fontCharacter : { type : 'string' , description : localize ( 'iconDefintion.fontCharacter' , 'The font character associated with the icon definition.' ) }
81+ } ,
82+ additionalProperties : false ,
83+ defaultSnippets : [ { body : { fontCharacter : '\\\\e030' } } ]
84+ }
85+ } ,
86+ type : 'object' ,
87+ properties : { }
88+ } ;
7389 private iconReferenceSchema : IJSONSchema & { enum : string [ ] , enumDescriptions : string [ ] } = { type : 'string' , enum : [ ] , enumDescriptions : [ ] } ;
7490
7591 constructor ( ) {
@@ -79,7 +95,7 @@ class IconRegistry implements IIconRegistry {
7995 public registerIcon ( id : string , defaults : IconDefaults , description : string , deprecationMessage ?: string ) : ThemeIcon {
8096 let iconContribution : IconContribution = { id, description, defaults, deprecationMessage } ;
8197 this . iconsById [ id ] = iconContribution ;
82- let propertySchema : IJSONSchema = { type : 'object' , description, properties : { font : { type : 'string' } , fontCharacter : { type : 'string' } } , defaultSnippets : [ { body : { fontCharacter : '\\\\e030' } } ] } ;
98+ let propertySchema : IJSONSchema = { description, $ref : '#/definitions/icons' } ;
8399 if ( deprecationMessage ) {
84100 propertySchema . deprecationMessage = deprecationMessage ;
85101 }
@@ -539,5 +555,17 @@ registerIcon('bell-dot', { character: '\f101' }, localize('bell-dot', ''));
539555registerIcon ( 'debug-alt-2' , { character : '\f102' } , localize ( 'debug-alt-2' , '' ) ) ;
540556registerIcon ( 'debug-alt' , { character : '\f103' } , localize ( 'debug-alt' , '' ) ) ;
541557
558+ export const iconsSchemaId = 'vscode://schemas/icons' ;
559+
560+ let schemaRegistry = platform . Registry . as < IJSONContributionRegistry > ( JSONExtensions . JSONContribution ) ;
561+ schemaRegistry . registerSchema ( iconsSchemaId , iconRegistry . getIconSchema ( ) ) ;
562+
563+ const delayer = new RunOnceScheduler ( ( ) => schemaRegistry . notifySchemaChanged ( iconsSchemaId ) , 200 ) ;
564+ iconRegistry . onDidChangeSchema ( ( ) => {
565+ if ( ! delayer . isScheduled ( ) ) {
566+ delayer . schedule ( ) ;
567+ }
568+ } ) ;
569+
542570
543571// setTimeout(_ => console.log(colorRegistry.toString()), 5000);
0 commit comments