Hello,

Here is how I get an hierarchical data structure of information on ns
in clojure-dev :

The tree has really just 3 levels : one root node representing all ns,
one child node of the root node representing one ns each, one child
node per ns node for ns interned symbols.
Each node is represented as a map, with a simple convention : the
"type" of the node is at key :key, the children of the node are at
key :children, and are a vector of maps. Other information for the
given node are other keys.

And now the code (that uses (var ..) :

(defn- meta-info [v]
  (reduce (fn [m e] (merge m { (first e) (str (second e)) })) {} (meta
v)))

(defn- var-info [v]
  (merge { :type "var" :name (str v) } (meta-info v)))

(defn- ns-info [n]
  { :name ((comp str ns-name) n)
    :type "ns"
    :children (apply vector (map #(var-info (second %)) (ns-interns
n))) })

(defn namespaces-info []
  { :name "namespaces" :type "namespaces"
    :children (apply vector (map ns-info (all-ns))) })

HTH,

Regards,

--
Laurent

On 22 jan, 19:20, Peter Wolf <opus...@gmail.com> wrote:
> Here's a dumb question which has been answered before... but I can't
> find it in the docs.
>
> How does one find out the file and line number upon which a symbol was
> defined?  I want to use it for "go-to-defintion" in the IntelliJ plugin.
>
> Also, is there any way to find all the code that is referencing a
> symbol?  I need that to implement "find-usages", "rename" and "move".
>
> Thanks
> Peter
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to