Skip to content

Commit

Permalink
Upgrade to new rewrite-clj, handle deprecated edn*, Issue #247
Browse files Browse the repository at this point in the history
  • Loading branch information
kkinnear committed Jul 26, 2022
1 parent cce5184 commit 38825fb
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
;; To use zprint with babashka, include the following dependency:
;; org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
;; :sha "0dec1f88cbde74a0470b454396f09a03adb4ae39"}
rewrite-clj/rewrite-clj {:mvn/version "1.0.767-alpha"}},
rewrite-clj/rewrite-clj {:mvn/version "1.1.45"}},
:paths ["src" "test" "cljs-test-runner-out/gen"]}
8 changes: 4 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject zprint "1.2.4-alpha1"
(defproject zprint "1.2.4"
:description "Pretty print zippers and s-expressions"
:url "https://github.com/kkinnear/zprint"
:license {:name "MIT License",
Expand All @@ -11,10 +11,10 @@
[olical/cljs-test-runner "3.7.0"]
[pjstadig/humane-test-output "0.10.0"]
[org.clojure/core.match "0.3.0-alpha5"]
[com.bhauman/rebel-readline "0.1.4"]
#_[com.bhauman/rebel-readline "0.1.4"]
[hiccup "1.0.5"]
#_[clojure-future-spec "1.9.0-alpha17"]]},
:dev {:dependencies [[com.bhauman/rebel-readline "0.1.4"]
:dev {:dependencies [#_[com.bhauman/rebel-readline "0.1.4"]
[hiccup "1.0.5"]

]}
Expand Down Expand Up @@ -51,4 +51,4 @@
#_[org.clojure/clojure "1.9.0"]
#_[org.clojure/clojure "1.8.0"]
[org.babashka/sci "0.3.4"]
[rewrite-clj/rewrite-clj "1.0.767-alpha"]])
[rewrite-clj/rewrite-clj "1.1.45"]])
8 changes: 4 additions & 4 deletions src/zprint/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
reassemble-range wrap-comment-api drop-lines]]
[rewrite-clj.parser :as p]
[rewrite-clj.zip :as z
:refer [edn* string]]
:refer [of-node* string]]
#_[clojure.spec.alpha :as s])
#?@(:clj ((:import #?(:bb []
:clj (java.net URL URLConnection))
Expand Down Expand Up @@ -324,7 +324,7 @@
; a tab is found.
x (clojure.string/join "\n" lines)
n (p/parse-string (clojure.string/trim x))]
(when n [(edn* n) line-ending]))
(when n [(of-node* n) line-ending]))
(when (zipper? x) [x nil])))

;;
Expand Down Expand Up @@ -766,7 +766,7 @@
{}
zprint-str-internal
":parse-string-all? call"
(edn* (p/parse-string-all coll)))
(of-node* (p/parse-string-all coll)))
; Note that we don't use error-vec, because it should never
; have anything in it. Any errors should have been thrown
; already.
Expand Down Expand Up @@ -1675,7 +1675,7 @@
"ends-with-nl?" ends-with-nl?
"range-lines:" range-lines
"filestring:" filestring))
forms (edn* (p/parse-string-all filestring))
forms (of-node* (p/parse-string-all filestring))
pmf-options {:process-bang-zprint? true}
pmf-options (if (:interpose (:parse full-options))
(assoc pmf-options :trim-comments? true)
Expand Down
4 changes: 2 additions & 2 deletions src/zprint/rewrite.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[zprint.zutil :as zu :refer [zreplace]]
[rewrite-clj.parser :as p]
[rewrite-clj.node :as n]
[rewrite-clj.zip :as z :refer [string tag sexpr edn*]]))
[rewrite-clj.zip :as z :refer [string tag sexpr of-node*]]))

;;
;; No prewalk in rewrite-cljs, so we'll do it ourselves here
Expand All @@ -30,7 +30,7 @@
; Make a zipper whose root is zloc
(some-> zloc
z/node
edn*)))))
of-node*)))))


;;
Expand Down
4 changes: 2 additions & 2 deletions src/zprint/zprint.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
[zprint.optionfn :refer [rodfn]]
[rewrite-clj.parser :as p]
[rewrite-clj.zip :as z
:refer [edn* tag right* down*]]
:refer [of-node* tag right* down*]]
#_[taoensso.tufte :as tufte :refer (p defnp profiled profile)]))

#_(tufte/add-basic-println-handler! {})
Expand Down Expand Up @@ -147,7 +147,7 @@
sexpr
(try
(let [n (p/parse-string (clojure.string/trim new-s))
new-zloc (edn* n)
new-zloc (of-node* n)
sexpr (zsexpr new-zloc)]
sexpr)
(catch #?(:clj Exception
Expand Down
16 changes: 8 additions & 8 deletions src/zprint/zutil.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[rewrite-clj.node :as n]
[rewrite-clj.zip :as z
:refer [down* up* right* left* next* prev* replace*
insert-right* edn* sexpr string tag skip
insert-right* of-node* sexpr string tag skip
whitespace-or-comment? length rightmost?
leftmost?]]))

Expand Down Expand Up @@ -197,7 +197,7 @@
(when (not (nil? nloc))
(if (zthing? nloc) i (recur (zrightnws nloc) (inc i))))))

(defn znl [] "Return a zloc which is a newline." (edn* (p/parse-string "\n")))
(defn znl [] "Return a zloc which is a newline." (of-node* (p/parse-string "\n")))

(defn multi-nl
"Return a sequence of zloc newlines."
Expand Down Expand Up @@ -602,7 +602,7 @@
(defn zdotdotdot
"Return a zloc that will turn into a string of three dots."
[]
(edn* (p/parse-string "...")))
(of-node* (p/parse-string "...")))

(defn zconstant?
"Returns true if this is a keyword, string, or number, in other words,
Expand Down Expand Up @@ -662,12 +662,12 @@
#_(println "spec-str:" spec-str)
(if-let [doc-zloc (find-docstring zloc)]
(let [new-doc-zloc (replace* doc-zloc
(z/node (edn* (p/parse-string
(z/node (of-node* (p/parse-string
(str "\""
(str (sexpr doc-zloc))
spec-str
"\"")))))]
(edn* (z/root new-doc-zloc)))
(of-node* (z/root new-doc-zloc)))
zloc))

(defn zloc-to-keyword
Expand Down Expand Up @@ -733,13 +733,13 @@
(recur ns
(next pair-seq)
(conj out
(cons (edn* (n/token-node (strip-ns (z/sexpr
(cons (of-node* (n/token-node (strip-ns (z/sexpr
k))))
rest-of-pair))))
(recur current-ns
(next pair-seq)
(conj out
(cons (edn* (n/token-node (strip-ns (z/sexpr
(cons (of-node* (n/token-node (strip-ns (z/sexpr
k))))
rest-of-pair))))
(when (= (count pair) 1)
Expand Down Expand Up @@ -774,7 +774,7 @@
(next pair-seq)
(conj out
; put ns with k
(cons (edn* (n/token-node
(cons (of-node* (n/token-node
(symbol
; If k is a zkeyword? then it
; is a :token, and will not
Expand Down

0 comments on commit 38825fb

Please sign in to comment.