| 
57 | 57 |                    (comp :end-line :env)  | 
58 | 58 |                    (comp :column :env)  | 
59 | 59 |                    (comp :end-column :env)  | 
60 |  | -                   pred))))  | 
 | 60 | +                   pred))  | 
 | 61 | +        (map #(zipmap [:line-beg :line-end :col-beg :col-end] %))))  | 
61 | 62 |   ([name asts pred]  | 
62 | 63 |    (find-nodes (map #(postwalk % (partial dissoc-macro-nodes name)) asts) pred)))  | 
63 | 64 | 
 
  | 
 | 
111 | 112 |   (let [file-content (slurp file)  | 
112 | 113 |         locs (try (->> (ns-ast file-content)  | 
113 | 114 |                        (find-symbol-in-ast fully-qualified-name)  | 
114 |  | -                       (filter first))  | 
115 |  | -                  (catch Throwable th  | 
 | 115 | +                       (filter :line-beg))  | 
 | 116 | +                  (catch Exception e  | 
116 | 117 |                     (when-not ignore-errors  | 
117 |  | -                      (throw th))))  | 
 | 118 | +                      (throw e))))  | 
118 | 119 |         gather (fn [info]  | 
119 |  | -                 (conj info  | 
120 |  | -                       (.getCanonicalPath file)  | 
121 |  | -                       (match file-content  | 
122 |  | -                         (first info)  | 
123 |  | -                         (second info))))]  | 
124 |  | -    (when (seq locs) (map gather locs))))  | 
 | 120 | +                 (merge info  | 
 | 121 | +                        {:file (.getCanonicalPath file)  | 
 | 122 | +                         :name fully-qualified-name  | 
 | 123 | +                         :match (match file-content  | 
 | 124 | +                                  (:line-beg info)  | 
 | 125 | +                                  (:line-end  info))}))]  | 
 | 126 | +    (map gather locs)))  | 
125 | 127 | 
 
  | 
126 | 128 | (defn- find-global-symbol [file ns var-name clj-dir ignore-errors]  | 
127 | 129 |   (let [dir (or clj-dir ".")  | 
 | 
158 | 160 |                                 (filter (partial util/node-at-loc? line column))  | 
159 | 161 |                                 first  | 
160 | 162 |                                 :name)]  | 
161 |  | -        (map #(conj (vec (take 4 %))  | 
162 |  | -                    var-name  | 
163 |  | -                    (.getCanonicalPath (java.io.File. file))  | 
164 |  | -                    (match file-content  | 
165 |  | -                      (first %)  | 
166 |  | -                      (second %)))  | 
 | 163 | +        (map #(merge %  | 
 | 164 | +                     {:name var-name  | 
 | 165 | +                      :file (.getCanonicalPath (java.io.File. file))  | 
 | 166 | +                      :match (match file-content  | 
 | 167 | +                               (:line-beg %)  | 
 | 168 | +                               (:line-end %))})  | 
167 | 169 |              (find-nodes var-name  | 
168 | 170 |                          [top-level-form-ast]  | 
169 | 171 |                          #(and (#{:local :binding} (:op %))  | 
170 | 172 |                                (= local-var-name (-> % :name))  | 
171 | 173 |                                (:local %))))))))  | 
172 | 174 | 
 
  | 
173 |  | -(defn to-find-symbol-result  | 
 | 175 | +(defn- to-find-symbol-result  | 
174 | 176 |   [{:keys [line-beg line-end col-beg col-end name file match]}]  | 
175 | 177 |   [line-beg line-end col-beg col-end name file match])  | 
176 | 178 | 
 
  | 
177 | 179 | (defn find-symbol [{:keys [file ns name dir line column ignore-errors]}]  | 
178 | 180 |   (util/throw-unless-clj-file file)  | 
179 |  | -  (or  | 
180 |  | -   ;; find-macro is first because find-global-symbol returns garb for macros  | 
181 |  | -   (some->> name find-macro (map to-find-symbol-result))  | 
182 |  | -   (not-empty (find-local-symbol file name line column))  | 
183 |  | -   (find-global-symbol file ns name dir (and ignore-errors  | 
184 |  | -                                             (or (not (coll? ignore-errors))  | 
185 |  | -                                                 (not-empty ignore-errors))))))  | 
 | 181 | +  (map to-find-symbol-result  | 
 | 182 | +       (or  | 
 | 183 | +        ;; find-macro is first because find-global-symbol returns garb for macros  | 
 | 184 | +        (some->> name find-macro)  | 
 | 185 | +        (and (seq file) (not-empty (find-local-symbol file name line column)))  | 
 | 186 | +        (find-global-symbol file ns name dir (and ignore-errors  | 
 | 187 | +                                                  (or (not (coll? ignore-errors))  | 
 | 188 | +                                                      (not-empty ignore-errors)))))))  | 
186 | 189 | 
 
  | 
187 | 190 | (defn create-result-alist  | 
188 | 191 |   [line-beg line-end col-beg col-end name file match]  | 
 | 
195 | 198 |         :match match))  | 
196 | 199 | 
 
  | 
197 | 200 | (defn find-debug-fns [{:keys [ns-string debug-fns]}]  | 
198 |  | -  (let [res  (-> ns-string ns-ast (find-invokes debug-fns))]  | 
 | 201 | +  (let [res  (-> ns-string ns-ast (find-invokes debug-fns))  | 
 | 202 | +        res (map to-find-symbol-result res)]  | 
199 | 203 |     (when (seq res)  | 
200 | 204 |       res)))  | 
0 commit comments