Skip to content

Commit

Permalink
fix(typescript): define accurate SemanticTokensLegend
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jun 22, 2024
1 parent 0038413 commit 7ac2881
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
17 changes: 1 addition & 16 deletions packages/typescript/lib/plugins/semantic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,37 +138,22 @@ export function create(
'class',
'enum',
'interface',
'struct',
'typeParameter',
'type',
'parameter',
'variable',
'property',
'enumMember',
'decorator',
'event',
'function',
'method',
'macro',
'label',
'comment',
'string',
'keyword',
'number',
'regexp',
'operator',
],
tokenModifiers: [
'declaration',
'definition',
'readonly',
'static',
'deprecated',
'abstract',
'async',
'modification',
'documentation',
'defaultLibrary',
'local', // additional
],
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript/lib/semanticFeatures/semanticTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function register(ts: typeof import('typescript'), ctx: SharedContext) {
tokenModifiersTable[TokenModifier.declaration] = 1 << legend.tokenModifiers.indexOf('declaration');
tokenModifiersTable[TokenModifier.readonly] = 1 << legend.tokenModifiers.indexOf('readonly');
tokenModifiersTable[TokenModifier.static] = 1 << legend.tokenModifiers.indexOf('static');
tokenModifiersTable[TokenModifier.local] = 1 << legend.tokenModifiers.indexOf('local'); // missing in server tokenModifiers
tokenModifiersTable[TokenModifier.local] = 1 << legend.tokenModifiers.indexOf('local');
tokenModifiersTable[TokenModifier.defaultLibrary] = 1 << legend.tokenModifiers.indexOf('defaultLibrary');
tokenModifiersTable = tokenModifiersTable.map(mod => Math.max(mod, 0));

Expand Down Expand Up @@ -146,7 +146,7 @@ tokenModifiers[TokenModifier.async] = 'async';
tokenModifiers[TokenModifier.declaration] = 'declaration';
tokenModifiers[TokenModifier.readonly] = 'readonly';
tokenModifiers[TokenModifier.static] = 'static';
tokenModifiers[TokenModifier.local] = 'local'; // missing in server tokenModifiers
tokenModifiers[TokenModifier.local] = 'local';
tokenModifiers[TokenModifier.defaultLibrary] = 'defaultLibrary';

// mapping for the original ExperimentalProtocol.ClassificationType from TypeScript (only used when plugin is not available)
Expand Down

0 comments on commit 7ac2881

Please sign in to comment.