@@ -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 ) => {
@@ -248,13 +248,16 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
248248 // no need to pass `resolve` into any code past this point,
249249 // since `resolve` is a no-op from now on
250250
251+ const serverOptions = prepareExecutable ( requirements , syntaxServerWorkspacePath , getJavaConfig ( requirements . java_home ) , context , true ) ;
251252 if ( requireSyntaxServer ) {
252253 if ( process . env [ 'SYNTAXLS_CLIENT_PORT' ] ) {
253254 syntaxClient . initialize ( requirements , clientOptions ) ;
254255 } else {
255- syntaxClient . initialize ( requirements , clientOptions , prepareExecutable ( requirements , syntaxServerWorkspacePath , getJavaConfig ( requirements . java_home ) , context , true ) ) ;
256+ syntaxClient . initialize ( requirements , clientOptions , serverOptions ) ;
256257 }
257- syntaxClient . start ( ) ;
258+ syntaxClient . start ( ) . then ( ( ) => {
259+ syntaxClient . registerSyntaxClientActions ( serverOptions ) ;
260+ } ) ;
258261 serverStatusBarProvider . showLightWeightStatus ( ) ;
259262 }
260263
@@ -429,7 +432,9 @@ async function startStandardServer(context: ExtensionContext, requirements: requ
429432 apiManager . fireDidServerModeChange ( ServerMode . hybrid ) ;
430433 }
431434 await standardClient . initialize ( context , requirements , clientOptions , workspacePath , jdtEventEmitter ) ;
432- standardClient . start ( ) ;
435+ standardClient . start ( ) . then ( async ( ) => {
436+ standardClient . registerLanguageClientActions ( context , await fse . pathExists ( path . join ( workspacePath , ".metadata" , ".plugins" ) ) , jdtEventEmitter ) ;
437+ } ) ;
433438 serverStatusBarProvider . showStandardStatus ( ) ;
434439}
435440
@@ -531,7 +536,9 @@ export async function getActiveLanguageClient(): Promise<LanguageClient | undefi
531536 return undefined ;
532537 }
533538
534- await languageClient . onReady ( ) ;
539+ if ( languageClient . needsStart ( ) ) {
540+ await languageClient . start ( ) ;
541+ }
535542
536543 return languageClient ;
537544}
0 commit comments