@@ -8,7 +8,6 @@ import org.eclipse.lsp4j.debug.StackFrame
8
8
import org.eclipse.lsp4j.debug.StackTraceArguments
9
9
import org.eclipse.lsp4j.debug.StoppedEventArguments
10
10
import org.eclipse.lsp4j.debug.VariablesArguments
11
- import org.eclipse.lsp4j.debug.services.IDebugProtocolClient
12
11
import org.junit.Assert.assertThat
13
12
import org.junit.Test
14
13
import org.hamcrest.Matchers.contains
@@ -20,33 +19,9 @@ import java.util.concurrent.Semaphore
20
19
* using a sample application.
21
20
*/
22
21
class SampleWorkspaceTest : DebugAdapterTestFixture (" sample-workspace" , " sample.workspace.AppKt" ) {
23
- @Test fun testBreakpointsAndVariables () {
24
- val semaphore = Semaphore (0 )
25
-
26
- debugAdapter.connect(object : IDebugProtocolClient {
27
- override fun stopped (args : StoppedEventArguments ) {
28
- assertThat(args.reason, equalTo(" breakpoint" ))
22
+ private val semaphore = Semaphore (0 )
29
23
30
- // Query information about the debuggee's current state
31
- val stackTrace = debugAdapter.stackTrace(StackTraceArguments ().apply {
32
- threadId = args.threadId
33
- }).join()
34
- val topFrame = stackTrace.stackFrames.first()
35
- val scopes = debugAdapter.scopes(ScopesArguments ().apply {
36
- frameId = topFrame.id
37
- }).join()
38
- val scope = scopes.scopes.first()
39
- val variables = debugAdapter.variables(VariablesArguments ().apply {
40
- variablesReference = scope.variablesReference
41
- }).join()
42
-
43
- assertThat(variables.variables.map { Pair (it.name, it.value) }, contains(
44
- Pair (" member" , " \" test\" " ),
45
- Pair (" local" , " 123" )
46
- ))
47
- semaphore.release()
48
- }
49
- })
24
+ @Test fun testBreakpointsAndVariables () {
50
25
debugAdapter.setBreakpoints(SetBreakpointsArguments ().apply {
51
26
source = Source ().apply {
52
27
path = absoluteWorkspaceRoot
@@ -65,4 +40,27 @@ class SampleWorkspaceTest : DebugAdapterTestFixture("sample-workspace", "sample.
65
40
launch()
66
41
semaphore.acquire() // Wait for the end
67
42
}
43
+
44
+ override fun stopped (args : StoppedEventArguments ) {
45
+ assertThat(args.reason, equalTo(" breakpoint" ))
46
+
47
+ // Query information about the debuggee's current state
48
+ val stackTrace = debugAdapter.stackTrace(StackTraceArguments ().apply {
49
+ threadId = args.threadId
50
+ }).join()
51
+ val topFrame = stackTrace.stackFrames.first()
52
+ val scopes = debugAdapter.scopes(ScopesArguments ().apply {
53
+ frameId = topFrame.id
54
+ }).join()
55
+ val scope = scopes.scopes.first()
56
+ val variables = debugAdapter.variables(VariablesArguments ().apply {
57
+ variablesReference = scope.variablesReference
58
+ }).join()
59
+
60
+ assertThat(variables.variables.map { Pair (it.name, it.value) }, contains(
61
+ Pair (" member" , " \" test\" " ),
62
+ Pair (" local" , " 123" )
63
+ ))
64
+ semaphore.release()
65
+ }
68
66
}
0 commit comments