Class: Moult::SymbolScanner::Visitor

Inherits:
Prism::Visitor
  • Object
show all
Defined in:
lib/moult/symbol_scanner.rb

Overview

Walks the tree tracking lexical nesting (mirroring Parser::Visitor) so a collected symbol can be attributed to its enclosing class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVisitor

Returns a new instance of Visitor.



59
60
61
62
63
# File 'lib/moult/symbol_scanner.rb', line 59

def initialize
  @namespace = []
  @referenced_names = []
  super
end

Instance Attribute Details

#referenced_namesObject (readonly)

Returns the value of attribute referenced_names.



57
58
59
# File 'lib/moult/symbol_scanner.rb', line 57

def referenced_names
  @referenced_names
end

Instance Method Details

#visit_call_node(node) ⇒ Object



77
78
79
80
# File 'lib/moult/symbol_scanner.rb', line 77

def visit_call_node(node)
  collect(node) if CALLBACK_DSL.include?(node.name.to_s)
  super
end

#visit_class_node(node) ⇒ Object



65
66
67
68
69
# File 'lib/moult/symbol_scanner.rb', line 65

def visit_class_node(node)
  @namespace.push(node.constant_path.slice)
  super
  @namespace.pop
end

#visit_module_node(node) ⇒ Object



71
72
73
74
75
# File 'lib/moult/symbol_scanner.rb', line 71

def visit_module_node(node)
  @namespace.push(node.constant_path.slice)
  super
  @namespace.pop
end