Replies: 1 comment
-
In case this interests you, take a look at the related PR (#602) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Given how frequently method delegation is used in Ruby, it would be nice if Solargraph had a pin type that could express this concept directly. In particular, I want to be able to tell solargraph that "everything about method can be found on another object" so that completion queries can pull docstrings and types etc. from the original method.
To demonstrate why I think this should be part of Solargraph, consider this code from solargraph-rails for handling
delegate
calls: https://github.com/iftheshoefritz/solargraph-rails/blob/1b322ddc4ca7f71657334402a50d47480e442e5d/lib/solargraph/rails/delegate.rbThis matches a calls like
delegate :foo, to: :bar
and defines a#foo
method on the containing namespace. However, the defined method can't copy the parameters or return type from the original method, because the local convention can't query an ApiMap for pins.How this could work
If the convention could create a pin like:
Then, when asked about "SomeClass#foo", solargraph would compute the delegate (the return type of "SomeClass#bar" -> "Bar") and finally return information about "Bar#foo".
What do you think? I'd be willing to take a stab at implementing it if you think the design makes sense.
Beta Was this translation helpful? Give feedback.
All reactions