Class: RubyLsp::RuboCop::WrapsBuiltinLspRuntime
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
RubyLsp::Requests::Support::Formatter
|
|
Inherits: | Object |
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.
Class Method Summary
- .new ⇒ WrapsBuiltinLspRuntime constructor
Instance Method Summary
- #init!
- #run_diagnostic(uri, document)
- #run_formatting(uri, document)
- #run_range_formatting(_uri, _partial_source, _base_indentation)
-
#uri_to_path(uri)
private
duplicated from: lib/standard/lsp/routes.rb modified to incorporate Ruby LSP’s to_standardized_path method.
Constructor Details
.new ⇒ WrapsBuiltinLspRuntime
# File 'lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb', line 11
def initialize init! end
Instance Method Details
#init!
[ GitHub ]#run_diagnostic(uri, document)
[ GitHub ]# 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)
[ GitHub ]# 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)
[ GitHub ]# 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
#uri_to_path(uri) (private)
duplicated from: lib/standard/lsp/routes.rb modified to incorporate Ruby LSP’s to_standardized_path method
# File 'lib/ruby_lsp/rubocop/wraps_built_in_lsp_runtime.rb', line 41
def uri_to_path(uri) if uri.respond_to?(:to_standardized_path) && (standardized_path = uri.to_standardized_path) standardized_path else uri.to_s.delete_prefix('file://') end end