Skip to content

Commit 657d13a

Browse files
committed
Propagate thread events to the client
1 parent e043fbd commit 657d13a

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

adapter/src/main/kotlin/org/javacs/ktda/adapter/DAPConverter.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ private typealias DAPExceptionBreakpointsFilter = org.eclipse.lsp4j.debug.Except
1818
private typealias DAPCompletionItem = org.eclipse.lsp4j.debug.CompletionItem
1919
private typealias DAPCompletionItemType = org.eclipse.lsp4j.debug.CompletionItemType
2020
private typealias DAPExceptionDetails = org.eclipse.lsp4j.debug.ExceptionDetails
21+
private typealias DAPThreadEventReason = org.eclipse.lsp4j.debug.ThreadEventArgumentsReason
2122
private typealias InternalSource = org.javacs.ktda.core.Source
2223
private typealias InternalSourceBreakpoint = org.javacs.ktda.core.breakpoint.SourceBreakpoint
2324
private typealias InternalExceptionBreakpoint = org.javacs.ktda.core.breakpoint.ExceptionBreakpoint
@@ -26,6 +27,7 @@ private typealias InternalStackFrame = org.javacs.ktda.core.stack.StackFrame
2627
private typealias InternalCompletionItem = org.javacs.ktda.core.completion.CompletionItem
2728
private typealias InternalCompletionItemType = org.javacs.ktda.core.completion.CompletionItemType
2829
private typealias InternalException = org.javacs.ktda.core.exception.DebuggeeException
30+
private typealias InternalThreadEventReason = org.javacs.ktda.core.event.ThreadEventReason
2931

3032
/**
3133
* Handles conversions between debug adapter types
@@ -137,4 +139,9 @@ class DAPConverter(
137139
stackTrace = internalException.stackTrace
138140
innerException = internalException.innerException?.let(::toDAPExceptionDetails)?.let { arrayOf(it) }
139141
}
142+
143+
fun toDAPThreadEventReason(reason: InternalThreadEventReason): String = when (reason) {
144+
InternalThreadEventReason.STARTED -> DAPThreadEventReason.STARTED
145+
InternalThreadEventReason.STOPPED -> DAPThreadEventReason.EXITED
146+
}
140147
}

adapter/src/main/kotlin/org/javacs/ktda/adapter/KotlinDebugAdapter.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class KotlinDebugAdapter(
148148
sendStopEvent(it.threadID, StoppedEventArgumentsReason.EXCEPTION)
149149
}
150150
eventBus.threadListeners.add {
151-
151+
sendThreadEvent(it.threadID, converter.toDAPThreadEventReason(it.reason))
152152
}
153153
stdoutAsync.execute {
154154
debuggee.stdout?.let { pipeStreamToOutput(it, OutputEventArgumentsCategory.STDOUT) }
@@ -171,6 +171,13 @@ class KotlinDebugAdapter(
171171
}
172172
}
173173
}
174+
175+
private fun sendThreadEvent(threadId: Long, reason: String) {
176+
client!!.thread(ThreadEventArguments().also {
177+
it.reason = reason
178+
it.threadId = threadId
179+
})
180+
}
174181

175182
private fun sendStopEvent(threadId: Long, reason: String) {
176183
client!!.stopped(StoppedEventArguments().also {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.javacs.ktda.core.event
22

3-
enum class ThreadEventReason(val value: String) {
4-
STARTED("started"),
5-
STOPPED("stopped")
3+
enum class ThreadEventReason {
4+
STARTED,
5+
STOPPED
66
}

0 commit comments

Comments
 (0)