Class: RBS::EnvironmentLoader
- Inherits:
-
Object
- Object
- RBS::EnvironmentLoader
- Defined in:
- lib/rbs_loading_optimizer/loading/optimizer/environment_loader.rb
Instance Attribute Summary collapse
-
#cached_sources ⇒ Object
Returns the value of attribute cached_sources.
- #latest_modified_time ⇒ Object
-
#resolved ⇒ Object
Returns the value of attribute resolved.
Instance Method Summary collapse
Instance Attribute Details
#cached_sources ⇒ Object
Returns the value of attribute cached_sources.
5 6 7 |
# File 'lib/rbs_loading_optimizer/loading/optimizer/environment_loader.rb', line 5 def cached_sources @cached_sources end |
#latest_modified_time ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rbs_loading_optimizer/loading/optimizer/environment_loader.rb', line 8 def latest_modified_time @latest_modified_time ||= begin mtimes = [] each_dir do |source, dir| skip_hidden = !source.is_a?(Pathname) mtimes << RBS::FileFinder.each_file(dir, skip_hidden:, immediate: true).map { |f| File.mtime(f) }.max end mtimes.max end end |
#resolved ⇒ Object
Returns the value of attribute resolved.
5 6 7 |
# File 'lib/rbs_loading_optimizer/loading/optimizer/environment_loader.rb', line 5 def resolved @resolved end |
Instance Method Details
#load(env:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rbs_loading_optimizer/loading/optimizer/environment_loader.rb', line 19 def load(env:) loaded = [] cached = cached_sources || [] each_signature do |source, path, buffer, decls, dirs| decls.each do |decl| decl.resolved = cached.include?(source) # NOTE: Mark as resolved if decl is came from cache loaded << [decl, path, source] end env.add_signature(buffer:, directives: dirs, decls:) end loaded end |