diff options
author | Kevin Newton <kddnewton@gmail.com> | 2023-12-08 09:40:26 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-12-08 14:40:32 +0000 |
commit | a54eb9c6f9c12816f6befefd3828b78689076549 (patch) | |
tree | aaa96b14f26c66dc8bc1e85f09c72c97092e3503 /prism | |
parent | 0166040939fd9057a7fb724e290fbe6c9cc036c2 (diff) |
[ruby/prism] A couple of small dot enhancements
https://github.com/ruby/prism/commit/5642a57f39
Diffstat (limited to 'prism')
-rw-r--r-- | prism/templates/lib/prism/dot_visitor.rb.erb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/prism/templates/lib/prism/dot_visitor.rb.erb b/prism/templates/lib/prism/dot_visitor.rb.erb index 5e01388c6d..fc3dd4b223 100644 --- a/prism/templates/lib/prism/dot_visitor.rb.erb +++ b/prism/templates/lib/prism/dot_visitor.rb.erb @@ -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 -%> |