Class: Rubydex::Linter::RubyLsp::Addon

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

Constant Summary collapse

CONFIGURATION_FILE =

: String

"rubydex.toml"

Instance Method Summary collapse

Instance Method Details

#activate(global_state, outgoing_queue) ⇒ Object

: (::RubyLsp::GlobalState, Thread::Queue) -> void



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ruby_lsp/rubydex/addon.rb', line 31

def activate(global_state, outgoing_queue)
  @outgoing_queue = outgoing_queue #: Thread::Queue?

  @linter = Linter.new(global_state) #: Linter?


  global_state.register_formatter(
    "rubydex",
    @linter, #: as !nil

  )

  register_additional_file_watchers(global_state, outgoing_queue)
end

#deactivateObject

: () -> void



45
# File 'lib/ruby_lsp/rubydex/addon.rb', line 45

def deactivate; end

#nameObject

: () -> String



19
20
21
# File 'lib/ruby_lsp/rubydex/addon.rb', line 19

def name
  "Rubydex Linter"
end

#versionObject

: () -> String



25
26
27
# File 'lib/ruby_lsp/rubydex/addon.rb', line 25

def version
  ::Rubydex::VERSION
end

#workspace_did_change_watched_files(changes) ⇒ Object

: (Array[{ uri: String, type: Integer }]) -> void



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ruby_lsp/rubydex/addon.rb', line 48

def workspace_did_change_watched_files(changes)
  return unless @linter && @outgoing_queue

  @linter.reload_configuration if changes.any? { |change| configuration_change?(change) }
  @linter.lint!

  @linter.diagnostics_to_clear.each do |uri|
    @outgoing_queue << ::RubyLsp::Notification.publish_diagnostics(uri, [])
  end

  @linter.current_diagnostics.each do |uri, diagnostics|
    @outgoing_queue << ::RubyLsp::Notification.publish_diagnostics(uri, diagnostics)
  end
end