@@ -183,7 +183,6 @@ internal object DebugProbesImpl {
183
183
*/
184
184
@OptIn(ExperimentalStdlibApi ::class )
185
185
public fun dumpCoroutinesInfoAsJsonAndReferences (): Array <Any > {
186
- fun Any.toStringWithQuotes () = " \" $this \" "
187
186
val coroutinesInfo = dumpCoroutinesInfo()
188
187
val size = coroutinesInfo.size
189
188
val lastObservedThreads = ArrayList <Thread ?>(size)
@@ -196,11 +195,11 @@ internal object DebugProbesImpl {
196
195
coroutinesInfoAsJson.add(
197
196
"""
198
197
{
199
- "name": $name ,
200
- "id": ${context[CoroutineId .Key ]?.id} ,
201
- "dispatcher": $dispatcher ,
202
- "sequenceNumber": ${info.sequenceNumber} ,
203
- "state": "${info.state} "
198
+ "name": $name ,
199
+ "id": ${context[CoroutineId .Key ]?.id} ,
200
+ "dispatcher": $dispatcher ,
201
+ "sequenceNumber": ${info.sequenceNumber} ,
202
+ "state": "${info.state} "
204
203
}
205
204
""" .trimIndent()
206
205
)
@@ -216,6 +215,30 @@ internal object DebugProbesImpl {
216
215
)
217
216
}
218
217
218
+ /*
219
+ * Internal (JVM-public) method used by IDEA debugger as of 1.6.0-RC.
220
+ */
221
+ public fun enhanceStackTraceWithThreadDumpAsJson (info : DebugCoroutineInfo ): String {
222
+ val stackTraceElements = enhanceStackTraceWithThreadDump(info, info.lastObservedStackTrace)
223
+ val stackTraceElementsInfoAsJson = mutableListOf<String >()
224
+ for (element in stackTraceElements) {
225
+ stackTraceElementsInfoAsJson.add(
226
+ """
227
+ {
228
+ "declaringClass": "${element.className} ",
229
+ "methodName": "${element.methodName} ",
230
+ "fileName": ${element.fileName?.toStringWithQuotes()} ,
231
+ "lineNumber": ${element.lineNumber}
232
+ }
233
+ """ .trimIndent()
234
+ )
235
+ }
236
+
237
+ return " [${stackTraceElementsInfoAsJson.joinToString()} ]"
238
+ }
239
+
240
+ private fun Any.toStringWithQuotes () = " \" $this \" "
241
+
219
242
/*
220
243
* Internal (JVM-public) method used by IDEA debugger as of 1.4-M3.
221
244
*/
0 commit comments