Skip to content

Commit 519d557

Browse files
author
Yannick Scherer
committed
remove 'fast-zip' dependency. (see #26)
1 parent d403d0e commit 519d557

21 files changed

+71
-80
lines changed

project.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
:repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"}
77
:dependencies [[org.clojure/clojure "1.6.0"]
88
[org.clojure/tools.reader "0.8.13"]
9-
[fast-zip "0.5.2"]
109
[potemkin "0.3.11"]]
1110
:profiles {:dev {:dependencies [[midje "1.6.3" :exclusions [joda-time]]
1211
[joda-time "2.7"]]

src/rewrite_clj/zip.clj

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
[rewrite-clj
1717
[parser :as p]
1818
[node :as node]]
19-
[fast-zip.core :as z]
19+
[clojure.zip :as z]
2020
[potemkin :refer [import-vars]]))
2121

2222
;; ## API Facade
2323

2424
(import-vars
25-
[fast-zip.core
25+
[clojure.zip
2626
node root]
2727

2828
[rewrite-clj.zip.base
@@ -92,17 +92,17 @@
9292
:arglists `(quote ~arglists)})]
9393
`(def ~sym ~base)))
9494

95-
(defbase right* fast-zip.core/right)
96-
(defbase left* fast-zip.core/left)
97-
(defbase up* fast-zip.core/up)
98-
(defbase down* fast-zip.core/down)
99-
(defbase next* fast-zip.core/next)
100-
(defbase prev* fast-zip.core/prev)
101-
(defbase rightmost* fast-zip.core/rightmost)
102-
(defbase leftmost* fast-zip.core/leftmost)
103-
(defbase replace* fast-zip.core/replace)
104-
(defbase edit* fast-zip.core/edit)
105-
(defbase remove* fast-zip.core/remove)
95+
(defbase right* clojure.zip/right)
96+
(defbase left* clojure.zip/left)
97+
(defbase up* clojure.zip/up)
98+
(defbase down* clojure.zip/down)
99+
(defbase next* clojure.zip/next)
100+
(defbase prev* clojure.zip/prev)
101+
(defbase rightmost* clojure.zip/rightmost)
102+
(defbase leftmost* clojure.zip/leftmost)
103+
(defbase replace* clojure.zip/replace)
104+
(defbase edit* clojure.zip/edit)
105+
(defbase remove* clojure.zip/remove)
106106

107107
;; ## DEPRECATED
108108

src/rewrite_clj/zip/base.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[node :as node]
55
[parser :as p]]
66
[rewrite-clj.zip.whitespace :as ws]
7-
[fast-zip.core :as z]))
7+
[clojure.zip :as z]))
88

99
;; ## Zipper
1010

src/rewrite_clj/zip/edit.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[utils :as u]
88
[whitespace :as ws]]
99
[rewrite-clj.node :as node]
10-
[fast-zip.core :as z]))
10+
[clojure.zip :as z]))
1111

1212
;; ## In-Place Modification
1313

src/rewrite_clj/zip/find.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[base :as base]
55
[move :as m]]
66
[rewrite-clj.node :as node]
7-
[fast-zip.core :as z]))
7+
[clojure.zip :as z]))
88

99
;; ## Helpers
1010

src/rewrite_clj/zip/insert.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[base :as base]
44
[whitespace :as ws]]
55
[rewrite-clj.node :as node]
6-
[fast-zip.core :as z]))
6+
[clojure.zip :as z]))
77

88
(def ^:private space
99
(node/spaces 1))

src/rewrite_clj/zip/move.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(ns ^:no-doc rewrite-clj.zip.move
22
(:refer-clojure :exclude [next])
33
(:require [rewrite-clj.zip.whitespace :as ws]
4-
[fast-zip.core :as z]))
4+
[clojure.zip :as z]))
55

66
(defn right
77
"Move right to next non-whitespace/non-comment location."

src/rewrite_clj/zip/remove.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[move :as m]
55
[utils :as u]
66
[whitespace :as ws]]
7-
[fast-zip.core :as z]))
7+
[clojure.zip :as z]))
88

99
(defn- remove-trailing-space
1010
"Remove all whitespace following a given node."

src/rewrite_clj/zip/seq.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[find :as f]
77
[insert :as i]
88
[move :as m]]
9-
[fast-zip.core :as z]))
9+
[clojure.zip :as z]))
1010

1111
;; ## Predicates
1212

src/rewrite_clj/zip/subedit.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns ^:no-doc rewrite-clj.zip.subedit
22
(:require [rewrite-clj.zip.base :as base]
3-
[fast-zip.core :as z]))
3+
[clojure.zip :as z]))
44

55
;; ## Edit Scope
66

src/rewrite_clj/zip/utils.clj

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,26 @@
11
(ns ^:no-doc rewrite-clj.zip.utils
2-
(:require [fast-zip.core :as z])
3-
(:import [fast_zip.core ZipperPath ZipperLocation]))
2+
(:require [clojure.zip :as z]))
3+
4+
;; ## Remove
5+
6+
(defn- update-in-path
7+
[[node path :as loc] k f]
8+
(let [v (get path k)]
9+
(if (seq v)
10+
(with-meta
11+
[node (assoc path k (f v) :changed? true)]
12+
(meta loc))
13+
loc)))
414

515
(defn remove-right
616
"Remove right sibling of the current node (if there is one)."
7-
[^ZipperLocation zloc]
8-
(let [path ^ZipperPath (.path zloc)]
9-
(if (zero? (count (.r path)))
10-
zloc
11-
(ZipperLocation.
12-
(.branch? zloc)
13-
(.children zloc)
14-
(.make-node zloc)
15-
(.node zloc)
16-
(assoc path :r (clojure.core/next (.r path)) :changed? true)))))
17+
[loc]
18+
(update-in-path loc :r next))
1719

1820
(defn remove-left
1921
"Remove left sibling of the current node (if there is one)."
20-
[^ZipperLocation zloc]
21-
(let [path ^ZipperPath (.path zloc)]
22-
(if (zero? (count (.l path)))
23-
zloc
24-
(ZipperLocation.
25-
(.branch? zloc)
26-
(.children zloc)
27-
(.make-node zloc)
28-
(.node zloc)
29-
(assoc path :l (pop (.l path)) :changed? true)))))
30-
31-
(defn remove-and-move-left
32-
"Remove current node and move left. If current node is at the leftmost
33-
location, returns `nil`."
34-
[^ZipperLocation zloc]
35-
(let [path ^ZipperPath (.path zloc)]
36-
(when (pos? (count (.l path)))
37-
(ZipperLocation.
38-
(.branch? zloc)
39-
(.children zloc)
40-
(.make-node zloc)
41-
(peek (.l path))
42-
(assoc path :l (pop (.l path)) :changed? true)))))
43-
44-
(defn remove-and-move-right
45-
"Remove current node and move right. If current node is at the rightmost
46-
location, returns `nil`."
47-
[^ZipperLocation zloc]
48-
(let [path ^ZipperPath (.path zloc)]
49-
(when (pos? (count (.r path)))
50-
(ZipperLocation.
51-
(.branch? zloc)
52-
(.children zloc)
53-
(.make-node zloc)
54-
(first (.r path))
55-
(assoc path :r (clojure.core/next (.r path)) :changed? true)))))
22+
[loc]
23+
(update-in-path loc :l pop))
5624

5725
(defn remove-right-while
5826
"Remove elements to the right of the current zipper location as long as
@@ -75,3 +43,27 @@
7543
(recur (remove-left zloc))
7644
zloc)
7745
zloc)))
46+
47+
;; ## Remove and Move
48+
49+
(defn remove-and-move-left
50+
"Remove current node and move left. If current node is at the leftmost
51+
location, returns `nil`."
52+
[[_ {:keys [l] :as path} :as loc]]
53+
(if (seq l)
54+
(with-meta
55+
[(peek l) (-> path
56+
(update-in [:l] pop)
57+
(assoc :changed? true))]
58+
(meta loc))))
59+
60+
(defn remove-and-move-right
61+
"Remove current node and move right. If current node is at the rightmost
62+
location, returns `nil`."
63+
[[_ {:keys [r] :as path} :as loc]]
64+
(if (seq r)
65+
(with-meta
66+
[(first r) (-> path
67+
(update-in [:r] next)
68+
(assoc :changed? true))]
69+
(meta loc))))

src/rewrite_clj/zip/walk.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(ns ^:no-doc rewrite-clj.zip.walk
2-
(:require [fast-zip.core :as z]
2+
(:require [clojure.zip :as z]
33
[rewrite-clj.zip
44
[subedit :refer [subedit-node]]
55
[move :as m]]))

src/rewrite_clj/zip/whitespace.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns ^:no-doc rewrite-clj.zip.whitespace
22
(:require [rewrite-clj.node :as node]
3-
[fast-zip.core :as z]))
3+
[clojure.zip :as z]))
44

55
;; ## Predicates
66

test/rewrite_clj/regression_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[rewrite-clj
44
[node :as node]
55
[zip :as z]]
6-
[fast-zip.core :as fz]))
6+
[clojure.zip :as fz]))
77

88
;; ## Regression Tests for 0.3.x -> 0.4.x
99

test/rewrite_clj/zip/base_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(:require [midje.sweet :refer :all]
33
[rewrite-clj.node :as node]
44
[rewrite-clj.zip.base :as base]
5-
[fast-zip.core :as z]))
5+
[clojure.zip :as z]))
66

77
(let [n (node/forms-node
88
[(node/spaces 3)

test/rewrite_clj/zip/find_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns rewrite-clj.zip.find-test
22
(:require [midje.sweet :refer :all]
3-
[fast-zip.core :as z]
3+
[clojure.zip :as z]
44
[rewrite-clj.zip
55
[base :as base]
66
[find :as f]]))

test/rewrite_clj/zip/insert_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[base :as base]
55
[move :as m]
66
[insert :refer :all]]
7-
[fast-zip.core :as z]))
7+
[clojure.zip :as z]))
88

99
(tabular
1010
(fact "about whitespace-aware insertion."

test/rewrite_clj/zip/remove_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[base :as base]
55
[move :as m]
66
[remove :as r]]
7-
[fast-zip.core :as z]))
7+
[clojure.zip :as z]))
88

99
(tabular
1010
(fact "about whitespace-aware removal."

test/rewrite_clj/zip/subedit_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[base :as base]
55
[move :as m]
66
[subedit :refer :all]]
7-
[fast-zip.core :as z]))
7+
[clojure.zip :as z]))
88

99
(let [root (base/of-string "[1 #{2 [3 4] 5} 6]")]
1010
(fact "about modifying subtrees."

test/rewrite_clj/zip/utils_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns rewrite-clj.zip.utils-test
22
(:require [midje.sweet :refer :all]
3-
[fast-zip.core :as z]
3+
[clojure.zip :as z]
44
[rewrite-clj.zip.utils :refer :all]))
55

66
(let [loc (z/down (z/vector-zip '[a b c d]))]

test/rewrite_clj/zip/whitespace_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns rewrite-clj.zip.whitespace-test
22
(:require [midje.sweet :refer :all]
3-
[fast-zip.core :as z]
3+
[clojure.zip :as z]
44
[rewrite-clj.node :as node]
55
[rewrite-clj.zip.whitespace :refer :all]))
66

0 commit comments

Comments
 (0)