Class: Moult::SymbolScanner::Visitor
- Inherits:
-
Prism::Visitor
- Object
- Prism::Visitor
- Moult::SymbolScanner::Visitor
- 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
-
#referenced_names ⇒ Object
readonly
Returns the value of attribute referenced_names.
Instance Method Summary collapse
-
#initialize ⇒ Visitor
constructor
A new instance of Visitor.
- #visit_call_node(node) ⇒ Object
- #visit_class_node(node) ⇒ Object
- #visit_module_node(node) ⇒ Object
Constructor Details
#initialize ⇒ Visitor
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_names ⇒ Object (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 |