Class: RubyLsp::Typeprof::Addon

Inherits:
Addon
  • Object
show all
Includes:
Loggable
Defined in:
lib/ruby_lsp/ruby_lsp_typeprof/addon.rb

Instance Method Summary collapse

Constructor Details

#initializeAddon

Returns a new instance of Addon.



15
16
17
18
19
20
21
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 15

def initialize
  super
  @service = nil
  @mutex = Mutex.new
  @enabled = true
  @code_lens_enabled = true
end

Instance Method Details

#activate(global_state, outgoing_queue) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 23

def activate(global_state, outgoing_queue)
  @outgoing_queue = outgoing_queue
  log_message("Activating Ruby LSP TypeProf add-on v#{VERSION}")

  load_settings(global_state)
  return unless @enabled

  require "typeprof"
  @service = build_service(global_state.workspace_path)
rescue StandardError => e
  log_error("Ruby LSP TypeProf failed to activate: #{e.full_message(highlight: false)}")
end

#create_code_lens_listener(response_builder, uri, dispatcher) ⇒ Object



48
49
50
51
52
53
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 48

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, @outgoing_queue)
end

#deactivateObject



36
37
38
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 36

def deactivate
  @service = nil
end

#nameObject



40
41
42
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 40

def name
  "TypeProf"
end

#versionObject



44
45
46
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 44

def version
  VERSION
end

#workspace_did_change_watched_files(changes) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 55

def workspace_did_change_watched_files(changes)
  return unless @service

  @mutex.synchronize do
    changes.each { |change| update_changed_file(change) }
  end
end