@@ -5,7 +5,7 @@ import * as fs from 'fs';
55import * as fse from 'fs-extra' ;
66import * as os from 'os' ;
77import * as path from 'path' ;
8- import { CodeActionContext , commands , ConfigurationTarget , Diagnostic , env , EventEmitter , ExtensionContext , extensions , IndentAction , InputBoxOptions , languages , RelativePattern , TextDocument , UIKind , Uri , ViewColumn , window , workspace , WorkspaceConfiguration } from 'vscode' ;
8+ import { CodeActionContext , commands , ConfigurationTarget , Diagnostic , env , EventEmitter , ExtensionContext , extensions , IndentAction , InputBoxOptions , languages , RelativePattern , TextDocument , UIKind , Uri , ViewColumn , window , workspace , WorkspaceConfiguration , ProgressLocation } from 'vscode' ;
99import { CancellationToken , CodeActionParams , CodeActionRequest , Command , DidChangeConfigurationNotification , ExecuteCommandParams , ExecuteCommandRequest , LanguageClientOptions , RevealOutputChannelOn } from 'vscode-languageclient' ;
1010import { LanguageClient } from 'vscode-languageclient/node' ;
1111import { apiManager } from './apiManager' ;
@@ -329,6 +329,8 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
329329
330330 context . subscriptions . push ( onConfigurationChange ( workspacePath , context ) ) ;
331331
332+ registerRestartJavaLanguageServerCommand ( context ) ;
333+
332334 /**
333335 * Command to switch the server mode. Currently it only supports switch from lightweight to standard.
334336 * @param force force to switch server mode without asking
@@ -965,3 +967,24 @@ function registerOutOfMemoryDetection(storagePath: string) {
965967 showOOMMessage ( ) ;
966968 } ) ;
967969}
970+
971+ function registerRestartJavaLanguageServerCommand ( context : ExtensionContext ) {
972+ context . subscriptions . push ( commands . registerCommand ( Commands . RESTART_LANGUAGE_SERVER , async ( ) => {
973+ switch ( getJavaServerMode ( ) ) {
974+ case ( ServerMode . standard ) :
975+ // Standard server restart
976+ await standardClient . getClient ( ) . restart ( ) ;
977+ break ;
978+ case ( ServerMode . lightWeight ) :
979+ // Syntax server restart
980+ await syntaxClient . getClient ( ) . restart ( ) ;
981+ break ;
982+ case ( ServerMode . hybrid ) :
983+ if ( syntaxClient . isAlive ( ) ) {
984+ await syntaxClient . getClient ( ) . restart ( ) ;
985+ }
986+ await standardClient . getClient ( ) . restart ( ) ;
987+ break ;
988+ }
989+ } ) ) ;
990+ }
0 commit comments