@@ -7,7 +7,7 @@ import * as fse from 'fs-extra';
77import { workspace , extensions , ExtensionContext , window , commands , ViewColumn , Uri , languages , IndentAction , InputBoxOptions , Selection , Position , EventEmitter , OutputChannel , TextDocument , RelativePattern , ConfigurationTarget , WorkspaceConfiguration , env , UIKind } from 'vscode' ;
88import { ExecuteCommandParams , ExecuteCommandRequest , LanguageClientOptions , RevealOutputChannelOn , ErrorHandler , Message , ErrorAction , CloseAction , DidChangeConfigurationNotification , CancellationToken } from 'vscode-languageclient' ;
99import { LanguageClient } from 'vscode-languageclient/node' ;
10- import { collectJavaExtensions } from './plugin' ;
10+ import { collectJavaExtensions , isContributedPartUpdated } from './plugin' ;
1111import { prepareExecutable } from './javaServerStarter' ;
1212import * as requirements from './requirements' ;
1313import { initialize as initializeRecommendation } from './recommendation' ;
@@ -355,7 +355,19 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
355355 if ( onDidGrantWorkspaceTrust !== undefined ) { // keep compatibility for old engines < 1.56.0
356356 context . subscriptions . push ( onDidGrantWorkspaceTrust ( ( ) => {
357357 if ( getJavaServerMode ( ) !== ServerMode . LIGHTWEIGHT ) {
358- commands . executeCommand ( Commands . SWITCH_SERVER_MODE , ServerMode . STANDARD , true ) ;
358+ // See the issue https://github.com/redhat-developer/vscode-java/issues/1994
359+ // Need to recollect the Java bundles before starting standard mode.
360+ let pollingCount : number = 0 ;
361+ // Poll every ~100ms (timeout after 1s) and check whether contributing javaExtensions have changed.
362+ const intervalId = setInterval ( ( ) => {
363+ const existingJavaExtensions = clientOptions . initializationOptions . bundles ;
364+ clientOptions . initializationOptions . bundles = collectJavaExtensions ( extensions . all ) ;
365+ if ( ++ pollingCount >= 10 || isContributedPartUpdated ( existingJavaExtensions , clientOptions . initializationOptions . bundles ) ) {
366+ clearInterval ( intervalId ) ;
367+ commands . executeCommand ( Commands . SWITCH_SERVER_MODE , ServerMode . STANDARD , true ) ;
368+ return ;
369+ }
370+ } , 100 ) ;
359371 }
360372 } ) ) ;
361373 }
0 commit comments