Class: RubyLsp::Requests::Diagnostics

Inherits:
RuboCopRequest
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/ruby_lsp/requests/diagnostics.rb

Overview

The [diagnostics](microsoft.github.io/language-server-protocol/specification#textDocument_publishDiagnostics) request informs the editor of RuboCop offenses for a given file.

# Example

“‘ruby def say_hello puts “Hello” # –> diagnostics: incorrect indentantion end “`

Constant Summary

Constants inherited from RuboCopRequest

RuboCopRequest::COMMON_RUBOCOP_FLAGS

Instance Attribute Summary

Attributes inherited from RuboCopRequest

#file, #text

Instance Method Summary collapse

Methods inherited from RuboCopRequest

#initialize

Constructor Details

This class inherits a constructor from RubyLsp::Requests::RuboCopRequest

Instance Method Details

#file_finished(_file, offenses) ⇒ Object



37
38
39
# File 'lib/ruby_lsp/requests/diagnostics.rb', line 37

def file_finished(_file, offenses)
  @diagnostics = offenses.map { |offense| Support::RuboCopDiagnostic.new(offense, @uri) }
end

#runObject



28
29
30
31
32
33
34
# File 'lib/ruby_lsp/requests/diagnostics.rb', line 28

def run
  return syntax_error_diagnostics if @document.syntax_errors?

  super

  @diagnostics
end