diff --git a/extensions/vscode-colorize-tests/src/colorizerTestMain.ts b/extensions/vscode-colorize-tests/src/colorizerTestMain.ts index e9536994cf7..7f30a330ffb 100644 --- a/extensions/vscode-colorize-tests/src/colorizerTestMain.ts +++ b/extensions/vscode-colorize-tests/src/colorizerTestMain.ts @@ -8,7 +8,7 @@ import * as jsoncParser from 'jsonc-parser'; export function activate(context: vscode.ExtensionContext): any { - const tokenTypes = ['types', 'structs', 'classes', 'interfaces', 'enums', 'parameterTypes', 'functions', 'variables']; + const tokenTypes = ['type', 'struct', 'class', 'interface', 'enum', 'parameterType', 'function', 'variable']; const tokenModifiers = ['static', 'abstract', 'deprecated', 'declaration', 'documentation', 'member', 'async']; const legend = new vscode.SemanticTokensLegend(tokenTypes, tokenModifiers); diff --git a/src/vs/platform/theme/common/tokenClassificationRegistry.ts b/src/vs/platform/theme/common/tokenClassificationRegistry.ts index 3fa3e0c9c46..fa4303f57a9 100644 --- a/src/vs/platform/theme/common/tokenClassificationRegistry.ts +++ b/src/vs/platform/theme/common/tokenClassificationRegistry.ts @@ -320,40 +320,45 @@ export function getTokenClassificationRegistry(): ITokenClassificationRegistry { return tokenClassificationRegistry; } -export const comments = registerTokenType('comments', nls.localize('comments', "Style for comments."), [['comment']]); -export const strings = registerTokenType('strings', nls.localize('strings', "Style for strings."), [['string']]); -export const keywords = registerTokenType('keywords', nls.localize('keywords', "Style for keywords."), [['keyword.control']]); -export const numbers = registerTokenType('numbers', nls.localize('numbers', "Style for numbers."), [['constant.numeric']]); -export const regexp = registerTokenType('regexp', nls.localize('regexp', "Style for expressions."), [['constant.regexp']]); -export const operators = registerTokenType('operators', nls.localize('operator', "Style for operators."), [['keyword.operator']]); +// default token types -export const namespaces = registerTokenType('namespaces', nls.localize('namespace', "Style for namespaces."), [['entity.name.namespace']]); +registerTokenType('comment', nls.localize('comment', "Style for comments."), [['comment']]); +registerTokenType('string', nls.localize('string', "Style for strings."), [['string']]); +registerTokenType('keyword', nls.localize('keyword', "Style for keywords."), [['keyword.control']]); +registerTokenType('number', nls.localize('number', "Style for numbers."), [['constant.numeric']]); +registerTokenType('regexp', nls.localize('regexp', "Style for expressions."), [['constant.regexp']]); +registerTokenType('operator', nls.localize('operator', "Style for operators."), [['keyword.operator']]); -export const types = registerTokenType('types', nls.localize('types', "Style for types."), [['entity.name.type'], ['entity.name.class'], ['support.type'], ['support.class']]); -export const structs = registerTokenType('structs', nls.localize('struct', "Style for structs."), [['storage.type.struct']], types); -export const classes = registerTokenType('classes', nls.localize('class', "Style for classes."), [['entity.name.class']], types); -export const interfaces = registerTokenType('interfaces', nls.localize('interface', "Style for interfaces."), undefined, types); -export const enums = registerTokenType('enums', nls.localize('enum', "Style for enums."), undefined, types); -export const parameterTypes = registerTokenType('parameterTypes', nls.localize('parameterType', "Style for parameter types."), undefined, types); +registerTokenType('namespace', nls.localize('namespace', "Style for namespaces."), [['entity.name.namespace']]); -export const functions = registerTokenType('functions', nls.localize('functions', "Style for functions"), [['entity.name.function'], ['support.function']]); -export const macros = registerTokenType('macros', nls.localize('macro', "Style for macros."), undefined, functions); +registerTokenType('type', nls.localize('type', "Style for types."), [['entity.name.type'], ['entity.name.class'], ['support.type'], ['support.class']]); +registerTokenType('struct', nls.localize('struct', "Style for structs."), [['storage.type.struct']], 'type'); +registerTokenType('class', nls.localize('class', "Style for classes."), [['entity.name.class']], 'type'); +registerTokenType('interface', nls.localize('interface', "Style for interfaces."), undefined, 'type'); +registerTokenType('enum', nls.localize('enum', "Style for enums."), undefined, 'type'); +registerTokenType('parameterType', nls.localize('parameterType', "Style for parameter types."), undefined, 'type'); -export const variables = registerTokenType('variables', nls.localize('variables', "Style for variables."), [['variable'], ['entity.name.variable']]); -export const constants = registerTokenType('constants', nls.localize('constants', "Style for constants."), undefined, variables); -export const parameters = registerTokenType('parameters', nls.localize('parameters', "Style for parameters."), undefined, variables); -export const property = registerTokenType('properties', nls.localize('properties', "Style for properties."), undefined, variables); +registerTokenType('function', nls.localize('function', "Style for functions"), [['entity.name.function'], ['support.function']]); +registerTokenType('macro', nls.localize('macro', "Style for macros."), undefined, 'function'); -export const labels = registerTokenType('labels', nls.localize('labels', "Style for labels. "), undefined); +registerTokenType('variable', nls.localize('variable', "Style for variables."), [['variable'], ['entity.name.variable']]); +registerTokenType('constant', nls.localize('constant', "Style for constants."), undefined, 'variable'); +registerTokenType('parameter', nls.localize('parameter', "Style for parameters."), undefined, 'variable'); +registerTokenType('property', nls.localize('propertie', "Style for properties."), undefined, 'variable'); + +registerTokenType('label', nls.localize('labels', "Style for labels. "), undefined); + +// default token modifiers + +registerTokenModifier('declaration', nls.localize('declaration', "Style for all symbol declarations."), undefined); +registerTokenModifier('documentation', nls.localize('documentation', "Style to use for references in documentation."), undefined); +registerTokenModifier('member', nls.localize('member', "Style to use for member functions, variables (fields) and types."), undefined); +registerTokenModifier('static', nls.localize('static', "Style to use for symbols that are static."), undefined); +registerTokenModifier('abstract', nls.localize('abstract', "Style to use for symbols that are abstract."), undefined); +registerTokenModifier('deprecated', nls.localize('deprecated', "Style to use for symbols that are deprecated."), undefined); +registerTokenModifier('modification', nls.localize('modification', "Style to use for write accesses."), undefined); +registerTokenModifier('async', nls.localize('async', "Style to use for symbols that are async."), undefined); -export const m_declaration = registerTokenModifier('declaration', nls.localize('declaration', "Style for all symbol declarations."), undefined); -export const m_documentation = registerTokenModifier('documentation', nls.localize('documentation', "Style to use for references in documentation."), undefined); -export const m_member = registerTokenModifier('member', nls.localize('member', "Style to use for member functions, variables (fields) and types."), undefined); -export const m_static = registerTokenModifier('static', nls.localize('static', "Style to use for symbols that are static."), undefined); -export const m_abstract = registerTokenModifier('abstract', nls.localize('abstract', "Style to use for symbols that are abstract."), undefined); -export const m_deprecated = registerTokenModifier('deprecated', nls.localize('deprecated', "Style to use for symbols that are deprecated."), undefined); -export const m_modification = registerTokenModifier('modification', nls.localize('modification', "Style to use for write accesses."), undefined); -export const m_async = registerTokenModifier('async', nls.localize('async', "Style to use for symbols that are async."), undefined); function bitCount(u: number) { // https://blogs.msdn.microsoft.com/jeuge/2005/06/08/bit-fiddling-3/ diff --git a/src/vs/workbench/services/themes/test/electron-browser/tokenStyleResolving.test.ts b/src/vs/workbench/services/themes/test/electron-browser/tokenStyleResolving.test.ts index b256164b7b4..0e84f4e22c4 100644 --- a/src/vs/workbench/services/themes/test/electron-browser/tokenStyleResolving.test.ts +++ b/src/vs/workbench/services/themes/test/electron-browser/tokenStyleResolving.test.ts @@ -6,7 +6,7 @@ import { ColorThemeData } from 'vs/workbench/services/themes/common/colorThemeData'; import * as assert from 'assert'; import { ITokenColorCustomizations } from 'vs/workbench/services/themes/common/workbenchThemeService'; -import { TokenStyle, comments, variables, types, functions, keywords, numbers, strings, getTokenClassificationRegistry } from 'vs/platform/theme/common/tokenClassificationRegistry'; +import { TokenStyle, getTokenClassificationRegistry } from 'vs/platform/theme/common/tokenClassificationRegistry'; import { Color } from 'vs/base/common/color'; import { isString } from 'vs/base/common/types'; import { FileService } from 'vs/platform/files/common/fileService'; @@ -107,13 +107,13 @@ suite('Themes - TokenStyleResolving', () => { assert.equal(themeData.isLoaded, true); assertTokenStyles(themeData, { - [comments]: ts('#88846f', undefinedStyle), - [variables]: ts('#F8F8F2', unsetStyle), - [types]: ts('#A6E22E', { underline: true }), - [functions]: ts('#A6E22E', unsetStyle), - [strings]: ts('#E6DB74', undefinedStyle), - [numbers]: ts('#AE81FF', undefinedStyle), - [keywords]: ts('#F92672', undefinedStyle) + 'comment': ts('#88846f', undefinedStyle), + 'variable': ts('#F8F8F2', unsetStyle), + 'type': ts('#A6E22E', { underline: true }), + 'function': ts('#A6E22E', unsetStyle), + 'string': ts('#E6DB74', undefinedStyle), + 'number': ts('#AE81FF', undefinedStyle), + 'keyword': ts('#F92672', undefinedStyle) }); }); @@ -127,13 +127,13 @@ suite('Themes - TokenStyleResolving', () => { assert.equal(themeData.isLoaded, true); assertTokenStyles(themeData, { - [comments]: ts('#6A9955', undefinedStyle), - [variables]: ts('#9CDCFE', undefinedStyle), - [types]: ts('#4EC9B0', undefinedStyle), - [functions]: ts('#DCDCAA', undefinedStyle), - [strings]: ts('#CE9178', undefinedStyle), - [numbers]: ts('#B5CEA8', undefinedStyle), - [keywords]: ts('#C586C0', undefinedStyle) + 'comment': ts('#6A9955', undefinedStyle), + 'variable': ts('#9CDCFE', undefinedStyle), + 'type': ts('#4EC9B0', undefinedStyle), + 'function': ts('#DCDCAA', undefinedStyle), + 'string': ts('#CE9178', undefinedStyle), + 'number': ts('#B5CEA8', undefinedStyle), + 'keyword': ts('#C586C0', undefinedStyle) }); }); @@ -147,13 +147,13 @@ suite('Themes - TokenStyleResolving', () => { assert.equal(themeData.isLoaded, true); assertTokenStyles(themeData, { - [comments]: ts('#008000', undefinedStyle), - [variables]: ts(undefined, undefinedStyle), - [types]: ts(undefined, undefinedStyle), - [functions]: ts(undefined, undefinedStyle), - [strings]: ts('#a31515', undefinedStyle), - [numbers]: ts('#09885a', undefinedStyle), - [keywords]: ts('#0000ff', undefinedStyle) + 'comment': ts('#008000', undefinedStyle), + 'variable': ts(undefined, undefinedStyle), + 'type': ts(undefined, undefinedStyle), + 'function': ts(undefined, undefinedStyle), + 'string': ts('#a31515', undefinedStyle), + 'number': ts('#09885a', undefinedStyle), + 'keyword': ts('#0000ff', undefinedStyle) }); }); @@ -167,13 +167,13 @@ suite('Themes - TokenStyleResolving', () => { assert.equal(themeData.isLoaded, true); assertTokenStyles(themeData, { - [comments]: ts('#7ca668', undefinedStyle), - [variables]: ts('#9CDCFE', undefinedStyle), - [types]: ts('#4EC9B0', undefinedStyle), - [functions]: ts('#DCDCAA', undefinedStyle), - [strings]: ts('#ce9178', undefinedStyle), - [numbers]: ts('#b5cea8', undefinedStyle), - [keywords]: ts('#C586C0', undefinedStyle) + 'comment': ts('#7ca668', undefinedStyle), + 'variable': ts('#9CDCFE', undefinedStyle), + 'type': ts('#4EC9B0', undefinedStyle), + 'function': ts('#DCDCAA', undefinedStyle), + 'string': ts('#ce9178', undefinedStyle), + 'number': ts('#b5cea8', undefinedStyle), + 'keyword': ts('#C586C0', undefinedStyle) }); }); @@ -187,13 +187,13 @@ suite('Themes - TokenStyleResolving', () => { assert.equal(themeData.isLoaded, true); assertTokenStyles(themeData, { - [comments]: ts('#a57a4c', undefinedStyle), - [variables]: ts('#dc3958', undefinedStyle), - [types]: ts('#f06431', undefinedStyle), - [functions]: ts('#8ab1b0', undefinedStyle), - [strings]: ts('#889b4a', undefinedStyle), - [numbers]: ts('#f79a32', undefinedStyle), - [keywords]: ts('#98676a', undefinedStyle) + 'comment': ts('#a57a4c', undefinedStyle), + 'variable': ts('#dc3958', undefinedStyle), + 'type': ts('#f06431', undefinedStyle), + 'function': ts('#8ab1b0', undefinedStyle), + 'string': ts('#889b4a', undefinedStyle), + 'number': ts('#f79a32', undefinedStyle), + 'keyword': ts('#98676a', undefinedStyle) }); }); @@ -207,13 +207,13 @@ suite('Themes - TokenStyleResolving', () => { assert.equal(themeData.isLoaded, true); assertTokenStyles(themeData, { - [comments]: ts('#384887', undefinedStyle), - [variables]: ts(undefined, unsetStyle), - [types]: ts('#ffeebb', { underline: true }), - [functions]: ts('#ddbb88', unsetStyle), - [strings]: ts('#22aa44', undefinedStyle), - [numbers]: ts('#f280d0', undefinedStyle), - [keywords]: ts('#225588', undefinedStyle) + 'comment': ts('#384887', undefinedStyle), + 'variable': ts(undefined, unsetStyle), + 'type': ts('#ffeebb', { underline: true }), + 'function': ts('#ddbb88', unsetStyle), + 'string': ts('#22aa44', undefinedStyle), + 'number': ts('#f280d0', undefinedStyle), + 'keyword': ts('#225588', undefinedStyle) }); }); @@ -301,8 +301,8 @@ suite('Themes - TokenStyleResolving', () => { const themeData = ColorThemeData.createLoadedEmptyTheme('test', 'test'); themeData.setCustomColors({ 'editor.foreground': '#000000' }); themeData.setCustomTokenStyleRules({ - 'types': '#ff0000', - 'classes': { foreground: '#0000ff', fontStyle: 'italic' }, + 'type': '#ff0000', + 'class': { foreground: '#0000ff', fontStyle: 'italic' }, '*.static': { fontStyle: 'bold' }, '*.declaration': { fontStyle: 'italic' }, '*.async.static': { fontStyle: 'italic underline' }, @@ -310,14 +310,14 @@ suite('Themes - TokenStyleResolving', () => { }); assertTokenStyles(themeData, { - 'types': ts('#ff0000', undefinedStyle), - 'types.static': ts('#ff0000', { bold: true }), - 'types.static.declaration': ts('#ff0000', { bold: true, italic: true }), - 'classes': ts('#0000ff', { italic: true }), - 'classes.static.declaration': ts('#0000ff', { bold: true, italic: true }), - 'classes.declaration': ts('#0000ff', { italic: true }), - 'classes.declaration.async': ts('#000fff', { underline: true, italic: false }), - 'classes.declaration.async.static': ts('#000fff', { italic: true, underline: true, bold: true }), + 'type': ts('#ff0000', undefinedStyle), + 'type.static': ts('#ff0000', { bold: true }), + 'type.static.declaration': ts('#ff0000', { bold: true, italic: true }), + 'class': ts('#0000ff', { italic: true }), + 'class.static.declaration': ts('#0000ff', { bold: true, italic: true }), + 'class.declaration': ts('#0000ff', { italic: true }), + 'class.declaration.async': ts('#000fff', { underline: true, italic: false }), + 'class.declaration.async.static': ts('#000fff', { italic: true, underline: true, bold: true }), }); });