Class: Solargraph::Bench
- Inherits:
-
Object
- Object
- Solargraph::Bench
- Defined in:
- lib/solargraph/bench.rb
Overview
A container of source maps and workspace data to be cataloged in an ApiMap.
Instance Attribute Summary collapse
- #external_requires ⇒ Set<String> readonly
- #live_map ⇒ SourceMap readonly
- #source_maps ⇒ Set<SourceMap> readonly
- #workspace ⇒ Workspace readonly
Instance Method Summary collapse
- #icebox ⇒ Set<SourceMap>
-
#initialize(source_maps: [], workspace: Workspace.new, live_map: nil, external_requires: []) ⇒ Bench
constructor
A new instance of Bench.
-
#source_map_hash ⇒ Hash{String => SourceMap}
@sg-ignore flow sensitive typing needs better handling of ||= on lvars.
Constructor Details
#initialize(source_maps: [], workspace: Workspace.new, live_map: nil, external_requires: []) ⇒ Bench
Returns a new instance of Bench.
23 24 25 26 27 28 29 30 |
# File 'lib/solargraph/bench.rb', line 23 def initialize source_maps: [], workspace: Workspace.new, live_map: nil, external_requires: [] @source_maps = source_maps.to_set @workspace = workspace @live_map = live_map @external_requires = external_requires.reject { |path| workspace.would_require?(path) } .compact .to_set end |
Instance Attribute Details
#external_requires ⇒ Set<String> (readonly)
17 18 19 |
# File 'lib/solargraph/bench.rb', line 17 def external_requires @external_requires end |
#live_map ⇒ SourceMap (readonly)
14 15 16 |
# File 'lib/solargraph/bench.rb', line 14 def live_map @live_map end |
#source_maps ⇒ Set<SourceMap> (readonly)
8 9 10 |
# File 'lib/solargraph/bench.rb', line 8 def source_maps @source_maps end |
#workspace ⇒ Workspace (readonly)
11 12 13 |
# File 'lib/solargraph/bench.rb', line 11 def workspace @workspace end |
Instance Method Details
#icebox ⇒ Set<SourceMap>
40 41 42 |
# File 'lib/solargraph/bench.rb', line 40 def icebox @icebox ||= (source_maps - [live_map]) end |
#source_map_hash ⇒ Hash{String => SourceMap}
@sg-ignore flow sensitive typing needs better handling of ||= on lvars
34 35 36 37 |
# File 'lib/solargraph/bench.rb', line 34 def source_map_hash # @todo Work around #to_h bug in current Ruby head (3.5) with #map#to_h @source_map_hash ||= source_maps.to_h { |s| [s.filename, s] } end |