clojure-emacs / orchard

A fertile ground for Clojure tooling
Eclipse Public License 1.0
326 stars 54 forks source link

Provide cider function to find all known impls of a protocol function #204

Open kapilreddy opened 6 years ago

kapilreddy commented 6 years ago

The feature-request has been posted on "cider"

https://github.com/clojure-emacs/cider/issues/1969

Creating an issue here to send a pull request and start a discussion about the solution.

vemv commented 1 year ago

(Moved from cider-nrepl)

harold commented 1 month ago

Related discussion on Clojurians slack: https://clojurians.slack.com/archives/C0617A8PQ/p1729784739018019


Super interesting, thank you @vemv for the pointer here.

Do people have strong feelings on implementing this with/without kondo? Is it possible to do it without kondo?

vemv commented 1 month ago

I think that using clj-kondo would be a quite natural thing (to be done in cider-nrepl though - not Orchard). cider-nrepl already uses a variety of libs.

It would be a large undertaking though with many possible ramifications and implications.

So my thinking is that we could also read .clj-kondo / clojure-lsp directories on the fly, no lib involved, using some heuristics to determine if the contents are fresh, and finally, double-checking if the results makes sense (i.e. do they look like protocol impls).

(This thinking comes from the observation that many users of commercial codebases regularly run kondo / lsp locally in some or other way, or have a means to trigger a CI-oriented script)

It's also possible to roll our own static codebase parsing, although I wouldn't underestimate its complexity (and proneness to false positives / negatives). I'd reserve the technique for simpler use cases, as I outlined in another issue https://github.com/clojure-emacs/orchard/issues/181

Cheers - V

harold commented 1 month ago

Relevant bit of clj-kondo analysis config:

https://github.com/clj-kondo/clj-kondo/tree/master/analysis#extra-analysis

Need to include :analysis {:protocol-impls true} in clj-kondo config to get it to locate individual protocol method implementations.

c.f., this issue as well (with some additional hints in it):

https://github.com/clj-kondo/clj-kondo/issues/405