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