add semantic token example folder
parent
013132d657
commit
2bde45241a
|
@ -8,11 +8,13 @@ import * as jsoncParser from 'jsonc-parser';
|
|||
|
||||
export function activate(context: vscode.ExtensionContext): any {
|
||||
|
||||
const tokenTypes = ['type', 'struct', 'class', 'interface', 'enum', 'parameterType', 'function', 'variable'];
|
||||
const tokenModifiers = ['static', 'abstract', 'deprecated', 'declaration', 'documentation', 'member', 'async'];
|
||||
const tokenTypes = ['type', 'struct', 'class', 'interface', 'enum', 'parameterType', 'function', 'variable', 'testToken'];
|
||||
const tokenModifiers = ['static', 'abstract', 'deprecated', 'declaration', 'documentation', 'member', 'async', 'testModifier'];
|
||||
|
||||
const legend = new vscode.SemanticTokensLegend(tokenTypes, tokenModifiers);
|
||||
|
||||
const outputChannel = vscode.window.createOutputChannel('Semantic Tokens Test');
|
||||
|
||||
const semanticHighlightProvider: vscode.SemanticTokensProvider = {
|
||||
provideSemanticTokens(document: vscode.TextDocument): vscode.ProviderResult<vscode.SemanticTokens> {
|
||||
const builder = new vscode.SemanticTokensBuilder();
|
||||
|
@ -35,8 +37,13 @@ export function activate(context: vscode.ExtensionContext): any {
|
|||
|
||||
|
||||
builder.push(startLine, startCharacter, length, tokenType, tokenModifiers);
|
||||
|
||||
const selectedModifiers = legend.tokenModifiers.filter((_val, bit) => tokenModifiers & (1 << bit)).join(' ');
|
||||
outputChannel.appendLine(`line: ${startLine}, character: ${startCharacter}, length ${length}, ${legend.tokenTypes[tokenType]} (${tokenType}), ${selectedModifiers} ${tokenModifiers.toString(2)}`);
|
||||
}
|
||||
|
||||
outputChannel.appendLine('---');
|
||||
|
||||
const visitor: jsoncParser.JSONVisitor = {
|
||||
onObjectProperty: (property: string, _offset: number, _length: number, startLine: number, startCharacter: number) => {
|
||||
addToken(property, startLine, startCharacter, property.length + 2);
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"editor.tokenColorCustomizationsExperimental": {
|
||||
"class": "#00b0b0",
|
||||
"interface": "#845faf",
|
||||
"function": "#ff00ff",
|
||||
"*.declaration": {
|
||||
"fontStyle": "underline"
|
||||
},
|
||||
"*.declaration.member": {
|
||||
"fontStyle": "italic bold",
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
[
|
||||
"class", "function.member.declaration",
|
||||
"parameterType.declaration", "type", "parameterType.declaration", "type",
|
||||
"variable.declaration", "parameterNames",
|
||||
"function.member.declaration",
|
||||
"interface.declaration",
|
||||
"function.member.declaration", "testToken.testModifier"
|
||||
|
||||
]
|
Loading…
Reference in New Issue