Class: Reek::Context::GhostContext

Inherits:
ModuleContext show all
Defined in:
lib/reek/context/ghost_context.rb

Overview

Semi-transparent context to represent a metaclass while building the context tree. This context will not be part of the resulting tree, but will track context and visibility separately while building is in progress.

Constant Summary

Constants inherited from ModuleContext

ModuleContext::CONSTANT_SEXP_TYPES

Instance Attribute Summary collapse

Attributes inherited from ModuleContext

#visibility_tracker

Attributes inherited from CodeContext

#exp, #parent, #refs

Instance Method Summary collapse

Methods inherited from ModuleContext

#defined_instance_methods, #descriptively_commented?, #initialize, #instance_method_calls, #instance_method_children, #instance_method_names_via_to_call, #namespace_module?, #node_instance_methods, #singleton_method_children

Methods inherited from CodeContext

#apply_current_visibility, #config_for, #configuration_via_code_commment, #each, #full_comment, #full_name, #initialize, #instance_method?, #local_nodes, #matches?, #number_of_statements, #parent_config_for, #record_call_to, #singleton_method?

Constructor Details

This class inherits a constructor from Reek::Context::ModuleContext

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



13
14
15
# File 'lib/reek/context/ghost_context.rb', line 13

def children
  @children
end

Instance Method Details

#append_child_context(child) ⇒ Object



19
20
21
22
23
# File 'lib/reek/context/ghost_context.rb', line 19

def append_child_context(child)
  real_parent = parent.append_child_context(child)
  super
  real_parent
end

#attribute_context_classObject

Return the correct class for child attribute contexts. For GhostContext, this is the class that represents singleton attributes.



34
35
36
# File 'lib/reek/context/ghost_context.rb', line 34

def attribute_context_class
  SingletonAttributeContext
end

#method_context_classObject

Return the correct class for child method contexts (representing nodes of type ‘:def`). For GhostContext, this is the class that represents singleton methods.



28
29
30
# File 'lib/reek/context/ghost_context.rb', line 28

def method_context_class
  SingletonMethodContext
end

#record_use_of_selfObject



44
45
46
# File 'lib/reek/context/ghost_context.rb', line 44

def record_use_of_self
  parent.record_use_of_self
end

#register_with_parent(parent) ⇒ Object



15
16
17
# File 'lib/reek/context/ghost_context.rb', line 15

def register_with_parent(parent)
  @parent = parent
end

#statement_counterObject



48
49
50
# File 'lib/reek/context/ghost_context.rb', line 48

def statement_counter
  parent.statement_counter
end

#track_visibility(visibility, names) ⇒ Object



38
39
40
41
42
# File 'lib/reek/context/ghost_context.rb', line 38

def track_visibility(visibility, names)
  visibility_tracker.track_visibility children: children,
                                      visibility: visibility,
                                      names: names
end