Class: RubyLsp::RuboCop::WrapsBuiltinLspRuntime
- Inherits:
-
Object
- Object
- RubyLsp::RuboCop::WrapsBuiltinLspRuntime
- Includes:
- RubyLsp::Requests::Support::Formatter
- Defined in:
- lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb
Overview
Wrap RuboCop’s built-in runtime for Ruby LSP’s add-on.
Instance Method Summary collapse
- #init! ⇒ Object
-
#initialize ⇒ WrapsBuiltinLspRuntime
constructor
A new instance of WrapsBuiltinLspRuntime.
- #run_diagnostic(uri, document) ⇒ Object
- #run_formatting(uri, document) ⇒ Object
- #run_range_formatting(_uri, _partial_source, _base_indentation) ⇒ Object
Constructor Details
#initialize ⇒ WrapsBuiltinLspRuntime
Returns a new instance of WrapsBuiltinLspRuntime.
11 12 13 |
# File 'lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb', line 11 def initialize init! end |
Instance Method Details
#init! ⇒ Object
15 16 17 18 19 |
# File 'lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb', line 15 def init! config = ::RuboCop::ConfigStore.new @runtime = ::RuboCop::LSP::Runtime.new(config) end |
#run_diagnostic(uri, document) ⇒ Object
21 22 23 |
# File 'lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb', line 21 def run_diagnostic(uri, document) @runtime.offenses(uri_to_path(uri), document.source, document.encoding) end |
#run_formatting(uri, document) ⇒ Object
25 26 27 |
# File 'lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb', line 25 def run_formatting(uri, document) @runtime.format(uri_to_path(uri), document.source, command: 'rubocop.formatAutocorrects') end |
#run_range_formatting(_uri, _partial_source, _base_indentation) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb', line 29 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 |