diff --git a/extensions/typescript-language-features/src/features/semanticTokens.ts b/extensions/typescript-language-features/src/features/semanticTokens.ts index 252d946eb25..f75ec6eb32b 100644 --- a/extensions/typescript-language-features/src/features/semanticTokens.ts +++ b/extensions/typescript-language-features/src/features/semanticTokens.ts @@ -35,12 +35,6 @@ class DocumentSemanticTokensProvider implements vscode.DocumentSemanticTokensPro } getLegend(): vscode.SemanticTokensLegend { - if (tokenTypes.length !== TokenType._) { - console.warn('typescript-vscode-sh-plugin has added new tokens types.'); - } - if (tokenModifiers.length !== TokenModifier._) { - console.warn('typescript-vscode-sh-plugin has added new tokens modifiers.'); - } return new vscode.SemanticTokensLegend(tokenTypes, tokenModifiers); } @@ -146,6 +140,7 @@ tokenTypes[TokenType.typeParameter] = 'typeParameter'; tokenTypes[TokenType.type] = 'type'; tokenTypes[TokenType.parameter] = 'parameter'; tokenTypes[TokenType.variable] = 'variable'; +tokenTypes[TokenType.enumMember] = 'enumMember'; tokenTypes[TokenType.property] = 'property'; tokenTypes[TokenType.function] = 'function'; tokenTypes[TokenType.member] = 'member'; @@ -156,6 +151,14 @@ tokenModifiers[TokenModifier.declaration] = 'declaration'; tokenModifiers[TokenModifier.readonly] = 'readonly'; tokenModifiers[TokenModifier.static] = 'static'; +// make sure token types and modifiers are complete +if (tokenTypes.filter(t => !!t).length !== TokenType._) { + console.warn('typescript-vscode-sh-plugin has added new tokens types.'); +} +if (tokenModifiers.filter(t => !!t).length !== TokenModifier._) { + console.warn('typescript-vscode-sh-plugin has added new tokens modifiers.'); +} + // mapping for the original ExperimentalProtocol.ClassificationType from TypeScript (only used when plugin is not available) const tokenTypeMap: number[] = []; tokenTypeMap[ExperimentalProtocol.ClassificationType.className] = TokenType.class;