|
9 | 9 | [clojure.tools.namespace.parse :refer [read-ns-decl]]
|
10 | 10 | [clojure.walk :as walk]
|
11 | 11 | [refactor-nrepl
|
12 |
| - [config :as config]] |
| 12 | + [config :as config] |
| 13 | + [core :as core] |
| 14 | + [util :as util]] |
13 | 15 | [refactor-nrepl.ns.tracker :as tracker])
|
14 | 16 | (:import java.io.PushbackReader
|
15 | 17 | java.util.regex.Pattern))
|
|
71 | 73 |
|
72 | 74 | (defn- build-ast
|
73 | 75 | [ns aliases]
|
74 |
| - (when (ns-on-cp? ns) |
75 |
| - (let [opts {:passes-opts |
76 |
| - {:validate/unresolvable-symbol-handler shadow-unresolvable-symbol-handler |
77 |
| - :validate/throw-on-arity-mismatch false |
78 |
| - :validate/wrong-tag-handler shadow-wrong-tag-handler}}] |
79 |
| - (binding [ana/macroexpand-1 noop-macroexpand-1 |
80 |
| - reader/*data-readers* *data-readers*] |
81 |
| - (assoc-in (aj/analyze-ns ns (aj/empty-env) opts) [0 :alias-info] aliases))))) |
| 76 | + (when (and (ns-on-cp? ns) |
| 77 | + (not (util/invalid-fqn? ns))) |
| 78 | + ;; Use `locking`, because AST analysis can perform arbitrary evaluation. |
| 79 | + ;; Parallel analysis is not safe, especially as it can perform `require` calls. |
| 80 | + (locking core/require-lock |
| 81 | + (let [opts {:passes-opts |
| 82 | + {:validate/unresolvable-symbol-handler shadow-unresolvable-symbol-handler |
| 83 | + :validate/throw-on-arity-mismatch false |
| 84 | + :validate/wrong-tag-handler shadow-wrong-tag-handler}}] |
| 85 | + (binding [ana/macroexpand-1 noop-macroexpand-1 |
| 86 | + reader/*data-readers* *data-readers*] |
| 87 | + (assoc-in (aj/analyze-ns ns (aj/empty-env) opts) [0 :alias-info] aliases)))))) |
82 | 88 |
|
83 | 89 | (defn- cachable-ast [file-content]
|
84 | 90 | (let [[ns aliases] (parse-ns file-content)]
|
|
0 commit comments