Skip to content

Commit

Permalink
Use parseedn
Browse files Browse the repository at this point in the history
  • Loading branch information
vemv committed Dec 26, 2020
1 parent a9092b2 commit d5f3b1a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions clj-refactor.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
;; Benedek Fazekas <[email protected]>
;; Version: 2.4.0
;; Keywords: convenience, clojure, cider
;; Package-Requires: ((emacs "24.4") (s "1.8.0") (seq "2.19") (yasnippet "0.6.1") (paredit "24") (multiple-cursors "1.2.2") (edn "1.1.2") (inflections "2.3") (hydra "0.13.2"))
;; Package-Requires: ((emacs "24.4") (s "1.8.0") (seq "2.19") (yasnippet "0.6.1") (paredit "24") (multiple-cursors "1.2.2") (parseedn "0.1") (inflections "2.3") (hydra "0.13.2"))

;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -42,7 +42,7 @@
(require 'multiple-cursors-core)
(require 'clojure-mode)
(require 'cider)
(require 'edn)
(require 'parseedn)
(require 'sgml-mode)
(require 'inflections)
(require 'hydra)
Expand Down Expand Up @@ -1906,7 +1906,7 @@ FEATURE is either :clj or :cljs."
cljr--ensure-op-supported
cljr--create-msg
(cljr--call-middleware-sync "namespace-aliases")
edn-read))
parseedn-read-str))

(defun cljr--get-aliases-from-middleware ()
(when-let (aliases (cljr--call-middleware-for-namespace-aliases))
Expand Down Expand Up @@ -2493,7 +2493,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-promote-function
(unless (cljr--empty-buffer-p)
(goto-char (point-min))
(while (not (cljr--end-of-buffer-p))
(push (edn-read) occurrences))))
(push (parseedn-read) occurrences))))
occurrences))

(defun cljr--find-symbol (symbol ns callback)
Expand Down Expand Up @@ -2547,7 +2547,7 @@ root."
(when (= cjr--occurrence-count cljr--num-syms)
(cljr--finalise-find-symbol-buffer cljr--num-syms)))
(when-let (occurrence-data (nrepl-dict-get occurrence-resp "occurrence"))
(let* ((occurrence (edn-read occurrence-data))
(let* ((occurrence (parseedn-read-str occurrence-data))
(occurrence-id (format "%s%s"
(cljr--get-valid-filename occurrence)
(gethash :line-beg occurrence))))
Expand Down Expand Up @@ -2686,15 +2686,15 @@ Also adds the alias prefix to all occurrences of public symbols in the namespace
"used-ns" ns
"file" filename))
(occurrences (thread-last (cljr--call-middleware-sync request "used-publics")
(edn-read))))
(parseedn-read-str))))
(cljr--replace-refer-all-with-alias ns occurrences alias))))

(defun cljr--maybe-nses-in-bad-state (response)
(let ((asts-in-bad-state (seq-filter
(lambda (it)
(not (stringp (car (last it)))))
(thread-first (nrepl-dict-get response "ast-statuses")
edn-read
parseedn-read-str
(seq-partition 2)))))
(when (not (= 0 (length asts-in-bad-state)))
(user-error (concat "Some namespaces are in a bad state: "
Expand Down Expand Up @@ -2873,7 +2873,7 @@ Date. -> Date
"session" (cider-current-session))
(cljr--call-middleware-sync
"candidates")))
(edn-read candidates)))
(parseedn-read-str candidates)))

(defun cljr--get-error-value (response)
"Gets the error value from the middleware response.
Expand Down Expand Up @@ -3082,7 +3082,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-add-stubs"
(format "%s/%s" alias? (cljr--symbol-suffix interface))
interface)
(format "%s/%s" (cider-current-ns) interface)))
(functions (edn-read (cljr--call-middleware-sync
(functions (parseedn-read-str (cljr--call-middleware-sync
(cljr--create-msg "stubs-for-interface"
"interface" interface)
"functions"))))
Expand Down Expand Up @@ -3223,7 +3223,7 @@ See: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-inline-symbol"
"name" symbol-name
"ignore-errors"
(when cljr-ignore-analyzer-errors "true")))
(response (edn-read (cljr--call-middleware-sync
(response (parseedn-read-str (cljr--call-middleware-sync
extract-definition-request "definition")))
(definition (gethash :definition response))
(occurrences (gethash :occurrences response)))
Expand Down
20 changes: 10 additions & 10 deletions features/step-definitions/clj-refactor-steps.el
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@

(Given "^I call the add-stubs function directly with mock data for java.util.List from the middleware"
(lambda ()
(cljr--insert-function-stubs (edn-read "(
(cljr--insert-function-stubs (parseedn-read-str "(
{:parameter-list \"[^int arg]\", :name \"remove\"}
{:parameter-list \"[^int arg0 ^Object arg1]\", :name \"add\"}
{:parameter-list \"[^java.util.function.UnaryOperator arg]\", :name \"replaceAll\"}
Expand Down Expand Up @@ -187,11 +187,11 @@

(Given "^I call the add-stubs function directly with mock data for clojure.reflect from the middleware"
(lambda ()
(cljr--insert-function-stubs (edn-read "({:parameter-list \"[this]\", :name \"typename\"})"))))
(cljr--insert-function-stubs (parseedn-read-str "({:parameter-list \"[this]\", :name \"typename\"})"))))

(Given "I call the cljr--inline-symbol function directly with mockdata to inline my-constant"
(lambda ()
(let ((response (edn-read "{:occurrences ({:match \"(println my-constant my-constant another-val)))\"
(let ((response (parseedn-read-str "{:occurrences ({:match \"(println my-constant my-constant another-val)))\"
:file \"core.clj\"
:name \"refactor-nrepl.test/my-constant\"
:col-end 26
Expand All @@ -217,7 +217,7 @@

(Given "I call the cljr--inline-symbol function directly with mockdata to inline another-val"
(lambda ()
(let ((response (edn-read "{:definition {:line-beg 4
(let ((response (parseedn-read-str "{:definition {:line-beg 4
:line-end 4
:col-beg 9
:col-end 21
Expand All @@ -237,7 +237,7 @@

(Given "I call the cljr--inline-symbol function directly with mockdata to inline some-val"
(lambda ()
(let ((response (edn-read "{:definition {:line-beg 5
(let ((response (parseedn-read-str "{:definition {:line-beg 5
:line-end 5
:col-beg 9
:col-end 17
Expand All @@ -251,7 +251,7 @@

(Given "I call the cljr--inline-symbol function directly with mockdata to inline my-inc"
(lambda ()
(let ((response (edn-read "{:definition {:definition \"(fn [n]\\n (+ 1 n))\"
(let ((response (parseedn-read-str "{:definition {:definition \"(fn [n]\\n (+ 1 n))\"
:line-beg 1
:line-end 2
:col-beg 1
Expand All @@ -273,11 +273,11 @@
:file \"core.clj\"
:match \"(map my-inc (range 10))\"})}")))
(cljr--inline-symbol (gethash :definition response)
(gethash :occurrences response)))))
(gethash :occurrences response)))))

(Given "I call the cljr--inline-symbol function directly with mockdata to inline trim-lower"
(lambda ()
(let ((response (edn-read "{:definition {:definition \"(comp str/lower-case str/trim)\"
(let ((response (parseedn-read-str "{:definition {:definition \"(comp str/lower-case str/trim)\"
:line-beg 1
:line-end 1
:col-beg 2
Expand Down Expand Up @@ -411,7 +411,7 @@
(Given "The cache of namespace aliases is populated"
(lambda ()
(defun cljr--call-middleware-for-namespace-aliases ()
(edn-read "{:clj {t (clojure.test)
(parseedn-read-str "{:clj {t (clojure.test)
set (clojure.set)
pprint (clojure.pprint)
util (refactor-nrepl.util clojure.tools.analyzer.jvm.utils)
Expand Down Expand Up @@ -460,7 +460,7 @@ pprint (cljs.pprint)}}"))))
(lambda (ns-name)
(cljr--replace-refer-all-with-alias
ns-name
(edn-read
(parseedn-read-str
"({:line-beg 5 :line-end 5 :col-beg 13 :col-end 30 :file\"one.clj\" :name \"foo\"} {:line-beg 8 :line-end 8 :col-beg 15 :col-end 28 :file \"one.clj\" :name \"star*\"})")
"two")))

Expand Down

0 comments on commit d5f3b1a

Please sign in to comment.