Skip to content

Commit 967538d

Browse files
committed
find-symbol-in-file: improve nil handling
Some nil results could be returned; it's better not to include them.
1 parent b1102f6 commit 967538d

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/refactor_nrepl/find/find_symbol.clj

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,13 @@
121121
:line-end end-line
122122
:col-beg column
123123
:col-end end-column})))))
124-
gather (fn [info]
125-
(merge info
126-
{:file (.getCanonicalPath file)
127-
:name fully-qualified-name
128-
:match (match file-content
129-
(:line-beg info)
130-
(:line-end info))}))]
131-
(map gather locs)))
124+
gather (fn [{:keys [line-beg line-end] :as info}]
125+
(some-> info
126+
(merge
127+
{:file (.getCanonicalPath file)
128+
:name fully-qualified-name
129+
:match (match file-content line-beg line-end)})))]
130+
(keep gather locs)))
132131

133132
(defn- find-global-symbol [file ns var-name ignore-errors]
134133
(let [namespace (or ns (core/ns-from-string (slurp file)))
@@ -220,12 +219,11 @@
220219
first
221220
:name)
222221
local-occurrences
223-
(map #(merge %
224-
{:name var-name
225-
:file (.getCanonicalPath (java.io.File. file))
226-
:match (match file-content
227-
(:line-beg %)
228-
(:line-end %))})
222+
(map (fn [{:keys [line-beg line-end] :as m}]
223+
(merge m
224+
{:name var-name
225+
:file (.getCanonicalPath (java.io.File. file))
226+
:match (match file-content line-beg line-end)}))
229227
(find-nodes var-name
230228
[top-level-form-ast]
231229
#(and (#{:local :binding} (:op %))

0 commit comments

Comments
 (0)