@@ -67,7 +67,7 @@ import { initializeRunConfiguration, runConfigurationProvider, runConfigurationN
67
67
import { InputStep , MultiStepInput } from './utils' ;
68
68
import { PropertiesView } from './propertiesView/propertiesView' ;
69
69
import { openJDKSelectionView } from './jdkDownloader' ;
70
-
70
+ import { NODE_WINDOWS_LABEL } from './constants' ;
71
71
const API_VERSION : string = "1.0" ;
72
72
const SERVER_NAME : string = "Oracle Java SE Language Server" ;
73
73
export const COMMAND_PREFIX : string = "jdk" ;
@@ -78,7 +78,7 @@ let nbProcess : ChildProcess | null = null;
78
78
let debugPort : number = - 1 ;
79
79
let debugHash : string | undefined ;
80
80
let consoleLog : boolean = ! ! process . env [ 'ENABLE_CONSOLE_LOG' ] ;
81
-
81
+ let deactivated : boolean = true ;
82
82
export class NbLanguageClient extends LanguageClient {
83
83
private _treeViewService : TreeViewService ;
84
84
@@ -330,8 +330,8 @@ class InitialPromise extends Promise<NbLanguageClient> {
330
330
}
331
331
332
332
export function activate ( context : ExtensionContext ) : VSNetBeansAPI {
333
+ deactivated = false ;
333
334
let log = vscode . window . createOutputChannel ( SERVER_NAME ) ;
334
-
335
335
var clientResolve : ( x : NbLanguageClient ) => void ;
336
336
var clientReject : ( err : any ) => void ;
337
337
@@ -513,19 +513,26 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
513
513
514
514
context . subscriptions . push ( vscode . commands . registerCommand ( COMMAND_PREFIX + ".delete.cache" , async ( ) => {
515
515
const storagePath = context . storageUri ?. fsPath ;
516
- if ( ! storagePath ) {
516
+ if ( ! storagePath ) {
517
517
vscode . window . showErrorMessage ( 'Cannot find workspace path' ) ;
518
518
return ;
519
519
}
520
+
520
521
const userDir = path . join ( storagePath , "userdir" ) ;
521
522
if ( userDir && fs . existsSync ( userDir ) ) {
522
- const confirmation = await vscode . window . showInformationMessage ( 'Are you sure you want to delete cache for this workspace?' ,
523
+ const confirmation = await vscode . window . showInformationMessage ( 'Are you sure you want to delete cache for this workspace and reload the window ?' ,
523
524
'Yes' , 'Cancel' ) ;
524
525
if ( confirmation === 'Yes' ) {
525
- await fs . promises . rmdir ( userDir , { recursive : true } ) ;
526
- const res = await vscode . window . showInformationMessage ( 'Cache cleared successfully for this workspace' , 'Reload window' ) ;
527
- if ( res === 'Reload window' ) {
528
- await vscode . commands . executeCommand ( 'workbench.action.reloadWindow' ) ;
526
+ try {
527
+ await stopClient ( client ) ;
528
+ deactivated = true ;
529
+ await killNbProcess ( false , log ) ;
530
+ await fs . promises . rmdir ( userDir , { recursive : true } ) ;
531
+ await vscode . window . showInformationMessage ( "Cache deleted successfully" , 'Reload window' ) ;
532
+ } catch ( err ) {
533
+ await vscode . window . showErrorMessage ( 'Error deleting the cache' , 'Reload window' ) ;
534
+ } finally {
535
+ vscode . commands . executeCommand ( "workbench.action.reloadWindow" ) ;
529
536
}
530
537
}
531
538
} else {
@@ -960,7 +967,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
960
967
if ( p == nbProcess && code != 0 && code ) {
961
968
vscode . window . showWarningMessage ( `${ SERVER_NAME } exited with ` + code ) ;
962
969
}
963
- if ( stdErr ?. match ( / C a n n o t f i n d j a v a / ) || os . type ( ) === "Windows_NT" ) {
970
+ if ( stdErr ?. match ( / C a n n o t f i n d j a v a / ) || ( os . type ( ) === NODE_WINDOWS_LABEL && ! deactivated ) ) {
964
971
vscode . window . showInformationMessage (
965
972
"No JDK found!" ,
966
973
"Download JDK and setup automatically"
0 commit comments