Skip to content

Commit

Permalink
refactor munge-forms to also provide munge-expr fn
Browse files Browse the repository at this point in the history
  • Loading branch information
cemerick committed Feb 14, 2013
1 parent bf8f3b0 commit 1c55c01
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions src/cljx/core.clj
Expand Up @@ -36,24 +36,37 @@ Returns a sequence of File objects, in breadth-first sort order."
[f form]
(walk (partial postwalk f) f form))

(defn- remove-exclusions
[{:keys [nested-exclusions]} munged-exprs]
(if-not nested-exclusions
(remove #(= % :cljx.core/exclude) munged-exprs)
(postwalk
#(cond
(instance? clojure.lang.IMapEntry %) %
(seq? %) (with-meta
(apply list (remove (partial = :cljx.core/exclude) %))
(meta %))
(coll? %) (into (empty %) (remove (partial = :cljx.core/exclude) %))
:else %)
munged-exprs)))

(defn munge-expr
[expr {:keys [rules nested-exclusions] :as options}]
(->> (kibit.check/check-expr expr
:rules rules
:guard identity
:resolution :toplevel)
(map #(or (:alt %) (:expr %)))
(remove-exclusions options)))

(defn munge-forms
[reader {:keys [rules nested-exclusions]}]
(let [munged (map #(or (:alt %) (:expr %))
(kibit.check/check-reader reader
:rules rules
:guard identity
:resolution :toplevel))]
(if-not nested-exclusions
(remove #(= % :cljx.core/exclude) munged)
(postwalk
#(cond
(instance? clojure.lang.IMapEntry %) %
(seq? %) (with-meta
(apply list (remove (partial = :cljx.core/exclude) %))
(meta %))
(coll? %) (into (empty %) (remove (partial = :cljx.core/exclude) %))
:else %)
munged))))
[reader {:keys [rules nested-exclusions] :as options}]
(->> (kibit.check/check-reader reader
:rules rules
:guard identity
:resolution :toplevel)
(map #(or (:alt %) (:expr %)))
(remove-exclusions options)))

(defn- write-on-correct-lines
[line-number form]
Expand Down

0 comments on commit 1c55c01

Please sign in to comment.