Class: Solargraph::RbsMap::CoreMap

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

Overview

Ruby core pins

Constant Summary collapse

FILLS_DIRECTORY =
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'rbs', 'fills'))

Constants included from Logging

Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS

Instance Method Summary collapse

Methods included from Logging

log_level, logger

Constructor Details

#initializeCoreMap

Returns a new instance of CoreMap.



16
# File 'lib/solargraph/rbs_map/core_map.rb', line 16

def initialize; end

Instance Method Details

#cache_core(out: $stderr) ⇒ Array<Pin::Base>

Parameters:

  • out (StringIO, IO, nil) (defaults to: $stderr)

    output stream for logging

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/solargraph/rbs_map/core_map.rb', line 27

def cache_core out: $stderr
  new_pins = []
  cache = PinCache.deserialize_core
  return cache if cache
  new_pins.concat conversions.pins

  # Avoid RBS::DuplicatedDeclarationError by loading in a different EnvironmentLoader
  fill_loader = RBS::EnvironmentLoader.new(core_root: nil, repository: RBS::Repository.new(no_stdlib: false))
  fill_loader.add(path: Pathname(FILLS_DIRECTORY))
  out&.puts 'Caching RBS pins for Ruby core'
  fill_conversions = Conversions.new(loader: fill_loader)
  new_pins.concat fill_conversions.pins

  # add some overrides
  new_pins.concat RbsMap::CoreFills::ALL

  # process overrides, then remove any which couldn't be resolved
  processed = ApiMap::Store.new(new_pins).pins.reject { |p| p.is_a?(Solargraph::Pin::Reference::Override) }
  new_pins.replace processed

  PinCache.serialize_core new_pins

  new_pins
end

#pins(out: $stderr) ⇒ Enumerable<Pin::Base>

Parameters:

  • out (IO, nil) (defaults to: $stderr)

    output stream for logging

Returns:



20
21
22
23
# File 'lib/solargraph/rbs_map/core_map.rb', line 20

def pins out: $stderr
  return @pins if @pins
  @pins = cache_core(out: out)
end

#resolved?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/solargraph/rbs_map/core_map.rb', line 10

def resolved?
  true
end