Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 86a75572e8
Fetching contributors…


Cannot retrieve contributors at this time

file 27 lines (23 sloc) 0.978 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
(ns lazytest.nsdeps
  "Parsing namespace declarations for dependency information."
  (:use [clojure.set :only (union)]))

(defn- deps-from-libspec [prefix form]
  (cond (list? form) (apply union (map (fn [f] (deps-from-libspec
(symbol (str (when prefix (str prefix "."))
(first form)))
(rest form)))
(vector? form) (deps-from-libspec prefix (first form))
(symbol? form) #{(symbol (str (when prefix (str prefix ".")) form))}
(keyword? form) #{}
:else (throw (IllegalArgumentException.
(pr-str "Unparsable namespace form:" form)))))

(defn- deps-from-ns-form [form]
  (when (and (list? form)
(contains? #{:use :require} (first form)))
    (apply union (map #(deps-from-libspec nil %) (rest form)))))

(defn deps-from-ns-decl
  "Given a (quoted) ns declaration, returns a set of symbols naming
the dependencies of that namespace. Handles :use and :require clauses."
  (apply union (map deps-from-ns-form decl)))
Something went wrong with that request. Please try again.