@@ -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 ) => {
@@ -244,13 +244,15 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
244
244
245
245
apiManager . initialize ( requirements , serverMode ) ;
246
246
247
+ const serverOptions = prepareExecutable ( requirements , syntaxServerWorkspacePath , getJavaConfig ( requirements . java_home ) , context , true ) ;
247
248
if ( requireSyntaxServer ) {
248
249
if ( process . env [ 'SYNTAXLS_CLIENT_PORT' ] ) {
249
250
syntaxClient . initialize ( requirements , clientOptions , resolve ) ;
250
251
} else {
251
- syntaxClient . initialize ( requirements , clientOptions , resolve , prepareExecutable ( requirements , syntaxServerWorkspacePath , getJavaConfig ( requirements . java_home ) , context , true ) ) ;
252
+ syntaxClient . initialize ( requirements , clientOptions , resolve , serverOptions ) ;
252
253
}
253
- syntaxClient . start ( ) ;
254
+ await syntaxClient . start ( ) ;
255
+ syntaxClient . registerSyntaxClientActions ( resolve , serverOptions ) ;
254
256
serverStatusBarProvider . showLightWeightStatus ( ) ;
255
257
}
256
258
@@ -427,7 +429,8 @@ async function startStandardServer(context: ExtensionContext, requirements: requ
427
429
apiManager . fireDidServerModeChange ( ServerMode . hybrid ) ;
428
430
}
429
431
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 ) ;
431
434
serverStatusBarProvider . showStandardStatus ( ) ;
432
435
}
433
436
@@ -525,12 +528,10 @@ export async function getActiveLanguageClient(): Promise<LanguageClient | undefi
525
528
languageClient = syntaxClient . getClient ( ) ;
526
529
}
527
530
528
- if ( ! languageClient ) {
531
+ if ( ! languageClient || languageClient . state !== State . Running ) {
529
532
return undefined ;
530
533
}
531
534
532
- await languageClient . onReady ( ) ;
533
-
534
535
return languageClient ;
535
536
}
536
537
0 commit comments