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
28 29 30 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 28 def child_executed_loc_keys(_child, _child_name) nil end |
#diagnostic_expression ⇒ Object
56 57 58 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 56 def diagnostic_expression expression || parent.diagnostic_expression end |
#executed_loc_hash ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 32 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
23 24 25 26 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 23 def executed_loc_keys return [] unless executable? loc_hash.keys - [:expression] end |
#executed_locs ⇒ Object
40 41 42 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 40 def executed_locs executed_loc_hash.values end |
#expression ⇒ Object
48 49 50 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 48 def expression loc_hash[:expression] end |
#loc_hash ⇒ Object
44 45 46 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 44 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).
62 63 64 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 62 def proper_range executed_locs.map(&:to_a).inject([], :+).uniq end |
#source ⇒ Object
52 53 54 |
# File 'lib/deep_cover/node/mixin/execution_location.rb', line 52 def source expression.source if expression end |