Skip to content

Commit 370f66e

Browse files
fix typos (#812)
* fix typos Signed-off-by: Jinbo Wang <[email protected]> * tune error message Signed-off-by: Jinbo Wang <[email protected]> * tune message Signed-off-by: Jinbo Wang <[email protected]> * tune message Signed-off-by: Jinbo Wang <[email protected]>
1 parent 4ce7a94 commit 370f66e

File tree

4 files changed

+30
-28
lines changed

4 files changed

+30
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht
7979
- `hostName` (required, unless using `processId`) - The host name or IP address of remote debuggee.
8080
- `port` (required, unless using `processId`) - The debug port of remote debuggee.
8181
- `processId` - Use process picker to select a process to attach, or Process ID as integer.
82-
- `${command:pickJavaProcess}` - Use process picker to select a process to attach.
82+
- `${command:PickJavaProcess}` - Use process picker to select a process to attach.
8383
- an integer pid - Attach to the specified local process.
8484
- `timeout` - Timeout value before reconnecting, in milliseconds (default to 30000ms).
8585
- `sourcePaths` - The extra source directories of the program. The debugger looks for source code from project settings by default. This option allows the debugger to look for source code in extra directories.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@
350350
"${command:PickJavaProcess}"
351351
],
352352
"description": "%java.debugger.attach.processPicker.description%",
353-
"default": "${command:pickJavaProcess}"
353+
"default": "${command:PickJavaProcess}"
354354
},
355355
{
356356
"type": "integer",

src/configurationProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
236236
return undefined;
237237
}
238238
} catch (error) {
239-
vscode.window.showErrorMessage(String(error));
239+
vscode.window.showErrorMessage(error.message ? error.message : String(error));
240240
return undefined;
241241
}
242242
} else if (!config.hostName || !config.port) {

src/processPicker.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ interface IJavaProcess {
1818

1919
export async function resolveProcessId(config: DebugConfiguration): Promise<boolean> {
2020
let javaProcess;
21+
const pid: number = Number(config.processId);
2122
// tslint:disable-next-line
22-
if (!config.processId || config.processId === "${command:PickJavaProcess}") {
23+
if (!config.processId || Number.isNaN(pid)) {
2324
javaProcess = await pickJavaProcess();
2425
} else {
25-
javaProcess = await resolveJavaProcess(parseInt(String(config.processId), 10));
26+
javaProcess = await resolveJavaProcess(pid);
2627
if (!javaProcess) {
27-
throw new Error(`Attach to process: pid '${config.processId}' doesn't look like a debuggable Java process. `
28-
+ `Please ensure the process has enabled debug mode with vmArgs like `
28+
throw new Error(`Attach to process: pid '${config.processId}' is not a debuggable Java process. `
29+
+ `Please make sure the process has turned on debug mode using vmArgs like `
2930
+ `'-agentlib:jdwp=transport=dt_socket,server=y,address=5005.'`);
3031
}
3132
}
@@ -68,38 +69,39 @@ function convertToJavaProcess(pid: number, command: string, args: string): IJava
6869
}
6970

7071
async function pickJavaProcess(): Promise<IJavaProcess> {
72+
const javaProcesses: IJavaProcess[] = [];
7173
try {
72-
const javaProcesses: IJavaProcess[] = [];
7374
await getProcesses((pid: number, ppid: number, command: string, args: string, date: number) => {
7475
const javaProcess = convertToJavaProcess(pid, command, args);
7576
if (javaProcess) {
7677
javaProcesses.push(javaProcess);
7778
}
7879
});
80+
} catch (error) {
81+
throw new Error("Process picker failed: " + error);
82+
}
7983

80-
if (!javaProcesses.length) {
81-
throw new Error("Process picker: No debuggable Java process found. Please ensure enable debugging for "
82-
+ "your application with vmArgs like '-agentlib:jdwp=transport=dt_socket,server=y,address=5005'.");
83-
}
84+
if (!javaProcesses.length) {
85+
throw new Error("Process picker: No debuggable Java process was found. Please make sure to use vmArgs like "
86+
+ "'-agentlib:jdwp=transport=dt_socket,server=y,address=5005' to turn on debug mode when you start your "
87+
+ "program.");
88+
}
8489

85-
const items = javaProcesses.map((process) => {
86-
return {
87-
label: process.command,
88-
description: process.args,
89-
detail: `process id: ${process.pid}, debug port: ${process.debugPort}`,
90-
process,
91-
};
92-
});
90+
const items = javaProcesses.map((process) => {
91+
return {
92+
label: process.command,
93+
description: process.args,
94+
detail: `process id: ${process.pid}, debug port: ${process.debugPort}`,
95+
process,
96+
};
97+
});
9398

94-
const pick = await window.showQuickPick(items, {
95-
placeHolder: "Pick Java process to attach to",
96-
});
99+
const pick = await window.showQuickPick(items, {
100+
placeHolder: "Pick Java process to attach to",
101+
});
97102

98-
if (pick) {
99-
return pick.process;
100-
}
101-
} catch (error) {
102-
throw new Error("Process picker failed: " + error);
103+
if (pick) {
104+
return pick.process;
103105
}
104106
}
105107

0 commit comments

Comments
 (0)