-
Notifications
You must be signed in to change notification settings - Fork 65
/
source_info.clj
23 lines (20 loc) · 1.16 KB
/
source_info.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns eastwood.copieddeps.dep1.clojure.tools.analyzer.passes.source-info
(:require [eastwood.copieddeps.dep1.clojure.tools.analyzer.utils :refer [-source-info merge']]
[eastwood.copieddeps.dep1.clojure.tools.analyzer.ast :refer [update-children]]))
(defn -merge-source-info [source-info]
(fn [ast]
(update-in ast [:env] merge' source-info)))
(defn source-info
"Adds (when avaliable) :line, :column, :end-line, :end-column and :file info to the AST :env"
{:pass-info {:walk :pre :depends #{}}}
[ast]
(let [source-info (-source-info (:form ast) (:env ast))
merge-source-info (-merge-source-info source-info)]
(update-children (merge-source-info ast) merge-source-info)))