Class: Masamune::AbstractSyntaxTree::VariablesVisitor

Inherits:
Prism::Visitor
  • Object
show all
Defined in:
lib/masamune/abstract_syntax_tree/visitors/variables_visitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_value) ⇒ VariablesVisitor

Returns a new instance of VariablesVisitor.



6
7
8
9
# File 'lib/masamune/abstract_syntax_tree/visitors/variables_visitor.rb', line 6

def initialize(token_value)
  @token_value = token_value
  @results = []
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



4
5
6
# File 'lib/masamune/abstract_syntax_tree/visitors/variables_visitor.rb', line 4

def results
  @results
end

#token_valueObject (readonly)

Returns the value of attribute token_value.



4
5
6
# File 'lib/masamune/abstract_syntax_tree/visitors/variables_visitor.rb', line 4

def token_value
  @token_value
end

Instance Method Details

#visit_call_node(node) ⇒ Object



26
27
28
29
30
31
# File 'lib/masamune/abstract_syntax_tree/visitors/variables_visitor.rb', line 26

def visit_call_node(node)
  if node.variable_call?
    results << node if token_value.nil? || token_value == node.name
  end
  super
end

#visit_local_variable_read_node(node) ⇒ Object



16
17
18
19
# File 'lib/masamune/abstract_syntax_tree/visitors/variables_visitor.rb', line 16

def visit_local_variable_read_node(node)
  results << node if token_value.nil? || token_value == node.name.to_s
  super
end

#visit_local_variable_write_node(node) ⇒ Object



11
12
13
14
# File 'lib/masamune/abstract_syntax_tree/visitors/variables_visitor.rb', line 11

def visit_local_variable_write_node(node)
  results << node if token_value.nil? || token_value == node.name.to_s
  super
end

#visit_required_parameter_node(node) ⇒ Object



21
22
23
24
# File 'lib/masamune/abstract_syntax_tree/visitors/variables_visitor.rb', line 21

def visit_required_parameter_node(node)
  results << node if token_value.nil? || token_value == node.name.to_s
  super
end