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

#initialize ⇒ Addon

Returns a new instance of Addon.



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

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

Instance Method Details

#activate(global_state, outgoing_queue) ⇒ Object



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

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 = with_utf8_default_external { 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



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

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

#create_document_symbol_listener(response_builder, dispatcher) ⇒ Object



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

def create_document_symbol_listener(response_builder, dispatcher)
  return unless @service
  return unless @document_symbol_enabled

  DocumentSymbolListener.new(response_builder, dispatcher, @service, @mutex, @outgoing_queue)
end

#deactivate ⇒ Object



38
39
40
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 38

def deactivate
  @service = nil
end

#name ⇒ Object



42
43
44
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 42

def name
  "TypeProf"
end

#version ⇒ Object



46
47
48
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 46

def version
  VERSION
end

#workspace_did_change_watched_files(changes) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 64

def workspace_did_change_watched_files(changes)
  return unless @service

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