10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/rbi/rewriters/nest_non_public_members.rb', line 10
def visit(node)
return unless node
case node
when Tree
public_group = VisibilityGroup.new(Public.new)
protected_group = VisibilityGroup.new(Protected.new)
private_group = VisibilityGroup.new(Private.new)
node.nodes.dup.each do |child|
visit(child)
next unless child.is_a?(Attr) || child.is_a?(Method)
child.detach
case child.visibility
when Protected
protected_group << child
when Private
private_group << child
else
public_group << child
end
end
node << public_group unless public_group.empty?
node << protected_group unless protected_group.empty?
node << private_group unless private_group.empty?
end
end
|