Class: Yoda::AST::Node
- Extended by:
- Forwardable
- Defined in:
- lib/yoda/ast/node.rb
Direct Known Subclasses
ArrayNode, AssignmentNode, BlockCallNode, BlockNode, CaseNode, CenterOperatorNode, ClassNode, ConditionalLoopNode, ConstantAssignmentNode, ConstantBaseNode, ConstantNode, DefNode, DefSingletonNode, EnsureNode, HashNode, IfNode, InterpolationTextNode, KwsplatNode, LeftOperatorNode, LiteralNode, ModuleNode, MultipleLeftHandSideNode, OptionalParameterNode, PairNode, ParameterNode, ParametersNode, RescueClauseNode, RescueNode, SendNode, SingletonClassNode, SpecialCallNode, VariableNode, WhenNode
Instance Attribute Summary collapse
- #node ⇒ String readonly
Attributes inherited from Vnode
Instance Method Summary collapse
- #children ⇒ Array<Vnode>
- #identifier ⇒ String
-
#initialize(node, parent: nil, comments_by_node: {}) ⇒ Node
constructor
A new instance of Node.
- #kind ⇒ Symbol
- #source_map ⇒ Parser::Source::Map?
Methods inherited from Vnode
#constant?, #empty?, #inspect, #inspect_content, #nesting, #present?, #try, #type, #wrap_child
Methods included from Vnode::CommentPositional
#comments_by_vnode, #positionally_nearest_comment, #positionally_nearest_commenting_node
Methods included from Vnode::Positional
#location, #positionally_include?, #positionally_nearest_child, #range
Methods included from Vnode::CommentAssociation
#all_nodes_lazy, #associate_comments, #comments, #wrapping?
Methods included from Traversable
#query, #query_all, #query_ancestor, #query_ancestors
Methods included from MethodTraversable
#calc_current_location_method, #including_method, #method?
Methods included from NamespaceTraversable
#calc_current_location_namespace, #full_name, #namespace, #namespace?, #namespace_path, #root?
Constructor Details
#initialize(node, parent: nil, comments_by_node: {}) ⇒ Node
Returns a new instance of Node.
20 21 22 23 |
# File 'lib/yoda/ast/node.rb', line 20 def initialize(node, parent: nil, comments_by_node: {}) @node = node super(parent: parent, comments_by_node: comments_by_node) end |
Instance Attribute Details
#node ⇒ String (readonly)
9 10 11 |
# File 'lib/yoda/ast/node.rb', line 9 def node @node end |
Instance Method Details
#children ⇒ Array<Vnode>
26 27 28 |
# File 'lib/yoda/ast/node.rb', line 26 def children @children ||= node.children.map(&method(:wrap_child)) end |
#identifier ⇒ String
31 32 33 |
# File 'lib/yoda/ast/node.rb', line 31 def identifier "#{type}:#{source_map&.expression ? source_map_expression : object_id}" end |
#kind ⇒ Symbol
41 42 43 |
# File 'lib/yoda/ast/node.rb', line 41 def kind node.type end |
#source_map ⇒ Parser::Source::Map?
36 37 38 |
# File 'lib/yoda/ast/node.rb', line 36 def source_map node.location end |