Get debug settings from user preference and send it to debuggee (#135)
* 1. watch user settings for changed event, apply it when change happens 2. get debug settings from user settings and send it to debuggee * change settings names * merge log level to other settings. * update desc to debug settings. * update description for better clause * update description for better clause * fix typo * update description for better clause
This commit is contained in:
parent
4b9ee81de5
commit
96f2b7c3de
|
@ -69,6 +69,10 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht
|
|||
### User Settings
|
||||
|
||||
- `java.debug.logLevel`: minimum level of debugger logs that are sent to VS Code, defaults to `warn`.
|
||||
- `java.debug.settings.showHex`: show numbers in hex format in "Variables" viewlet, defaults to `false`.
|
||||
- `java.debug.settings.showStaticVariables`: show static variables in "Variables" viewlet, defaults to `true`.
|
||||
- `java.debug.settings.showQualifiedNames`: show fully qualified class names in "Variables" viewlet, defaults to `false`.
|
||||
- `java.debug.settings.maxStringLength`: the maximum length of string displayed in "Variables" or "Debug Console" viewlet, the string longer than this length will be trimmed, defaults to `0` which means no trim is performed.
|
||||
|
||||
## Feedback and Questions
|
||||
You can find the full list of issues at [Issue Tracker](https://github.com/Microsoft/vscode-java-debug/issues). You can submit a [bug or feature suggestion](https://github.com/Microsoft/vscode-java-debug/issues/new), and participate community driven [](https://gitter.im/Microsoft/vscode-java-debug)
|
||||
|
|
21
package.json
21
package.json
|
@ -190,12 +190,33 @@
|
|||
"java.debug.logLevel": {
|
||||
"type": "string",
|
||||
"default": "warn",
|
||||
"description": "minimum level of debugger logs that are sent to VS Code",
|
||||
"enum": [
|
||||
"error",
|
||||
"warn",
|
||||
"info",
|
||||
"verbose"
|
||||
]
|
||||
},
|
||||
"java.debug.settings.showHex": {
|
||||
"type": "boolean",
|
||||
"description" : "show numbers in hex format in \"Variables\" viewlet.",
|
||||
"default": false
|
||||
},
|
||||
"java.debug.settings.showStaticVariables": {
|
||||
"type": "boolean",
|
||||
"description": "show static variables in \"Variables\" viewlet",
|
||||
"default": true
|
||||
},
|
||||
"java.debug.settings.showQualifiedNames": {
|
||||
"type": "boolean",
|
||||
"description": "show fully qualified class names in \"Variables\" viewlet",
|
||||
"default": false
|
||||
},
|
||||
"java.debug.settings.maxStringLength": {
|
||||
"type": "number",
|
||||
"description": "the maximum length of string displayed in \"Variables\" or \"Debug Console\" viewlet, the string longer than this length will be trimmed, defaults to 0 which means no trim is performed.",
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ export const JAVA_EXECUTE_WORKSPACE_COMMAND = "java.execute.workspaceCommand";
|
|||
|
||||
export const JAVA_FETCH_USAGE_DATA = "vscode.java.fetchUsageData";
|
||||
|
||||
export const JAVA_CONFIG_LOG_LEVEL = "vscode.java.configLogLevel";
|
||||
export const JAVA_UPDATE_DEBUG_SETTINGS = "vscode.java.updateDebugSettings";
|
||||
|
||||
export function executeJavaLanguageServerCommand(...rest) {
|
||||
// TODO: need to handle error and trace telemetry
|
||||
|
|
|
@ -6,7 +6,16 @@ import TelemetryReporter from "vscode-extension-telemetry";
|
|||
import * as commands from "./commands";
|
||||
|
||||
export class JavaDebugConfigurationProvider implements vscode.DebugConfigurationProvider {
|
||||
private isUserSettingsDirty: boolean = true;
|
||||
constructor(private _reporter: TelemetryReporter) {
|
||||
vscode.workspace.onDidChangeConfiguration((event) => {
|
||||
if (vscode.debug.activeDebugSession) {
|
||||
this.isUserSettingsDirty = false;
|
||||
return updateDebugSettings();
|
||||
} else {
|
||||
this.isUserSettingsDirty = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Returns an initial debug configurations based on contextual information.
|
||||
|
@ -72,12 +81,9 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
|
|||
|
||||
private async heuristicallyResolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration) {
|
||||
try {
|
||||
try {
|
||||
const level = await configLogLevel(vscode.workspace.getConfiguration().get("java.debug.logLevel"));
|
||||
console.log("setting log level to ", level);
|
||||
} catch (err) {
|
||||
// log a warning message and continue, since logger failure should not block debug session
|
||||
console.log("Cannot set log level to java debuggeer.")
|
||||
if (this.isUserSettingsDirty) {
|
||||
this.isUserSettingsDirty = false;
|
||||
await updateDebugSettings();
|
||||
}
|
||||
|
||||
// trigger build workspace
|
||||
|
@ -218,8 +224,21 @@ function resolveMainClass() {
|
|||
return commands.executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_MAINCLASS);
|
||||
}
|
||||
|
||||
function configLogLevel(level) {
|
||||
return commands.executeJavaLanguageServerCommand(commands.JAVA_CONFIG_LOG_LEVEL, convertLogLevel(level));
|
||||
async function updateDebugSettings() {
|
||||
const debugSettingsRoot: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("java.debug");
|
||||
if (!debugSettingsRoot) {
|
||||
return;
|
||||
}
|
||||
const logLevel = convertLogLevel(debugSettingsRoot.logLevel || "");
|
||||
if (debugSettingsRoot.settings && Object.keys(debugSettingsRoot.settings).length) {
|
||||
try {
|
||||
console.log("settings:", await commands.executeJavaLanguageServerCommand(commands.JAVA_UPDATE_DEBUG_SETTINGS, JSON.stringify(
|
||||
{ ...debugSettingsRoot.settings, logLevel })));
|
||||
} catch (err) {
|
||||
// log a warning message and continue, since update settings failure should not block debug session
|
||||
console.log("Cannot update debug settings.", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function convertLogLevel(commonLogLevel: string) {
|
||||
|
|
Loading…
Reference in New Issue