|
60 | 60 |
|
61 | 61 | (defn- ns->symbols []
|
62 | 62 | (caching :ns->symbols
|
63 |
| - (let [xs (all-ns)] |
64 |
| - (zipmap xs (mapv (comp set keys ns-publics) xs))))) |
| 63 | + (let [xs (all-ns)] |
| 64 | + (zipmap xs (mapv (comp set keys ns-publics) xs))))) |
65 | 65 |
|
66 | 66 | (defn- symbols->ns-syms*
|
67 | 67 | ([]
|
|
78 | 78 | (defn- symbols->ns-syms []
|
79 | 79 | (cache-with-dirty-tracking :symbols->ns-syms symbols->ns-syms*))
|
80 | 80 |
|
81 |
| - |
82 | 81 | (defn- walk
|
83 | 82 | "Adapted from clojure.walk/walk and clojure.walk/prewalk; this version
|
84 | 83 | preserves metadata on compound forms."
|
|
110 | 109 |
|
111 | 110 | (def ^:private ns-qualifed-syms
|
112 | 111 | (memoize
|
113 |
| - (fn [body] |
114 |
| - (apply merge-with set/union {} |
115 |
| - (for [ss (symbols-in-body body) |
116 |
| - :let [[_ alias var-name] (re-matches #"(.+)/(.+)" (str ss))] |
117 |
| - :when alias] |
118 |
| - {(symbol alias) #{(symbol var-name)}}))))) |
| 112 | + (fn [body] |
| 113 | + (apply merge-with set/union {} |
| 114 | + (for [ss (symbols-in-body body) |
| 115 | + :let [[_ alias var-name] (re-matches #"(.+)/(.+)" (str ss))] |
| 116 | + :when alias] |
| 117 | + {(symbol alias) #{(symbol var-name)}}))))) |
119 | 118 |
|
120 | 119 | (defn- ns-import-candidates
|
121 | 120 | "Search (all-ns) for imports that match missing-sym, returning a set of
|
|
131 | 130 |
|
132 | 131 | (defn- alias-candidates [type missing body]
|
133 | 132 | (set
|
134 |
| - (let [syms-with-alias (get (ns-qualifed-syms body) missing)] |
135 |
| - (when (seq syms-with-alias) |
136 |
| - (let [ns->syms (ns->symbols)] |
137 |
| - (for [ns (all-ns) |
138 |
| - :when (set/subset? syms-with-alias (ns->syms ns))] |
139 |
| - (ns-name ns))))))) |
| 133 | + (let [syms-with-alias (get (ns-qualifed-syms body) missing)] |
| 134 | + (when (seq syms-with-alias) |
| 135 | + (let [ns->syms (ns->symbols)] |
| 136 | + (for [ns (all-ns) |
| 137 | + :when (set/subset? syms-with-alias (ns->syms ns))] |
| 138 | + (ns-name ns))))))) |
140 | 139 |
|
141 | 140 | (defn candidates
|
142 | 141 | "Return a set of class or ns symbols that match the given constraints."
|
|
155 | 154 | (alias-candidates type missing body')))))
|
156 | 155 | :refer (get (symbols->ns-syms) missing)
|
157 | 156 | :rename (reduce-kv
|
158 |
| - (fn [s ns orig->rename] |
159 |
| - (cond->* s |
160 |
| - (some #{missing} (vals orig->rename)) (conj ns))) |
161 |
| - #{} (:rename old-ns-map)))) |
| 157 | + (fn [s ns orig->rename] |
| 158 | + (cond->* s |
| 159 | + (some #{missing} (vals orig->rename)) (conj ns))) |
| 160 | + #{} (:rename old-ns-map)))) |
0 commit comments