@@ -2,24 +2,46 @@ package org.javacs.ktda
2
2
3
3
import java.nio.file.Path
4
4
import java.nio.file.Paths
5
+ import org.eclipse.lsp4j.debug.ConfigurationDoneArguments
6
+ import org.eclipse.lsp4j.debug.InitializeRequestArguments
5
7
import org.eclipse.lsp4j.debug.DisconnectArguments
6
8
import org.eclipse.lsp4j.debug.OutputEventArguments
7
9
import org.eclipse.lsp4j.debug.services.IDebugProtocolClient
8
10
import org.javacs.ktda.adapter.KotlinDebugAdapter
9
11
import org.javacs.ktda.jdi.launch.JDILauncher
10
12
import org.junit.After
11
13
12
- abstract class DebugAdapterTestFixture (relativeWorkspaceRoot : String , mainClass : String ) : IDebugProtocolClient {
14
+ abstract class DebugAdapterTestFixture (
15
+ relativeWorkspaceRoot : String ,
16
+ private val mainClass : String
17
+ ) : IDebugProtocolClient {
13
18
val absoluteWorkspaceRoot: Path = Paths .get(DebugAdapterTestFixture ::class .java.getResource(" /" ).toURI()).resolve(relativeWorkspaceRoot)
14
19
val debugAdapter: KotlinDebugAdapter = JDILauncher ()
15
20
.let (::KotlinDebugAdapter )
16
- .also { it.connect(this ) }
21
+ .also {
22
+ it.connect(this )
23
+ val configDone = it.configurationDone(ConfigurationDoneArguments ())
24
+ it.initialize(InitializeRequestArguments ().apply {
25
+ adapterID = " test-debug-adapter"
26
+ linesStartAt1 = true
27
+ columnsStartAt1 = true
28
+ }).join()
29
+ // Slightly hacky workaround to ensure someone is
30
+ // waiting on the ConfigurationDoneResponse. See
31
+ // KotlinDebugAdapter.kt:performInitialization for
32
+ // details.
33
+ Thread {
34
+ configDone.join()
35
+ }.start()
36
+ }
17
37
18
38
fun launch () {
39
+ println (" Launching..." )
19
40
debugAdapter.launch(mapOf (
20
41
" projectRoot" to absoluteWorkspaceRoot.toString(),
21
- " mainClass" to " sample.workspace.AppKt"
22
- ))
42
+ " mainClass" to mainClass
43
+ )).join()
44
+ println (" Launched" )
23
45
}
24
46
25
47
@After fun closeDebugAdapter () {
0 commit comments