Skip to content

[inspector] Add analytics and table view-mode #3802

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

Merged
merged 3 commits into from
Apr 7, 2025
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
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,33 @@

## master (unreleased)

### New features

- [#3802](https://github.com/clojure-emacs/cider/issues/3802): Inspector analytics.
- [#3802](https://github.com/clojure-emacs/cider/issues/3802): Inspector table view-mode.
- [orchard#320](https://github.com/clojure-emacs/orchard/pull/320): Info: recognize printed Java classes/methods and munged Clojure functions in stacktrace outputs.

### Changes

- [#3782](https://github.com/clojure-emacs/cider/issues/3782): **(Breaking)** Drop official support for Emacs 26.
- [#3793](https://github.com/clojure-emacs/cider/issues/3793): **(Breaking)** Remove features that relied on printed exception parsing:
- `cider-stacktrace-analyze-string` and `cider-stacktrace-analyze-at-point` functions.
- Automatic stacktrace parsing in log viewer.
- Bump the injected `cider-nrepl` to [0.53.1](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0531-2025-03-26).
- Bump the injected `cider-nrepl` to [0.53.2](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0532-2025-03-26).
- Info: recognize printed Java classes/methods and munged Clojure functions in stacktrace outputs.
- Bump the injected `cider-nrepl` to [0.54.0](https://github.com/clojure-emacs/cider-nrepl/blob/master/CHANGELOG.md#0540-2025-04-05).
- [compliment#122](https://github.com/alexander-yakushev/compliment/pull/122): Completion: sort candidates by priority.
- Inspector: add dedicated view for Exceptions.
- Stop vendoring Haystack dependency.
- Stop vendoring Puget dependency. You can still use `puget` pretty-printer in CIDER, but you need to depend on Puget explicitly. If Puget is not found on the classpath, CIDER will revert to `clojure.pprint/pprint` for pretty-printing.
- [#3777](https://github.com/clojure-emacs/cider/issues/3777): Inspector no longer displays parsed Javadoc for Java classes and members.
- [#3784](https://github.com/clojure-emacs/cider/issues/3784): Inspector: make point less erratic when navigating between inspector screens.
- [#3790](https://github.com/clojure-emacs/cider/issues/3790): Stacktrace: show messages and data for all exception causes by default.
- [#3789](https://github.com/clojure-emacs/cider/issues/3789): Refactor and simplify exception handling.
- [#3789](https://github.com/clojure-emacs/cider/issues/3796): Completion: disable client-side sorting (defer to backend-provided candidate order).
- [#3797](https://github.com/clojure-emacs/cider/issues/3797): Completion: enable `cider-completion-style` by default (this enables richer completion suggestions where candidates don't have to strictly match the prefix).

### Bugs fixed

- [#3784](https://github.com/clojure-emacs/cider/issues/3784): Inspector: make point less erratic when navigating between inspector screens.

## 1.17.1 (2025-02-25)

### Changes
Expand Down
22 changes: 21 additions & 1 deletion cider-inspector.el
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ by clicking or navigating to them by other means."
:type 'boolean
:package-version '(cider . "0.27.0"))

(defcustom cider-inspector-display-analytics-hint t
"When true, display hint about analytics feature for eligible objects.
Can be turned to nil once the user sees and acknowledges the feature."
:type 'boolean
:package-version '(cider . "1.18.0"))

(defvar cider-inspector-uninteresting-regexp
(concat "nil" ; nils are not interesting
"\\|:" clojure--sym-regexp ; nor keywords
Expand Down Expand Up @@ -125,6 +131,7 @@ by clicking or navigating to them by other means."
(define-key map "c" #'cider-inspector-set-max-coll-size)
(define-key map "C" #'cider-inspector-set-max-nested-depth)
(define-key map "v" #'cider-inspector-toggle-view-mode)
(define-key map "y" #'cider-inspector-display-analytics)
(define-key map "d" #'cider-inspector-def-current-val)
(define-key map "t" #'cider-inspector-tap-current-val)
(define-key map "1" #'cider-inspector-tap-at-point)
Expand Down Expand Up @@ -325,6 +332,17 @@ MAX-NESTED-DEPTH is the new value."
(interactive (list (read-number "Max nested depth: " cider-inspector-max-nested-depth)))
(cider-inspector--refresh-with-opts "max-nested-depth" max-nested-depth))

(defun cider-inspector-display-analytics ()
"Toggle the display of analytics for the inspected object."
(interactive)
;; Disable hint about analytics feature so that it is never displayed again.
(when cider-inspector-display-analytics-hint
(customize-set-variable 'cider-inspector-display-analytics-hint nil))
(let ((result (cider-nrepl-send-sync-request `("op" "inspect-display-analytics")
(cider-current-repl))))
(when (nrepl-dict-get result "value")
(cider-inspector--render-value result :next-inspectable))))

(defun cider-inspector-toggle-view-mode ()
"Toggle the view mode of the inspector between normal and object view mode."
(interactive)
Expand Down Expand Up @@ -490,7 +508,9 @@ MAX-COLL-SIZE if non nil."
,@(when cider-inspector-max-coll-size
`("max-coll-size" ,cider-inspector-max-coll-size))
,@(when cider-inspector-max-nested-depth
`("max-nested-depth" ,cider-inspector-max-nested-depth))))
`("max-nested-depth" ,cider-inspector-max-nested-depth))
,@(when cider-inspector-display-analytics-hint
`("display-analytics-hint" "true"))))
(cider-nrepl-send-sync-request (cider-current-repl))))

(declare-function cider-set-buffer-ns "cider-mode")
Expand Down
2 changes: 1 addition & 1 deletion cider.el
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ the artifact.")

Used when `cider-jack-in-auto-inject-clojure' is set to `latest'.")

(defconst cider-required-middleware-version "0.53.2"
(defconst cider-required-middleware-version "0.54.0"
"The CIDER nREPL version that's known to work properly with CIDER.")

(defcustom cider-injected-middleware-version cider-required-middleware-version
Expand Down
2 changes: 1 addition & 1 deletion dev/docker-sample-project/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
:dependencies [[org.clojure/clojure "1.11.1"]
[clj-http "3.12.3"]]
:source-paths ["src"]
:plugins [[cider/cider-nrepl "0.53.2"]])
:plugins [[cider/cider-nrepl "0.54.0"]])
2 changes: 1 addition & 1 deletion dev/tramp-sample-project/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
:dependencies [[org.clojure/clojure "1.11.1"]
[clj-http "3.12.3"]]
:source-paths ["src"]
:plugins [[cider/cider-nrepl "0.53.2"]
:plugins [[cider/cider-nrepl "0.54.0"]
[refactor-nrepl "3.9.0"]])
10 changes: 5 additions & 5 deletions doc/modules/ROOT/pages/basics/middleware_setup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ Use the convenient plugin for defaults, either in your project's

[source,clojure]
----
:plugins [[cider/cider-nrepl "0.53.2"]]
:plugins [[cider/cider-nrepl "0.54.0"]]
----

A minimal `profiles.clj` for CIDER would be:

[source,clojure]
----
{:repl {:plugins [[cider/cider-nrepl "0.53.2"]]}}
{:repl {:plugins [[cider/cider-nrepl "0.54.0"]]}}
----

WARNING: Be careful not to place this in the `:user` profile, as this way CIDER's
Expand All @@ -43,11 +43,11 @@ run `cider-connect` or `cider-connect-cljs`.

[source,clojure]
----
:cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.53.2"}}
:cider-clj {:extra-deps {cider/cider-nrepl {:mvn/version "0.54.0"}}
:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}

:cider-cljs {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.339"}
cider/cider-nrepl {:mvn/version "0.53.2"}
cider/cider-nrepl {:mvn/version "0.54.0"}
cider/piggieback {:mvn/version "0.6.0"}}
:main-opts ["-m" "nrepl.cmdline" "--middleware"
"[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}
Expand All @@ -66,7 +66,7 @@ NOTE: Make sure you're using https://github.com/clojurephant/clojurephant[Clojur
----
dependencies {
devImplementation 'nrepl:nrepl:0.9.0'
devImplementation 'cider:cider-nrepl:0.53.2'
devImplementation 'cider:cider-nrepl:0.54.0'
}

tasks.named('clojureRepl') {
Expand Down
4 changes: 2 additions & 2 deletions doc/modules/ROOT/pages/basics/up_and_running.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ simple - CIDER passes the extra dependencies and nREPL configuration to
your build tool in the command it runs to start the nREPL server. Here's how
this looks for `tools.deps`:

$ clojure -Sdeps '{:deps {nrepl {:mvn/version "1.3.1"} cider/cider-nrepl {:mvn/version "0.53.2"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'
$ clojure -Sdeps '{:deps {nrepl {:mvn/version "1.3.1"} cider/cider-nrepl {:mvn/version "0.54.0"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'

TIP: If you don't want `cider-jack-in` to inject dependencies automatically, set
`cider-inject-dependencies-at-jack-in` to `nil`. Note that you'll have to setup
Expand Down Expand Up @@ -332,7 +332,7 @@ It is also possible for plain `clj`, although the command is somewhat longer:

[source,sh]
----
$ clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.53.2"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
$ clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.54.0"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
----

Alternatively, you can start nREPL either manually or using the facilities
Expand Down
2 changes: 1 addition & 1 deletion doc/modules/ROOT/pages/cljs/shadow-cljs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ And connect to it with `cider-connect`.
...For that to work, `shadow-cljs.edn` contents like the following are assumed:

```clj
:dependencies [[cider/cider-nrepl "0.53.2"] ;; mandatory (unless it's inherited from deps.edn or otherwise present in the classpath of shadow-cljs's JVM process)
:dependencies [[cider/cider-nrepl "0.54.0"] ;; mandatory (unless it's inherited from deps.edn or otherwise present in the classpath of shadow-cljs's JVM process)
[refactor-nrepl/refactor-nrepl "3.9.0"]] ;; refactor-nrepl is optional

:nrepl {:middleware [cider.nrepl/cider-middleware ;; it's advisable to explicitly add this middleware. It's automatically added by shadow-cljs (if available in the classpath), unless `:nrepl {:cider false}`
Expand Down
2 changes: 1 addition & 1 deletion doc/modules/ROOT/pages/cljs/up_and_running.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ or in `build.gradle`:
----
dependencies {
devImplementation 'nrepl:nrepl:1.3.1'
devImplementation 'cider:cider-nrepl:0.53.2'
devImplementation 'cider:cider-nrepl:0.54.0'
devImplementation 'cider:cider-piggieback:0.5.3'
}

Expand Down
13 changes: 7 additions & 6 deletions doc/modules/ROOT/pages/debugging/inspector.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ You'll have access to additional keybindings in the inspector buffer
| `cider-inspector-next-inspectable-object`
| Navigate inspectable sub-objects

| kbd:[f] and kbd:[b]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were those removed?

Copy link
Member Author

@alexander-yakushev alexander-yakushev Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I decided this binding is too standard and obvious to be listed here, and we already have too many bindings to communicate to the user.

| `forward-char`, `backward-char`
| Navigate across characters on a line

| kbd:[Return]
| `cider-inspector-operate-on-point`
| Inspect sub-objects
Expand All @@ -52,14 +48,18 @@ You'll have access to additional keybindings in the inspector buffer
| `cider-inspector-refresh`
| Refresh the inspector (e.g. if viewing an atom/ref/agent)

| kbd:[SPC] or kbd:[Next]
| kbd:[SPC] or kbd:[Next]
| `cider-inspector-next-page`
| Jump to next page in paginated view

| kbd:[M-SPC] or kbd:[Prev]
| `cider-inspector-prev-page`
| Jump to previous page in paginated view

| kbd:[y]
| `cider-inspector-display-analytics`
| Calculate and display analytics for the inspected object. Analytics is supported for lists of numbers, strings, tuples, maps; for large key-value maps.

| kbd:[s]
| `cider-inspector-set-page-size`
| Set a new page size in paginated view
Expand All @@ -78,7 +78,8 @@ You'll have access to additional keybindings in the inspector buffer

| kbd:[v]
| `cider-inspector-toggle-view-mode`
| Switch the rendering of the current value between `:normal` and `:object` view mode. In `:object` mode, any value is rendered as a plain Java object (by displaying its fields) instead of custom rendering rules that the Inspector applies in `:normal` mode.
| Switch the rendering of the current value between `:normal`, `:table`, and
`:object` view modes. In `:table` mode, render the value as a table (only supported for sequences of maps or tuples). In `:object` mode, any value is rendered as a plain Java object (by displaying its fields) instead of custom rendering rules that the Inspector applies in `:normal` mode.

| kbd:[d]
| `cider-inspector-def-current-val`
Expand Down
Loading