Skip to content

Commit 54151bb

Browse files
committed
[semantic tokens] Use singular for token type names Fixes microsoft#86281
1 parent 08b0a9b commit 54151bb

3 files changed

Lines changed: 93 additions & 88 deletions

File tree

extensions/vscode-colorize-tests/src/colorizerTestMain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as jsoncParser from 'jsonc-parser';
88

99
export function activate(context: vscode.ExtensionContext): any {
1010

11-
const tokenTypes = ['types', 'structs', 'classes', 'interfaces', 'enums', 'parameterTypes', 'functions', 'variables'];
11+
const tokenTypes = ['type', 'struct', 'class', 'interface', 'enum', 'parameterType', 'function', 'variable'];
1212
const tokenModifiers = ['static', 'abstract', 'deprecated', 'declaration', 'documentation', 'member', 'async'];
1313

1414
const legend = new vscode.SemanticTokensLegend(tokenTypes, tokenModifiers);

src/vs/platform/theme/common/tokenClassificationRegistry.ts

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -320,40 +320,45 @@ export function getTokenClassificationRegistry(): ITokenClassificationRegistry {
320320
return tokenClassificationRegistry;
321321
}
322322

323-
export const comments = registerTokenType('comments', nls.localize('comments', "Style for comments."), [['comment']]);
324-
export const strings = registerTokenType('strings', nls.localize('strings', "Style for strings."), [['string']]);
325-
export const keywords = registerTokenType('keywords', nls.localize('keywords', "Style for keywords."), [['keyword.control']]);
326-
export const numbers = registerTokenType('numbers', nls.localize('numbers', "Style for numbers."), [['constant.numeric']]);
327-
export const regexp = registerTokenType('regexp', nls.localize('regexp', "Style for expressions."), [['constant.regexp']]);
328-
export const operators = registerTokenType('operators', nls.localize('operator', "Style for operators."), [['keyword.operator']]);
329-
330-
export const namespaces = registerTokenType('namespaces', nls.localize('namespace', "Style for namespaces."), [['entity.name.namespace']]);
331-
332-
export const types = registerTokenType('types', nls.localize('types', "Style for types."), [['entity.name.type'], ['entity.name.class'], ['support.type'], ['support.class']]);
333-
export const structs = registerTokenType('structs', nls.localize('struct', "Style for structs."), [['storage.type.struct']], types);
334-
export const classes = registerTokenType('classes', nls.localize('class', "Style for classes."), [['entity.name.class']], types);
335-
export const interfaces = registerTokenType('interfaces', nls.localize('interface', "Style for interfaces."), undefined, types);
336-
export const enums = registerTokenType('enums', nls.localize('enum', "Style for enums."), undefined, types);
337-
export const parameterTypes = registerTokenType('parameterTypes', nls.localize('parameterType', "Style for parameter types."), undefined, types);
338-
339-
export const functions = registerTokenType('functions', nls.localize('functions', "Style for functions"), [['entity.name.function'], ['support.function']]);
340-
export const macros = registerTokenType('macros', nls.localize('macro', "Style for macros."), undefined, functions);
341-
342-
export const variables = registerTokenType('variables', nls.localize('variables', "Style for variables."), [['variable'], ['entity.name.variable']]);
343-
export const constants = registerTokenType('constants', nls.localize('constants', "Style for constants."), undefined, variables);
344-
export const parameters = registerTokenType('parameters', nls.localize('parameters', "Style for parameters."), undefined, variables);
345-
export const property = registerTokenType('properties', nls.localize('properties', "Style for properties."), undefined, variables);
346-
347-
export const labels = registerTokenType('labels', nls.localize('labels', "Style for labels. "), undefined);
348-
349-
export const m_declaration = registerTokenModifier('declaration', nls.localize('declaration', "Style for all symbol declarations."), undefined);
350-
export const m_documentation = registerTokenModifier('documentation', nls.localize('documentation', "Style to use for references in documentation."), undefined);
351-
export const m_member = registerTokenModifier('member', nls.localize('member', "Style to use for member functions, variables (fields) and types."), undefined);
352-
export const m_static = registerTokenModifier('static', nls.localize('static', "Style to use for symbols that are static."), undefined);
353-
export const m_abstract = registerTokenModifier('abstract', nls.localize('abstract', "Style to use for symbols that are abstract."), undefined);
354-
export const m_deprecated = registerTokenModifier('deprecated', nls.localize('deprecated', "Style to use for symbols that are deprecated."), undefined);
355-
export const m_modification = registerTokenModifier('modification', nls.localize('modification', "Style to use for write accesses."), undefined);
356-
export const m_async = registerTokenModifier('async', nls.localize('async', "Style to use for symbols that are async."), undefined);
323+
// default token types
324+
325+
registerTokenType('comment', nls.localize('comment', "Style for comments."), [['comment']]);
326+
registerTokenType('string', nls.localize('string', "Style for strings."), [['string']]);
327+
registerTokenType('keyword', nls.localize('keyword', "Style for keywords."), [['keyword.control']]);
328+
registerTokenType('number', nls.localize('number', "Style for numbers."), [['constant.numeric']]);
329+
registerTokenType('regexp', nls.localize('regexp', "Style for expressions."), [['constant.regexp']]);
330+
registerTokenType('operator', nls.localize('operator', "Style for operators."), [['keyword.operator']]);
331+
332+
registerTokenType('namespace', nls.localize('namespace', "Style for namespaces."), [['entity.name.namespace']]);
333+
334+
registerTokenType('type', nls.localize('type', "Style for types."), [['entity.name.type'], ['entity.name.class'], ['support.type'], ['support.class']]);
335+
registerTokenType('struct', nls.localize('struct', "Style for structs."), [['storage.type.struct']], 'type');
336+
registerTokenType('class', nls.localize('class', "Style for classes."), [['entity.name.class']], 'type');
337+
registerTokenType('interface', nls.localize('interface', "Style for interfaces."), undefined, 'type');
338+
registerTokenType('enum', nls.localize('enum', "Style for enums."), undefined, 'type');
339+
registerTokenType('parameterType', nls.localize('parameterType', "Style for parameter types."), undefined, 'type');
340+
341+
registerTokenType('function', nls.localize('function', "Style for functions"), [['entity.name.function'], ['support.function']]);
342+
registerTokenType('macro', nls.localize('macro', "Style for macros."), undefined, 'function');
343+
344+
registerTokenType('variable', nls.localize('variable', "Style for variables."), [['variable'], ['entity.name.variable']]);
345+
registerTokenType('constant', nls.localize('constant', "Style for constants."), undefined, 'variable');
346+
registerTokenType('parameter', nls.localize('parameter', "Style for parameters."), undefined, 'variable');
347+
registerTokenType('property', nls.localize('propertie', "Style for properties."), undefined, 'variable');
348+
349+
registerTokenType('label', nls.localize('labels', "Style for labels. "), undefined);
350+
351+
// default token modifiers
352+
353+
registerTokenModifier('declaration', nls.localize('declaration', "Style for all symbol declarations."), undefined);
354+
registerTokenModifier('documentation', nls.localize('documentation', "Style to use for references in documentation."), undefined);
355+
registerTokenModifier('member', nls.localize('member', "Style to use for member functions, variables (fields) and types."), undefined);
356+
registerTokenModifier('static', nls.localize('static', "Style to use for symbols that are static."), undefined);
357+
registerTokenModifier('abstract', nls.localize('abstract', "Style to use for symbols that are abstract."), undefined);
358+
registerTokenModifier('deprecated', nls.localize('deprecated', "Style to use for symbols that are deprecated."), undefined);
359+
registerTokenModifier('modification', nls.localize('modification', "Style to use for write accesses."), undefined);
360+
registerTokenModifier('async', nls.localize('async', "Style to use for symbols that are async."), undefined);
361+
357362

358363
function bitCount(u: number) {
359364
// https://blogs.msdn.microsoft.com/jeuge/2005/06/08/bit-fiddling-3/

src/vs/workbench/services/themes/test/electron-browser/tokenStyleResolving.test.ts

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { ColorThemeData } from 'vs/workbench/services/themes/common/colorThemeData';
77
import * as assert from 'assert';
88
import { ITokenColorCustomizations } from 'vs/workbench/services/themes/common/workbenchThemeService';
9-
import { TokenStyle, comments, variables, types, functions, keywords, numbers, strings, getTokenClassificationRegistry } from 'vs/platform/theme/common/tokenClassificationRegistry';
9+
import { TokenStyle, getTokenClassificationRegistry } from 'vs/platform/theme/common/tokenClassificationRegistry';
1010
import { Color } from 'vs/base/common/color';
1111
import { isString } from 'vs/base/common/types';
1212
import { FileService } from 'vs/platform/files/common/fileService';
@@ -107,13 +107,13 @@ suite('Themes - TokenStyleResolving', () => {
107107
assert.equal(themeData.isLoaded, true);
108108

109109
assertTokenStyles(themeData, {
110-
[comments]: ts('#88846f', undefinedStyle),
111-
[variables]: ts('#F8F8F2', unsetStyle),
112-
[types]: ts('#A6E22E', { underline: true }),
113-
[functions]: ts('#A6E22E', unsetStyle),
114-
[strings]: ts('#E6DB74', undefinedStyle),
115-
[numbers]: ts('#AE81FF', undefinedStyle),
116-
[keywords]: ts('#F92672', undefinedStyle)
110+
'comment': ts('#88846f', undefinedStyle),
111+
'variable': ts('#F8F8F2', unsetStyle),
112+
'type': ts('#A6E22E', { underline: true }),
113+
'function': ts('#A6E22E', unsetStyle),
114+
'string': ts('#E6DB74', undefinedStyle),
115+
'number': ts('#AE81FF', undefinedStyle),
116+
'keyword': ts('#F92672', undefinedStyle)
117117
});
118118

119119
});
@@ -127,13 +127,13 @@ suite('Themes - TokenStyleResolving', () => {
127127
assert.equal(themeData.isLoaded, true);
128128

129129
assertTokenStyles(themeData, {
130-
[comments]: ts('#6A9955', undefinedStyle),
131-
[variables]: ts('#9CDCFE', undefinedStyle),
132-
[types]: ts('#4EC9B0', undefinedStyle),
133-
[functions]: ts('#DCDCAA', undefinedStyle),
134-
[strings]: ts('#CE9178', undefinedStyle),
135-
[numbers]: ts('#B5CEA8', undefinedStyle),
136-
[keywords]: ts('#C586C0', undefinedStyle)
130+
'comment': ts('#6A9955', undefinedStyle),
131+
'variable': ts('#9CDCFE', undefinedStyle),
132+
'type': ts('#4EC9B0', undefinedStyle),
133+
'function': ts('#DCDCAA', undefinedStyle),
134+
'string': ts('#CE9178', undefinedStyle),
135+
'number': ts('#B5CEA8', undefinedStyle),
136+
'keyword': ts('#C586C0', undefinedStyle)
137137
});
138138

139139
});
@@ -147,13 +147,13 @@ suite('Themes - TokenStyleResolving', () => {
147147
assert.equal(themeData.isLoaded, true);
148148

149149
assertTokenStyles(themeData, {
150-
[comments]: ts('#008000', undefinedStyle),
151-
[variables]: ts(undefined, undefinedStyle),
152-
[types]: ts(undefined, undefinedStyle),
153-
[functions]: ts(undefined, undefinedStyle),
154-
[strings]: ts('#a31515', undefinedStyle),
155-
[numbers]: ts('#09885a', undefinedStyle),
156-
[keywords]: ts('#0000ff', undefinedStyle)
150+
'comment': ts('#008000', undefinedStyle),
151+
'variable': ts(undefined, undefinedStyle),
152+
'type': ts(undefined, undefinedStyle),
153+
'function': ts(undefined, undefinedStyle),
154+
'string': ts('#a31515', undefinedStyle),
155+
'number': ts('#09885a', undefinedStyle),
156+
'keyword': ts('#0000ff', undefinedStyle)
157157
});
158158

159159
});
@@ -167,13 +167,13 @@ suite('Themes - TokenStyleResolving', () => {
167167
assert.equal(themeData.isLoaded, true);
168168

169169
assertTokenStyles(themeData, {
170-
[comments]: ts('#7ca668', undefinedStyle),
171-
[variables]: ts('#9CDCFE', undefinedStyle),
172-
[types]: ts('#4EC9B0', undefinedStyle),
173-
[functions]: ts('#DCDCAA', undefinedStyle),
174-
[strings]: ts('#ce9178', undefinedStyle),
175-
[numbers]: ts('#b5cea8', undefinedStyle),
176-
[keywords]: ts('#C586C0', undefinedStyle)
170+
'comment': ts('#7ca668', undefinedStyle),
171+
'variable': ts('#9CDCFE', undefinedStyle),
172+
'type': ts('#4EC9B0', undefinedStyle),
173+
'function': ts('#DCDCAA', undefinedStyle),
174+
'string': ts('#ce9178', undefinedStyle),
175+
'number': ts('#b5cea8', undefinedStyle),
176+
'keyword': ts('#C586C0', undefinedStyle)
177177
});
178178

179179
});
@@ -187,13 +187,13 @@ suite('Themes - TokenStyleResolving', () => {
187187
assert.equal(themeData.isLoaded, true);
188188

189189
assertTokenStyles(themeData, {
190-
[comments]: ts('#a57a4c', undefinedStyle),
191-
[variables]: ts('#dc3958', undefinedStyle),
192-
[types]: ts('#f06431', undefinedStyle),
193-
[functions]: ts('#8ab1b0', undefinedStyle),
194-
[strings]: ts('#889b4a', undefinedStyle),
195-
[numbers]: ts('#f79a32', undefinedStyle),
196-
[keywords]: ts('#98676a', undefinedStyle)
190+
'comment': ts('#a57a4c', undefinedStyle),
191+
'variable': ts('#dc3958', undefinedStyle),
192+
'type': ts('#f06431', undefinedStyle),
193+
'function': ts('#8ab1b0', undefinedStyle),
194+
'string': ts('#889b4a', undefinedStyle),
195+
'number': ts('#f79a32', undefinedStyle),
196+
'keyword': ts('#98676a', undefinedStyle)
197197
});
198198

199199
});
@@ -207,13 +207,13 @@ suite('Themes - TokenStyleResolving', () => {
207207
assert.equal(themeData.isLoaded, true);
208208

209209
assertTokenStyles(themeData, {
210-
[comments]: ts('#384887', undefinedStyle),
211-
[variables]: ts(undefined, unsetStyle),
212-
[types]: ts('#ffeebb', { underline: true }),
213-
[functions]: ts('#ddbb88', unsetStyle),
214-
[strings]: ts('#22aa44', undefinedStyle),
215-
[numbers]: ts('#f280d0', undefinedStyle),
216-
[keywords]: ts('#225588', undefinedStyle)
210+
'comment': ts('#384887', undefinedStyle),
211+
'variable': ts(undefined, unsetStyle),
212+
'type': ts('#ffeebb', { underline: true }),
213+
'function': ts('#ddbb88', unsetStyle),
214+
'string': ts('#22aa44', undefinedStyle),
215+
'number': ts('#f280d0', undefinedStyle),
216+
'keyword': ts('#225588', undefinedStyle)
217217
});
218218

219219
});
@@ -301,23 +301,23 @@ suite('Themes - TokenStyleResolving', () => {
301301
const themeData = ColorThemeData.createLoadedEmptyTheme('test', 'test');
302302
themeData.setCustomColors({ 'editor.foreground': '#000000' });
303303
themeData.setCustomTokenStyleRules({
304-
'types': '#ff0000',
305-
'classes': { foreground: '#0000ff', fontStyle: 'italic' },
304+
'type': '#ff0000',
305+
'class': { foreground: '#0000ff', fontStyle: 'italic' },
306306
'*.static': { fontStyle: 'bold' },
307307
'*.declaration': { fontStyle: 'italic' },
308308
'*.async.static': { fontStyle: 'italic underline' },
309309
'*.async': { foreground: '#000fff', fontStyle: '-italic underline' }
310310
});
311311

312312
assertTokenStyles(themeData, {
313-
'types': ts('#ff0000', undefinedStyle),
314-
'types.static': ts('#ff0000', { bold: true }),
315-
'types.static.declaration': ts('#ff0000', { bold: true, italic: true }),
316-
'classes': ts('#0000ff', { italic: true }),
317-
'classes.static.declaration': ts('#0000ff', { bold: true, italic: true }),
318-
'classes.declaration': ts('#0000ff', { italic: true }),
319-
'classes.declaration.async': ts('#000fff', { underline: true, italic: false }),
320-
'classes.declaration.async.static': ts('#000fff', { italic: true, underline: true, bold: true }),
313+
'type': ts('#ff0000', undefinedStyle),
314+
'type.static': ts('#ff0000', { bold: true }),
315+
'type.static.declaration': ts('#ff0000', { bold: true, italic: true }),
316+
'class': ts('#0000ff', { italic: true }),
317+
'class.static.declaration': ts('#0000ff', { bold: true, italic: true }),
318+
'class.declaration': ts('#0000ff', { italic: true }),
319+
'class.declaration.async': ts('#000fff', { underline: true, italic: false }),
320+
'class.declaration.async.static': ts('#000fff', { italic: true, underline: true, bold: true }),
321321
});
322322

323323
});

0 commit comments

Comments
 (0)