diff --git a/src/cider/nrepl/middleware/info.clj b/src/cider/nrepl/middleware/info.clj index 8ea729467..cbfdaa835 100644 --- a/src/cider/nrepl/middleware/info.clj +++ b/src/cider/nrepl/middleware/info.clj @@ -2,12 +2,11 @@ (:require [cider.nrepl.middleware.util.cljs :as cljs] [cider.nrepl.middleware.util.error-handling :refer [with-safe-transport]] - [cljs-tooling.info :as cljs-info] [clojure.java.io :as io] [clojure.string :as str] [orchard.eldoc :as eldoc] [orchard.info :as clj-info] - [orchard.misc :as u])) + [orchard.misc :as orchard-misc])) (declare format-response) @@ -45,48 +44,23 @@ (clj-info/javadoc-info path))) format-nested blacklist - u/transform-value)))) - -(defn info-cljs - [env symbol ns] - (some-> (cljs-info/info env symbol ns) - (select-keys [:file :line :ns :doc :column :name :arglists]) - (update - :file - (fn [f] - (if (u/boot-project?) - ;; Boot stores files in a temporary directory & ClojureScript - ;; stores the :file metadata location absolutely instead of - ;; relatively to the classpath. This means when doing jump to - ;; source in Boot & ClojureScript, you end up at the temp file. - ;; This code attempts to find the classpath-relative location - ;; of the file, so that it can be opened correctly. - (let [path (java.nio.file.Paths/get f (into-array String [])) - path-count (.getNameCount path)] - (or - (first - (sequence - (comp (map #(.subpath path % path-count)) - (map str) - (filter io/resource)) - (range path-count))) - f)) - f))))) + orchard-misc/transform-value)))) (defn info [{:keys [ns symbol class member] :as msg}] - (let [[ns symbol class member] (map u/as-sym [ns symbol class member])] - (if-let [cljs-env (cljs/grab-cljs-env msg)] - (info-cljs cljs-env symbol ns) - (let [var-info (cond (and ns symbol) (clj-info/info ns symbol) - (and class member) (clj-info/info-java class member) - :else (throw (Exception. - "Either \"symbol\", or (\"class\", \"member\") must be supplied"))) - ;; we have to use the resolved (real) namespace and name here - see-also (clj-info/see-also (:ns var-info) (:name var-info))] - (if (seq see-also) - (merge {:see-also see-also} var-info) - var-info))))) + (let [[ns symbol class member] (map orchard-misc/as-sym [ns symbol class member]) + env (cljs/grab-cljs-env msg) + info-params (merge {:dialect :clj + :ns ns + :sym symbol} + (when env + {:env env + :dialect :cljs}))] + (cond + (and ns symbol) (clj-info/info info-params) + (and class member) (clj-info/info-java class member) + :else (throw (Exception. + "Either \"symbol\", or (\"class\", \"member\") must be supplied"))))) (defn info-reply [msg]