Open simon-katz opened 6 years ago
Does anyone know if there's some existing API we can leverage to retrieve this info?
Looks like there's some data available via getMethodTable
, i.e. (.getMethodTable print-method)
.
See https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/MultiFn.java#L579-L581
There's methods
, which seems to give the same as .getMethodTable
…
(= (.getMethodTable print-method)
(methods print-method))
=> true
EDIT Indeed they are the same: see https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L1803-L1807
Do we have a source location for the results of methods
from somewhere? I tried calling meta
on the functions in there, hoping for compiler metadata, but found none.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!
This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it.
Just to note that dumb-jump (https://github.com/jacktasia/dumb-jump) works with multimethods — it lets you select from all the methods of a multimethod.
It only works within the current project, though.
It only works within the current project, though.
Could grep through the jars on path too to get the rest, right?
I think implementing this in the middleware is the simplest path, it's just a matter of someone finding the time to do it. Grepping is easy, but it's never accurate.
Does Orchard support this?
Not yet.
defmethods aren't vars and don't have metadata. What would the alternative to grepping be in this case?
I've moved this issue to Orchard.
methods
indeed seems useful:
> (methods print-method)
{nil #function[clojure.core/fn--7368],
clojure.lang.IRecord #function[clojure.core/fn--7480],
refactor_nrepl.inlined_deps.rewrite_clj.v1v1v47.rewrite_clj.node.meta.MetaNode
#function[refactor-nrepl.inlined-deps.rewrite-clj.v1v1v47.rewrite-clj.node.protocols/make-printable!/fn--422],
refactor_nrepl.inlined_deps.rewrite_clj.v1v1v47.rewrite_clj.node.stringz.StringNode
#function[refactor-nrepl.inlined-deps.rewrite-clj.v1v1v47.rewrite-clj.node.protocols/make-printable!/fn--422],
java.lang.Character #function[clojure.core/fn--7486],
clojure.lang.MultiFn
#function[cider.nrepl.print-method/eval825998/fn--825999],
refactor_nrepl.inlined_deps.rewrite_clj.v1v1v47.rewrite_clj.node.regex.RegexNode
#function[refactor-nrepl.inlined-deps.rewrite-clj.v1v1v47.rewrite-clj.node.protocols/make-printable!/fn--422],
,,,
We can take those function objects, infer the namespace that backs them, and read their whole source in search of something like looks like a matching defmethod.
i.e. bit of a mixture of static and dynamic approaches 😄
(Feature request)
It would be good to have a way of viewing and navigating to all the methods for a multimethod.
Two things I've seen before (in LispWorks for Common Lisp) are: