Skip to content

Commit

Permalink
udap: Responding to continue, next, stepIn, and stepOut
Browse files Browse the repository at this point in the history
Signed-off-by: mstreeter10 <[email protected]>
  • Loading branch information
mstreeter10 committed Jan 6, 2024
1 parent 0eb3f4d commit b985fb2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
9 changes: 5 additions & 4 deletions uni/ulsp/udap/communicator.icn
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ class Communicator(udb, udbSock, progSock, filePath)
return pathfind("udb")
end

method run()
method progress(cmd)
local udbRes, udbResTable, udbResList, progRes, progResTable

if /cmd then cmd := "run"
udbRes := ""
udbResList := list()
progRes := ""

write(udbSock, "run")
write(udbSock, cmd)

#in json
udbRes := udb_output()
Expand All @@ -55,8 +56,8 @@ class Communicator(udb, udbSock, progSock, filePath)
every udbResTable := jtou(udbRes) do {
put(udbResList, udbResTable)
if member(udbResTable, "type") then {
if udbResTable["type"] == "stderr" | udbResTable["type"] == "exited" | udbResTable["type"] == "breakpoint" then {
suspend progResTable
if udbResTable["type"] == "stderr" | udbResTable["type"] == "exited" | udbResTable["type"] == "breakpoint" | udbResTable["type"] == "step" then {
if progRes ~== "" then suspend progResTable
return udbResTable
}
}
Expand Down
19 changes: 15 additions & 4 deletions uni/ulsp/udap/server.icn
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ class Server(port, sock, communicator)
"initialize": { initialize(request_seq, request_command) }
"launch" : { launch(request_seq, request_command, request_arguments) }
"setBreakpoints" : { set_breakpoints(request_seq, request_command, request_arguments) }
"configurationDone" : { acknowledge(request_seq, request_command); run_prog() }
"configurationDone" : { acknowledge(request_seq, request_command); progress("run") }
"threads" : { threads(request_seq, request_command) }
"continue" : { acknowledge(request_seq, request_command); progress("cont") }
"next" : { acknowledge(request_seq, request_command); progress("next") }
"stepIn" : { acknowledge(request_seq, request_command); progress("step") }
"stepOut" : { acknowledge(request_seq, request_command); progress("return") }
"stackTrace" : { stackTrace(request_seq, request_command, request_arguments) }
"scopes" : { scopes(request_seq, request_command, request_arguments) }
"variables" : { variables(request_seq, request_command, request_arguments) }
Expand Down Expand Up @@ -197,13 +201,13 @@ class Server(port, sock, communicator)
end

########################################################
# run #
# progress #
########################################################

method run_prog()
method progress(cmd)
local outputTable, res

every outputTable := communicator.run() do {
every outputTable := communicator.progress(cmd) do {
if member(outputTable, "consoleMsg") then outputTable["consoleMsg"] := replace(outputTable["consoleMsg"], "\"", "\\\"")
if outputTable["type"] == "exited" then {
res := build_event("terminated")
Expand All @@ -218,6 +222,7 @@ class Server(port, sock, communicator)
res := build_event("stopped", table(
"reason", "exception",
"description", outputTable["consoleMsg"],
"text", outputTable["consoleMsg"],
"threadId", 1))
writes(sock, res)
}
Expand All @@ -229,6 +234,12 @@ class Server(port, sock, communicator)
"threadId", 1))
writes(sock, res)
}
else if outputTable["type"] == "step" then {
res := build_event("stopped", table(
"reason", "step",
"threadId", 1))
writes(sock, res)
}
}
}
end
Expand Down

0 comments on commit b985fb2

Please sign in to comment.