Class: RubyLsp::RuboCop::RuntimeAdapter Private
- Inherits:
-
Object
- Object
- RubyLsp::RuboCop::RuntimeAdapter
- Includes:
- RubyLsp::Requests::Support::Formatter
- 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 ⇒ RuntimeAdapter
constructor
private
A new instance of RuntimeAdapter.
- #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 ⇒ 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.
12 13 14 15 16 |
# File 'lib/ruby_lsp/rubocop/runtime_adapter.rb', line 12 def initialize config_store = ::RuboCop::ConfigStore.new @runtime = ::RuboCop::LSP::Runtime.new(config_store) end |
Instance Method Details
#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.
18 19 20 21 22 23 24 25 |
# File 'lib/ruby_lsp/rubocop/runtime_adapter.rb', line 18 def run_diagnostic(uri, document) @runtime.offenses( uri_to_path(uri), document.source, document.encoding, prism_result: prism_result(document) ) 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.
27 28 29 30 31 32 33 34 |
# File 'lib/ruby_lsp/rubocop/runtime_adapter.rb', line 27 def run_formatting(uri, document) @runtime.format( uri_to_path(uri), document.source, command: 'rubocop.formatAutocorrects', prism_result: prism_result(document) ) 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.
36 37 38 39 40 41 42 |
# File 'lib/ruby_lsp/rubocop/runtime_adapter.rb', line 36 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 |