Class: LanguageServer::Protocol::Interface::Diagnostic
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::Diagnostic
- Defined in:
- lib/language_server/protocol/interface/diagnostic.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#code ⇒ string | number
The diagnostic’s code.
-
#initialize(range:, severity: nil, code: nil, source: nil, message:) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
-
#message ⇒ string
The diagnostic’s message.
-
#range ⇒ Range
The range at which the message applies.
-
#severity ⇒ number
The diagnostic’s severity.
-
#source ⇒ string
A human-readable string describing the source of this diagnostic, e.g.
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(range:, severity: nil, code: nil, source: nil, message:) ⇒ Diagnostic
Returns a new instance of Diagnostic.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 5 def initialize(range:, severity: nil, code: nil, source: nil, message:) @attributes = {} @attributes[:range] = range @attributes[:severity] = severity if severity @attributes[:code] = code if code @attributes[:source] = source if source @attributes[:message] = @attributes.freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
59 60 61 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 59 def attributes @attributes end |
Instance Method Details
#code ⇒ string | number
The diagnostic’s code. Can be omitted.
38 39 40 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 38 def code attributes.fetch(:code) end |
#message ⇒ string
The diagnostic’s message.
55 56 57 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 55 def attributes.fetch(:message) end |
#range ⇒ Range
The range at which the message applies.
21 22 23 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 21 def range attributes.fetch(:range) end |
#severity ⇒ number
The diagnostic’s severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error, warning, info or hint.
30 31 32 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 30 def severity attributes.fetch(:severity) end |
#source ⇒ string
A human-readable string describing the source of this diagnostic, e.g. ‘typescript’ or ‘super lint’.
47 48 49 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 47 def source attributes.fetch(:source) end |
#to_json(*args) ⇒ Object
61 62 63 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 61 def to_json(*args) attributes.to_json(*args) end |