class Sorbet::Private::GemGeneratorTracepoint::Tracer
def self.install_tracepoints
def self.install_tracepoints @class_tracepoint = TracePoint.new(:class) do |tp| module_created(tp.self) end @c_call_tracepoint = TracePoint.new(:c_call) do |tp| case tp.method_id when :require, :require_relative @context_stack << [] end end @c_return_tracepoint = TracePoint.new(:c_return) do |tp| case tp.method_id when :require, :require_relative popped = @context_stack.pop next if popped.empty? path = $LOADED_FEATURES.last if tp.return_value != true # intentional true check next if popped.size == 1 && popped[0][:module].is_a?(LoadError) # warn("Unexpected: constants or methods were defined when #{tp.method_id} didn't return true; adding to #{path} instead") end # raise 'Unexpected: constants or methods were defined without a file added to $LOADED_FEATURES' if path.nil? # raise "Unexpected: #{path} is already defined in files" if files.key?(path) @files[path] ||= [] @files[path] += popped # popped.each { |item| item[:path] = path } when :method_added, :singleton_method_added begin tp.disable singleton = tp.method_id == :singleton_method_added receiver = singleton ? Sorbet::Private::RealStdlib.real_singleton_class(tp.self) : tp.self methods = Sorbet::Private::RealStdlib.real_instance_methods(receiver, false) + Sorbet::Private::RealStdlib.real_private_instance_methods(receiver, false) set = @modules[Sorbet::Private::RealStdlib.real_object_id(receiver)] ||= Set.new added = methods.find { |m| !set.include?(m) } if added.nil? # warn("Warning: could not find method added to #{tp.self} at #{tp.path}:#{tp.lineno}") next end set << added method_added(tp.self, added, singleton) ensure tp.enable end end end @class_tracepoint.enable @c_call_tracepoint.enable @c_return_tracepoint.enable end