lib/prism/inspect_visitor.rb in prism-0.28.0 vs lib/prism/inspect_visitor.rb in prism-0.30.0

- old
+ new

@@ -394,12 +394,12 @@ end commands << ["├── call_operator_loc: #{inspect_location(node.call_operator_loc)}\n", indent] commands << ["├── message_loc: #{inspect_location(node.message_loc)}\n", indent] commands << ["├── read_name: #{node.read_name.inspect}\n", indent] commands << ["├── write_name: #{node.write_name.inspect}\n", indent] - commands << ["├── operator: #{node.operator.inspect}\n", indent] - commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent] + commands << ["├── binary_operator: #{node.binary_operator.inspect}\n", indent] + commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent] commands << ["└── value:\n", indent] commands << [node.value, "#{indent} "] end # Inspect a CallOrWriteNode node. @@ -537,14 +537,14 @@ # Inspect a ClassVariableOperatorWriteNode node. def visit_class_variable_operator_write_node(node) commands << [inspect_node("ClassVariableOperatorWriteNode", node), indent] commands << ["├── name: #{node.name.inspect}\n", indent] commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent] - commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent] + commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent] commands << ["├── value:\n", indent] commands << [node.value, "#{indent}│ "] - commands << ["└── operator: #{node.operator.inspect}\n", indent] + commands << ["└── binary_operator: #{node.binary_operator.inspect}\n", indent] end # Inspect a ClassVariableOrWriteNode node. def visit_class_variable_or_write_node(node) commands << [inspect_node("ClassVariableOrWriteNode", node), indent] @@ -590,14 +590,14 @@ # Inspect a ConstantOperatorWriteNode node. def visit_constant_operator_write_node(node) commands << [inspect_node("ConstantOperatorWriteNode", node), indent] commands << ["├── name: #{node.name.inspect}\n", indent] commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent] - commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent] + commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent] commands << ["├── value:\n", indent] commands << [node.value, "#{indent}│ "] - commands << ["└── operator: #{node.operator.inspect}\n", indent] + commands << ["└── binary_operator: #{node.binary_operator.inspect}\n", indent] end # Inspect a ConstantOrWriteNode node. def visit_constant_or_write_node(node) commands << [inspect_node("ConstantOrWriteNode", node), indent] @@ -639,14 +639,14 @@ # Inspect a ConstantPathOperatorWriteNode node. def visit_constant_path_operator_write_node(node) commands << [inspect_node("ConstantPathOperatorWriteNode", node), indent] commands << ["├── target:\n", indent] commands << [node.target, "#{indent}│ "] - commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent] + commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent] commands << ["├── value:\n", indent] commands << [node.value, "#{indent}│ "] - commands << ["└── operator: #{node.operator.inspect}\n", indent] + commands << ["└── binary_operator: #{node.binary_operator.inspect}\n", indent] end # Inspect a ConstantPathOrWriteNode node. def visit_constant_path_or_write_node(node) commands << [inspect_node("ConstantPathOrWriteNode", node), indent] @@ -906,14 +906,14 @@ # Inspect a GlobalVariableOperatorWriteNode node. def visit_global_variable_operator_write_node(node) commands << [inspect_node("GlobalVariableOperatorWriteNode", node), indent] commands << ["├── name: #{node.name.inspect}\n", indent] commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent] - commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent] + commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent] commands << ["├── value:\n", indent] commands << [node.value, "#{indent}│ "] - commands << ["└── operator: #{node.operator.inspect}\n", indent] + commands << ["└── binary_operator: #{node.binary_operator.inspect}\n", indent] end # Inspect a GlobalVariableOrWriteNode node. def visit_global_variable_or_write_node(node) commands << [inspect_node("GlobalVariableOrWriteNode", node), indent] @@ -1101,12 +1101,12 @@ commands << ["├── block: ∅\n", indent] else commands << ["├── block:\n", indent] commands << [block, "#{indent}│ "] end - commands << ["├── operator: #{node.operator.inspect}\n", indent] - commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent] + commands << ["├── binary_operator: #{node.binary_operator.inspect}\n", indent] + commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent] commands << ["└── value:\n", indent] commands << [node.value, "#{indent} "] end # Inspect a IndexOrWriteNode node. @@ -1176,14 +1176,14 @@ # Inspect a InstanceVariableOperatorWriteNode node. def visit_instance_variable_operator_write_node(node) commands << [inspect_node("InstanceVariableOperatorWriteNode", node), indent] commands << ["├── name: #{node.name.inspect}\n", indent] commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent] - commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent] + commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent] commands << ["├── value:\n", indent] commands << [node.value, "#{indent}│ "] - commands << ["└── operator: #{node.operator.inspect}\n", indent] + commands << ["└── binary_operator: #{node.binary_operator.inspect}\n", indent] end # Inspect a InstanceVariableOrWriteNode node. def visit_instance_variable_or_write_node(node) commands << [inspect_node("InstanceVariableOrWriteNode", node), indent] @@ -1308,10 +1308,15 @@ commands << [parts[-1], "#{indent}│ "] end commands << ["└── closing_loc: #{inspect_location(node.closing_loc)}\n", indent] end + # Inspect a ItLocalVariableReadNode node. + def visit_it_local_variable_read_node(node) + commands << [inspect_node("ItLocalVariableReadNode", node), indent] + end + # Inspect a ItParametersNode node. def visit_it_parameters_node(node) commands << [inspect_node("ItParametersNode", node), indent] end @@ -1379,15 +1384,15 @@ # Inspect a LocalVariableOperatorWriteNode node. def visit_local_variable_operator_write_node(node) commands << [inspect_node("LocalVariableOperatorWriteNode", node), indent] commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent] - commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent] + commands << ["├── binary_operator_loc: #{inspect_location(node.binary_operator_loc)}\n", indent] commands << ["├── value:\n", indent] commands << [node.value, "#{indent}│ "] commands << ["├── name: #{node.name.inspect}\n", indent] - commands << ["├── operator: #{node.operator.inspect}\n", indent] + commands << ["├── binary_operator: #{node.binary_operator.inspect}\n", indent] commands << ["└── depth: #{node.depth.inspect}\n", indent] end # Inspect a LocalVariableOrWriteNode node. def visit_local_variable_or_write_node(node) @@ -1775,12 +1780,14 @@ end # Inspect a RationalNode node. def visit_rational_node(node) commands << [inspect_node("RationalNode", node), indent] - commands << ["└── numeric:\n", indent] - commands << [node.numeric, "#{indent} "] + flags = [("binary" if node.binary?), ("decimal" if node.decimal?), ("octal" if node.octal?), ("hexadecimal" if node.hexadecimal?)].compact + commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent] + commands << ["├── numerator: #{node.numerator.inspect}\n", indent] + commands << ["└── denominator: #{node.denominator.inspect}\n", indent] end # Inspect a RedoNode node. def visit_redo_node(node) commands << [inspect_node("RedoNode", node), indent] @@ -2133,16 +2140,11 @@ private # Compose a header for the given node. def inspect_node(name, node) - result = +"@ #{name} (" - location = node.location - result << "location: (#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column})" - result << ", newline: true" if node.newline? - - result << ")\n" + "@ #{name} (location: (#{location.start_line},#{location.start_column})-(#{location.end_line},#{location.end_column}))\n" end # Compose a string representing the given inner location field. def inspect_location(location) if location