Class: SorbetAutoTyper::Tracer

Inherits:
Object
  • Object
show all
Defined in:
lib/sorbet_auto_typer/tracer.rb

Constant Summary collapse

METHOD_TYPE_INSTANCE =
'instance'
METHOD_TYPE_CLASS =
'class'
OUTPUT_TYPE_CALL =
'C'
OUTPUT_TYPE_RETURN =
'R'
OUTPUT_DELIMITER =
'|'
OUTPUT_TYPE_INNER_LEFT =
'('
OUTPUT_TYPE_INNER_RIGHT =
')'
OUTPUT_TYPE_DELIMITER =
';'
OUTPUT_TYPE_DEFAULT =
'D'
OUTPUT_TYPE_ARRAY =
'A'
OUTPUT_TYPE_RANGE =
'R'
OUTPUT_TYPE_SET =
'S'
OUTPUT_TYPE_HASH =
'H'

Instance Method Summary collapse

Constructor Details

#initialize(io_writer, filter_path = '') ⇒ Tracer

Returns a new instance of Tracer.



20
21
22
23
24
25
26
27
28
# File 'lib/sorbet_auto_typer/tracer.rb', line 20

def initialize(io_writer, filter_path='')
  @io_writer = io_writer
  @io_writer.sync = false
  @filter_path = filter_path
  @trace_point = TracePoint.new(:call, :return) do |trace|
    handle_trace(trace)
  end
  @traces_seen = {}
end

Instance Method Details

#start!Object



30
31
32
# File 'lib/sorbet_auto_typer/tracer.rb', line 30

def start!
  trace_point.enable
end

#stop!Object



34
35
36
37
# File 'lib/sorbet_auto_typer/tracer.rb', line 34

def stop!
  trace_point.disable
  @io_writer.close
end