instance method
Prism::DotVisitor#visit_when_node
visit_when_node(node)
lib/prism/dot_visitor.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/dot_visitor.rb, line 4464
def visit_when_node(node)
table = Table.new("WhenNode")
id = node_id(node)
# keyword_loc
table.field("keyword_loc", location_inspect(node.keyword_loc))
# conditions
if node.conditions.any?
table.field("conditions", port: true)
waypoint = "#{id}_conditions"
digraph.waypoint("#{waypoint};")
digraph.edge("#{id}:conditions -> #{waypoint};")
node.conditions.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
else
table.field("conditions", "[]")
end
# then_keyword_loc
unless (then_keyword_loc = node.then_keyword_loc).nil?
table.field("then_keyword_loc", location_inspect(then_keyword_loc))
end
# statements
unless (statements = node.statements).nil?
table.field("statements", port: true)
digraph.edge("#{id}:statements -> #{node_id(statements)};")
end
digraph.nodes << <<~DOT
#{id} [
label=<#{table.to_dot.gsub(/\n/, "\n ")}>
];
DOT
super
end
Visit a WhenNode node.