Class: RuboCop::LSP::Diagnostic Private
- Inherits:
-
Object
- Object
- RuboCop::LSP::Diagnostic
- Defined in:
- lib/rubocop/lsp/diagnostic.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.
Diagnostic for Language Server Protocol of RuboCop.
Instance Method Summary collapse
-
#initialize(document_encoding, offense, uri, cop_class) ⇒ Diagnostic
constructor
private
A new instance of Diagnostic.
- #to_lsp_code_actions ⇒ Object private
-
#to_lsp_diagnostic(config) ⇒ Object
private
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Constructor Details
#initialize(document_encoding, offense, uri, cop_class) ⇒ Diagnostic
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 Diagnostic.
19 20 21 22 23 24 |
# File 'lib/rubocop/lsp/diagnostic.rb', line 19 def initialize(document_encoding, offense, uri, cop_class) @document_encoding = document_encoding @offense = offense @uri = uri @cop_class = cop_class end |
Instance Method Details
#to_lsp_code_actions ⇒ 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.
26 27 28 29 30 31 32 33 |
# File 'lib/rubocop/lsp/diagnostic.rb', line 26 def to_lsp_code_actions code_actions = [] code_actions << autocorrect_action if correctable? code_actions << disable_line_action code_actions end |
#to_lsp_diagnostic(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.
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rubocop/lsp/diagnostic.rb', line 36 def to_lsp_diagnostic(config) highlighted = @offense.highlighted_area LanguageServer::Protocol::Interface::Diagnostic.new( message: , source: 'RuboCop', code: @offense.cop_name, code_description: code_description(config), severity: severity, range: LanguageServer::Protocol::Interface::Range.new( start: LanguageServer::Protocol::Interface::Position.new( line: @offense.line - 1, character: highlighted.begin_pos ), end: LanguageServer::Protocol::Interface::Position.new( line: @offense.line - 1, character: highlighted.end_pos ) ), data: { correctable: correctable?, code_actions: to_lsp_code_actions } ) end |