Skip to content

Commit

Permalink
add find-unused-locals
Browse files Browse the repository at this point in the history
  • Loading branch information
Bronsa committed Feb 14, 2019
1 parent 6f6602d commit 8c7c393
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/clojure/tools/analyzer/jvm/deps.clj
Expand Up @@ -88,3 +88,14 @@
(conj asts a)))]
((if include-meta? identity dedupe)
(mapv mexpansions asts)))))

(defn find-undefined-locals
"Takes a form and returns a set of all the free locals in it"
[expr]
(->> (binding [a.j/run-passes identity]
(a.j/analyze expr (a.j/empty-env)))
ast/nodes
(filter (fn [{:keys [op]}] (= op :maybe-class)))
(map :class)
(remove (fn [x] (-> x str (.contains "."))))
(into #{})))

0 comments on commit 8c7c393

Please sign in to comment.