Class: Mui::Lsp::Protocol::Diagnostic
- Inherits:
-
Object
- Object
- Mui::Lsp::Protocol::Diagnostic
- Defined in:
- lib/mui/lsp/protocol/diagnostic.rb
Overview
LSP Diagnostic (error/warning/info/hint message)
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#message ⇒ Object
Returns the value of attribute message.
-
#range ⇒ Object
Returns the value of attribute range.
-
#related_information ⇒ Object
Returns the value of attribute related_information.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#source ⇒ Object
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #error? ⇒ Boolean
- #hint? ⇒ Boolean
- #information? ⇒ Boolean
-
#initialize(range:, message:, severity: nil, code: nil, source: nil, related_information: nil) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
- #severity_name ⇒ Object
- #to_h ⇒ Object
- #warning? ⇒ Boolean
Constructor Details
#initialize(range:, message:, severity: nil, code: nil, source: nil, related_information: nil) ⇒ Diagnostic
Returns a new instance of Diagnostic.
18 19 20 21 22 23 24 25 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 18 def initialize(range:, message:, severity: nil, code: nil, source: nil, related_information: nil) @range = range.is_a?(Range) ? range : Range.from_hash(range) = @severity = severity @code = code @source = source = end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
16 17 18 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 16 def code @code end |
#message ⇒ Object
Returns the value of attribute message.
16 17 18 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 16 def end |
#range ⇒ Object
Returns the value of attribute range.
16 17 18 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 16 def range @range end |
#related_information ⇒ Object
Returns the value of attribute related_information.
16 17 18 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 16 def end |
#severity ⇒ Object
Returns the value of attribute severity.
16 17 18 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 16 def severity @severity end |
#source ⇒ Object
Returns the value of attribute source.
16 17 18 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 16 def source @source end |
Class Method Details
.from_hash(hash) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 39 def self.from_hash(hash) new( range: hash["range"] || hash[:range], message: hash["message"] || hash[:message], severity: hash["severity"] || hash[:severity], code: hash["code"] || hash[:code], source: hash["source"] || hash[:source], related_information: hash["relatedInformation"] || hash[:relatedInformation] ) end |
Instance Method Details
#==(other) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 76 def ==(other) return false unless other.is_a?(Diagnostic) @range == other.range && == other. && @severity == other.severity && @code == other.code && @source == other.source end |
#error? ⇒ Boolean
50 51 52 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 50 def error? @severity == DiagnosticSeverity::ERROR end |
#hint? ⇒ Boolean
62 63 64 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 62 def hint? @severity == DiagnosticSeverity::HINT end |
#information? ⇒ Boolean
58 59 60 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 58 def information? @severity == DiagnosticSeverity::INFORMATION end |
#severity_name ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 66 def severity_name case @severity when DiagnosticSeverity::ERROR then "Error" when DiagnosticSeverity::WARNING then "Warning" when DiagnosticSeverity::INFORMATION then "Information" when DiagnosticSeverity::HINT then "Hint" else "Unknown" end end |
#to_h ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 27 def to_h result = { range: @range.to_h, message: } result[:severity] = @severity if @severity result[:code] = @code if @code result[:source] = @source if @source result[:relatedInformation] = if result end |
#warning? ⇒ Boolean
54 55 56 |
# File 'lib/mui/lsp/protocol/diagnostic.rb', line 54 def warning? @severity == DiagnosticSeverity::WARNING end |