Skip to content

Commit

Permalink
implant: support detectedMacroNamespaces from parsed ns forms
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Jun 5, 2016
1 parent e9df04d commit 08b2690
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/implant/dirac/implant.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,22 @@
(if-not (empty? uses)
(clj->js uses))))

(defn collect-macro-namespaces [ast]
(let [{:keys [use-macros require-macros]} ast]
(-> (concat (vals use-macros) (vals require-macros))
(sort)
(dedupe)
(clj->js))))

(defn parse-ns-from-source* [source]
(when-let [ns-form (parse-ns-form source)]
(let [ast (analyze-ns ns-form {})
ns-descriptor #js {:name (str (:name ast))
:aliases (get-aliases (:requires ast))
:maliases (get-aliases (:require-macros ast))
:uses (get-uses (:uses ast))
:muses (get-uses (:use-macros ast))}]
;(log "parse-ns-from-source" ns-descriptor (envelope source) (envelope ast))
ns-descriptor)))
(let [ast (analyze-ns ns-form {})]
#js {"name" (str (:name ast))
"namespaceAliases" (get-aliases (:requires ast))
"macroNamespaceAliases" (get-aliases (:require-macros ast))
"namespaceRefers" (get-uses (:uses ast))
"macroRefers" (get-uses (:use-macros ast))
"detectedMacroNamespaces" (collect-macro-namespaces ast)})))

(defn parse-ns-from-source [source]
(try
Expand Down

0 comments on commit 08b2690

Please sign in to comment.