Skip to content
Browse files

refactor munge-forms to also provide munge-expr fn

  • Loading branch information...
1 parent bf8f3b0 commit 1c55c0176b22ca95830b651a7177a896c5991c05 @cemerick cemerick committed Feb 13, 2013
Showing with 30 additions and 17 deletions.
  1. +30 −17 src/cljx/core.clj
View
47 src/cljx/core.clj
@@ -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]

0 comments on commit 1c55c01

Please sign in to comment.
Something went wrong with that request. Please try again.