solargraph
solargraph copied to clipboard
Struct Support?
suppose following code:
class BBB
def initialize(*args)
a = A.new(1) # <-- a can't be infer
end
A = Struct.new(:foo) do |o|
self # <-- self is class<BBB>
end
end
can we support Struct, or through some comment annotation?
Struct support is on the roadmap, but it's a little tricky. I don't have an ETA for it yet.
Comment annotation is currently possible, but it's a weak solution. You'd have to do something like this:
A = Struct.new(:foo)
# @!parse
# class A
# attr_accessor :foo
# end
...in which case, you might as well get rid of the Struct and just declare the class. I'd definitely prefer a solution that can map the class from the Struct.new call itself.
Is this something that would need YARD to be updated to understand?