             [clojure.tools.analyzer.jvm :as ana.jvm]
             [clojure.tools.namespace.parse :refer [read-ns-decl]])
   (:import java.io.PushbackReader))
+
+;;; The structure here is {ns {content-hash ast}}
+(def ^:private ast-cache (atom {}))
 
 ;; these two fns could go to clojure.tools.namespace.parse: would worth a pull request
 (defn get-alias [as v]

(defn- noop-macroexpand-1 [form]
  form)

(defn string-ast [string]
  (try
    (let [[ns aliases] (parse-ns string)]
      (binding [ana/macroexpand-1 noop-macroexpand-1]
        (when ns
          (assoc-in (ana.jvm/analyze-ns ns) [0 :alias-info] aliases))))
    (catch Exception ex
      (println "error when building AST for" (first (parse-ns string)))
      (.printStackTrace ex)
      [])))


(defn parse-ns
  "Returns tuples with the ns as the first element and
  a map of the aliases for the namespace as the second element
  in the same format as ns-aliases"
  [body]
  (let [ns-decl (read-ns-decl (PushbackReader. (java.io.StringReader. body)))
        aliases (->> ns-decl
