@@ -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' ;
@@ -167,16 +167,15 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
167
167
resolveAdditionalTextEditsSupport : true ,
168
168
advancedIntroduceParameterRefactoringSupport : true ,
169
169
actionableRuntimeNotificationSupport : true ,
170
- shouldLanguageServerExitOnShutdown : true ,
171
170
onCompletionItemSelectedCommand : "editor.action.triggerParameterHints" ,
172
171
extractInterfaceSupport : true ,
173
172
} ,
174
173
triggerFiles,
175
174
} ,
176
175
middleware : {
177
176
workspace : {
178
- didChangeConfiguration : ( ) => {
179
- standardClient . getClient ( ) . sendNotification ( DidChangeConfigurationNotification . type , {
177
+ didChangeConfiguration : async ( ) => {
178
+ await standardClient . getClient ( ) . sendNotification ( DidChangeConfigurationNotification . type , {
180
179
settings : {
181
180
java : getJavaConfig ( requirements . java_home ) ,
182
181
}
@@ -185,12 +184,12 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
185
184
} ,
186
185
// https://github.com/redhat-developer/vscode-java/issues/2130
187
186
// include all diagnostics for the current line in the CodeActionContext params for the performance reason
188
- provideCodeActions : ( document , range , context , token , next ) => {
187
+ provideCodeActions : async ( document , range , context , token , next ) => {
189
188
const client : LanguageClient = standardClient . getClient ( ) ;
190
189
const params : CodeActionParams = {
191
190
textDocument : client . code2ProtocolConverter . asTextDocumentIdentifier ( document ) ,
192
191
range : client . code2ProtocolConverter . asRange ( range ) ,
193
- context : client . code2ProtocolConverter . asCodeActionContext ( context )
192
+ context : await client . code2ProtocolConverter . asCodeActionContext ( context )
194
193
} ;
195
194
const showAt = getJavaConfiguration ( ) . get < string > ( "quickfix.showAt" ) ;
196
195
if ( showAt === 'line' && range . start . line === range . end . line && range . start . character === range . end . character ) {
@@ -209,12 +208,12 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
209
208
const codeActionContext : CodeActionContext = {
210
209
diagnostics : allDiagnostics ,
211
210
only : context . only ,
212
- triggerKind : CodeActionTriggerKind . Invoke ,
211
+ triggerKind : context . triggerKind ,
213
212
} ;
214
- params . context = client . code2ProtocolConverter . asCodeActionContext ( codeActionContext ) ;
213
+ params . context = await client . code2ProtocolConverter . asCodeActionContext ( codeActionContext ) ;
215
214
}
216
215
}
217
- return client . sendRequest ( CodeActionRequest . type , params , token ) . then ( ( values ) => {
216
+ return client . sendRequest ( CodeActionRequest . type , params , token ) . then ( async ( values ) => {
218
217
if ( values === null ) {
219
218
return undefined ;
220
219
}
@@ -224,7 +223,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
224
223
result . push ( client . protocol2CodeConverter . asCommand ( item ) ) ;
225
224
}
226
225
else {
227
- result . push ( client . protocol2CodeConverter . asCodeAction ( item ) ) ;
226
+ result . push ( await client . protocol2CodeConverter . asCodeAction ( item ) ) ;
228
227
}
229
228
}
230
229
return result ;
@@ -249,13 +248,16 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
249
248
// no need to pass `resolve` into any code past this point,
250
249
// since `resolve` is a no-op from now on
251
250
251
+ const serverOptions = prepareExecutable ( requirements , syntaxServerWorkspacePath , getJavaConfig ( requirements . java_home ) , context , true ) ;
252
252
if ( requireSyntaxServer ) {
253
253
if ( process . env [ 'SYNTAXLS_CLIENT_PORT' ] ) {
254
254
syntaxClient . initialize ( requirements , clientOptions ) ;
255
255
} else {
256
- syntaxClient . initialize ( requirements , clientOptions , prepareExecutable ( requirements , syntaxServerWorkspacePath , getJavaConfig ( requirements . java_home ) , context , true ) ) ;
256
+ syntaxClient . initialize ( requirements , clientOptions , serverOptions ) ;
257
257
}
258
- syntaxClient . start ( ) ;
258
+ syntaxClient . start ( ) . then ( ( ) => {
259
+ syntaxClient . registerSyntaxClientActions ( serverOptions ) ;
260
+ } ) ;
259
261
serverStatusBarProvider . showLightWeightStatus ( ) ;
260
262
}
261
263
@@ -430,7 +432,9 @@ async function startStandardServer(context: ExtensionContext, requirements: requ
430
432
apiManager . fireDidServerModeChange ( ServerMode . hybrid ) ;
431
433
}
432
434
await standardClient . initialize ( context , requirements , clientOptions , workspacePath , jdtEventEmitter ) ;
433
- standardClient . start ( ) ;
435
+ standardClient . start ( ) . then ( async ( ) => {
436
+ standardClient . registerLanguageClientActions ( context , await fse . pathExists ( path . join ( workspacePath , ".metadata" , ".plugins" ) ) , jdtEventEmitter ) ;
437
+ } ) ;
434
438
serverStatusBarProvider . showStandardStatus ( ) ;
435
439
}
436
440
@@ -532,7 +536,9 @@ export async function getActiveLanguageClient(): Promise<LanguageClient | undefi
532
536
return undefined ;
533
537
}
534
538
535
- await languageClient . onReady ( ) ;
539
+ if ( languageClient . needsStart ( ) ) {
540
+ await languageClient . start ( ) ;
541
+ }
536
542
537
543
return languageClient ;
538
544
}
0 commit comments