class Sorbet::Private::HiddenMethodFinder

def write_constants

def write_constants
  puts "Printing your code's symbol table into #{SOURCE_CONSTANTS}"
  io = IO.popen(
    [
      File.realpath("#{__dir__}/../bin/srb"),
      'tc',
      '--print=symbol-table-full-json',
      '--stdout-hup-hack',
      '--silence-dev-message',
      '--no-error-count',
      '-e', # this is additive with any files / dirs
      '""',
    ],
    err: SOURCE_CONSTANTS_ERR
  )
  File.write(SOURCE_CONSTANTS, io.read)
  io.close
  raise "Your source can't be read by Sorbet.\nYou can try `find . -type f | xargs -L 1 -t bundle exec srb tc --no-config --isolate-error-code 1000` and hopefully the last file it is processing before it dies is the culprit.\nIf not, maybe the errors in this file will help: #{SOURCE_CONSTANTS_ERR}" if File.read(SOURCE_CONSTANTS).empty?
  puts "Printing #{TMP_RBI}'s symbol table into #{RBI_CONSTANTS}"
  io = IO.popen(
    [
      {'SRB_SKIP_GEM_RBIS' => 'true'},
      File.realpath("#{__dir__}/../bin/srb"),
      'tc',
      # Make sure we don't load a sorbet/config in your cwd
      '--no-config',
      '--print=symbol-table-full-json',
      # The hidden-definition serializer is not smart enough to put T::Enum
      # constants it discovers inside an `enums do` block. We probably want
      # to come up with a better long term solution here.
      '--suppress-error-code=3506',
      # Method redefined with mismatched argument is ok since sometime
      # people monkeypatch over method
      '--suppress-error-code=4010',
      # Redefining constant is needed because we serialize things both as
      # aliases and in-class constants.
      '--suppress-error-code=4012',
      # At one point we split 4012 into 4012/4022
      '--suppress-error-code=4022',
      # Invalid nesting is ok because we don't generate all the intermediate
      # namespaces for aliases
      '--suppress-error-code=4015',
      # The `Random` class has a super class of `Object` in ruby-2.7 and
      # `Random::Base` in ruby-2. We can remove this once we no longer support
      # ruby-2.7.
      '--suppress-error-code=5012',
      '--stdout-hup-hack',
      '--silence-dev-message',
      '--no-error-count',
      TMP_RBI,
    ],
    err: RBI_CONSTANTS_ERR
  )
  File.write(RBI_CONSTANTS, io.read)
  io.close
  raise "#{TMP_RBI} had unexpected errors. Check this file for a clue: #{RBI_CONSTANTS_ERR}" unless $?.success?
end