File tree Expand file tree Collapse file tree 8 files changed +30
-23
lines changed
Expand file tree Collapse file tree 8 files changed +30
-23
lines changed Original file line number Diff line number Diff line change 7474(defn- build-ast
7575 [ns aliases]
7676 (when (and (ns-on-cp? ns )
77- (not (util/invalid-fqn ? ns )))
77+ (not (util/self-referential ? ns )))
7878 ; ; Use `locking`, because AST analysis can perform arbitrary evaluation.
7979 ; ; Parallel analysis is not safe, especially as it can perform `require` calls.
8080 (locking core/require-lock
9494 (when-let [new-ast-or-err (try
9595 (build-ast ns aliases)
9696 (catch Throwable th
97- (when (System/getProperty " refactor-nrepl.internal.log-exceptions" )
98- (-> th .printStackTrace))
97+ (util/maybe-log-exception th)
9998 th))]
10099 (update-ast-cache file-content ns new-ast-or-err))))))
101100
Original file line number Diff line number Diff line change 66 [orchard.java.classpath :as cp]
77 [orchard.misc :as misc]
88 [me.raynes.fs :as fs]
9- [refactor-nrepl.util :refer [normalize-to-unix-path]]
9+ [refactor-nrepl.util :as util : refer [normalize-to-unix-path]]
1010 [refactor-nrepl.s-expressions :as sexp]
1111 [refactor-nrepl.config :as config])
1212 (:import [java.io File FileReader PushbackReader StringReader]))
325325 (require n))
326326 (find-ns n)
327327 (catch Throwable e
328- (-> e .printStackTrace )
328+ (util/maybe-log-exception e )
329329 (when-not ignore-error?
330330 (throw e)))))
331331
Original file line number Diff line number Diff line change 8585 (mapcat #(try
8686 (get-macro-definitions-in-file-with-caching %)
8787 (catch Exception e
88- (when (System/getProperty " refactor-nrepl.internal.log-exceptions" )
89- (-> e .printStackTrace))
88+ (util/maybe-log-exception e)
9089 (when-not ignore-errors?
9190 (throw e)))))))
9291
Original file line number Diff line number Diff line change 22 (:require [clojure
33 [set :as set]
44 [string :as str]]
5- [refactor-nrepl.util :refer [invalid-fqn ?]]
5+ [refactor-nrepl.util :as util : refer [self-referential ?]]
66 [clojure.tools.analyzer.ast :refer [nodes postwalk]]
77 [clojure.tools.namespace.parse :as parse]
88 [refactor-nrepl
109109 (find-symbol-in-ast fully-qualified-name)
110110 (filter :line-beg ))
111111 (catch Exception e
112- (when (System/getProperty " refactor-nrepl.internal.log-exceptions" )
113- (-> e .printStackTrace))
112+ (util/maybe-log-exception e)
114113 (when-not ignore-errors
115114 (throw e))))
116115 locs (into
140139 (->> (core/dirs-on-classpath )
141140 (mapcat (partial core/find-in-dir (every-pred (some-fn core/clj-file? core/cljc-file?)
142141 (fn [f]
143- (let [n (some-> f
144- core/read-ns-form
145- parse/name-from-ns-decl)]
146- (if-not n
147- false
148- (not (invalid-fqn? n))))))))
142+ (try
143+ (let [n (some-> f
144+ core/read-ns-form
145+ parse/name-from-ns-decl)]
146+ (if-not n
147+ false
148+ (not (self-referential? n))))
149+ (catch Exception e
150+ (util/maybe-log-exception e)
151+ false ))))))
149152 (mapcat (partial find-symbol-in-file fully-qualified-name ignore-errors referred-syms)))))
150153
151154(defn- get &read-enclosing-sexps
Original file line number Diff line number Diff line change 5959 cljs? (= dialect :cljs )
6060 file-ns (or (when-let [s (-> parsed-ns :ns symbol)]
6161 (when-not cljs?
62- (core/safe-find-ns s true )))
62+ (core/safe-find-ns s :ignore-errors )))
6363 *ns*)
6464 ns-aliases (if cljs?
6565 (ns-parser/aliases
Original file line number Diff line number Diff line change 55 [orchard.cljs.analysis :as cljs-ana]
66 [clojure.string :as str]
77 [refactor-nrepl.core :refer [prefix suffix]]
8- [refactor-nrepl.util :refer [invalid-fqn ?]]
8+ [refactor-nrepl.util :refer [self-referential ?]]
99 [refactor-nrepl.ns.slam.hound.regrow :as slamhound]))
1010
1111(defn- candidates [sym]
7171 (some->> sym
7272 symbol
7373 candidates
74- (remove invalid-fqn ?)
74+ (remove self-referential ?)
7575 collate-type-info
7676 pr-str)))
Original file line number Diff line number Diff line change 134134(defn reset
135135 " Reset the cache of classes"
136136 []
137- (alter-var-root #'available-classes (constantly (delay ( get-available-classes ) )))
138- (alter-var-root #'available-classes-by-last-segment (constantly (delay ( get-available-classes-by-last-segment ) ))))
137+ (alter-var-root #'available-classes (constantly (get-available-classes )))
138+ (alter-var-root #'available-classes-by-last-segment (constantly (get-available-classes-by-last-segment ))))
Original file line number Diff line number Diff line change 6363 (and (-> candidate str (.startsWith " refactor-nrepl" ))
6464 (not (-> candidate str (.contains " test" )))))
6565
66- (def invalid-fqn ?
66+ (defn self-referential ?
6767 " Does the argument represent namespace name (or a fully qualified name) that should not be analyzed?"
68- (some-fn inlined-dependency? refactor-nrepl?))
68+ [candidate]
69+ ((some-fn inlined-dependency? refactor-nrepl?)
70+ candidate))
71+
72+ (defn maybe-log-exception [^Throwable e]
73+ (when (System/getProperty " refactor-nrepl.internal.log-exceptions" )
74+ (.printStackTrace e)))
You can’t perform that action at this time.
0 commit comments