Class: RubyLsp::Typeprof::SignatureCache
- Inherits:
-
Object
- Object
- RubyLsp::Typeprof::SignatureCache
- Includes:
- Loggable
- Defined in:
- lib/ruby_lsp/ruby_lsp_typeprof/signature_cache.rb
Overview
Collects the method signatures TypeProf inferred for a single file, keyed by the 1-based line number of the method definition.
Instance Method Summary collapse
- #[](line) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(service, mutex, path, outgoing_queue, feature:) ⇒ SignatureCache
constructor
A new instance of SignatureCache.
Constructor Details
#initialize(service, mutex, path, outgoing_queue, feature:) ⇒ SignatureCache
Returns a new instance of SignatureCache.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ruby_lsp/ruby_lsp_typeprof/signature_cache.rb', line 12 def initialize(service, mutex, path, outgoing_queue, feature:) @outgoing_queue = outgoing_queue @hints = {} return unless path mutex.synchronize do service.code_lens(path) do |code_range, hint| @hints[code_range.first.lineno] = hint end end rescue StandardError => e log_error("Ruby LSP TypeProf failed to compute #{feature} for #{path}: #{e.(highlight: false)}") end |
Instance Method Details
#[](line) ⇒ Object
26 27 28 |
# File 'lib/ruby_lsp/ruby_lsp_typeprof/signature_cache.rb', line 26 def [](line) @hints[line] end |
#empty? ⇒ Boolean
30 31 32 |
# File 'lib/ruby_lsp/ruby_lsp_typeprof/signature_cache.rb', line 30 def empty? @hints.empty? end |