module Tapioca::Compilers::SymbolTable::SymbolLoader

Public Class Methods

ignore_symbol?(symbol) click to toggle source
# File lib/tapioca/compilers/symbol_table/symbol_loader.rb, line 19
def ignore_symbol?(symbol)
  symbol = symbol[2..-1] if symbol.start_with?("::")
  ignored_symbols.include?(symbol)
end
list_from_paths(paths) click to toggle source
# File lib/tapioca/compilers/symbol_table/symbol_loader.rb, line 15
def list_from_paths(paths)
  load_symbols(paths.map(&:to_s))
end

Private Class Methods

ignored_symbols() click to toggle source
# File lib/tapioca/compilers/symbol_table/symbol_loader.rb, line 41
def ignored_symbols
  unless @ignored_symbols
    output = symbol_table_json_from("-e ''", table_type: "symbol-table-full-json")
    json = JSON.parse(output)
    @ignored_symbols = SymbolTableParser.parse(json)
  end

  @ignored_symbols
end
load_symbols(paths) click to toggle source
# File lib/tapioca/compilers/symbol_table/symbol_loader.rb, line 27
def load_symbols(paths)
  output = T.cast(Tempfile.create("sorbet") do |file|
    file.write(Array(paths).join("\n"))
    file.flush

    symbol_table_json_from("@#{file.path.shellescape}")
  end, T.nilable(String))

  return Set.new if output.nil? || output.empty?

  json = JSON.parse(output)
  SymbolTableParser.parse(json)
end
symbol_table_json_from(input, table_type: "symbol-table-json") click to toggle source
# File lib/tapioca/compilers/symbol_table/symbol_loader.rb, line 51
def symbol_table_json_from(input, table_type: "symbol-table-json")
  Tapioca::Compilers::Sorbet.run("--no-config", "--print=#{table_type}", input)
end