Class: Solargraph::RbsMap

Inherits:
Object
  • Object
show all
Includes:
Conversions
Defined in:
lib/solargraph/rbs_map.rb,
lib/solargraph/rbs_map/core_map.rb,
lib/solargraph/rbs_map/core_fills.rb,
lib/solargraph/rbs_map/core_signs.rb,
lib/solargraph/rbs_map/stdlib_map.rb,
lib/solargraph/rbs_map/conversions.rb

Direct Known Subclasses

StdlibMap

Defined Under Namespace

Modules: Conversions, CoreFills, CoreSigns Classes: CoreMap, StdlibMap

Constant Summary collapse

@@rbs_maps_hash =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Conversions

#pins

Constructor Details

#initialize(library) ⇒ RbsMap

Returns a new instance of RbsMap.

Parameters:

  • library (String)


22
23
24
25
26
27
28
29
# File 'lib/solargraph/rbs_map.rb', line 22

def initialize library
  @library = library
  loader = RBS::EnvironmentLoader.new(core_root: nil, repository: repository)
  add_library loader, library
  return unless resolved?
  environment = RBS::Environment.from_loader(loader).resolve_type_names
  environment.declarations.each { |decl| convert_decl_to_pin(decl, Solargraph::Pin::ROOT_PIN) }
end

Instance Attribute Details

#libraryObject (readonly)

Returns the value of attribute library.



19
20
21
# File 'lib/solargraph/rbs_map.rb', line 19

def library
  @library
end

Class Method Details

.load(library) ⇒ RbsMap

Parameters:

  • library (String)

Returns:



45
46
47
# File 'lib/solargraph/rbs_map.rb', line 45

def self.load library
  @@rbs_maps_hash[library] ||= RbsMap.new(library)
end

Instance Method Details

#path_pin(path) ⇒ Object



31
32
33
# File 'lib/solargraph/rbs_map.rb', line 31

def path_pin path
  pins.find { |p| p.path == path }
end

#path_pins(path) ⇒ Object



35
36
37
# File 'lib/solargraph/rbs_map.rb', line 35

def path_pins path
  pins.select { |p| p.path == path }
end

#repositoryObject



49
50
51
# File 'lib/solargraph/rbs_map.rb', line 49

def repository
  @repository ||= RBS::Repository.new(no_stdlib: true)
end

#resolved?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/solargraph/rbs_map.rb', line 39

def resolved?
  @resolved
end