Class: RubyLsp::Typeprof::Addon
- Inherits:
-
Addon
- Object
- Addon
- RubyLsp::Typeprof::Addon
- Defined in:
- lib/ruby_lsp/ruby_lsp_typeprof/addon.rb
Instance Method Summary collapse
- #activate(global_state, _outgoing_queue) ⇒ Object
- #create_code_lens_listener(response_builder, uri, dispatcher) ⇒ Object
- #deactivate ⇒ Object
-
#initialize ⇒ Addon
constructor
A new instance of Addon.
- #name ⇒ Object
- #version ⇒ Object
- #workspace_did_change_watched_files(changes) ⇒ Object
Constructor Details
#initialize ⇒ Addon
Returns a new instance of Addon.
12 13 14 15 16 17 18 |
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 12 def initialize super @service = nil @mutex = Mutex.new @enabled = true @code_lens_enabled = true end |
Instance Method Details
#activate(global_state, _outgoing_queue) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 20 def activate(global_state, _outgoing_queue) settings = global_state.settings_for_addon(name) @enabled = settings&.dig(:enabled) != false return unless @enabled require "typeprof" @code_lens_enabled = settings&.dig(:enableCodeLens) != false @service = build_service(global_state.workspace_path) rescue StandardError => e warn "ruby-lsp-typeprof: Failed to activate: #{e.}" end |
#create_code_lens_listener(response_builder, uri, dispatcher) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 45 def create_code_lens_listener(response_builder, uri, dispatcher) return unless @service return unless @code_lens_enabled CodeLensListener.new(response_builder, uri, dispatcher, @service, @mutex) end |
#deactivate ⇒ Object
33 34 35 |
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 33 def deactivate @service = nil end |
#name ⇒ Object
37 38 39 |
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 37 def name "TypeProf" end |
#version ⇒ Object
41 42 43 |
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 41 def version VERSION end |
#workspace_did_change_watched_files(changes) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 52 def workspace_did_change_watched_files(changes) return unless @service @mutex.synchronize do changes.each { |change| update_changed_file(change) } end end |