Module: DeepCover::Node::Mixin::ExecutionLocation
- Defined in:
- lib/deep_cover/node/mixin/execution_location.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #child_executed_loc_keys(_child, _child_name) ⇒ Object
- #diagnostic_expression ⇒ Object
- #executed_loc_hash ⇒ Object
- #executed_loc_keys ⇒ Object
- #executed_locs ⇒ Object
- #expression ⇒ Object
- #loc_hash ⇒ Object
-
#proper_range ⇒ Object
Returns an array of character numbers (in the original buffer) that pertain exclusively to this node (and thus not to any children).
- #source ⇒ Object
Class Method Details
.included(base) ⇒ Object
6 7 8 9 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 6 def self.included(base) base.extend ClassMethods base.has_child_handler('%{name}_executed_loc_keys') end |
Instance Method Details
#child_executed_loc_keys(_child, _child_name) ⇒ Object
27 28 29 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 27 def child_executed_loc_keys(_child, _child_name) nil end |
#diagnostic_expression ⇒ Object
55 56 57 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 55 def diagnostic_expression expression || parent.diagnostic_expression end |
#executed_loc_hash ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 31 def executed_loc_hash h = Tools.slice(loc_hash, *executed_loc_keys) if (keys = parent.child_executed_loc_keys(self)) h.merge!(Tools.slice(parent.loc_hash, *keys)) end h.reject { |k, v| v.nil? } end |
#executed_loc_keys ⇒ Object
22 23 24 25 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 22 def executed_loc_keys return [] unless executable? loc_hash.keys - [:expression] end |
#executed_locs ⇒ Object
39 40 41 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 39 def executed_locs executed_loc_hash.values end |
#expression ⇒ Object
47 48 49 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 47 def expression loc_hash[:expression] end |
#loc_hash ⇒ Object
43 44 45 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 43 def loc_hash base_node.respond_to?(:location) ? base_node.location.to_hash : {} end |
#proper_range ⇒ Object
Returns an array of character numbers (in the original buffer) that pertain exclusively to this node (and thus not to any children).
61 62 63 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 61 def proper_range executed_locs.map(&:to_a).inject([], :+).uniq end |
#source ⇒ Object
51 52 53 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 51 def source expression.source if expression end |