Skip to content

Commit

Permalink
Build AST for nses in project in topological order
Browse files Browse the repository at this point in the history
when warming the AST cache

- fixes error after global rename symbol when def(n) being renamed is
  referred
- might give remedy for #126
  • Loading branch information
benedekfazekas committed Oct 31, 2015
1 parent ee9cf14 commit fc5f293
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/refactor_nrepl/analyzer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
[clojure.tools.namespace.parse :refer [read-ns-decl]]
[clojure.walk :as walk]
[refactor-nrepl
[config :as config]
[core :as core]]
[config :as config]]
[refactor-nrepl.ns.tracker :as tracker]
[clojure.string :as str])
(:import java.io.PushbackReader
java.util.regex.Pattern))
Expand Down Expand Up @@ -121,7 +121,7 @@
"OK"))))))

(defn warm-ast-cache []
(doseq [f (core/find-in-project core/clj-file?)]
(doseq [f (tracker/project-files-in-topo-order)]
(try
(ns-ast (slurp f))
(catch Throwable th))) ;noop, ast-status will be reported separately
Expand Down
8 changes: 8 additions & 0 deletions src/refactor_nrepl/ns/tracker.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@
(for [[file ns] (:clojure.tools.namespace.file/filemap tracker)
:when ((set deps) ns)]
file)))

(defn project-files-in-topo-order []
(let [tracker (file/add-files (tracker/tracker) (core/find-in-project core/clj-file?))
nses (dep/topo-sort (:clojure.tools.namespace.track/deps tracker))
filemap (:clojure.tools.namespace.file/filemap tracker)
ns2file (zipmap (vals filemap) (keys filemap))]
(->> (map ns2file nses)
(remove nil?))))

0 comments on commit fc5f293

Please sign in to comment.