@@ -3,7 +3,11 @@ import { Commands } from './commands';
33import { getJavaConfiguration } from './utils' ;
44
55export function registerSemanticTokensProvider ( context : vscode . ExtensionContext ) {
6- if ( isSemanticHTokensEnabled ( ) ) {
6+ if ( ! vscode . languages . registerDocumentSemanticTokensProvider ) { // in case Theia doesn't support this API
7+ return ;
8+ }
9+
10+ if ( isSemanticHighlightingEnabled ( ) ) {
711 getSemanticTokensLegend ( ) . then ( legend => {
812 const semanticTokensProviderDisposable = vscode . languages . registerDocumentSemanticTokensProvider ( { scheme : 'file' , language : 'java' } , semanticTokensProvider , legend ) ;
913 context . subscriptions . push ( semanticTokensProviderDisposable ) ;
@@ -38,7 +42,7 @@ function onceSemanticTokenEnabledChange(context: vscode.ExtensionContext, regist
3842 const configChangeListener = vscode . workspace . onDidChangeConfiguration ( e => {
3943 configChangeListener . dispose ( ) ;
4044 if ( e . affectsConfiguration ( 'java.semanticHighlighting.enabled' ) ) {
41- if ( isSemanticHTokensEnabled ( ) ) {
45+ if ( isSemanticHighlightingEnabled ( ) ) {
4246 // turn on
4347 registerSemanticTokensProvider ( context ) ;
4448 } else if ( registeredDisposable ) {
@@ -50,7 +54,7 @@ function onceSemanticTokenEnabledChange(context: vscode.ExtensionContext, regist
5054 } ) ;
5155}
5256
53- function isSemanticHTokensEnabled ( ) : boolean {
57+ function isSemanticHighlightingEnabled ( ) : boolean {
5458 const config = getJavaConfiguration ( ) ;
5559 const section = 'semanticHighlighting.enabled' ;
5660 return config . get ( section ) ;
0 commit comments