@@ -32,30 +32,40 @@ async function activateExtension(_operationId: string, context: ExtensionContext
32
32
context . subscriptions . push ( syncHandler ) ;
33
33
context . subscriptions . push ( tasks . registerTaskProvider ( ExportJarTaskProvider . exportJarType , new ExportJarTaskProvider ( ) ) ) ;
34
34
35
- const javaLanguageSupport : Extension < any > | undefined = extensions . getExtension ( ExtensionName . JAVA_LANGUAGE_SUPPORT ) ;
36
- if ( ! javaLanguageSupport ) {
37
- return ;
38
- }
39
- javaLanguageSupport . activate ( ) . then ( ( ) => {
40
- const extensionApi : any = javaLanguageSupport . exports ;
41
- if ( ! extensionApi ) {
35
+ const pollingJLS = ( ) => {
36
+ const javaLanguageSupport : Extension < any > | undefined = extensions . getExtension ( ExtensionName . JAVA_LANGUAGE_SUPPORT ) ;
37
+ if ( ! javaLanguageSupport ) {
42
38
return ;
43
39
}
44
40
45
- if ( extensionApi . onDidClasspathUpdate ) {
46
- const onDidClasspathUpdate : Event < Uri > = extensionApi . onDidClasspathUpdate ;
47
- context . subscriptions . push ( onDidClasspathUpdate ( async ( ) => {
48
- syncHandler . updateFileWatcher ( Settings . autoRefresh ( ) ) ;
49
- } ) ) ;
50
- }
41
+ if ( javaLanguageSupport . isActive ) {
42
+ const extensionApi : any = javaLanguageSupport . exports ;
43
+ if ( ! extensionApi ) {
44
+ return ;
45
+ }
46
+
47
+ if ( extensionApi . onDidClasspathUpdate ) {
48
+ const onDidClasspathUpdate : Event < Uri > = extensionApi . onDidClasspathUpdate ;
49
+ context . subscriptions . push ( onDidClasspathUpdate ( async ( ) => {
50
+ syncHandler . updateFileWatcher ( Settings . autoRefresh ( ) ) ;
51
+ } ) ) ;
52
+ }
51
53
52
- if ( extensionApi . onDidServerModeChange ) {
53
- const onDidServerModeChange : Event < string > = extensionApi . onDidServerModeChange ;
54
- context . subscriptions . push ( onDidServerModeChange ( async ( ) => {
54
+ if ( extensionApi . serverMode === "Standard" ) {
55
55
syncHandler . updateFileWatcher ( Settings . autoRefresh ( ) ) ;
56
- } ) ) ;
56
+ } else {
57
+ if ( extensionApi . onDidServerModeChange ) {
58
+ const onDidServerModeChange : Event < string > = extensionApi . onDidServerModeChange ;
59
+ context . subscriptions . push ( onDidServerModeChange ( async ( ) => {
60
+ syncHandler . updateFileWatcher ( Settings . autoRefresh ( ) ) ;
61
+ } ) ) ;
62
+ }
63
+ }
64
+ } else {
65
+ setTimeout ( pollingJLS , 3 * 1000 /*ms*/ ) ;
57
66
}
58
- } ) ;
67
+ } ;
68
+ pollingJLS ( ) ;
59
69
}
60
70
61
71
// this method is called when your extension is deactivated
0 commit comments