@@ -6,7 +6,7 @@ import * as fse from 'fs-extra';
66import * as os from 'os' ;
77import * as path from 'path' ;
88import { CodeActionContext , CodeActionTriggerKind , commands , ConfigurationTarget , Diagnostic , env , EventEmitter , ExtensionContext , extensions , IndentAction , InputBoxOptions , languages , RelativePattern , TextDocument , UIKind , Uri , ViewColumn , window , workspace , WorkspaceConfiguration } from 'vscode' ;
9- import { CancellationToken , CodeActionParams , CodeActionRequest , Command , DidChangeConfigurationNotification , ExecuteCommandParams , ExecuteCommandRequest , LanguageClientOptions , RevealOutputChannelOn } from 'vscode-languageclient' ;
9+ import { CancellationToken , CodeActionParams , CodeActionRequest , Command , DidChangeConfigurationNotification , ExecuteCommandParams , ExecuteCommandRequest , LanguageClientOptions , RevealOutputChannelOn , State } from 'vscode-languageclient' ;
1010import { LanguageClient } from 'vscode-languageclient/node' ;
1111import { apiManager } from './apiManager' ;
1212import { ClientErrorHandler } from './clientErrorHandler' ;
@@ -184,12 +184,12 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
184184 } ,
185185 // https://github.com/redhat-developer/vscode-java/issues/2130
186186 // include all diagnostics for the current line in the CodeActionContext params for the performance reason
187- provideCodeActions : ( document , range , context , token , next ) => {
187+ provideCodeActions : async ( document , range , context , token , next ) => {
188188 const client : LanguageClient = standardClient . getClient ( ) ;
189189 const params : CodeActionParams = {
190190 textDocument : client . code2ProtocolConverter . asTextDocumentIdentifier ( document ) ,
191191 range : client . code2ProtocolConverter . asRange ( range ) ,
192- context : client . code2ProtocolConverter . asCodeActionContext ( context )
192+ context : await client . code2ProtocolConverter . asCodeActionContext ( context )
193193 } ;
194194 const showAt = getJavaConfiguration ( ) . get < string > ( "quickfix.showAt" ) ;
195195 if ( showAt === 'line' && range . start . line === range . end . line && range . start . character === range . end . character ) {
@@ -210,7 +210,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
210210 only : context . only ,
211211 triggerKind : context . triggerKind ,
212212 } ;
213- params . context = client . code2ProtocolConverter . asCodeActionContext ( codeActionContext ) ;
213+ params . context = await client . code2ProtocolConverter . asCodeActionContext ( codeActionContext ) ;
214214 }
215215 }
216216 return client . sendRequest ( CodeActionRequest . type , params , token ) . then ( ( values ) => {
@@ -244,13 +244,15 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
244244
245245 apiManager . initialize ( requirements , serverMode ) ;
246246
247+ const serverOptions = prepareExecutable ( requirements , syntaxServerWorkspacePath , getJavaConfig ( requirements . java_home ) , context , true ) ;
247248 if ( requireSyntaxServer ) {
248249 if ( process . env [ 'SYNTAXLS_CLIENT_PORT' ] ) {
249250 syntaxClient . initialize ( requirements , clientOptions , resolve ) ;
250251 } else {
251- syntaxClient . initialize ( requirements , clientOptions , resolve , prepareExecutable ( requirements , syntaxServerWorkspacePath , getJavaConfig ( requirements . java_home ) , context , true ) ) ;
252+ syntaxClient . initialize ( requirements , clientOptions , resolve , serverOptions ) ;
252253 }
253- syntaxClient . start ( ) ;
254+ await syntaxClient . start ( ) ;
255+ syntaxClient . registerSyntaxClientActions ( resolve , serverOptions ) ;
254256 serverStatusBarProvider . showLightWeightStatus ( ) ;
255257 }
256258
@@ -427,7 +429,8 @@ async function startStandardServer(context: ExtensionContext, requirements: requ
427429 apiManager . fireDidServerModeChange ( ServerMode . hybrid ) ;
428430 }
429431 await standardClient . initialize ( context , requirements , clientOptions , workspacePath , jdtEventEmitter , resolve ) ;
430- standardClient . start ( ) ;
432+ await standardClient . start ( ) ;
433+ standardClient . registerLanguageClientActions ( context , await fse . pathExists ( path . join ( workspacePath , ".metadata" , ".plugins" ) ) , jdtEventEmitter , resolve ) ;
431434 serverStatusBarProvider . showStandardStatus ( ) ;
432435}
433436
@@ -525,12 +528,10 @@ export async function getActiveLanguageClient(): Promise<LanguageClient | undefi
525528 languageClient = syntaxClient . getClient ( ) ;
526529 }
527530
528- if ( ! languageClient ) {
531+ if ( ! languageClient || languageClient . state !== State . Running ) {
529532 return undefined ;
530533 }
531534
532- await languageClient . onReady ( ) ;
533-
534535 return languageClient ;
535536}
536537
0 commit comments