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

[inspector] Use orchard.inspect/refresh instead of individual setters #877

Merged
merged 2 commits into from
May 30, 2024
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## master (unreleased)

### Changes

* [#877](https://github.com/clojure-emacs/cider-nrepl/pull/877): `inspect-refresh` middleware is now capable of setting all config options that `orchard.inspect` supports.
* [#877](https://github.com/clojure-emacs/cider-nrepl/pull/877): Deprecate all `inspect-set-*` middleware ops.
* Bump `orchard` to [0.26.0](https://github.com/clojure-emacs/orchard/blob/master/CHANGELOG.md#0260-2024-06-30).

## 0.48.0 (2024-05-13)

### Changes
Expand Down
20 changes: 12 additions & 8 deletions doc/modules/ROOT/pages/nrepl-api/ops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -675,14 +675,18 @@ Returns::

=== `inspect-refresh`

Re-renders the currently inspected value.
Updates inspector with the provided config and re-renders the current value.

Required parameters::
* `:session` The current session


Optional parameters::
{blank}
* `:max-atom-length` New max length of single rendered value
* `:max-coll-size` New max size of rendered collection
* `:max-nested-depth` New max nested depth of rendered collection
* `:page-size` New page size


Returns::
* `:doc-block-tags-fragments` May be absent. Represent the 'param', 'returns' and 'throws' sections a Java doc comment. It's a vector of fragments, where fragment is a map with ``:type`` ('text' or 'html') and ``:content`` plain text or html markup, respectively
Expand All @@ -696,7 +700,7 @@ Returns::

=== `inspect-set-max-atom-length`

Set the max length of nested atoms to specified value.
[DEPRECATED - use ``inspect-refresh`` instead] Set the max length of nested atoms to specified value.

Required parameters::
* `:max-atom-length` New max length.
Expand All @@ -718,7 +722,7 @@ Returns::

=== `inspect-set-max-coll-size`

Set the number of nested collection members to display before truncating.
[DEPRECATED - use ``inspect-refresh`` instead] Set the number of nested collection members to display before truncating.

Required parameters::
* `:max-coll-size` New collection size.
Expand All @@ -740,7 +744,7 @@ Returns::

=== `inspect-set-max-nested-depth`

Set the maximum nested levels to display before truncating.
[DEPRECATED - use ``inspect-refresh`` instead] Set the maximum nested levels to display before truncating.

Required parameters::
* `:max-nested-depth` New nested depth.
Expand All @@ -762,7 +766,7 @@ Returns::

=== `inspect-set-page-size`

Sets the page size in paginated view to specified value.
[DEPRECATED - use ``inspect-refresh`` instead] Sets the page size in paginated view to specified value.

Required parameters::
* `:page-size` New page size.
Expand Down Expand Up @@ -1147,7 +1151,7 @@ Returns::

=== `retest`

[DEPRECATED - ``use test-var-query`` instead] Run all tests in the project. If ``load?`` is truthy, all project namespaces are loaded; otherwise, only tests in presently loaded namespaces are run. Results are cached for exception retrieval and to enable re-running of failed/erring tests.
[DEPRECATED - use ``test-var-query`` instead] Run all tests in the project. If ``load?`` is truthy, all project namespaces are loaded; otherwise, only tests in presently loaded namespaces are run. Results are cached for exception retrieval and to enable re-running of failed/erring tests.

Required parameters::
{blank}
Expand Down Expand Up @@ -1281,7 +1285,7 @@ Returns::

=== `test`

[DEPRECATED - ``use test-var-query`` instead] Run tests in the specified namespace and return results. This accepts a set of ``tests`` to be run; if nil, runs all tests. Results are cached for exception retrieval and to enable re-running of failed/erring tests.
[DEPRECATED - use ``test-var-query`` instead] Run tests in the specified namespace and return results. This accepts a set of ``tests`` to be run; if nil, runs all tests. Results are cached for exception retrieval and to enable re-running of failed/erring tests.

Required parameters::
{blank}
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:url "http://www.eclipse.org/legal/epl-v10.html"}
:scm {:name "git" :url "https://github.com/clojure-emacs/cider-nrepl"}
:dependencies [[nrepl "1.1.1" :exclusions [org.clojure/clojure]]
[cider/orchard "0.25.0" :exclusions [org.clojure/clojure]]
[cider/orchard "0.26.0" :exclusions [org.clojure/clojure]]
^:inline-dep [mx.cider/haystack "0.3.3" :exclusions [cider/orchard]]
^:inline-dep [thunknyc/profile "0.5.2"]
^:inline-dep [mvxcvi/puget "1.3.4" :exclusions [org.clojure/clojure]]
Expand Down
18 changes: 11 additions & 7 deletions src/cider/nrepl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,12 @@ if applicable, and re-render the updated value."
:requires {"session" "The current session"}
:returns inspector-returns}
"inspect-refresh"
{:doc "Re-renders the currently inspected value."
{:doc "Updates inspector with the provided config and re-renders the current value."
:requires {"session" "The current session"}
:optional {"page-size" "New page size"
"max-atom-length" "New max length of single rendered value"
"max-coll-size" "New max size of rendered collection"
"max-nested-depth" "New max nested depth of rendered collection"}
:returns inspector-returns}
"inspect-next-page"
{:doc "Jumps to the next page in paginated collection view."
Expand All @@ -347,22 +351,22 @@ if applicable, and re-render the updated value."
:requires {"session" "The current session"}
:returns inspector-returns}
"inspect-set-page-size"
{:doc "Sets the page size in paginated view to specified value."
{:doc "[DEPRECATED - use `inspect-refresh` instead] Sets the page size in paginated view to specified value."
:requires {"page-size" "New page size."
"session" "The current session"}
:returns inspector-returns}
"inspect-set-max-atom-length"
{:doc "Set the max length of nested atoms to specified value."
{:doc "[DEPRECATED - use `inspect-refresh` instead] Set the max length of nested atoms to specified value."
:requires {"max-atom-length" "New max length."
"session" "The current session"}
:returns inspector-returns}
"inspect-set-max-coll-size"
{:doc "Set the number of nested collection members to display before truncating."
{:doc "[DEPRECATED - use `inspect-refresh` instead] Set the number of nested collection members to display before truncating."
:requires {"max-coll-size" "New collection size."
"session" "The current session"}
:returns inspector-returns}
"inspect-set-max-nested-depth"
{:doc "Set the maximum nested levels to display before truncating."
{:doc "[DEPRECATED - use `inspect-refresh` instead] Set the maximum nested levels to display before truncating."
:requires {"max-nested-depth" "New nested depth."
"session" "The current session"}
:returns inspector-returns}
Expand Down Expand Up @@ -757,7 +761,7 @@ stack frame of the most recent exception. This op is deprecated, please use the
:optional (merge wrap-print-optional-arguments)
:returns (merge fail-fast-doc timing-info-return-doc)}
"test"
{:doc "[DEPRECATED - `use test-var-query` instead] Run tests in the specified namespace and return results. This accepts a set of `tests` to be run; if nil, runs all tests. Results are cached for exception retrieval and to enable re-running of failed/erring tests."
{:doc "[DEPRECATED - use `test-var-query` instead] Run tests in the specified namespace and return results. This accepts a set of `tests` to be run; if nil, runs all tests. Results are cached for exception retrieval and to enable re-running of failed/erring tests."
:optional wrap-print-optional-arguments
:returns (merge fail-fast-doc timing-info-return-doc)}
"test-all"
Expand All @@ -768,7 +772,7 @@ stack frame of the most recent exception. This op is deprecated, please use the
{:doc "Rerun all tests that did not pass when last run. Results are cached for exception retrieval and to enable re-running of failed/erring tests."
:optional wrap-print-optional-arguments}
"retest"
{:doc "[DEPRECATED - `use test-var-query` instead] Run all tests in the project. If `load?` is truthy, all project namespaces are loaded; otherwise, only tests in presently loaded namespaces are run. Results are cached for exception retrieval and to enable re-running of failed/erring tests."
{:doc "[DEPRECATED - use `test-var-query` instead] Run all tests in the project. If `load?` is truthy, all project namespaces are loaded; otherwise, only tests in presently loaded namespaces are run. Results are cached for exception retrieval and to enable re-running of failed/erring tests."
:optional wrap-print-optional-arguments
:returns (merge fail-fast-doc timing-info-return-doc)}}})

Expand Down
50 changes: 22 additions & 28 deletions src/cider/nrepl/middleware/inspect.clj
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,18 @@
(doseq [^Class interface (.getInterfaces clazz)]
(info/info 'user (-> interface .getCanonicalName symbol)))))))

(defn- msg->inspector-config [msg]
(let [config (select-keys msg [:page-size :max-atom-length :max-coll-size
:max-value-length :max-nested-depth :spacious])]
(if (contains? config :spacious)
(update config :spacious #(case %
("false" "nil") false
true))
config)))

(defn inspect-reply*
[msg value]
(let [config (select-keys msg [:page-size :max-atom-length :max-coll-size
:max-value-length :max-nested-depth :spacious])
config (if (contains? config :spacious)
(update config :spacious #(case %
("false" "nil") false
true))
config)
(let [config (msg->inspector-config msg)
inspector (swap-inspector! msg #(inspect/start (merge % config) value))]
(warmup-javadoc-cache (class (:value inspector)))
(inspector-response msg inspector {})))
Expand Down Expand Up @@ -128,29 +131,20 @@
(defn previous-sibling-reply [msg]
(inspector-response msg (swap-inspector! msg inspect/previous-sibling)))

(defn refresh-reply [msg]
(inspector-response msg (swap-inspector! msg inspect/inspect-render)))

(defn next-page-reply [msg]
(inspector-response msg (swap-inspector! msg inspect/next-page)))

(defn prev-page-reply [msg]
(inspector-response msg (swap-inspector! msg inspect/prev-page)))

(defn set-page-size-reply [msg]
(inspector-response msg (swap-inspector! msg inspect/set-page-size (:page-size msg))))

(defn set-max-atom-length-reply [msg]
(inspector-response msg (swap-inspector! msg inspect/set-max-atom-length
(:max-atom-length msg))))

(defn set-max-coll-size-reply [msg]
(inspector-response msg (swap-inspector! msg inspect/set-max-coll-size
(:max-coll-size msg))))
(defn refresh-reply [msg]
(let [overrides (msg->inspector-config msg)]
(inspector-response msg (swap-inspector! msg #(inspect/refresh % overrides)))))

(defn set-max-nested-depth-reply [msg]
(inspector-response msg (swap-inspector! msg inspect/set-max-nested-depth
(:max-nested-depth msg))))
(defn ^:deprecated set-page-size-reply [msg] (refresh-reply msg))
(defn ^:deprecated set-max-atom-length-reply [msg] (refresh-reply msg))
(defn ^:deprecated set-max-coll-size-reply [msg] (refresh-reply msg))
(defn ^:deprecated set-max-nested-depth-reply [msg] (refresh-reply msg))

(defn clear-reply [msg]
(inspector-response msg (swap-inspector! msg (constantly (inspect/start nil)))))
Expand All @@ -173,13 +167,13 @@
"inspect-push" push-reply
"inspect-next-sibling" next-sibling-reply
"inspect-previous-sibling" previous-sibling-reply
"inspect-refresh" refresh-reply
"inspect-next-page" next-page-reply
"inspect-prev-page" prev-page-reply
"inspect-set-page-size" set-page-size-reply
"inspect-set-max-atom-length" set-max-atom-length-reply
"inspect-set-max-coll-size" set-max-coll-size-reply
"inspect-set-max-nested-depth" set-max-nested-depth-reply
"inspect-refresh" refresh-reply
"inspect-set-page-size" refresh-reply
"inspect-set-max-atom-length" refresh-reply
"inspect-set-max-coll-size" refresh-reply
"inspect-set-max-nested-depth" refresh-reply
"inspect-clear" clear-reply
"inspect-def-current-value" def-current-value
"inspect-tap-current-value" tap-current-value
Expand Down
Loading