Module: ArchSpec::Analyzer::SourceVisitor

Extended by:
SourceVisitor
Included in:
SourceVisitor
Defined in:
lib/archspec/analyzer.rb

Constant Summary collapse

DYNAMIC_MESSAGES =
%i[
  class_eval
  const_get
  const_set
  define_method
  instance_eval
  method_missing
  module_eval
  public_send
  send
].freeze
MIXIN_MESSAGES =
{
  include: :includes,
  prepend: :prepends,
  extend: :extends
}.freeze

Instance Method Summary collapse

Instance Method Details

#visit(graph, path, node, current_constant: nil, namespace: []) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/archspec/analyzer.rb', line 164

def visit(graph, path, node, current_constant: nil, namespace: [])
  return unless node

  case node
  when Prism::ProgramNode, Prism::StatementsNode
    visit_children(graph, path, node, current_constant: current_constant, namespace: namespace)
  when Prism::ClassNode
    visit_class(graph, path, node, current_constant: current_constant, namespace: namespace)
  when Prism::ModuleNode
    visit_module(graph, path, node, current_constant: current_constant, namespace: namespace)
  when Prism::DefNode
    visit_def(graph, path, node, current_constant: current_constant, namespace: namespace)
  when Prism::CallNode
    visit_call(graph, path, node, current_constant: current_constant, namespace: namespace)
  when Prism::ConstantPathNode, Prism::ConstantReadNode
    add_constant_reference(graph, path, node, current_constant)
  else
    visit_children(graph, path, node, current_constant: current_constant, namespace: namespace)
  end
end