Class: DeepCover::Node::EmptyBody
- Inherits:
-
DeepCover::Node
- Object
- DeepCover::Node
- DeepCover::Node::EmptyBody
- Defined in:
- lib/deep_cover/node/empty_body.rb
Direct Known Subclasses
Constant Summary
Constants inherited from DeepCover::Node
CLASSES, Complex, Cvasgn, Dsym, Erange, Float, Int, Ivar, Kwarg, Kwoptarg, Kwrestarg, OrAsgn, Rational, Sym, True, Zsuper
Instance Attribute Summary
Attributes inherited from DeepCover::Node
#base_node, #children, #index, #next_sibling, #parent, #previous_sibling
Instance Method Summary collapse
-
#initialize(base_node, parent:, index: 0, position: ChildCanBeEmpty.last_empty_position) ⇒ EmptyBody
constructor
A new instance of EmptyBody.
- #is_statement ⇒ Object
- #loc_hash ⇒ Object
-
#rewriting_rules ⇒ Object
When parent rewrites us, the %node must always be at the beginning because our location can also be rewritten by out parent, and we want the rewrite to be after it.
- #type ⇒ Object
Methods inherited from DeepCover::Node
#[], [], atom, #children_nodes, #covered_code, #each_node, #fancy_type, #find_all, has_evaluated_segments, inherited, #simple_literal?, #to_s
Methods included from Memoize
Constructor Details
#initialize(base_node, parent:, index: 0, position: ChildCanBeEmpty.last_empty_position) ⇒ EmptyBody
Returns a new instance of EmptyBody.
5 6 7 8 |
# File 'lib/deep_cover/node/empty_body.rb', line 5 def initialize(base_node, parent:, index: 0, position: ChildCanBeEmpty.last_empty_position) @position = position super(base_node, parent: parent, index: index, base_children: []) end |
Instance Method Details
#is_statement ⇒ Object
19 20 21 |
# File 'lib/deep_cover/node/empty_body.rb', line 19 def is_statement false end |
#loc_hash ⇒ Object
14 15 16 17 |
# File 'lib/deep_cover/node/empty_body.rb', line 14 def loc_hash return {} if @position == true {expression: @position} end |
#rewriting_rules ⇒ Object
When parent rewrites us, the %node must always be at the beginning because our location can also be rewritten by out parent, and we want the rewrite to be after it.
25 26 27 28 29 30 |
# File 'lib/deep_cover/node/empty_body.rb', line 25 def rewriting_rules rules = super rules.map do |expression, rule| [expression, "%{node};#{rule.sub('%{node}', 'nil;')}"] end end |
#type ⇒ Object
10 11 12 |
# File 'lib/deep_cover/node/empty_body.rb', line 10 def type :EmptyBody end |