Class: RuboCop::LSP::Runtime Private
- Inherits:
-
Object
- Object
- RuboCop::LSP::Runtime
- Defined in:
- lib/rubocop/lsp/runtime.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.
Runtime for Language Server Protocol of RuboCop.
Instance Attribute Summary collapse
- #layout_mode ⇒ Object writeonly private
- #lint_mode ⇒ Object writeonly private
- #safe_autocorrect ⇒ Object writeonly private
Instance Method Summary collapse
- #format(path, text, command:) ⇒ Object private
-
#initialize(config_store) ⇒ Runtime
constructor
private
A new instance of Runtime.
- #offenses(path, text, document_encoding = nil) ⇒ Object private
Constructor Details
permalink #initialize(config_store) ⇒ Runtime
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 Runtime.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rubocop/lsp/runtime.rb', line 22 def initialize(config_store) RuboCop::LSP.enable @runner = RuboCop::Lsp::StdinRunner.new(config_store) @cop_registry = RuboCop::Cop::Registry.global.to_h @safe_autocorrect = true @lint_mode = false @layout_mode = false end |
Instance Attribute Details
permalink #layout_mode=(value) ⇒ Object (writeonly)
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.
20 21 22 |
# File 'lib/rubocop/lsp/runtime.rb', line 20 def layout_mode=(value) @layout_mode = value end |
permalink #lint_mode=(value) ⇒ Object (writeonly)
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.
20 21 22 |
# File 'lib/rubocop/lsp/runtime.rb', line 20 def lint_mode=(value) @lint_mode = value end |
permalink #safe_autocorrect=(value) ⇒ Object (writeonly)
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.
20 21 22 |
# File 'lib/rubocop/lsp/runtime.rb', line 20 def safe_autocorrect=(value) @safe_autocorrect = value end |
Instance Method Details
permalink #format(path, text, command:) ⇒ 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.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubocop/lsp/runtime.rb', line 33 def format(path, text, command:) safe_autocorrect = if command command == 'rubocop.formatAutocorrects' else @safe_autocorrect end = { autocorrect: true, safe_autocorrect: safe_autocorrect } [:only] = if @lint_mode || @layout_mode @runner.run(path, text, ) @runner.formatted_source end |
permalink #offenses(path, text, document_encoding = nil) ⇒ 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.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rubocop/lsp/runtime.rb', line 47 def offenses(path, text, document_encoding = nil) = {} [:only] = if @lint_mode || @layout_mode @runner.run(path, text, ) @runner.offenses.map do |offense| Diagnostic.new( document_encoding, offense, path, @cop_registry[offense.cop_name]&.first ).to_lsp_diagnostic(@runner.config_for_working_directory) end end |