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
ATTR_MESSAGES =
{
  attr_reader: %i[reader],
  attr_writer: %i[writer],
  attr_accessor: %i[reader writer]
}.freeze

Instance Method Summary collapse

Instance Method Details

#visit(graph, path, node, current_constant: nil, namespace: [], nesting: [], visibility: :public, default_scope: :instance) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/archspec/analyzer.rb', line 146

def visit(graph, path, node, current_constant: nil, namespace: [], nesting: [], visibility: :public,
          default_scope: :instance)
  return unless node

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