lib/prism/dot_visitor.rb in prism-0.24.0 vs lib/prism/dot_visitor.rb in prism-0.25.0

- old
+ new

@@ -1,6 +1,7 @@ # frozen_string_literal: true + =begin This file is generated by the templates/template.rb script and should not be modified manually. See templates/lib/prism/dot_visitor.rb.erb if you are looking to modify the template =end @@ -22,11 +23,11 @@ def to_dot if port "<tr><td align=\"left\" colspan=\"2\" port=\"#{name}\">#{name}</td></tr>" else - "<tr><td align=\"left\">#{name}</td><td>#{CGI.escapeHTML(value)}</td></tr>" + "<tr><td align=\"left\">#{name}</td><td>#{CGI.escapeHTML(value || raise)}</td></tr>" end end end class Table # :nodoc: @@ -1153,13 +1154,11 @@ # value table.field("value", port: true) digraph.edge("#{id}:value -> #{node_id(node.value)};") # operator_loc - unless (operator_loc = node.operator_loc).nil? - table.field("operator_loc", location_inspect(operator_loc)) - end + table.field("operator_loc", location_inspect(node.operator_loc)) digraph.nodes << <<~DOT #{id} [ label=<#{table.to_dot.gsub(/\n/, "\n ")}> ]; @@ -1771,10 +1770,13 @@ # Visit a FloatNode node. def visit_float_node(node) table = Table.new("FloatNode") id = node_id(node) + # value + table.field("value", node.value.inspect) + digraph.nodes << <<~DOT #{id} [ label=<#{table.to_dot.gsub(/\n/, "\n ")}> ]; DOT @@ -2578,10 +2580,13 @@ id = node_id(node) # flags table.field("flags", integer_base_flags_inspect(node)) + # value + table.field("value", node.value.inspect) + digraph.nodes << <<~DOT #{id} [ label=<#{table.to_dot.gsub(/\n/, "\n ")}> ]; DOT @@ -2664,10 +2669,13 @@ # Visit a InterpolatedStringNode node. def visit_interpolated_string_node(node) table = Table.new("InterpolatedStringNode") id = node_id(node) + # flags + table.field("flags", interpolated_string_node_flags_inspect(node)) + # opening_loc unless (opening_loc = node.opening_loc).nil? table.field("opening_loc", location_inspect(opening_loc)) end @@ -2766,10 +2774,24 @@ DOT super end + # Visit a ItParametersNode node. + def visit_it_parameters_node(node) + table = Table.new("ItParametersNode") + id = node_id(node) + + digraph.nodes << <<~DOT + #{id} [ + label=<#{table.to_dot.gsub(/\n/, "\n ")}> + ]; + DOT + + super + end + # Visit a KeywordHashNode node. def visit_keyword_hash_node(node) table = Table.new("KeywordHashNode") id = node_id(node) @@ -4007,10 +4029,31 @@ DOT super end + # Visit a ShareableConstantNode node. + def visit_shareable_constant_node(node) + table = Table.new("ShareableConstantNode") + id = node_id(node) + + # flags + table.field("flags", shareable_constant_node_flags_inspect(node)) + + # write + table.field("write", port: true) + digraph.edge("#{id}:write -> #{node_id(node.write)};") + + digraph.nodes << <<~DOT + #{id} [ + label=<#{table.to_dot.gsub(/\n/, "\n ")}> + ]; + DOT + + super + end + # Visit a SingletonClassNode node. def visit_singleton_class_node(node) table = Table.new("SingletonClassNode") id = node_id(node) @@ -4062,10 +4105,13 @@ # Visit a SourceFileNode node. def visit_source_file_node(node) table = Table.new("SourceFileNode") id = node_id(node) + # flags + table.field("flags", string_flags_inspect(node)) + # filepath table.field("filepath", node.filepath.inspect) digraph.nodes << <<~DOT #{id} [ @@ -4388,10 +4434,15 @@ 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 @@ -4515,90 +4566,99 @@ end # Inspect a node that has arguments_node_flags flags to display the flags as a # comma-separated list. def arguments_node_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "contains_keyword_splat" if node.contains_keyword_splat? flags.join(", ") end # Inspect a node that has array_node_flags flags to display the flags as a # comma-separated list. def array_node_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "contains_splat" if node.contains_splat? flags.join(", ") end # Inspect a node that has call_node_flags flags to display the flags as a # comma-separated list. def call_node_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "safe_navigation" if node.safe_navigation? flags << "variable_call" if node.variable_call? flags << "attribute_write" if node.attribute_write? flags << "ignore_visibility" if node.ignore_visibility? flags.join(", ") end # Inspect a node that has encoding_flags flags to display the flags as a # comma-separated list. def encoding_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "forced_utf8_encoding" if node.forced_utf8_encoding? flags << "forced_binary_encoding" if node.forced_binary_encoding? flags.join(", ") end # Inspect a node that has integer_base_flags flags to display the flags as a # comma-separated list. def integer_base_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "binary" if node.binary? flags << "decimal" if node.decimal? flags << "octal" if node.octal? flags << "hexadecimal" if node.hexadecimal? flags.join(", ") end + # Inspect a node that has interpolated_string_node_flags flags to display the flags as a + # comma-separated list. + def interpolated_string_node_flags_inspect(node) + flags = [] #: Array[String] + flags << "frozen" if node.frozen? + flags << "mutable" if node.mutable? + flags.join(", ") + end + # Inspect a node that has keyword_hash_node_flags flags to display the flags as a # comma-separated list. def keyword_hash_node_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "symbol_keys" if node.symbol_keys? flags.join(", ") end # Inspect a node that has loop_flags flags to display the flags as a # comma-separated list. def loop_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "begin_modifier" if node.begin_modifier? flags.join(", ") end # Inspect a node that has parameter_flags flags to display the flags as a # comma-separated list. def parameter_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "repeated_parameter" if node.repeated_parameter? flags.join(", ") end # Inspect a node that has range_flags flags to display the flags as a # comma-separated list. def range_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "exclude_end" if node.exclude_end? flags.join(", ") end # Inspect a node that has regular_expression_flags flags to display the flags as a # comma-separated list. def regular_expression_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "ignore_case" if node.ignore_case? flags << "extended" if node.extended? flags << "multi_line" if node.multi_line? flags << "once" if node.once? flags << "euc_jp" if node.euc_jp? @@ -4609,23 +4669,34 @@ flags << "forced_binary_encoding" if node.forced_binary_encoding? flags << "forced_us_ascii_encoding" if node.forced_us_ascii_encoding? flags.join(", ") end + # Inspect a node that has shareable_constant_node_flags flags to display the flags as a + # comma-separated list. + def shareable_constant_node_flags_inspect(node) + flags = [] #: Array[String] + flags << "literal" if node.literal? + flags << "experimental_everything" if node.experimental_everything? + flags << "experimental_copy" if node.experimental_copy? + flags.join(", ") + end + # Inspect a node that has string_flags flags to display the flags as a # comma-separated list. def string_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "forced_utf8_encoding" if node.forced_utf8_encoding? flags << "forced_binary_encoding" if node.forced_binary_encoding? flags << "frozen" if node.frozen? + flags << "mutable" if node.mutable? flags.join(", ") end # Inspect a node that has symbol_flags flags to display the flags as a # comma-separated list. def symbol_flags_inspect(node) - flags = [] + flags = [] #: Array[String] flags << "forced_utf8_encoding" if node.forced_utf8_encoding? flags << "forced_binary_encoding" if node.forced_binary_encoding? flags << "forced_us_ascii_encoding" if node.forced_us_ascii_encoding? flags.join(", ") end