solargraph icon indicating copy to clipboard operation
solargraph copied to clipboard

Struct Support?

Open SolaWing opened this issue 6 years ago • 2 comments

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?

SolaWing avatar Jan 07 '20 03:01 SolaWing

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.

castwide avatar Jan 07 '20 14:01 castwide

Is this something that would need YARD to be updated to understand?

thomthom avatar Sep 13 '21 11:09 thomthom