Class: RubyLsp::Requests::Diagnostics
- Inherits:
-
BaseRequest
- Object
- SyntaxTree::Visitor
- BaseRequest
- RubyLsp::Requests::Diagnostics
- 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 indentation end “`
Instance Method Summary collapse
-
#initialize(document) ⇒ Diagnostics
constructor
A new instance of Diagnostics.
- #run ⇒ Object
Methods inherited from BaseRequest
Methods included from Support::Common
#create_code_lens, #full_constant_name, #range_from_syntax_tree_node, #visible?
Constructor Details
permalink #initialize(document) ⇒ Diagnostics
Returns a new instance of Diagnostics.
25 26 27 28 29 |
# File 'lib/ruby_lsp/requests/diagnostics.rb', line 25 def initialize(document) super(document) @uri = T.let(document.uri, String) end |
Instance Method Details
permalink #run ⇒ Object
[View source]
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ruby_lsp/requests/diagnostics.rb', line 32 def run # Running RuboCop is slow, so to avoid excessive runs we only do so if the file is syntactically valid return if @document.syntax_error? return unless defined?(Support::RuboCopDiagnosticsRunner) # Don't try to run RuboCop diagnostics for files outside the current working directory return unless URI(@uri).path&.start_with?(T.must(WORKSPACE_URI.path)) Support::RuboCopDiagnosticsRunner.instance.run(@uri, @document) end |