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 our parent, and we want the rewrite to be after it.
Methods inherited from DeepCover::Node
#[], [], atom, #children_nodes, #covered_code, define_module_class, #each_node, #fancy_type, #find_all, has_evaluated_segments, inherited, #simple_literal?, #to_s, #type
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
15 16 17 |
# File 'lib/deep_cover/node/empty_body.rb', line 15 def is_statement false end |
#loc_hash ⇒ Object
10 11 12 13 |
# File 'lib/deep_cover/node/empty_body.rb', line 10 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 our parent, and we want the rewrite to be after it.
21 22 23 24 25 26 |
# File 'lib/deep_cover/node/empty_body.rb', line 21 def rewriting_rules rules = super rules.map do |expression, rule| [expression, "%{node};#{rule.sub('%{node}', 'nil;')}"] end end |