Skip to content

Commit

Permalink
added 'java.debug.logLevel' setting support
Browse files Browse the repository at this point in the history
Signed-off-by: Viacheslav Gagara <viacheslavg@gmail.com>
  • Loading branch information
gagara committed Jun 22, 2024
1 parent 1940918 commit 37cc4c4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 28 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The following settings are supported in [CocConfig][9]:

- `java.debug.vimspector.profile` : **(Deprecated)** Set to `null` and use `"default":true` in Vimspector.json instead. Specifies the Vimspector [profile][10] to activate when launching. Set to `null` to be prompted if multiple configurations are found and no default is set. Defaults to `Java Attach`
- `java.debug.vimspector.substitution.adapterPort` : Specifies the Vimspector [adapter port][11] substitution name in `.vimspector.json`. The actual port number will replace this value in the Vimspector config when the debug server is started. Defaults to `AdapterPort`
- `java.debug.logLevel`: minimum level of debugger logs that are sent to language server, 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 `false`.
- `java.debug.settings.showQualifiedNames`: show fully qualified class names in "Variables" viewlet, defaults to `false`.
Expand Down
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@
"description": "Specifies the Vimspector project name substitution name in `.vimspector.json`. The actual project name will replace this value in the Vimspector config when the debug server is started.",
"scope": "window"
},
"java.debug.logLevel": {
"type": "string",
"default": "warn",
"description": "minimum level of debugger logs that are sent to language server",
"enum": [
"error",
"warn",
"info",
"verbose"
],
"scope": "window"
},
"java.debug.settings.showHex": {
"type": "boolean",
"default": false,
Expand Down
55 changes: 27 additions & 28 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,68 @@ import {Commands} from "./commands";

export function onConfigurationChange() {
return workspace.onDidChangeConfiguration(params => {
if (!params.affectsConfiguration('java.debug.settings')) {
if (!params.affectsConfiguration('java.debug.settings') && !params.affectsConfiguration('java.debug.logLevel')) {
return
}
updateDebugSettings();
});
}

export async function updateDebugSettings() {
const debugSettingsRoot = workspace.getConfiguration('java.debug.settings');
const debugSettingsRoot = workspace.getConfiguration('java.debug');

if (!debugSettingsRoot) {
return;
}
const logLevel = convertLogLevel(debugSettingsRoot.logLevel || "");
if (debugSettingsRoot && Object.keys(debugSettingsRoot).length) {
if (debugSettingsRoot.settings && Object.keys(debugSettingsRoot.settings).length) {
try {
let extraSettings = {};
if (debugSettingsRoot.stepping && Object.keys(debugSettingsRoot.stepping).length) {
if (debugSettingsRoot.settings.stepping && Object.keys(debugSettingsRoot.settings.stepping).length) {
let stepFilters = {};
if (debugSettingsRoot.stepping.skipClasses) {
stepFilters["skipClasses"] = await substituteFilterVariables(debugSettingsRoot.stepping.skipClasses);
if (debugSettingsRoot.settings.stepping.skipClasses) {
stepFilters["skipClasses"] = await substituteFilterVariables(debugSettingsRoot.settings.stepping.skipClasses);
}
if (debugSettingsRoot.stepping.skipSynthetics) {
stepFilters["skipSynthetics"] = debugSettingsRoot.stepping.skipSynthetics;
if (debugSettingsRoot.settings.stepping.skipSynthetics) {
stepFilters["skipSynthetics"] = debugSettingsRoot.settings.stepping.skipSynthetics;
}
if (debugSettingsRoot.stepping.skipStaticInitializers) {
stepFilters["skipStaticInitializers"] = debugSettingsRoot.stepping.skipStaticInitializers;
if (debugSettingsRoot.settings.stepping.skipStaticInitializers) {
stepFilters["skipStaticInitializers"] = debugSettingsRoot.settings.stepping.skipStaticInitializers;
}
if (debugSettingsRoot.stepping.skipConstructors) {
stepFilters["skipConstructors"] = debugSettingsRoot.stepping.skipConstructors;
if (debugSettingsRoot.settings.stepping.skipConstructors) {
stepFilters["skipConstructors"] = debugSettingsRoot.settings.stepping.skipConstructors;
}
extraSettings["stepFilters"] = stepFilters;
}
if (debugSettingsRoot.exceptionBreakpoint && Object.keys(debugSettingsRoot.exceptionBreakpoint).length) {
if (debugSettingsRoot.settings.exceptionBreakpoint && Object.keys(debugSettingsRoot.settings.exceptionBreakpoint).length) {
let exceptionFilters = {};
if (debugSettingsRoot.exceptionBreakpoint.exceptionTypes) {
exceptionFilters["exceptionTypes"] = debugSettingsRoot.exceptionBreakpoint.exceptionTypes;
if (debugSettingsRoot.settings.exceptionBreakpoint.exceptionTypes) {
exceptionFilters["exceptionTypes"] = debugSettingsRoot.settings.exceptionBreakpoint.exceptionTypes;
}
if (debugSettingsRoot.exceptionBreakpoint.allowClasses) {
exceptionFilters["allowClasses"] = debugSettingsRoot.exceptionBreakpoint.allowClasses;
if (debugSettingsRoot.settings.exceptionBreakpoint.allowClasses) {
exceptionFilters["allowClasses"] = debugSettingsRoot.settings.exceptionBreakpoint.allowClasses;
}
if (debugSettingsRoot.exceptionBreakpoint.skipClasses) {
exceptionFilters["skipClasses"] = await substituteFilterVariables(debugSettingsRoot.exceptionBreakpoint.skipClasses);
if (debugSettingsRoot.settings.exceptionBreakpoint.skipClasses) {
exceptionFilters["skipClasses"] = await substituteFilterVariables(debugSettingsRoot.settings.exceptionBreakpoint.skipClasses);
}
extraSettings["exceptionFilters"] = exceptionFilters;
extraSettings["exceptionFiltersUpdated"] = true;
}

if (debugSettingsRoot.jdwp) {
if (debugSettingsRoot.jdwp.async) {
extraSettings["asyncJDWP"] = debugSettingsRoot.jdwp.async;
if (debugSettingsRoot.settings.jdwp) {
if (debugSettingsRoot.settings.jdwp.async) {
extraSettings["asyncJDWP"] = debugSettingsRoot.settings.jdwp.async;
}
if (debugSettingsRoot.jdwp.limitOfVariablesPerJdwpRequest) {
extraSettings["limitOfVariablesPerJdwpRequest"] = Math.max(debugSettingsRoot.jdwp.limitOfVariablesPerJdwpRequest, 1);
if (debugSettingsRoot.settings.jdwp.limitOfVariablesPerJdwpRequest) {
extraSettings["limitOfVariablesPerJdwpRequest"] = Math.max(debugSettingsRoot.settings.jdwp.limitOfVariablesPerJdwpRequest, 1);
}
if (debugSettingsRoot.jdwp.requestTimeout) {
extraSettings["jdwpRequestTimeout"] = Math.max(debugSettingsRoot.jdwp.requestTimeout, 100);
if (debugSettingsRoot.settings.jdwp.requestTimeout) {
extraSettings["requestTimeout"] = Math.max(debugSettingsRoot.settings.jdwp.requestTimeout, 100);
}
}
const settings = await commands.executeCommand(Commands.JAVA_UPDATE_DEBUG_SETTINGS, JSON.stringify(
{
...debugSettingsRoot,
...debugSettingsRoot.settings,
...extraSettings,
logLevel,
}));
Expand All @@ -74,7 +74,6 @@ export async function updateDebugSettings() {
}
} catch (err) {
// log a warning message and continue, since update settings failure should not block debug session
// tslint:disable-next-line:no-console
console.error("Cannot update debug settings.", err);
}
}
Expand Down

0 comments on commit 37cc4c4

Please sign in to comment.