@@ -26,15 +26,16 @@ let lastStatus;
2626let languageClient : LanguageClient ;
2727const jdtEventEmitter = new EventEmitter < Uri > ( ) ;
2828const cleanWorkspaceFileName = '.cleanWorkspace' ;
29+ let clientLogFile ;
2930
3031export function activate ( context : ExtensionContext ) : Promise < ExtensionAPI > {
3132
3233 let storagePath = context . storagePath ;
3334 if ( ! storagePath ) {
3435 storagePath = getTempWorkspace ( ) ;
3536 }
36-
37- initializeLogFile ( path . join ( storagePath , 'client.log' ) ) ;
37+ clientLogFile = path . join ( storagePath , 'client.log' ) ;
38+ initializeLogFile ( clientLogFile ) ;
3839
3940 enableJavadocSymbols ( ) ;
4041
@@ -331,6 +332,8 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
331332
332333 context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_SERVER_LOG , ( ) => openServerLogFile ( workspacePath ) ) ) ;
333334
335+ context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_CLIENT_LOG , ( ) => openClientLogFile ( clientLogFile ) ) ) ;
336+
334337 const extensionPath = context . extensionPath ;
335338 context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_FORMATTER , async ( ) => openFormatter ( extensionPath ) ) ) ;
336339
@@ -491,11 +494,20 @@ function deleteDirectory(dir) {
491494
492495function openServerLogFile ( workspacePath ) : Thenable < boolean > {
493496 const serverLogFile = path . join ( workspacePath , '.metadata' , '.log' ) ;
494- if ( ! fs . existsSync ( serverLogFile ) ) {
495- return window . showWarningMessage ( 'Java Language Server has not started logging.' ) . then ( ( ) => false ) ;
497+ return openLogFile ( serverLogFile , 'Could not open Java Language Server log file' ) ;
498+ }
499+
500+ function openClientLogFile ( logFile ) : Thenable < boolean > {
501+ return openLogFile ( logFile , 'Could not open Java extension log file' ) ;
502+ }
503+
504+
505+ function openLogFile ( logFile , openingFailureWarning :string ) : Thenable < boolean > {
506+ if ( ! fs . existsSync ( logFile ) ) {
507+ return window . showWarningMessage ( 'No log file available' ) . then ( ( ) => false ) ;
496508 }
497509
498- return workspace . openTextDocument ( serverLogFile )
510+ return workspace . openTextDocument ( logFile )
499511 . then ( doc => {
500512 if ( ! doc ) {
501513 return false ;
@@ -506,7 +518,7 @@ function openServerLogFile(workspacePath): Thenable<boolean> {
506518 } , ( ) => false )
507519 . then ( didOpen => {
508520 if ( ! didOpen ) {
509- window . showWarningMessage ( 'Could not open Java Language Server log file' ) ;
521+ window . showWarningMessage ( openingFailureWarning ) ;
510522 }
511523 return didOpen ;
512524 } ) ;
0 commit comments