-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsettings.ts
More file actions
105 lines (100 loc) · 4.07 KB
/
Copy pathsettings.ts
File metadata and controls
105 lines (100 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { commands, workspace } from 'coc.nvim';
import { substituteFilterVariables } from './classFilter';
import * as Commands from './commands';
import { getLogger } from './logger';
export function onConfigurationChange() {
return workspace.onDidChangeConfiguration((params) => {
if (!params.affectsConfiguration('java.debug.settings') && !params.affectsConfiguration('java.debug.logLevel')) {
return;
}
updateDebugSettings();
});
}
export async function updateDebugSettings() {
const debugSettingsRoot = workspace.getConfiguration('java.debug');
if (!debugSettingsRoot) {
return;
}
const logLevel = convertLogLevel(debugSettingsRoot.logLevel || '');
if (debugSettingsRoot.settings && Object.keys(debugSettingsRoot.settings).length) {
try {
const extraSettings = {};
if (debugSettingsRoot.settings.stepping && Object.keys(debugSettingsRoot.settings.stepping).length) {
const stepFilters = {};
if (debugSettingsRoot.settings.stepping.skipClasses) {
stepFilters['skipClasses'] = await substituteFilterVariables(debugSettingsRoot.settings.stepping.skipClasses);
}
if (debugSettingsRoot.settings.stepping.skipSynthetics) {
stepFilters['skipSynthetics'] = debugSettingsRoot.settings.stepping.skipSynthetics;
}
if (debugSettingsRoot.settings.stepping.skipStaticInitializers) {
stepFilters['skipStaticInitializers'] = debugSettingsRoot.settings.stepping.skipStaticInitializers;
}
if (debugSettingsRoot.settings.stepping.skipConstructors) {
stepFilters['skipConstructors'] = debugSettingsRoot.settings.stepping.skipConstructors;
}
extraSettings['stepFilters'] = stepFilters;
}
if (
debugSettingsRoot.settings.exceptionBreakpoint &&
Object.keys(debugSettingsRoot.settings.exceptionBreakpoint).length
) {
const exceptionFilters = {};
if (debugSettingsRoot.settings.exceptionBreakpoint.exceptionTypes) {
exceptionFilters['exceptionTypes'] = debugSettingsRoot.settings.exceptionBreakpoint.exceptionTypes;
}
if (debugSettingsRoot.settings.exceptionBreakpoint.allowClasses) {
exceptionFilters['allowClasses'] = debugSettingsRoot.settings.exceptionBreakpoint.allowClasses;
}
if (debugSettingsRoot.settings.exceptionBreakpoint.skipClasses) {
exceptionFilters['skipClasses'] = await substituteFilterVariables(
debugSettingsRoot.settings.exceptionBreakpoint.skipClasses,
);
}
extraSettings['exceptionFilters'] = exceptionFilters;
extraSettings['exceptionFiltersUpdated'] = true;
}
if (debugSettingsRoot.settings.jdwp) {
if (debugSettingsRoot.settings.jdwp.async) {
extraSettings['asyncJDWP'] = debugSettingsRoot.settings.jdwp.async;
}
if (debugSettingsRoot.settings.jdwp.limitOfVariablesPerJdwpRequest) {
extraSettings['limitOfVariablesPerJdwpRequest'] = Math.max(
debugSettingsRoot.settings.jdwp.limitOfVariablesPerJdwpRequest,
1,
);
}
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.settings,
...extraSettings,
logLevel,
}),
);
getLogger().debug('settings:', settings);
} catch (err) {
// log a warning message and continue, since update settings failure should not block debug session
getLogger().error('Cannot update debug settings.', err);
}
}
}
function convertLogLevel(commonLogLevel: string) {
// convert common log level to java log level
switch (commonLogLevel.toLowerCase()) {
case 'verbose':
return 'FINE';
case 'warn':
return 'WARNING';
case 'error':
return 'SEVERE';
case 'info':
return 'INFO';
default:
return 'FINE';
}
}