Query API for clj-xref cross-reference databases.
Typical usage:
;; Load a database generated by lein xref or clj -T:xref generate
(def db (xref/load-db))
;; Query it (xref/who-calls db 'my.ns/my-fn) (xref/calls-who db 'my.ns/my-fn) (xref/who-references db 'my.ns/config)
Query API for clj-xref cross-reference databases. Typical usage: ;; Load a database generated by `lein xref` or `clj -T:xref generate` (def db (xref/load-db)) ;; Query it (xref/who-calls db 'my.ns/my-fn) (xref/calls-who db 'my.ns/my-fn) (xref/who-references db 'my.ns/*config*)
(analyze paths & [opts])Run clj-kondo analysis on paths and return an indexed xref database.
Requires clj-kondo on the classpath. Options are passed to
clj-xref.analyze/analyze.
Run clj-kondo analysis on `paths` and return an indexed xref database. Requires clj-kondo on the classpath. Options are passed to `clj-xref.analyze/analyze`.
(apropos db pattern)Find vars whose fully-qualified name matches pattern (string or regex).
Find vars whose fully-qualified name matches `pattern` (string or regex).
(call-graph db
sym
&
[{:keys [depth direction] :or {depth 3 direction :outgoing}}])Build a transitive call graph starting from sym.
Returns a set of [from to] edges.
Options:
:depth - max traversal depth (default 3)
:direction - :outgoing (what does sym call?) or :incoming (who calls sym?)
Build a transitive call graph starting from `sym`. Returns a set of [from to] edges. Options: :depth - max traversal depth (default 3) :direction - :outgoing (what does sym call?) or :incoming (who calls sym?)
(calls-who db sym)Find all vars called by sym. Returns xref entries with :kind :call.
Find all vars called by `sym`. Returns xref entries with :kind :call.
(from-kondo-analysis kondo-result & [{:keys [paths project]}])Build an indexed xref database from a pre-computed clj-kondo result
(the return value of clj-kondo.core/run!). The result must contain
:analysis data (enable with {:config {:analysis true}}).
Build an indexed xref database from a pre-computed clj-kondo result
(the return value of `clj-kondo.core/run!`). The result must contain
:analysis data (enable with {:config {:analysis true}}).(index db)Add in-memory indexes to a flat xref database map.
Call this on raw database maps (e.g., from EDN or from analyze)
to enable queries.
Add in-memory indexes to a flat xref database map. Call this on raw database maps (e.g., from EDN or from `analyze`) to enable queries.
(load-db)(load-db path)Load an xref database from an EDN file and build in-memory indexes.
Defaults to .clj-xref/xref.edn in the current directory.
Load an xref database from an EDN file and build in-memory indexes. Defaults to `.clj-xref/xref.edn` in the current directory.
(ns-dependents db ns-sym)Return the set of namespaces that depend on ns-sym
(namespaces containing references to vars in ns-sym).
Return the set of namespaces that depend on `ns-sym` (namespaces containing references to vars in `ns-sym`).
(ns-deps db ns-sym)Return the set of namespaces that ns-sym depends on
(namespaces of vars referenced from ns-sym).
Return the set of namespaces that `ns-sym` depends on (namespaces of vars referenced from `ns-sym`).
(ns-vars db ns-sym)List all var definitions in namespace ns-sym.
List all var definitions in namespace `ns-sym`.
(unused-vars db & [{:keys [include-private?] :or {include-private? false}}])Find vars that are defined but never referenced. Options: :include-private? - include private vars (default false)
Find vars that are defined but never referenced. Options: :include-private? - include private vars (default false)
(who-calls db sym)Find all call sites of sym. Returns xref entries with :kind :call.
Find all call sites of `sym`. Returns xref entries with :kind :call.
(who-dispatches db sym)Find all defmethod dispatch values for the multimethod sym.
Find all defmethod dispatch values for the multimethod `sym`.
(who-implements db sym)Find all implementations of the protocol sym.
Find all implementations of the protocol `sym`.
(who-macroexpands db sym)Find all macroexpansion sites of the macro sym.
Find all macroexpansion sites of the macro `sym`.
(who-references db sym)Find all references to sym (any kind: call, reference, macroexpand, etc.).
Find all references to `sym` (any kind: call, reference, macroexpand, etc.).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |