Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change representation of debug-commands to a set of command names #654

Merged
merged 2 commits into from
Oct 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
## master (unreleased)

### New Features

* [#653](https://github.com/clojure-emacs/cider-nrepl/pull/653): Add `inspect-def-current-value` to inspect middleware.
* [#654](https://github.com/clojure-emacs/cider-nrepl/pull/654):
Change the format of debugger command messages to a set of command names, leaving key mappings up to client implementations.
* [#653](https://github.com/clojure-emacs/cider-nrepl/pull/653): Add `inspect-def-current-value` to inspect middleware.

## 0.22.4 (2019-10-08)

Expand Down
43 changes: 24 additions & 19 deletions src/cider/nrepl/middleware/debug.clj
Original file line number Diff line number Diff line change
Expand Up @@ -297,32 +297,37 @@ this map (identified by a key), and will `dissoc` it afterwards."}
last :stacktrace)}]}))

(def debug-commands
{"c" :continue
"C" :Continue
"e" :eval
"h" :here
"i" :in
"j" :inject
"l" :locals
"n" :next
"o" :out
"p" :inspect
"q" :quit
"s" :stacktrace
"t" :trace})
"An unsorted set of commands supported by the debugger."
#{:continue
:continue-all
:eval
:here
:in
:inject
:locals
:next
:out
:inspect
:quit
:stacktrace
:trace})

(defn read-debug-command
"Read and take action on a debugging command.
Ask for one of the following debug commands using `read-debug-input`:

next: Return value.
continue: Skip breakpoints for the remainder of this eval session.
continue: Skip the current breakpoint.
continue-all: Skip breakpoints for the remainder of this eval session.
in: Step into a function
out: Skip breakpoints in the current sexp.
inspect: Evaluate an expression and inspect it.
here: Skip all breakpoints up till specified coordinate `coord`
inspect: Prompt for an expression to evaluate and inspect it.
locals: Inspect local variables.
inject: Evaluate an expression and return it.
eval: Evaluate an expression, display result, and prompt again.
stacktrace: Print the current stacktrace, and prompt again.
trace: Continue, printing intermediate expressions and their values.
quit: Abort current eval session.

Response received can be any one of these values. It can also be a map
Expand All @@ -337,8 +342,8 @@ this map (identified by a key), and will `dissoc` it afterwards."}
:coor coor
:locals locals)]
(let [commands (cond-> debug-commands
(not (map? *msg*)) (dissoc "q")
(nil? (:locals dbg-state)) (dissoc "e" "j" "l" "p")
(not (map? *msg*)) (disj :quit)
(nil? (:locals dbg-state)) (disj :eval :inject :locals :inspect)
(cljs/grab-cljs-env *msg*) identity)
response-raw (read-debug-input dbg-state commands nil)
dbg-state (dissoc dbg-state :inspect)
Expand All @@ -354,8 +359,8 @@ this map (identified by a key), and will `dissoc` it afterwards."}
value)
:continue (do (reset! (:skip STATE__) true)
value)
:Continue (do (skip-breaks! :all)
value)
:continue-all (do (skip-breaks! :all)
value)
:out (do (skip-breaks! :deeper (butlast (:coor dbg-state)) (:code dbg-state) force?)
value)
:here (do (skip-breaks! :before coord (:code dbg-state) force?)
Expand Down
6 changes: 3 additions & 3 deletions test/clj/cider/nrepl/middleware/debug_integration_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

(def-debug-op :next)
(def-debug-op :continue)
(def-debug-op :Continue)
(def-debug-op :continue-all)
(def-debug-op :in)

(defmethod debugger-send :out [_ & [force?]]
Expand Down Expand Up @@ -261,7 +261,7 @@
(<-- {:debug-value "1" :coor [1 3 1]}) ; a in foo
(--> :continue)
(<-- {:debug-value "2" :coor [1 3 1]}) ; a in foo
(--> :Continue)
(--> :continue-all)
(<-- {:value ":fin"})
(<-- {:status ["done"]})))

Expand Down Expand Up @@ -615,6 +615,6 @@
(.startsWith file "jar:file:")
(.endsWith file "/nrepl/server.clj"))

(--> :Continue)
(--> :continue-all)
(<-- {:value "{:transport 23}"})
(<-- {:status ["done"]}))