@@ -24,7 +24,7 @@ export const typeAndModifierIdPattern = `^${idPattern}$`;
2424
2525export const selectorPattern = `^(${ idPattern } |\\*)(\\${ CLASSIFIER_MODIFIER_SEPARATOR } ${ idPattern } )*(\\${ TOKEN_CLASSIFIER_LANGUAGE_SEPARATOR } ${ idPattern } )?$` ;
2626
27- export const fontStylePattern = '^(\\s*(-? italic|-? bold|-? underline))*\\s*$' ;
27+ export const fontStylePattern = '^(\\s*(italic|bold|underline))*\\s*$' ;
2828
2929export interface TokenSelector {
3030 match ( type : string , modifiers : string [ ] , language : string ) : number ;
@@ -124,18 +124,18 @@ export interface TokenStyleDefaults {
124124 hc ?: TokenStyleValue ;
125125}
126126
127- export interface TokenStylingDefaultRule {
127+ export interface SemanticTokenDefaultRule {
128128 selector : TokenSelector ;
129129 defaults : TokenStyleDefaults ;
130130}
131131
132- export interface TokenStylingRule {
132+ export interface SemanticTokenRule {
133133 style : TokenStyle ;
134134 selector : TokenSelector ;
135135}
136136
137- export namespace TokenStylingRule {
138- export function fromJSONObject ( registry : ITokenClassificationRegistry , o : any ) : TokenStylingRule | undefined {
137+ export namespace SemanticTokenRule {
138+ export function fromJSONObject ( registry : ITokenClassificationRegistry , o : any ) : SemanticTokenRule | undefined {
139139 if ( o && typeof o . _selector === 'string' && o . _style ) {
140140 const style = TokenStyle . fromJSONObject ( o . _style ) ;
141141 if ( style ) {
@@ -147,21 +147,21 @@ export namespace TokenStylingRule {
147147 }
148148 return undefined ;
149149 }
150- export function toJSONObject ( rule : TokenStylingRule ) : any {
150+ export function toJSONObject ( rule : SemanticTokenRule ) : any {
151151 return {
152152 _selector : rule . selector . id ,
153153 _style : TokenStyle . toJSONObject ( rule . style )
154154 } ;
155155 }
156- export function equals ( r1 : TokenStylingRule | undefined , r2 : TokenStylingRule | undefined ) {
156+ export function equals ( r1 : SemanticTokenRule | undefined , r2 : SemanticTokenRule | undefined ) {
157157 if ( r1 === r2 ) {
158158 return true ;
159159 }
160160 return r1 !== undefined && r2 !== undefined
161161 && r1 . selector && r2 . selector && r1 . selector . id === r2 . selector . id
162162 && TokenStyle . equals ( r1 . style , r2 . style ) ;
163163 }
164- export function is ( r : any ) : r is TokenStylingRule {
164+ export function is ( r : any ) : r is SemanticTokenRule {
165165 return r && r . selector && typeof r . selector . selectorString === 'string' && TokenStyle . is ( r . style ) ;
166166 }
167167}
@@ -239,7 +239,7 @@ export interface ITokenClassificationRegistry {
239239 /**
240240 * The styling rules to used when a schema does not define any styling rules.
241241 */
242- getTokenStylingDefaultRules ( ) : TokenStylingDefaultRule [ ] ;
242+ getTokenStylingDefaultRules ( ) : SemanticTokenDefaultRule [ ] ;
243243
244244 /**
245245 * JSON schema for an object to assign styling to token classifications
@@ -258,14 +258,18 @@ class TokenClassificationRegistry implements ITokenClassificationRegistry {
258258 private tokenTypeById : { [ key : string ] : TokenTypeOrModifierContribution } ;
259259 private tokenModifierById : { [ key : string ] : TokenTypeOrModifierContribution } ;
260260
261- private tokenStylingDefaultRules : TokenStylingDefaultRule [ ] = [ ] ;
261+ private tokenStylingDefaultRules : SemanticTokenDefaultRule [ ] = [ ] ;
262262
263263 private typeHierarchy : { [ id : string ] : string [ ] } ;
264264
265- private tokenStylingSchema : IJSONSchema & { properties : IJSONSchemaMap } = {
265+ private tokenStylingSchema : IJSONSchema & { properties : IJSONSchemaMap , patternProperties : IJSONSchemaMap } = {
266266 type : 'object' ,
267267 properties : { } ,
268- additionalProperties : getStylingSchemeEntry ( ) ,
268+ patternProperties : {
269+ [ selectorPattern ] : getStylingSchemeEntry ( )
270+ } ,
271+ //errorMessage: nls.localize('schema.token.errors', 'Valid token selectors have the form (*|tokenType)(.tokenModifier)*(:tokenLanguage)?.'),
272+ additionalProperties : false ,
269273 definitions : {
270274 style : {
271275 type : 'object' ,
@@ -325,7 +329,8 @@ class TokenClassificationRegistry implements ITokenClassificationRegistry {
325329 let tokenStyleContribution : TokenTypeOrModifierContribution = { num, id, superType, description, deprecationMessage } ;
326330 this . tokenTypeById [ id ] = tokenStyleContribution ;
327331
328- this . tokenStylingSchema . properties [ id ] = getStylingSchemeEntry ( description , deprecationMessage ) ;
332+ const stylingSchemeEntry = getStylingSchemeEntry ( description , deprecationMessage ) ;
333+ this . tokenStylingSchema . properties [ id ] = stylingSchemeEntry ;
329334 this . typeHierarchy = { } ;
330335 }
331336
@@ -413,7 +418,7 @@ class TokenClassificationRegistry implements ITokenClassificationRegistry {
413418 return this . tokenStylingSchema ;
414419 }
415420
416- public getTokenStylingDefaultRules ( ) : TokenStylingDefaultRule [ ] {
421+ public getTokenStylingDefaultRules ( ) : SemanticTokenDefaultRule [ ] {
417422 return this . tokenStylingDefaultRules ;
418423 }
419424
0 commit comments