instance method
Prism::DotVisitor#visit_def_node
visit_def_node(node)
lib/prism/dot_visitor.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/dot_visitor.rb, line 1486
def visit_def_node(node)
table = Table.new("DefNode")
id = node_id(node)
# name
table.field("name", node.name.inspect)
# name_loc
table.field("name_loc", location_inspect(node.name_loc))
# receiver
unless (receiver = node.receiver).nil?
table.field("receiver", port: true)
digraph.edge("#{id}:receiver -> #{node_id(receiver)};")
end
# parameters
unless (parameters = node.parameters).nil?
table.field("parameters", port: true)
digraph.edge("#{id}:parameters -> #{node_id(parameters)};")
end
# body
unless (body = node.body).nil?
table.field("body", port: true)
digraph.edge("#{id}:body -> #{node_id(body)};")
end
# locals
table.field("locals", node.locals.inspect)
# def_keyword_loc
table.field("def_keyword_loc", location_inspect(node.def_keyword_loc))
# operator_loc
unless (operator_loc = node.operator_loc).nil?
table.field("operator_loc", location_inspect(operator_loc))
end
# lparen_loc
unless (lparen_loc = node.lparen_loc).nil?
table.field("lparen_loc", location_inspect(lparen_loc))
end
# rparen_loc
unless (rparen_loc = node.rparen_loc).nil?
table.field("rparen_loc", location_inspect(rparen_loc))
end
# equal_loc
unless (equal_loc = node.equal_loc).nil?
table.field("equal_loc", location_inspect(equal_loc))
end
# end_keyword_loc
unless (end_keyword_loc = node.end_keyword_loc).nil?
table.field("end_keyword_loc", location_inspect(end_keyword_loc))
end
digraph.nodes << <<~DOT
#{id} [
label=<#{table.to_dot.gsub(/\n/, "\n ")}>
];
DOT
super
end
Visit a DefNode node.