Skip to content

Commit 05ba417

Browse files
send a custom notification when processId/shellProcessId is ready
1 parent e0e4465 commit 05ba417

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/LaunchRequestHandler.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ protected CompletableFuture<Response> handleLaunchCommand(Arguments arguments, R
138138
}
139139

140140
return launch(launchArguments, response, context).thenCompose(res -> {
141+
long processId = context.getProcessId();
142+
long shellProcessId = context.getShellProcessId();
143+
if (context.getDebuggeeProcess() != null) {
144+
processId = context.getDebuggeeProcess().pid();
145+
}
146+
147+
// If processId or shellProcessId exist, send a notification to client.
148+
if (processId > 0 || shellProcessId > 0) {
149+
context.getProtocolServer().sendEvent(new Events.ProcessIdNotification(processId, shellProcessId));
150+
}
151+
141152
LaunchUtils.releaseTempLaunchFile(context.getClasspathJar());
142153
LaunchUtils.releaseTempLaunchFile(context.getArgsfile());
143154
if (res.success) {

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/protocol/Events.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,26 @@ public InvalidatedEvent(InvalidatedAreas area, int frameId) {
283283
this.frameId = frameId;
284284
}
285285
}
286+
287+
public static class ProcessIdNotification extends DebugEvent {
288+
/**
289+
* The process ID.
290+
*/
291+
public long processId = -1;
292+
/**
293+
* The process ID of the terminal shell if the process is running in a terminal shell.
294+
*/
295+
public long shellProcessId = -1;
296+
297+
public ProcessIdNotification(long processId) {
298+
super("processid");
299+
this.processId = processId;
300+
}
301+
302+
public ProcessIdNotification(long processId, long shellProcessId) {
303+
super("processid");
304+
this.processId = processId;
305+
this.shellProcessId = shellProcessId;
306+
}
307+
}
286308
}

0 commit comments

Comments
 (0)