@@ -13,29 +13,29 @@ export function registerVariableMenuCommands(context: vscode.ExtensionContext):
1313 // Initialize the context keys
1414 updateContextKeys ( ) ;
1515
16- context . subscriptions . push (
17- instrumentOperationAsVsCodeCommand ( "java.debug.variables.showHex" , ( ) => turnOnFormat ( "showHex" ) ) ) ;
18- context . subscriptions . push (
19- instrumentOperationAsVsCodeCommand ( "java.debug.variables.notShowHex" , ( ) => turnOffFormat ( "showHex" ) ) ) ;
20- context . subscriptions . push (
21- instrumentOperationAsVsCodeCommand ( "java.debug.variables.showQualifiedNames" , ( ) => turnOnFormat ( "showQualifiedNames" ) ) ) ;
22- context . subscriptions . push (
23- instrumentOperationAsVsCodeCommand ( "java.debug.variables.notShowQualifiedNames" , ( ) => turnOffFormat ( "showQualifiedNames" ) ) ) ;
24- context . subscriptions . push (
25- instrumentOperationAsVsCodeCommand ( "java.debug.variables.showStaticVariables" , ( ) => turnOnFormat ( "showStaticVariables" ) ) ) ;
26- context . subscriptions . push (
27- instrumentOperationAsVsCodeCommand ( "java.debug.variables.notShowStaticVariables" , ( ) => turnOffFormat ( "showStaticVariables" ) ) ) ;
28- context . subscriptions . push (
29- instrumentOperationAsVsCodeCommand ( "java.debug.variables.showLogicalStructure" , ( ) => turnOnFormat ( "showLogicalStructure" ) ) ) ;
30- context . subscriptions . push (
31- instrumentOperationAsVsCodeCommand ( "java.debug.variables.notShowLogicalStructure" , ( ) => turnOffFormat ( "showLogicalStructure" ) ) ) ;
32- context . subscriptions . push (
33- instrumentOperationAsVsCodeCommand ( "java.debug.variables.showToString" , ( ) => turnOnFormat ( "showToString" ) ) ) ;
34- context . subscriptions . push (
35- instrumentOperationAsVsCodeCommand ( "java.debug.variables.notShowToString" , ( ) => turnOffFormat ( "showToString" ) ) ) ;
16+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
17+ "java.debug.variables.showHex" , ( ) => updateVariableFormatter ( "showHex" , true ) ) ) ;
18+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
19+ "java.debug.variables.notShowHex" , ( ) => updateVariableFormatter ( "showHex" , false ) ) ) ;
20+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
21+ "java.debug.variables.showQualifiedNames" , ( ) => updateVariableFormatter ( "showQualifiedNames" , true ) ) ) ;
22+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
23+ "java.debug.variables.notShowQualifiedNames" , ( ) => updateVariableFormatter ( "showQualifiedNames" , false ) ) ) ;
24+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
25+ "java.debug.variables.showStaticVariables" , ( ) => updateVariableFormatter ( "showStaticVariables" , true ) ) ) ;
26+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
27+ "java.debug.variables.notShowStaticVariables" , ( ) => updateVariableFormatter ( "showStaticVariables" , false ) ) ) ;
28+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
29+ "java.debug.variables.showLogicalStructure" , ( ) => updateVariableFormatter ( "showLogicalStructure" , true ) ) ) ;
30+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
31+ "java.debug.variables.notShowLogicalStructure" , ( ) => updateVariableFormatter ( "showLogicalStructure" , false ) ) ) ;
32+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
33+ "java.debug.variables.showToString" , ( ) => updateVariableFormatter ( "showToString" , true ) ) ) ;
34+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
35+ "java.debug.variables.notShowToString" , ( ) => updateVariableFormatter ( "showToString" , false ) ) ) ;
3636}
3737
38- function turnOnFormat ( key : string ) {
38+ function updateVariableFormatter ( key : string , value : any ) {
3939 const debugSettingsRoot : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "java.debug.settings" ) ;
4040 if ( vscode . debug . activeDebugSession && vscode . debug . activeDebugSession . type === "java" ) {
4141 const formatter : any = {
@@ -45,7 +45,7 @@ function turnOnFormat(key: string) {
4545 showLogicalStructure : debugSettingsRoot . showLogicalStructure ,
4646 showToString : debugSettingsRoot . showToString ,
4747 } ;
48- formatter [ key ] = true ;
48+ formatter [ key ] = value ;
4949 vscode . debug . activeDebugSession . customRequest ( "refreshVariables" , formatter ) ;
5050 }
5151
@@ -57,42 +57,16 @@ function turnOnFormat(key: string) {
5757 } else if ( inspect && inspect . workspaceValue !== undefined ) {
5858 configurationTarget = vscode . ConfigurationTarget . Workspace ;
5959 }
60- debugSettingsRoot . update ( key , true , configurationTarget ) ;
61- }
62-
63- function turnOffFormat ( key : string ) {
64- const debugSettingsRoot : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "java.debug.settings" ) ;
65- if ( vscode . debug . activeDebugSession && vscode . debug . activeDebugSession . type === "java" ) {
66- const formatter : any = {
67- showHex : debugSettingsRoot . showHex ,
68- showQualifiedNames : debugSettingsRoot . showQualifiedNames ,
69- showStaticVariables : debugSettingsRoot . showStaticVariables ,
70- showLogicalStructure : debugSettingsRoot . showLogicalStructure ,
71- showToString : debugSettingsRoot . showToString ,
72- } ;
73- formatter [ key ] = false ;
74- vscode . debug . activeDebugSession . customRequest ( "refreshVariables" , formatter ) ;
75- }
76-
77- // Update the formatter to settings.json
78- const inspect = vscode . workspace . getConfiguration ( "java.debug" ) . inspect ( "settings" ) ;
79- let configurationTarget = vscode . ConfigurationTarget . Global ;
80- if ( inspect && inspect . workspaceFolderValue !== undefined ) {
81- configurationTarget = vscode . ConfigurationTarget . WorkspaceFolder ;
82- } else if ( inspect && inspect . workspaceValue !== undefined ) {
83- configurationTarget = vscode . ConfigurationTarget . Workspace ;
84- }
85- debugSettingsRoot . update ( key , false , configurationTarget ) ;
60+ debugSettingsRoot . update ( key , value , configurationTarget ) ;
8661}
8762
8863function updateContextKeys ( ) {
8964 const debugSettingsRoot : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "java.debug.settings" ) ;
9065 if ( debugSettingsRoot ) {
91- vscode . commands . executeCommand ( "setContext" , "java.debug.showHex" , debugSettingsRoot . showHex ? "on" : "off" ) ;
92- vscode . commands . executeCommand ( "setContext" , "java.debug.showLogicalStructure" , debugSettingsRoot . showLogicalStructure ? "on" : "off" ) ;
93- vscode . commands . executeCommand ( "setContext" , "java.debug.showQualifiedNames" , debugSettingsRoot . showQualifiedNames ? "on" : "off" ) ;
94- vscode . commands . executeCommand ( "setContext" , "java.debug.showStaticVariables" , debugSettingsRoot . showStaticVariables ? "on" : "off" ) ;
95- vscode . commands . executeCommand ( "setContext" , "java.debug.showToString" , debugSettingsRoot . showToString ? "on" : "off" ) ;
96- return ;
66+ vscode . commands . executeCommand ( "setContext" , "javadebug:showHex" , debugSettingsRoot . showHex ? "on" : "off" ) ;
67+ vscode . commands . executeCommand ( "setContext" , "javadebug:showLogicalStructure" , debugSettingsRoot . showLogicalStructure ? "on" : "off" ) ;
68+ vscode . commands . executeCommand ( "setContext" , "javadebug:showQualifiedNames" , debugSettingsRoot . showQualifiedNames ? "on" : "off" ) ;
69+ vscode . commands . executeCommand ( "setContext" , "javadebug:showStaticVariables" , debugSettingsRoot . showStaticVariables ? "on" : "off" ) ;
70+ vscode . commands . executeCommand ( "setContext" , "javadebug:showToString" , debugSettingsRoot . showToString ? "on" : "off" ) ;
9771 }
9872}
0 commit comments