@@ -8,6 +8,7 @@ import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema';
88import { Color } from 'vs/base/common/color' ;
99import { ITheme } from 'vs/platform/theme/common/themeService' ;
1010import { Event , Emitter } from 'vs/base/common/event' ;
11+ import * as nls from 'vs/nls' ;
1112
1213import { Extensions as JSONExtensions , IJSONContributionRegistry } from 'vs/platform/jsonschemas/common/jsonContributionRegistry' ;
1314import { RunOnceScheduler } from 'vs/base/common/async' ;
@@ -69,21 +70,21 @@ export namespace TokenStyle {
6970 }
7071}
7172
72-
73+ export type ProbeScope = string [ ] | string ;
7374
7475export interface TokenStyleFunction {
7576 ( theme : ITheme ) : TokenStyle | undefined ;
7677}
7778
7879export interface TokenStyleDefaults {
79- scopesToProbe ?: string [ ] ;
80- light : TokenStyle | null ;
81- dark : TokenStyle | null ;
82- hc : TokenStyle | null ;
80+ scopesToProbe ?: ProbeScope [ ] ;
81+ light : TokenStyleValue | null ;
82+ dark : TokenStyleValue | null ;
83+ hc : TokenStyleValue | null ;
8384}
8485
8586/**
86- * A TokenStyle Value is either a tokestyle literal, a reference to other color or a derived color
87+ * A TokenStyle Value is either a token style literal, a reference to other token style or a derived token style
8788 */
8889export type TokenStyleValue = TokenStyle | string | TokenStyleIdentifier | TokenStyleFunction ;
8990
@@ -117,7 +118,7 @@ export interface ITokenStyleRegistry {
117118 /**
118119 * Gets the default TokenStyle of the given id
119120 */
120- resolveDefaultTokenStyle ( id : TokenStyleIdentifier , theme : ITheme , findTokenStyleForScope : ( scope : string ) => TokenStyle | undefined ) : TokenStyle | undefined ;
121+ resolveDefaultTokenStyle ( id : TokenStyleIdentifier , theme : ITheme , findTokenStyleForScope : ( scope : ProbeScope ) => TokenStyle | undefined ) : TokenStyle | undefined ;
121122
122123 /**
123124 * JSON schema for an object to assign TokenStyle values to one of the TokenStyle contributions.
@@ -147,9 +148,18 @@ class TokenStyleRegistry implements ITokenStyleRegistry {
147148 }
148149
149150 public registerTokenStyle ( id : string , defaults : TokenStyleDefaults | null , description : string , deprecationMessage ?: string ) : TokenStyleIdentifier {
150- let colorContribution : TokenStyleContribution = { id, description, defaults, deprecationMessage } ;
151- this . tokenStyleById [ id ] = colorContribution ;
152- let propertySchema : IJSONSchema = { type : 'string' , description, format : 'color-hex' , default : '#ff0000' } ;
151+ let tokenStyleContribution : TokenStyleContribution = { id, description, defaults, deprecationMessage } ;
152+ this . tokenStyleById [ id ] = tokenStyleContribution ;
153+ let propertySchema : IJSONSchema = {
154+ type : 'object' ,
155+ description,
156+ properties : {
157+ 'foreground' : { type : 'string' , format : 'color-hex' , default : '#ff0000' } ,
158+ 'italic' : { type : 'boolean' } ,
159+ 'bold' : { type : 'boolean' } ,
160+ 'underline' : { type : 'boolean' }
161+ }
162+ } ;
153163 if ( deprecationMessage ) {
154164 propertySchema . deprecationMessage = deprecationMessage ;
155165 }
@@ -177,7 +187,7 @@ class TokenStyleRegistry implements ITokenStyleRegistry {
177187 return Object . keys ( this . tokenStyleById ) . map ( id => this . tokenStyleById [ id ] ) ;
178188 }
179189
180- public resolveDefaultTokenStyle ( id : TokenStyleIdentifier , theme : ITheme , findTokenStyleForScope : ( scope : string ) => TokenStyle | undefined ) : TokenStyle | undefined {
190+ public resolveDefaultTokenStyle ( id : TokenStyleIdentifier , theme : ITheme , findTokenStyleForScope : ( scope : ProbeScope ) => TokenStyle | undefined ) : TokenStyle | undefined {
181191 const tokenStyleDesc = this . tokenStyleById [ id ] ;
182192 if ( tokenStyleDesc && tokenStyleDesc . defaults ) {
183193 const scopesToProbe = tokenStyleDesc . defaults . scopesToProbe ;
@@ -229,7 +239,16 @@ export function getTokenStyleRegistry(): ITokenStyleRegistry {
229239 return tokenStyleRegistry ;
230240}
231241
232- // ----- implementation
242+ // colors
243+
244+
245+ export const comments = registerTokenStyle ( 'comments' , { scopesToProbe : [ 'comment' ] , dark : null , light : null , hc : null } , nls . localize ( 'comments' , "Token style for comments." ) ) ;
246+ export const strings = registerTokenStyle ( 'strings' , { scopesToProbe : [ 'strings' ] , dark : null , light : null , hc : null } , nls . localize ( 'strings' , "Token style for strings." ) ) ;
247+ export const keywords = registerTokenStyle ( 'keywords' , { scopesToProbe : [ 'keyword.control' , 'storage' , 'storage.type' ] , dark : null , light : null , hc : null } , nls . localize ( 'keywords' , "Token style for keywords." ) ) ;
248+ export const numbers = registerTokenStyle ( 'numbers' , { scopesToProbe : [ 'constant.numeric' ] , dark : null , light : null , hc : null } , nls . localize ( 'numbers' , "Token style for numbers." ) ) ;
249+ export const types = registerTokenStyle ( 'types' , { scopesToProbe : [ 'entity.name.type' , 'entity.name.class' , 'support.type' , 'support.class' ] , dark : null , light : null , hc : null } , nls . localize ( 'types' , "Token style for types." ) ) ;
250+ export const functions = registerTokenStyle ( 'functions' , { scopesToProbe : [ 'entity.name.function' , 'support.function' ] , dark : null , light : null , hc : null } , nls . localize ( 'functions' , "Token style for functions." ) ) ;
251+ export const variables = registerTokenStyle ( 'variables' , { scopesToProbe : [ 'variable' , 'entity.name.variable' ] , dark : null , light : null , hc : null } , nls . localize ( 'variables' , "Token style for variables." ) ) ;
233252
234253/**
235254 * @param colorValue Resolve a color value in the context of a theme
0 commit comments