Skip to content

Commit

Permalink
rm unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
erdos committed Nov 3, 2023
1 parent 117bced commit 73c8f5f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 43 deletions.
29 changes: 11 additions & 18 deletions src/stencil/merger.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,28 @@
(defn- ->action-inside-parser [chars-and-tokens-to-append]
(let [expected-close-tag-chars (volatile! (seq close-tag))
buffer-nonclose-chars-only (new java.util.ArrayList)
buffer-all-chars (new java.util.ArrayList)
buffer-tokens-only (new java.util.ArrayList)
buffer-all-read (new java.util.ArrayList)]
(fn self
([]
(when (or (seq buffer-all-chars) (seq buffer-nonclose-chars-only) (seq buffer-tokens-only))
(when (seq buffer-all-read)
(assert false "Not-empty buffer!"))
) ;; TODO: throw exception if any of the buffers is not empty.
([token]
(.add buffer-all-read token)
(if (= token (first @expected-close-tag-chars))
(if (= 1 (count @expected-close-tag-chars))
(when-not (vswap! expected-close-tag-chars next)
;; we have read the whole close token
(let [action (map-action-token {:action (apply str buffer-nonclose-chars-only)})]
(if (:action action)
(->action-parser (concat [action] (remove char? chars-and-tokens-to-append) (vec buffer-tokens-only)))
(->action-parser (concat (vec chars-and-tokens-to-append) (vec buffer-all-read)))))
;; we have read one char of the close
(do (vswap! expected-close-tag-chars next)
(.add buffer-all-chars token)
self))
(if (char? token)
(do (.add buffer-all-chars token)
(doto buffer-nonclose-chars-only
(.clear) (.addAll buffer-all-chars))
(vreset! expected-close-tag-chars (seq close-tag))
self)
(do (.add buffer-tokens-only token)
self)))))))
(->action-parser (concat [action]
(remove char? chars-and-tokens-to-append)
(remove char? buffer-all-read)))
(->action-parser (concat (vec chars-and-tokens-to-append) (vec buffer-all-read))))))
(when (char? token)
(doto buffer-nonclose-chars-only
(.clear) (.addAll (filter char? buffer-all-read)))
(vreset! expected-close-tag-chars (seq close-tag))
self))))))

;; returns either a collection of elements or nil
(defn ->action-parser [prepend]
Expand Down
5 changes: 0 additions & 5 deletions src/stencil/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
(defn assoc-if-val [m k v]
(if (some? v) (assoc m k v) m))

(defn suffixes [xs] (take-while seq (iterate next xs)))
(defn prefixes [xs] (take-while seq (iterate butlast xs)))

(defmacro fail [msg obj]
(assert (string? msg))
(assert (map? obj))
Expand All @@ -66,8 +63,6 @@
(number? x) (int x)
:else (fail "Unexpected type of input" {:type (:type x) :input x})))

(defn subs-last [^String s ^long n] (.substring s (- (.length s) n)))

(defn parsing-exception [expression message]
(ParsingException/fromMessage (str expression) (str message)))

Expand Down
20 changes: 0 additions & 20 deletions test/stencil/util_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@
(testing "Difference clojure core"
(is (not (zip/branch? (xml-zip 42))))))))

(deftest test-suffixes
(is (= [] (suffixes nil)))
(is (= [] (suffixes [])))
(is (= [[1]] (suffixes [1])))
(is (= [[1 2 3] [2 3] [3]] (suffixes [1 2 3]))))

(deftest test-prefixes
(is (= [] (prefixes nil)))
(is (= [] (prefixes [])))
(is (= [[1]] (prefixes [1])))
(is (= [[1 2 3] [1 2] [1]] (prefixes [1 2 3]))))

(deftest test-->int
(is (= nil (->int nil)))
(is (= 23 (->int 23)))
Expand Down Expand Up @@ -97,14 +85,6 @@
(deftest fail-test
(is (thrown? clojure.lang.ExceptionInfo (fail "test error" {}))))

(deftest prefixes-test
(is (= [] (prefixes []) (prefixes nil)))
(is (= [[1 2 3] [1 2] [1]] (prefixes [1 2 3]))))

(deftest suffixes-test
(is (= [] (suffixes []) (suffixes nil)))
(is (= [[1 2 3] [2 3] [3]] (suffixes [1 2 3]))))

(deftest whitespace?-test
(is (= true (whitespace? \space)))
(is (= true (whitespace? \tab)))
Expand Down

0 comments on commit 73c8f5f

Please sign in to comment.