Class: Solargraph::RbsMap::CoreMap

Inherits:
Object
  • Object
show all
Includes:
Conversions
Defined in:
lib/solargraph/rbs_map/core_map.rb

Overview

Ruby core pins

Instance Method Summary collapse

Methods included from Conversions

#pins

Constructor Details

#initializeCoreMap

Returns a new instance of CoreMap.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/solargraph/rbs_map/core_map.rb', line 10

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

Instance Method Details

#method_def_to_sigs(decl, pin) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/solargraph/rbs_map/core_map.rb', line 26

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