instance method
Prism::Translation::RubyParser::Compiler#visit_call_node
visit_call_node(node)
lib/prism/translation/ruby_parser.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/translation/ruby_parser.rb, line 292
def visit_call_node(node)
case node.name
when :!~
return s(node, :not, visit(node.copy(name: :"=~")))
when :=~
if node.arguments&.arguments&.length == 1 && node.block.nil?
case node.receiver
when StringNode
return s(node, :match3, visit(node.arguments.arguments.first), visit(node.receiver))
when RegularExpressionNode, InterpolatedRegularExpressionNode
return s(node, :match2, visit(node.receiver), visit(node.arguments.arguments.first))
end
case node.arguments.arguments.first
when RegularExpressionNode, InterpolatedRegularExpressionNode
return s(node, :match3, visit(node.arguments.arguments.first), visit(node.receiver))
end
end
end
type = node.attribute_write? ? :attrasgn : :call
type = :"safe_#{type}" if node.safe_navigation?
arguments = node.arguments&.arguments || []
write_value = arguments.pop if type == :attrasgn
block = node.block
if block.is_a?(BlockArgumentNode)
arguments << block
block = nil
end
result = s(node, type, visit(node.receiver), node.name).concat(visit_all(arguments))
result << visit_write_value(write_value) unless write_value.nil?
visit_block(node, result, block)
end
foo
^^^
foo.bar
^^^^^^^
foo.bar() {}
^^^^^^^^^^^^