class Solargraph::RbsMap::CoreMap

Ruby core pins

Public Class Methods

new() click to toggle source
# File lib/solargraph/rbs_map/core_map.rb, line 9
def initialize
  cache = Cache.load('core.ser')
  if cache
    pins.replace cache
  else
    loader = RBS::EnvironmentLoader.new(repository: RBS::Repository.new(no_stdlib: true))
    environment = RBS::Environment.from_loader(loader).resolve_type_names
    environment.declarations.each { |decl| convert_decl_to_pin(decl, Solargraph::Pin::ROOT_PIN) }
    pins.concat RbsMap::CoreFills::ALL
    processed = ApiMap::Store.new(pins).pins.reject { |p| p.is_a?(Solargraph::Pin::Reference::Override) }
    pins.replace processed

    Cache.save('core.ser', pins)
  end
end

Public Instance Methods

method_def_to_sigs(decl, pin) click to toggle source
# File lib/solargraph/rbs_map/core_map.rb, line 25
def method_def_to_sigs decl, pin
  stubs = CoreSigns.sign(pin.path)
  return super unless stubs
  stubs.map do |stub|
    Pin::Signature.new(
      [],
      ComplexType.try_parse(stub.return_type)
    )
  end
end