Class: RubyLsp::RuboCop::RuntimeAdapter Private
- Inherits:
-
Object
- Object
- RubyLsp::RuboCop::RuntimeAdapter
- Defined in:
- lib/ruby_lsp/rubocop/runtime_adapter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides an adapter to bridge RuboCop’s built-in LSP runtime with Ruby LSP’s add-on.
Instance Method Summary collapse
-
#initialize(message_queue) ⇒ RuntimeAdapter
constructor
private
A new instance of RuntimeAdapter.
- #reload_config ⇒ Object private
- #run_diagnostic(uri, document) ⇒ Object private
- #run_formatting(uri, document) ⇒ Object private
- #run_range_formatting(_uri, _partial_source, _base_indentation) ⇒ Object private
Constructor Details
#initialize(message_queue) ⇒ RuntimeAdapter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RuntimeAdapter.
10 11 12 13 |
# File 'lib/ruby_lsp/rubocop/runtime_adapter.rb', line 10 def initialize() @message_queue = reload_config end |
Instance Method Details
#reload_config ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby_lsp/rubocop/runtime_adapter.rb', line 15 def reload_config @runtime = nil , _paths = ::RuboCop::Options.new.parse([]) config_store = ::RuboCop::ConfigStore.new config_store.() @runtime = ::RuboCop::LSP::Runtime.new(config_store) rescue ::RuboCop::Error => e @message_queue << Notification.( "RuboCop configuration error: #{e.}. Formatting will not be available.", type: Constant::MessageType::ERROR ) end |
#run_diagnostic(uri, document) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruby_lsp/rubocop/runtime_adapter.rb', line 29 def run_diagnostic(uri, document) with_error_handling do @runtime.offenses( uri_to_path(uri), document.source, document.encoding, prism_result: prism_result(document) ) end end |
#run_formatting(uri, document) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ruby_lsp/rubocop/runtime_adapter.rb', line 40 def run_formatting(uri, document) with_error_handling do @runtime.format( uri_to_path(uri), document.source, command: 'rubocop.formatAutocorrects', prism_result: prism_result(document) ) end end |
#run_range_formatting(_uri, _partial_source, _base_indentation) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 54 55 56 57 |
# File 'lib/ruby_lsp/rubocop/runtime_adapter.rb', line 51 def run_range_formatting(_uri, _partial_source, _base_indentation) # Not yet supported. Should return the formatted version of `partial_source` which is # a partial selection of the entire document. For example, it should not try to add # a frozen_string_literal magic comment and all style corrections should start from # the `base_indentation`. nil end |