Skip to content

Commit 2a42d87

Browse files
[inspect] Support analytics for arrays
1 parent 869f0db commit 2a42d87

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## master (unreleased)
44

5+
* [#339](https://github.com/clojure-emacs/orchard/pull/339): Inspector: support analytics for all maps and arrays.
6+
57
## 0.34.1 (2025-04-23)
68

79
* [#314](https://github.com/clojure-emacs/orchard/pull/314): Print: add special printing rules for records and allow meta :type overrides.

src/orchard/inspect.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@
688688
(-> (render-class-name inspector obj)
689689
(render-counted-length obj)
690690
(render-labeled-value "Component Type" (.getComponentType (class obj)))
691+
(render-analytics)
691692
(render-section-header "Contents")
692693
(indent)
693694
(render-collection-paged)

src/orchard/inspect/analytics.clj

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,18 @@
165165
- lists of arbitrary collections
166166
- arbitrary key-value maps"
167167
[object]
168-
(or (tuples-stats object)
169-
(records-stats object)
170-
(keyvals-stats object)
171-
(basic-list-stats object true)))
168+
(let [object (if (some-> (class object) (.isArray))
169+
;; Convert arrays into vectors to simplify analytics for them.
170+
(vec object)
171+
object)]
172+
(or (tuples-stats object)
173+
(records-stats object)
174+
(keyvals-stats object)
175+
(basic-list-stats object true))))
172176

173177
(defn can-analyze?
174178
"Simple heuristic: we currently only analyze collections (but most of them)."
175179
[object]
176180
(or (instance? List object)
177-
(instance? Map object)))
181+
(instance? Map object)
182+
(some-> (class object) (.isArray))))

0 commit comments

Comments
 (0)