Class: Spoom::Sorbet::Sigs::SigsLocator

Inherits:
RBI::Visitor
  • Object
show all
Defined in:
lib/spoom/sorbet/sigs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSigsLocator

: -> void



92
93
94
95
96
# File 'lib/spoom/sorbet/sigs.rb', line 92

def initialize
  super
  @sigs = T.let([], T::Array[[RBI::Sig, T.any(RBI::Method, RBI::Attr)]])
  @rbs_comments = T.let([], T::Array[[RBI::RBSComment, T.any(RBI::Method, RBI::Attr)]])
end

Instance Attribute Details

#rbs_commentsObject (readonly)

: Array[[RBI::RBSComment, (RBI::Method | RBI::Attr)]]



89
90
91
# File 'lib/spoom/sorbet/sigs.rb', line 89

def rbs_comments
  @rbs_comments
end

#sigsObject (readonly)

: Array[[RBI::Sig, (RBI::Method | RBI::Attr)]]



86
87
88
# File 'lib/spoom/sorbet/sigs.rb', line 86

def sigs
  @sigs
end

Instance Method Details

#visit(node) ⇒ Object

: (RBI::Node? node) -> void



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/spoom/sorbet/sigs.rb', line 100

def visit(node)
  return unless node

  case node
  when RBI::Method, RBI::Attr
    node.sigs.each do |sig|
      next if sig.is_abstract

      @sigs << [sig, node]
    end
    node.comments.grep(RBI::RBSComment).each do |rbs_comment|
      @rbs_comments << [rbs_comment, node]
    end
  when RBI::Tree
    visit_all(node.nodes)
  end
end