本文整理汇总了TypeScript中vs/editor/common/modes/supports/tokenization.TokenTheme.createFromRawTokenTheme方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TokenTheme.createFromRawTokenTheme方法的具体用法?TypeScript TokenTheme.createFromRawTokenTheme怎么用?TypeScript TokenTheme.createFromRawTokenTheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/modes/supports/tokenization.TokenTheme
的用法示例。
在下文中一共展示了TokenTheme.createFromRawTokenTheme方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('gives higher priority to deeper matches', () => {
let theme = TokenTheme.createFromRawTokenTheme([
{ token: '', foreground: '100000', background: '200000' },
{ token: 'punctuation.definition.string.begin.html', foreground: '300000' },
{ token: 'punctuation.definition.string', foreground: '400000' },
], []);
let colorMap = new ColorMap();
colorMap.getId('100000');
const _B = colorMap.getId('200000');
colorMap.getId('400000');
const _D = colorMap.getId('300000');
let actual = theme._match('punctuation.definition.string.begin.html');
assert.deepEqual(actual, new ThemeTrieElementRule(FontStyle.None, _D, _B));
});
示例2: test
test('can match', () => {
let theme = TokenTheme.createFromRawTokenTheme([
{ token: '', foreground: 'F8F8F2', background: '272822' },
{ token: 'source', background: '100000' },
{ token: 'something', background: '100000' },
{ token: 'bar', background: '200000' },
{ token: 'baz', background: '200000' },
{ token: 'bar', fontStyle: 'bold' },
{ token: 'constant', fontStyle: 'italic', foreground: '300000' },
{ token: 'constant.numeric', foreground: '400000' },
{ token: 'constant.numeric.hex', fontStyle: 'bold' },
{ token: 'constant.numeric.oct', fontStyle: 'bold italic underline' },
{ token: 'constant.numeric.dec', fontStyle: '', foreground: '500000' },
{ token: 'storage.object.bar', fontStyle: '', foreground: '600000' },
], []);
let colorMap = new ColorMap();
const _A = colorMap.getId('F8F8F2');
const _B = colorMap.getId('272822');
const _C = colorMap.getId('200000');
const _D = colorMap.getId('300000');
const _E = colorMap.getId('400000');
const _F = colorMap.getId('500000');
const _G = colorMap.getId('100000');
const _H = colorMap.getId('600000');
function assertMatch(scopeName: string, expected: ThemeTrieElementRule): void {
let actual = theme._match(scopeName);
assert.deepEqual(actual, expected, 'when matching <<' + scopeName + '>>');
}
function assertSimpleMatch(scopeName: string, fontStyle: FontStyle, foreground: number, background: number): void {
assertMatch(scopeName, new ThemeTrieElementRule(fontStyle, foreground, background));
}
function assertNoMatch(scopeName: string): void {
assertMatch(scopeName, new ThemeTrieElementRule(FontStyle.None, _A, _B));
}
// matches defaults
assertNoMatch('');
assertNoMatch('bazz');
assertNoMatch('asdfg');
// matches source
assertSimpleMatch('source', FontStyle.None, _A, _G);
assertSimpleMatch('source.ts', FontStyle.None, _A, _G);
assertSimpleMatch('source.tss', FontStyle.None, _A, _G);
// matches something
assertSimpleMatch('something', FontStyle.None, _A, _G);
assertSimpleMatch('something.ts', FontStyle.None, _A, _G);
assertSimpleMatch('something.tss', FontStyle.None, _A, _G);
// matches baz
assertSimpleMatch('baz', FontStyle.None, _A, _C);
assertSimpleMatch('baz.ts', FontStyle.None, _A, _C);
assertSimpleMatch('baz.tss', FontStyle.None, _A, _C);
// matches constant
assertSimpleMatch('constant', FontStyle.Italic, _D, _B);
assertSimpleMatch('constant.string', FontStyle.Italic, _D, _B);
assertSimpleMatch('constant.hex', FontStyle.Italic, _D, _B);
// matches constant.numeric
assertSimpleMatch('constant.numeric', FontStyle.Italic, _E, _B);
assertSimpleMatch('constant.numeric.baz', FontStyle.Italic, _E, _B);
// matches constant.numeric.hex
assertSimpleMatch('constant.numeric.hex', FontStyle.Bold, _E, _B);
assertSimpleMatch('constant.numeric.hex.baz', FontStyle.Bold, _E, _B);
// matches constant.numeric.oct
assertSimpleMatch('constant.numeric.oct', FontStyle.Bold | FontStyle.Italic | FontStyle.Underline, _E, _B);
assertSimpleMatch('constant.numeric.oct.baz', FontStyle.Bold | FontStyle.Italic | FontStyle.Underline, _E, _B);
// matches constant.numeric.dec
assertSimpleMatch('constant.numeric.dec', FontStyle.None, _F, _B);
assertSimpleMatch('constant.numeric.dec.baz', FontStyle.None, _F, _B);
// matches storage.object.bar
assertSimpleMatch('storage.object.bar', FontStyle.None, _H, _B);
assertSimpleMatch('storage.object.bar.baz', FontStyle.None, _H, _B);
// does not match storage.object.bar
assertSimpleMatch('storage.object.bart', FontStyle.None, _A, _B);
assertSimpleMatch('storage.object', FontStyle.None, _A, _B);
assertSimpleMatch('storage', FontStyle.None, _A, _B);
assertSimpleMatch('bar', FontStyle.Bold, _A, _C);
});
示例3: tokenTheme
public get tokenTheme(): TokenTheme {
if (!this._tokenTheme) {
this._tokenTheme = TokenTheme.createFromRawTokenTheme(this.rules);
}
return this._tokenTheme;
}