Class: RubyLsp::Typeprof::Addon

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

Instance Method Summary collapse

Constructor Details

#initializeAddon

Returns a new instance of Addon.



12
13
14
15
16
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 12

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

Instance Method Details

#activate(global_state, _outgoing_queue) ⇒ Object



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

def activate(global_state, _outgoing_queue)
  require "typeprof"

  @service = build_service(global_state.workspace_path)
rescue StandardError => e
  warn "ruby-lsp-typeprof: Failed to activate: #{e.message}"
end

#create_code_lens_listener(response_builder, uri, dispatcher) ⇒ Object



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

def create_code_lens_listener(response_builder, uri, dispatcher)
  return unless @service

  CodeLensListener.new(response_builder, uri, dispatcher, @service, @mutex)
end

#deactivateObject



26
27
28
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 26

def deactivate
  @service = nil
end

#nameObject



30
31
32
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 30

def name
  "TypeProf"
end

#versionObject



34
35
36
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 34

def version
  VERSION
end

#workspace_did_change_watched_files(changes) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/ruby_lsp/ruby_lsp_typeprof/addon.rb', line 44

def workspace_did_change_watched_files(changes)
  return unless @service

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