Class: CallMap::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/call_map/analyzer.rb

Overview

Builds a call tree from a starting method definition by recursively extracting calls and resolving them against the SourceIndex.

Instance Method Summary collapse

Constructor Details

#initialize(index) ⇒ Analyzer

Returns a new instance of Analyzer.

Parameters:



15
16
17
18
# File 'lib/call_map/analyzer.rb', line 15

def initialize(index)
  @index = index
  @resolver = Resolver.new(index)
end

Instance Method Details

#build_call_tree(definition, depth: 3) ⇒ CallNode

Build a call tree rooted at the given definition.

Parameters:

  • definition (Definition)

    the starting method

  • depth (Integer) (defaults to: 3)

    maximum recursion depth (0 = no children)

Returns:



25
26
27
28
# File 'lib/call_map/analyzer.rb', line 25

def build_call_tree(definition, depth: 3)
  visited = Set.new
  build_node(definition, nil, depth, visited, entry: true)
end