instance method
Prism::Translation::Ripper#visit_lambda_node
visit_lambda_node(node)
lib/prism/translation/ripper.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/translation/ripper.rb, line 2286
def visit_lambda_node(node)
bounds(node.operator_loc)
on_tlambda(node.operator)
parameters =
if node.parameters.is_a?(BlockParametersNode)
# Ripper does not track block-locals within lambdas, so we skip
# directly to the parameters here.
params =
if node.parameters.parameters.nil?
bounds(node.location)
on_params(nil, nil, nil, nil, nil, nil, nil)
else
visit(node.parameters.parameters)
end
if node.parameters.opening_loc.nil?
params
else
bounds(node.parameters.opening_loc)
on_paren(params)
end
else
bounds(node.location)
on_params(nil, nil, nil, nil, nil, nil, nil)
end
braces = node.opening == "{"
if braces
bounds(node.opening_loc)
on_tlambeg(node.opening)
end
body =
case node.body
when nil
bounds(node.location)
stmts = on_stmts_add(on_stmts_new, on_void_stmt)
bounds(node.location)
braces ? stmts : on_bodystmt(stmts, nil, nil, nil)
when StatementsNode
stmts = node.body.body
stmts.unshift(nil) if void_stmt?(node.parameters&.location || node.opening_loc, node.body.location, false)
stmts = visit_statements_node_body(stmts)
bounds(node.body.location)
braces ? stmts : on_bodystmt(stmts, nil, nil, nil)
when BeginNode
visit_body_node(node.opening_loc, node.body)
else
raise
end
bounds(node.location)
on_lambda(parameters, body)
end
-> {}