@@ -6,7 +6,7 @@ import * as fse from 'fs-extra';
6
6
import * as os from 'os' ;
7
7
import * as path from 'path' ;
8
8
import { 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' ;
10
10
import { LanguageClient } from 'vscode-languageclient/node' ;
11
11
import { apiManager } from './apiManager' ;
12
12
import { ClientErrorHandler } from './clientErrorHandler' ;
@@ -184,12 +184,12 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
184
184
} ,
185
185
// https://github.com/redhat-developer/vscode-java/issues/2130
186
186
// 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 ) => {
188
188
const client : LanguageClient = standardClient . getClient ( ) ;
189
189
const params : CodeActionParams = {
190
190
textDocument : client . code2ProtocolConverter . asTextDocumentIdentifier ( document ) ,
191
191
range : client . code2ProtocolConverter . asRange ( range ) ,
192
- context : client . code2ProtocolConverter . asCodeActionContext ( context )
192
+ context : await client . code2ProtocolConverter . asCodeActionContext ( context )
193
193
} ;
194
194
const showAt = getJavaConfiguration ( ) . get < string > ( "quickfix.showAt" ) ;
195
195
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> {
210
210
only : context . only ,
211
211
triggerKind : context . triggerKind ,
212
212
} ;
213
- params . context = client . code2ProtocolConverter . asCodeActionContext ( codeActionContext ) ;
213
+ params . context = await client . code2ProtocolConverter . asCodeActionContext ( codeActionContext ) ;
214
214
}
215
215
}
216
216
return client . sendRequest ( CodeActionRequest . type , params , token ) . then ( ( values ) => {
@@ -248,13 +248,16 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
248
248
// no need to pass `resolve` into any code past this point,
249
249
// since `resolve` is a no-op from now on
250
250
251
+ const serverOptions = prepareExecutable ( requirements , syntaxServerWorkspacePath , getJavaConfig ( requirements . java_home ) , context , true ) ;
251
252
if ( requireSyntaxServer ) {
252
253
if ( process . env [ 'SYNTAXLS_CLIENT_PORT' ] ) {
253
254
syntaxClient . initialize ( requirements , clientOptions ) ;
254
255
} else {
255
- syntaxClient . initialize ( requirements , clientOptions , prepareExecutable ( requirements , syntaxServerWorkspacePath , getJavaConfig ( requirements . java_home ) , context , true ) ) ;
256
+ syntaxClient . initialize ( requirements , clientOptions , serverOptions ) ;
256
257
}
257
- syntaxClient . start ( ) ;
258
+ syntaxClient . start ( ) . then ( ( ) => {
259
+ syntaxClient . registerSyntaxClientActions ( serverOptions ) ;
260
+ } ) ;
258
261
serverStatusBarProvider . showLightWeightStatus ( ) ;
259
262
}
260
263
@@ -429,7 +432,9 @@ async function startStandardServer(context: ExtensionContext, requirements: requ
429
432
apiManager . fireDidServerModeChange ( ServerMode . hybrid ) ;
430
433
}
431
434
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
+ } ) ;
433
438
serverStatusBarProvider . showStandardStatus ( ) ;
434
439
}
435
440
@@ -531,7 +536,9 @@ export async function getActiveLanguageClient(): Promise<LanguageClient | undefi
531
536
return undefined ;
532
537
}
533
538
534
- await languageClient . onReady ( ) ;
539
+ if ( languageClient . needsStart ( ) ) {
540
+ await languageClient . start ( ) ;
541
+ }
535
542
536
543
return languageClient ;
537
544
}
0 commit comments