branch: elpa/cider
commit a569a5ffd9959b3e7a3ada57884b5c00530cbcb3
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    [Fix #3788] Remove cider-info-form eval fallback
    
    The `info` and `lookup` nREPL ops have been available for years now,
    making the eval-based fallback in `cider-var-info` unnecessary.
---
 CHANGELOG.md               |  1 +
 lisp/cider-client.el       | 31 +------------------------------
 test/cider-client-tests.el | 18 ++----------------
 3 files changed, 4 insertions(+), 46 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 62311f44e6..99740b40f6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@
 - [#3209](https://github.com/clojure-emacs/cider/issues/3209): Fix 
`cider-format` dropping non-map cljfmt options (e.g. 
`remove-consecutive-blank-lines?`).
 ### Changes
 
+- [#3788](https://github.com/clojure-emacs/cider/issues/3788): Remove the 
`cider-info-form` eval fallback for `cider-var-info`. The `info` and `lookup` 
nREPL ops are now required.
 - Bump the injected nREPL version to 1.6.
 - Convert modern tuple-format indent specs (e.g. `[[:block 1] [:inner 0]]`) to 
legacy format for compatibility with older clojure-mode versions.
 - Rename `cider-eval-spinner-type`, `cider-show-eval-spinner`, and 
`cider-eval-spinner-delay` to `cider-spinner-type`, `cider-show-spinner`, and 
`cider-spinner-delay`.  The old names are kept as obsolete aliases.
diff --git a/lisp/cider-client.el b/lisp/cider-client.el
index 491c191961..9503ea633c 100644
--- a/lisp/cider-client.el
+++ b/lisp/cider-client.el
@@ -524,34 +524,6 @@ contain a `candidates' key, it is returned as is."
           info)
       var-info)))
 
-;; FIXME: Now that nREPL supports a lookup op natively, we should
-;; remove this eval-based hack at some point.
-(defconst cider-info-form "
-(do
-  (require 'clojure.java.io)
-  (require 'clojure.walk)
-
-  (if-let [var (resolve '%s)]
-    (let [info (meta var)]
-      (-> info
-          (update :ns str)
-          (update :name str)
-          (update :file (comp str clojure.java.io/resource))
-          (cond-> (:macro info) (update :macro str))
-          (cond-> (:special-form info) (update :special-form str))
-          (cond-> (:protocol info) (update :protocol str))
-          (cond-> (:arglists info) (update :arglists str))
-          (assoc :arglists-str (str (:arglists info)))
-          (clojure.walk/stringify-keys)))))
-")
-
-(defun cider-fallback-eval:info (var)
-  "Obtain VAR metadata via a regular eval.
-Used only when the info nREPL middleware is not available."
-  (let* ((response (cider-sync-tooling-eval (format cider-info-form var)))
-         (var-info (nrepl-dict-from-hash (parseedn-read-str (nrepl-dict-get 
response "value")))))
-    var-info))
-
 (defun cider-var-info (var &optional all)
   "Return info for VAR as an nREPL dict.
 When multiple matching vars are returned you'll be prompted to select one,
@@ -559,8 +531,7 @@ unless ALL is truthy."
   (when (and var (not (string= var "")))
     (let ((var-info (cond
                      ((cider-nrepl-op-supported-p "info") 
(cider-sync-request:info var nil nil (cider-completion-get-context t)))
-                     ((cider-nrepl-op-supported-p "lookup") 
(cider-sync-request:lookup var))
-                     (t (cider-fallback-eval:info var)))))
+                     ((cider-nrepl-op-supported-p "lookup") 
(cider-sync-request:lookup var)))))
       (if all var-info (cider--var-choice var-info)))))
 
 (defun cider-member-info (class member)
diff --git a/test/cider-client-tests.el b/test/cider-client-tests.el
index ac2b276cf4..3b5bea665a 100644
--- a/test/cider-client-tests.el
+++ b/test/cider-client-tests.el
@@ -62,23 +62,9 @@
     (expect (nrepl-dict-get (cider-var-info "str") "doc")
             :to-equal "stub"))
 
-  (it "fallbacks to eval in the absence of the info middleware"
-    (spy-on 'cider-fallback-eval:info :and-return-value
-            '(dict
-              "arglists" "([] [x] [x & ys])"
-              "ns" "clojure.core"
-              "name" "str"
-              "column" 1
-              "added" "1.0"
-              "static" "true"
-              "doc" "stub"
-              "line" 504
-              "file" "jar:file:/clojure-1.5.1.jar!/clojure/core.clj"
-              "tag" "class java.lang.String"
-              "status" ("done")))
+  (it "returns nil in the absence of the info and lookup middleware"
     (spy-on 'cider-nrepl-op-supported-p :and-return-value nil)
-    (expect (nrepl-dict-get (cider-var-info "str") "doc")
-            :to-equal "stub")))
+    (expect (cider-var-info "str") :to-equal nil)))
 
 
 (describe "cider-repl-type-for-buffer"

Reply via email to