Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to list impls of protocol in info middleware #568

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/cider/nrepl/middleware/info.clj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
f))
f)))))


(defn info
[{:keys [ns symbol class member] :as msg}]
(let [[ns symbol class member] (map u/as-sym [ns symbol class member])]
Expand All @@ -86,7 +87,28 @@
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)))))
(if-let [p (:protocol var-info)]
(let [proto (deref p)
x (filter #(extends? proto
%)
(filter #(class? %)
(map val (mapcat ns-imports (all-ns)))))
xs (map (fn [x]
(let [xs (str/split (pr-str x)
#"\.")]
(str (str/replace (str/join "." (drop-last xs))
#"\_"
"-")
"/map->"
(last xs))))
x)]
{:candidates (into {}
Copy link
Contributor

@arichiardi arichiardi Jun 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this returning :candidates? shouldn't it go in compliment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are different candidates. :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we use the same key for several things here and there (I think it was used somewhere in info as well).

(map (fn [s]
[s (clj-info/info ns
(u/as-sym s))])
xs))})
var-info))))))


(defn info-reply
[msg]
Expand Down