Add menus to VARIABLES view to customize the display styles (#982)
* Add menus to VARIABLES view to customize the display styles
This commit is contained in:
parent
bed2489f62
commit
97aa63b5ba
132
package.json
132
package.json
|
@ -92,6 +92,46 @@
|
||||||
{
|
{
|
||||||
"command": "java.debug.pauseOthers",
|
"command": "java.debug.pauseOthers",
|
||||||
"title": "Pause Others"
|
"title": "Pause Others"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showHex",
|
||||||
|
"title": "Show as Hex"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowHex",
|
||||||
|
"title": "Show as Dec"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showQualifiedNames",
|
||||||
|
"title": "Show Qualified Names"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowQualifiedNames",
|
||||||
|
"title": "Show Simple Names"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showStaticVariables",
|
||||||
|
"title": "Show Static Variables"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowStaticVariables",
|
||||||
|
"title": "Hide Static Variables"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showLogicalStructure",
|
||||||
|
"title": "Enable Logical Structure View"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowLogicalStructure",
|
||||||
|
"title": "Disable Logical Structure View"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showToString",
|
||||||
|
"title": "Enable 'toString()' Object View"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowToString",
|
||||||
|
"title": "Disable 'toString()' Object View"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"menus": {
|
"menus": {
|
||||||
|
@ -209,6 +249,98 @@
|
||||||
{
|
{
|
||||||
"command": "java.debug.debugFromProjectView",
|
"command": "java.debug.debugFromProjectView",
|
||||||
"when": "false"
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showHex",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowHex",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showQualifiedNames",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowQualifiedNames",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showStaticVariables",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowStaticVariables",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showLogicalStructure",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowLogicalStructure",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showToString",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowToString",
|
||||||
|
"when": "false"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"debug/variables/context": [
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showHex",
|
||||||
|
"when": "debugConfigurationType == 'java' && javadebug:showHex == 'off'",
|
||||||
|
"group": "1_view@1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowHex",
|
||||||
|
"when": "debugConfigurationType == 'java' && javadebug:showHex == 'on'",
|
||||||
|
"group": "1_view@1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showQualifiedNames",
|
||||||
|
"when": "debugConfigurationType == 'java' && javadebug:showQualifiedNames == 'off'",
|
||||||
|
"group": "1_view@2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowQualifiedNames",
|
||||||
|
"when": "debugConfigurationType == 'java' && javadebug:showQualifiedNames == 'on'",
|
||||||
|
"group": "1_view@2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showStaticVariables",
|
||||||
|
"when": "debugConfigurationType == 'java' && javadebug:showStaticVariables == 'off'",
|
||||||
|
"group": "1_view@3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowStaticVariables",
|
||||||
|
"when": "debugConfigurationType == 'java' && javadebug:showStaticVariables == 'on'",
|
||||||
|
"group": "1_view@3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showLogicalStructure",
|
||||||
|
"when": "debugConfigurationType == 'java' && javadebug:showLogicalStructure == 'off'",
|
||||||
|
"group": "1_view@4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowLogicalStructure",
|
||||||
|
"when": "debugConfigurationType == 'java' && javadebug:showLogicalStructure == 'on'",
|
||||||
|
"group": "1_view@4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.showToString",
|
||||||
|
"when": "debugConfigurationType == 'java' && javadebug:showToString == 'off'",
|
||||||
|
"group": "1_view@5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "java.debug.variables.notShowToString",
|
||||||
|
"when": "debugConfigurationType == 'java' && javadebug:showToString == 'on'",
|
||||||
|
"group": "1_view@5"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -26,6 +26,7 @@ import { progressProvider } from "./progressImpl";
|
||||||
import { JavaTerminalLinkProvder } from "./terminalLinkProvider";
|
import { JavaTerminalLinkProvder } from "./terminalLinkProvider";
|
||||||
import { initializeThreadOperations } from "./threadOperations";
|
import { initializeThreadOperations } from "./threadOperations";
|
||||||
import * as utility from "./utility";
|
import * as utility from "./utility";
|
||||||
|
import { registerVariableMenuCommands } from "./variableMenu";
|
||||||
|
|
||||||
export async function activate(context: vscode.ExtensionContext): Promise<any> {
|
export async function activate(context: vscode.ExtensionContext): Promise<any> {
|
||||||
await initializeFromJsonFile(context.asAbsolutePath("./package.json"), {
|
await initializeFromJsonFile(context.asAbsolutePath("./package.json"), {
|
||||||
|
@ -40,6 +41,7 @@ function initializeExtension(_operationId: string, context: vscode.ExtensionCont
|
||||||
logger.initialize(context, true);
|
logger.initialize(context, true);
|
||||||
|
|
||||||
registerDebugEventListener(context);
|
registerDebugEventListener(context);
|
||||||
|
registerVariableMenuCommands(context);
|
||||||
context.subscriptions.push(logger);
|
context.subscriptions.push(logger);
|
||||||
context.subscriptions.push(vscode.window.registerTerminalLinkProvider(new JavaTerminalLinkProvder()));
|
context.subscriptions.push(vscode.window.registerTerminalLinkProvider(new JavaTerminalLinkProvder()));
|
||||||
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider("java", new JavaDebugConfigurationProvider()));
|
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider("java", new JavaDebugConfigurationProvider()));
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
import * as vscode from "vscode";
|
||||||
|
import { instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-wrapper";
|
||||||
|
|
||||||
|
export function registerVariableMenuCommands(context: vscode.ExtensionContext): void {
|
||||||
|
vscode.workspace.onDidChangeConfiguration((event) => {
|
||||||
|
if (event.affectsConfiguration("java.debug.settings")) {
|
||||||
|
updateContextKeys();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Initialize the context keys
|
||||||
|
updateContextKeys();
|
||||||
|
|
||||||
|
context.subscriptions.push(instrumentOperationAsVsCodeCommand(
|
||||||
|
"java.debug.variables.showHex", () => updateVariableFormatter("showHex", true)));
|
||||||
|
context.subscriptions.push(instrumentOperationAsVsCodeCommand(
|
||||||
|
"java.debug.variables.notShowHex", () => updateVariableFormatter("showHex", false)));
|
||||||
|
context.subscriptions.push(instrumentOperationAsVsCodeCommand(
|
||||||
|
"java.debug.variables.showQualifiedNames", () => updateVariableFormatter("showQualifiedNames", true)));
|
||||||
|
context.subscriptions.push(instrumentOperationAsVsCodeCommand(
|
||||||
|
"java.debug.variables.notShowQualifiedNames", () => updateVariableFormatter("showQualifiedNames", false)));
|
||||||
|
context.subscriptions.push(instrumentOperationAsVsCodeCommand(
|
||||||
|
"java.debug.variables.showStaticVariables", () => updateVariableFormatter("showStaticVariables", true)));
|
||||||
|
context.subscriptions.push(instrumentOperationAsVsCodeCommand(
|
||||||
|
"java.debug.variables.notShowStaticVariables", () => updateVariableFormatter("showStaticVariables", false)));
|
||||||
|
context.subscriptions.push(instrumentOperationAsVsCodeCommand(
|
||||||
|
"java.debug.variables.showLogicalStructure", () => updateVariableFormatter("showLogicalStructure", true)));
|
||||||
|
context.subscriptions.push(instrumentOperationAsVsCodeCommand(
|
||||||
|
"java.debug.variables.notShowLogicalStructure", () => updateVariableFormatter("showLogicalStructure", false)));
|
||||||
|
context.subscriptions.push(instrumentOperationAsVsCodeCommand(
|
||||||
|
"java.debug.variables.showToString", () => updateVariableFormatter("showToString", true)));
|
||||||
|
context.subscriptions.push(instrumentOperationAsVsCodeCommand(
|
||||||
|
"java.debug.variables.notShowToString", () => updateVariableFormatter("showToString", false)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateVariableFormatter(key: string, value: any) {
|
||||||
|
const debugSettingsRoot: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("java.debug.settings");
|
||||||
|
if (vscode.debug.activeDebugSession && vscode.debug.activeDebugSession.type === "java") {
|
||||||
|
const formatter: any = {
|
||||||
|
showHex: debugSettingsRoot.showHex,
|
||||||
|
showQualifiedNames: debugSettingsRoot.showQualifiedNames,
|
||||||
|
showStaticVariables: debugSettingsRoot.showStaticVariables,
|
||||||
|
showLogicalStructure: debugSettingsRoot.showLogicalStructure,
|
||||||
|
showToString: debugSettingsRoot.showToString,
|
||||||
|
};
|
||||||
|
formatter[key] = value;
|
||||||
|
vscode.debug.activeDebugSession.customRequest("refreshVariables", formatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the formatter to settings.json
|
||||||
|
const inspect = vscode.workspace.getConfiguration("java.debug").inspect("settings");
|
||||||
|
let configurationTarget = vscode.ConfigurationTarget.Global;
|
||||||
|
if (inspect && inspect.workspaceFolderValue !== undefined) {
|
||||||
|
configurationTarget = vscode.ConfigurationTarget.WorkspaceFolder;
|
||||||
|
} else if (inspect && inspect.workspaceValue !== undefined) {
|
||||||
|
configurationTarget = vscode.ConfigurationTarget.Workspace;
|
||||||
|
}
|
||||||
|
debugSettingsRoot.update(key, value, configurationTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateContextKeys() {
|
||||||
|
const debugSettingsRoot: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("java.debug.settings");
|
||||||
|
if (debugSettingsRoot) {
|
||||||
|
vscode.commands.executeCommand("setContext", "javadebug:showHex", debugSettingsRoot.showHex ? "on" : "off");
|
||||||
|
vscode.commands.executeCommand("setContext", "javadebug:showLogicalStructure", debugSettingsRoot.showLogicalStructure ? "on" : "off");
|
||||||
|
vscode.commands.executeCommand("setContext", "javadebug:showQualifiedNames", debugSettingsRoot.showQualifiedNames ? "on" : "off");
|
||||||
|
vscode.commands.executeCommand("setContext", "javadebug:showStaticVariables", debugSettingsRoot.showStaticVariables ? "on" : "off");
|
||||||
|
vscode.commands.executeCommand("setContext", "javadebug:showToString", debugSettingsRoot.showToString ? "on" : "off");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue