Class: RBI::Rewriters::GroupNodes
- Extended by:
- T::Sig
- Defined in:
- lib/rbi/rewriters/group_nodes.rb
Instance Method Summary collapse
Methods inherited from Visitor
Instance Method Details
#visit(node) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rbi/rewriters/group_nodes.rb', line 12 def visit(node) return unless node case node when Tree kinds = node.nodes.map { |child| group_kind(child) } kinds.uniq! groups = {} kinds.each { |kind| groups[kind] = Group.new(kind) } node.nodes.dup.each do |child| visit(child) child.detach groups[group_kind(child)] << child end groups.each { |_, group| node << group } end end |