<< Back to previous view

[CLJ-783] clojure.inspector/inspect-tree doesn't work on sets --patch in the description by Jason Wolfe Created: 28/Apr/11  Updated: 24/May/13  Resolved: 24/May/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.6

Type: Enhancement Priority: Minor
Reporter: Armando Blancas Assignee: Unassigned
Resolution: Completed Votes: 1
Labels: None


Attachments: Text File clj-783-patch.txt    
Patch: Code
Approval: Ok
Waiting On: Rich Hickey


As reported by Jason Wolfe on March 19, 2009 in the clojure group:

clojure.inspector/inspect-tree doesn't work on sets; patch attached

I was debugging with inspect-tree and noticed that it errors when it
encounters a set (it thinks it's not atomic, but then nth produces an

I made a small patch (below) that makes inspect-tree work on
java.util.Sets, and also anything else that implements
clojure.lang.Seqable. If this is of interest, please let me know and
I can create an issue.


Index: src/clj/clojure/inspector.clj
— src/clj/clojure/inspector.clj (revision 1335)
+++ src/clj/clojure/inspector.clj (working copy)
@@ -20,8 +20,10 @@
(defn collection-tag [x]
(instance? java.util.Map$Entry x) :entry

  • (instance? java.util.Map x) :map
    + (instance? java.util.Map x) :seqable
    + (instance? java.util.Set x) :seqable
    (sequential? x) :seq
    + (instance? clojure.lang.Seqable x) :seqable
    :else :atom))

(defmulti is-leaf collection-tag)
@@ -42,11 +44,15 @@
(defmethod get-child-count :entry [e]
(count (val e)))

-(defmethod is-leaf :map [m]
+(defmethod is-leaf :seqable [parent]
-(defmethod get-child :map [m index]

  • (nth (seq m) index))
    +(defmethod get-child :seqable [parent index]
    + (nth (seq parent) index))
    +(defmethod get-child-count :seqable [parent]
    + (count (seq parent)))

(defn tree-model [data]
(proxy [TreeModel] []
(getRoot [] data)

Comment by Andy Fingerhut [ 14/Feb/12 12:54 PM ]

Created a properly formatted patch, attached, for Jason's enhancement. I tested it with

(inspect-tree (:members (clojure.reflect/reflect java.lang.Math)))

and it worked, whereas it had many errors without Jason's changes.

Comment by Andy Fingerhut [ 23/Feb/12 11:58 PM ]

Jason Wolfe has signed a CA. Patch applies cleanly with latest master as of Feb 14, 2012. No errors, warnings, or test failures with the patch applied. No doc strings need updating.

Comment by Stuart Sierra [ 09/Nov/12 4:12 PM ]


Generated at Wed Jan 17 18:43:09 CST 2018 using JIRA 4.4#649-r158309.