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 74
74
(defn- build-ast
75
75
[ns aliases]
76
76
(when (and (ns-on-cp? ns )
77
- (not (util/invalid-fqn ? ns )))
77
+ (not (util/self-referential ? ns )))
78
78
; ; Use `locking`, because AST analysis can perform arbitrary evaluation.
79
79
; ; Parallel analysis is not safe, especially as it can perform `require` calls.
80
80
(locking core/require-lock
94
94
(when-let [new-ast-or-err (try
95
95
(build-ast ns aliases)
96
96
(catch Throwable th
97
- (when (System/getProperty " refactor-nrepl.internal.log-exceptions" )
98
- (-> th .printStackTrace))
97
+ (util/maybe-log-exception th)
99
98
th))]
100
99
(update-ast-cache file-content ns new-ast-or-err))))))
101
100
Original file line number Diff line number Diff line change 6
6
[orchard.java.classpath :as cp]
7
7
[orchard.misc :as misc]
8
8
[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]]
10
10
[refactor-nrepl.s-expressions :as sexp]
11
11
[refactor-nrepl.config :as config])
12
12
(:import [java.io File FileReader PushbackReader StringReader]))
325
325
(require n))
326
326
(find-ns n)
327
327
(catch Throwable e
328
- (-> e .printStackTrace )
328
+ (util/maybe-log-exception e )
329
329
(when-not ignore-error?
330
330
(throw e)))))
331
331
Original file line number Diff line number Diff line change 85
85
(mapcat #(try
86
86
(get-macro-definitions-in-file-with-caching %)
87
87
(catch Exception e
88
- (when (System/getProperty " refactor-nrepl.internal.log-exceptions" )
89
- (-> e .printStackTrace))
88
+ (util/maybe-log-exception e)
90
89
(when-not ignore-errors?
91
90
(throw e)))))))
92
91
Original file line number Diff line number Diff line change 2
2
(:require [clojure
3
3
[set :as set]
4
4
[string :as str]]
5
- [refactor-nrepl.util :refer [invalid-fqn ?]]
5
+ [refactor-nrepl.util :as util : refer [self-referential ?]]
6
6
[clojure.tools.analyzer.ast :refer [nodes postwalk]]
7
7
[clojure.tools.namespace.parse :as parse]
8
8
[refactor-nrepl
109
109
(find-symbol-in-ast fully-qualified-name)
110
110
(filter :line-beg ))
111
111
(catch Exception e
112
- (when (System/getProperty " refactor-nrepl.internal.log-exceptions" )
113
- (-> e .printStackTrace))
112
+ (util/maybe-log-exception e)
114
113
(when-not ignore-errors
115
114
(throw e))))
116
115
locs (into
140
139
(->> (core/dirs-on-classpath )
141
140
(mapcat (partial core/find-in-dir (every-pred (some-fn core/clj-file? core/cljc-file?)
142
141
(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 ))))))
149
152
(mapcat (partial find-symbol-in-file fully-qualified-name ignore-errors referred-syms)))))
150
153
151
154
(defn- get &read-enclosing-sexps
Original file line number Diff line number Diff line change 59
59
cljs? (= dialect :cljs )
60
60
file-ns (or (when-let [s (-> parsed-ns :ns symbol)]
61
61
(when-not cljs?
62
- (core/safe-find-ns s true )))
62
+ (core/safe-find-ns s :ignore-errors )))
63
63
*ns*)
64
64
ns-aliases (if cljs?
65
65
(ns-parser/aliases
Original file line number Diff line number Diff line change 5
5
[orchard.cljs.analysis :as cljs-ana]
6
6
[clojure.string :as str]
7
7
[refactor-nrepl.core :refer [prefix suffix]]
8
- [refactor-nrepl.util :refer [invalid-fqn ?]]
8
+ [refactor-nrepl.util :refer [self-referential ?]]
9
9
[refactor-nrepl.ns.slam.hound.regrow :as slamhound]))
10
10
11
11
(defn- candidates [sym]
71
71
(some->> sym
72
72
symbol
73
73
candidates
74
- (remove invalid-fqn ?)
74
+ (remove self-referential ?)
75
75
collate-type-info
76
76
pr-str)))
Original file line number Diff line number Diff line change 134
134
(defn reset
135
135
" Reset the cache of classes"
136
136
[]
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 63
63
(and (-> candidate str (.startsWith " refactor-nrepl" ))
64
64
(not (-> candidate str (.contains " test" )))))
65
65
66
- (def invalid-fqn ?
66
+ (defn self-referential ?
67
67
" 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