Skip to content

Commit f478d25

Browse files
address review comments
1 parent 6aad3fc commit f478d25

File tree

2 files changed

+38
-64
lines changed

2 files changed

+38
-64
lines changed

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,52 +294,52 @@
294294
"debug/variables/context": [
295295
{
296296
"command": "java.debug.variables.showHex",
297-
"when": "debugConfigurationType == 'java' && java.debug.showHex == 'off'",
297+
"when": "debugConfigurationType == 'java' && javadebug:showHex == 'off'",
298298
"group": "1_view@1"
299299
},
300300
{
301301
"command": "java.debug.variables.notShowHex",
302-
"when": "debugConfigurationType == 'java' && java.debug.showHex == 'on'",
302+
"when": "debugConfigurationType == 'java' && javadebug:showHex == 'on'",
303303
"group": "1_view@1"
304304
},
305305
{
306306
"command": "java.debug.variables.showQualifiedNames",
307-
"when": "debugConfigurationType == 'java' && java.debug.showQualifiedNames == 'off'",
307+
"when": "debugConfigurationType == 'java' && javadebug:showQualifiedNames == 'off'",
308308
"group": "1_view@2"
309309
},
310310
{
311311
"command": "java.debug.variables.notShowQualifiedNames",
312-
"when": "debugConfigurationType == 'java' && java.debug.showQualifiedNames == 'on'",
312+
"when": "debugConfigurationType == 'java' && javadebug:showQualifiedNames == 'on'",
313313
"group": "1_view@2"
314314
},
315315
{
316316
"command": "java.debug.variables.showStaticVariables",
317-
"when": "debugConfigurationType == 'java' && java.debug.showStaticVariables == 'off'",
317+
"when": "debugConfigurationType == 'java' && javadebug:showStaticVariables == 'off'",
318318
"group": "1_view@3"
319319
},
320320
{
321321
"command": "java.debug.variables.notShowStaticVariables",
322-
"when": "debugConfigurationType == 'java' && java.debug.showStaticVariables == 'on'",
322+
"when": "debugConfigurationType == 'java' && javadebug:showStaticVariables == 'on'",
323323
"group": "1_view@3"
324324
},
325325
{
326326
"command": "java.debug.variables.showLogicalStructure",
327-
"when": "debugConfigurationType == 'java' && java.debug.showLogicalStructure == 'off'",
327+
"when": "debugConfigurationType == 'java' && javadebug:showLogicalStructure == 'off'",
328328
"group": "1_view@4"
329329
},
330330
{
331331
"command": "java.debug.variables.notShowLogicalStructure",
332-
"when": "debugConfigurationType == 'java' && java.debug.showLogicalStructure == 'on'",
332+
"when": "debugConfigurationType == 'java' && javadebug:showLogicalStructure == 'on'",
333333
"group": "1_view@4"
334334
},
335335
{
336336
"command": "java.debug.variables.showToString",
337-
"when": "debugConfigurationType == 'java' && java.debug.showToString == 'off'",
337+
"when": "debugConfigurationType == 'java' && javadebug:showToString == 'off'",
338338
"group": "1_view@5"
339339
},
340340
{
341341
"command": "java.debug.variables.notShowToString",
342-
"when": "debugConfigurationType == 'java' && java.debug.showToString == 'on'",
342+
"when": "debugConfigurationType == 'java' && javadebug:showToString == 'on'",
343343
"group": "1_view@5"
344344
}
345345
]

src/variableMenu.ts

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -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

8863
function 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

Comments
 (0)