class Prism::DefNode
Represents a method definition.
def methodend^^^^^^^^^^
Attributes
attr_reader body:StatementsNode |BeginNode | nil
attr_reader parameters:ParametersNode?
attr_reader receiver: Prism::node?
Public Class Methods
Source
# File lib/prism/node.rb, line 5950definitialize(source,node_id,location,flags,name,name_loc,receiver,parameters,body,locals,def_keyword_loc,operator_loc,lparen_loc,rparen_loc,equal_loc,end_keyword_loc)@source =source@node_id =node_id@location =location@flags =flags@name =name@name_loc =name_loc@receiver =receiver@parameters =parameters@body =body@locals =locals@def_keyword_loc =def_keyword_loc@operator_loc =operator_loc@lparen_loc =lparen_loc@rparen_loc =rparen_loc@equal_loc =equal_loc@end_keyword_loc =end_keyword_locend
Initialize a newDefNode node.
Source
# File lib/prism/node.rb, line 6183defself.type:def_nodeend
Return a symbol representation of this node type. SeeNode::type.
Public Instance Methods
Source
# File lib/prism/node.rb, line 6189def===(other)other.is_a?(DefNode)&& (name===other.name)&& (name_loc.nil?==other.name_loc.nil?)&& (receiver===other.receiver)&& (parameters===other.parameters)&& (body===other.body)&& (locals.length==other.locals.length)&&locals.zip(other.locals).all? {|left,right|left===right }&& (def_keyword_loc.nil?==other.def_keyword_loc.nil?)&& (operator_loc.nil?==other.operator_loc.nil?)&& (lparen_loc.nil?==other.lparen_loc.nil?)&& (rparen_loc.nil?==other.rparen_loc.nil?)&& (equal_loc.nil?==other.equal_loc.nil?)&& (end_keyword_loc.nil?==other.end_keyword_loc.nil?)end
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
Source
# File lib/prism/node.rb, line 5970defaccept(visitor)visitor.visit_def_node(self)end
def accept: (Visitor visitor) -> void
Source
# File lib/prism/node.rb, line 5975defchild_nodes [receiver,parameters,body]end
defchild_nodes: () ->Array
Source
# File lib/prism/node.rb, line 5989defcomment_targets [name_loc,*receiver,*parameters,*body,def_keyword_loc,*operator_loc,*lparen_loc,*rparen_loc,*equal_loc,*end_keyword_loc]#: Array[Prism::node | Location]end
defcomment_targets: () -> Array[Node | Location]
Source
# File lib/prism/node.rb, line 5980defcompact_child_nodescompact = []#: Array[Prism::node]compact<<receiverifreceivercompact<<parametersifparameterscompact<<bodyifbodycompactend
defcompact_child_nodes: () ->Array
Source
# File lib/prism/node.rb, line 5994defcopy(node_id:self.node_id,location:self.location,flags:self.flags,name:self.name,name_loc:self.name_loc,receiver:self.receiver,parameters:self.parameters,body:self.body,locals:self.locals,def_keyword_loc:self.def_keyword_loc,operator_loc:self.operator_loc,lparen_loc:self.lparen_loc,rparen_loc:self.rparen_loc,equal_loc:self.equal_loc,end_keyword_loc:self.end_keyword_loc)DefNode.new(source,node_id,location,flags,name,name_loc,receiver,parameters,body,locals,def_keyword_loc,operator_loc,lparen_loc,rparen_loc,equal_loc,end_keyword_loc)end
def copy: (?node_id:Integer, ?location:Location, ?flags:Integer, ?name:Symbol, ?name_loc:Location, ?receiver: Prism::node?, ?parameters:ParametersNode?, ?body:StatementsNode |BeginNode | nil, ?locals:Array, ?def_keyword_loc:Location, ?operator_loc:Location?, ?lparen_loc:Location?, ?rparen_loc:Location?, ?equal_loc:Location?, ?end_keyword_loc:Location?) ->DefNode
Source
# File lib/prism/node.rb, line 6002defdeconstruct_keys(keys) {node_id:node_id,location:location,name:name,name_loc:name_loc,receiver:receiver,parameters:parameters,body:body,locals:locals,def_keyword_loc:def_keyword_loc,operator_loc:operator_loc,lparen_loc:lparen_loc,rparen_loc:rparen_loc,equal_loc:equal_loc,end_keyword_loc:end_keyword_loc }end
defdeconstruct_keys: (Array keys) -> { node_id:Integer, location:Location, name:Symbol,name_loc:Location, receiver: Prism::node?, parameters:ParametersNode?, body:StatementsNode |BeginNode | nil, locals:Array,def_keyword_loc:Location,operator_loc:Location?,lparen_loc:Location?,rparen_loc:Location?,equal_loc:Location?,end_keyword_loc:Location? }
Source
# File lib/prism/node.rb, line 6143defdef_keyworddef_keyword_loc.sliceend
defdef_keyword: () ->String
Source
# File lib/prism/node.rb, line 6035defdef_keyword_loclocation =@def_keyword_locreturnlocationiflocation.is_a?(Location)@def_keyword_loc =Location.new(source,location>>32,location&0xFFFFFFFF)end
attr_readerdef_keyword_loc:Location
Source
# File lib/prism/node.rb, line 6168defend_keywordend_keyword_loc&.sliceend
defend_keyword: () ->String?
Source
# File lib/prism/node.rb, line 6124defend_keyword_loclocation =@end_keyword_loccaselocationwhennilnilwhenLocationlocationelse@end_keyword_loc =Location.new(source,location>>32,location&0xFFFFFFFF)endend
attr_readerend_keyword_loc:Location?
Source
Source
# File lib/prism/node.rb, line 6173definspectInspectVisitor.compose(self)end
def inspect ->String
Source
# File lib/prism/node.rb, line 6153deflparenlparen_loc&.sliceend
def lparen: () ->String?
Source
# File lib/prism/node.rb, line 6067deflparen_loclocation =@lparen_loccaselocationwhennilnilwhenLocationlocationelse@lparen_loc =Location.new(source,location>>32,location&0xFFFFFFFF)endend
attr_readerlparen_loc:Location?
Source
Source
# File lib/prism/node.rb, line 6148defoperatoroperator_loc&.sliceend
def operator: () ->String?
Source
# File lib/prism/node.rb, line 6048defoperator_loclocation =@operator_loccaselocationwhennilnilwhenLocationlocationelse@operator_loc =Location.new(source,location>>32,location&0xFFFFFFFF)endend
attr_readeroperator_loc:Location?
Source
# File lib/prism/node.rb, line 6158defrparenrparen_loc&.sliceend
def rparen: () ->String?
Source
# File lib/prism/node.rb, line 6086defrparen_loclocation =@rparen_loccaselocationwhennilnilwhenLocationlocationelse@rparen_loc =Location.new(source,location>>32,location&0xFFFFFFFF)endend
attr_readerrparen_loc:Location?
Source
# File lib/prism/node.rb, line 6043defsave_def_keyword_loc(repository)repository.enter(node_id,:def_keyword_loc)end
Save thedef_keyword_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 6138defsave_end_keyword_loc(repository)repository.enter(node_id,:end_keyword_loc)unless@end_keyword_loc.nil?end
Save theend_keyword_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 6119defsave_equal_loc(repository)repository.enter(node_id,:equal_loc)unless@equal_loc.nil?end
Save theequal_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 6081defsave_lparen_loc(repository)repository.enter(node_id,:lparen_loc)unless@lparen_loc.nil?end
Save thelparen_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 6018defsave_name_loc(repository)repository.enter(node_id,:name_loc)end
Save thename_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 6062defsave_operator_loc(repository)repository.enter(node_id,:operator_loc)unless@operator_loc.nil?end
Save theoperator_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 6100defsave_rparen_loc(repository)repository.enter(node_id,:rparen_loc)unless@rparen_loc.nil?end
Save therparen_loc location using the given saved source so that it can be retrieved later.