@@ -376,7 +376,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
376376
377377 context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_FORMATTER , async ( ) => openFormatter ( context . extensionPath ) ) ) ;
378378
379- context . subscriptions . push ( commands . registerCommand ( Commands . CLEAN_WORKSPACE , ( ) => cleanWorkspace ( workspacePath ) ) ) ;
379+ context . subscriptions . push ( commands . registerCommand ( Commands . CLEAN_WORKSPACE , ( force ?: boolean ) => cleanWorkspace ( workspacePath , force ) ) ) ;
380380
381381 context . subscriptions . push ( commands . registerCommand ( Commands . GET_WORKSPACE_PATH , ( ) => workspacePath ) ) ;
382382
@@ -715,16 +715,18 @@ function makeRandomHexString(length) {
715715 return result ;
716716}
717717
718- async function cleanWorkspace ( workspacePath ) {
719- const doIt = 'Restart and delete' ;
720- window . showWarningMessage ( 'Are you sure you want to clean the Java language server workspace?' , 'Cancel' , doIt ) . then ( selection => {
721- if ( selection === doIt ) {
722- ensureExists ( workspacePath ) ;
723- const file = path . join ( workspacePath , cleanWorkspaceFileName ) ;
724- fs . closeSync ( fs . openSync ( file , 'w' ) ) ;
725- commands . executeCommand ( Commands . RELOAD_WINDOW ) ;
718+ async function cleanWorkspace ( workspacePath , force ?: boolean ) {
719+ if ( ! force ) {
720+ const doIt = 'Restart and delete' ;
721+ const selection = await window . showWarningMessage ( 'Are you sure you want to clean the Java language server workspace?' , 'Cancel' , doIt ) ;
722+ if ( selection !== doIt ) {
723+ return ;
726724 }
727- } ) ;
725+ }
726+ ensureExists ( workspacePath ) ;
727+ const file = path . join ( workspacePath , cleanWorkspaceFileName ) ;
728+ fs . closeSync ( fs . openSync ( file , 'w' ) ) ;
729+ commands . executeCommand ( Commands . RELOAD_WINDOW ) ;
728730}
729731
730732function openServerLogFile ( workspacePath , column : ViewColumn = ViewColumn . Active ) : Thenable < boolean > {
0 commit comments