Class: Browsable::LSP::Diagnostics
- Inherits:
-
Object
- Object
- Browsable::LSP::Diagnostics
- Defined in:
- lib/browsable/lsp/diagnostics.rb
Overview
Audits a single document’s contents and converts the resulting browsable Findings into LSP diagnostic hashes ready for textDocument/publishDiagnostics.
Constant Summary collapse
- SEVERITY =
browsable severity -> LSP DiagnosticSeverity
below_target -> Error (1) baseline_newly_available -> Warning (2) baseline_widely_available -> Information (3) { error: 1, warning: 2, info: 3 }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(uri:, content:, root:) ⇒ Diagnostics
constructor
A new instance of Diagnostics.
Constructor Details
#initialize(uri:, content:, root:) ⇒ Diagnostics
Returns a new instance of Diagnostics.
20 21 22 23 24 |
# File 'lib/browsable/lsp/diagnostics.rb', line 20 def initialize(uri:, content:, root:) @uri = uri @content = content.to_s @root = root end |
Class Method Details
.for(uri:, content:, root: Dir.pwd) ⇒ Object
16 17 18 |
# File 'lib/browsable/lsp/diagnostics.rb', line 16 def self.for(uri:, content:, root: Dir.pwd) new(uri: uri, content: content, root: root).call end |
Instance Method Details
#call ⇒ Object
26 27 28 29 30 31 |
# File 'lib/browsable/lsp/diagnostics.rb', line 26 def call findings.map { |finding| to_diagnostic(finding) } rescue StandardError # A diagnostics pass must never crash the editor session. [] end |