Add protocol-impls and multimethod-dispatch-values#401
Merged
Conversation
orchard.xref/protocol-impls returns the types implementing a protocol - both extend/extend-type/extend-protocol targets and inline defrecord/deftype implementers (found by scanning the loaded-class cache for the protocol's generated interface) - each with a source location where one is resolvable. orchard.xref/multimethod-dispatch-values returns a multimethod's dispatch values. These back a forthcoming cider-nrepl "who-implements" op, the foundational middleware envisioned in clojure-emacs/cider#1969.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The foundational piece for a "who-implements" feature in CIDER (clojure-emacs/cider#1969, whose original design sketch called for exactly this middleware).
orchard.xref/protocol-implsreturns the types implementing a protocol. It covers bothextend/extend-type/extend-protocoltargets (viaextenders) and inlinedefrecord/deftypeimplementers - the latter found by scanning the loaded-class cache for the protocol's generated interface (the sameDynamicClassLoadercachefn-depsalready uses). Each entry carries a source location when one is resolvable (records/types expose it through their->Namefactory var; Java targets have none).orchard.xref/multimethod-dispatch-valuesreturns a multimethod's dispatch values.Only loaded code is visible, consistent with the rest of
orchard.xref. Per-defmethodsource locations aren't included - those methods are anonymous fns with no runtime metadata, so they'd need bytecode line-table reading; that's left for a follow-up.