instance method
Prism::InspectVisitor#visit_def_node
visit_def_node(node)
lib/prism/inspect_visitor.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/inspect_visitor.rb, line 785
def visit_def_node(node)
commands << [inspect_node("DefNode", node), indent]
flags = [("newline" if node.newline?), ("static_literal" if node.static_literal?), ].compact
commands << ["├── flags: #{flags.empty? ? "∅" : flags.join(", ")}\n", indent]
commands << ["├── name: #{node.name.inspect}\n", indent]
commands << ["├── name_loc: #{inspect_location(node.name_loc)}\n", indent]
if (receiver = node.receiver).nil?
commands << ["├── receiver: ∅\n", indent]
else
commands << ["├── receiver:\n", indent]
commands << [receiver, "#{indent}│ "]
end
if (parameters = node.parameters).nil?
commands << ["├── parameters: ∅\n", indent]
else
commands << ["├── parameters:\n", indent]
commands << [parameters, "#{indent}│ "]
end
if (body = node.body).nil?
commands << ["├── body: ∅\n", indent]
else
commands << ["├── body:\n", indent]
commands << [body, "#{indent}│ "]
end
commands << ["├── locals: #{node.locals.inspect}\n", indent]
commands << ["├── def_keyword_loc: #{inspect_location(node.def_keyword_loc)}\n", indent]
commands << ["├── operator_loc: #{inspect_location(node.operator_loc)}\n", indent]
commands << ["├── lparen_loc: #{inspect_location(node.lparen_loc)}\n", indent]
commands << ["├── rparen_loc: #{inspect_location(node.rparen_loc)}\n", indent]
commands << ["├── equal_loc: #{inspect_location(node.equal_loc)}\n", indent]
commands << ["└── end_keyword_loc: #{inspect_location(node.end_keyword_loc)}\n", indent]
end
Inspect a DefNode node.