Skip to content

Commit

Permalink
[ruby/prism] A couple of small dot enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Dec 8, 2023
1 parent 0166040 commit a54eb9c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions prism/templates/lib/prism/dot_visitor.rb.erb
Expand Up @@ -122,13 +122,17 @@ module Prism
digraph.edge("#{id}:<%= field.name %> -> #{node_id(<%= field.name %>)};")
end
<%- when Prism::NodeListField -%>
table.field("<%= field.name %>", port: true)
if node.<%= field.name %>.any?
table.field("<%= field.name %>", port: true)

waypoint = "#{id}_<%= field.name %>"
digraph.waypoint("#{waypoint};")
waypoint = "#{id}_<%= field.name %>"
digraph.waypoint("#{waypoint};")

digraph.edge("#{id}:<%= field.name %> -> #{waypoint};")
node.<%= field.name %>.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
digraph.edge("#{id}:<%= field.name %> -> #{waypoint};")
node.<%= field.name %>.each { |child| digraph.edge("#{waypoint} -> #{node_id(child)};") }
else
table.field("<%= field.name %>", "[]")
end
<%- when Prism::StringField, Prism::ConstantField, Prism::OptionalConstantField, Prism::UInt8Field, Prism::UInt32Field, Prism::ConstantListField -%>
table.field("<%= field.name %>", node.<%= field.name %>.inspect)
<%- when Prism::LocationField -%>
Expand Down

0 comments on commit a54eb9c

Please sign in to comment.