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, which might appear in the user interface.
-
#code_description ⇒ CodeDescription
An optional property to describe the error code.
-
#data ⇒ unknown
A data entry field that is preserved between a ‘textDocument/publishDiagnostics` notification and `textDocument/codeAction` request.
-
#initialize(range:, severity: nil, code: nil, code_description: nil, source: nil, message:, tags: nil, related_information: nil, data: nil) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
-
#message ⇒ string
The diagnostic’s message.
-
#range ⇒ Range
The range at which the message applies.
-
#related_information ⇒ DiagnosticRelatedInformation[]
An array of related diagnostic information, e.g.
-
#severity ⇒ DiagnosticSeverity
The diagnostic’s severity.
-
#source ⇒ string
A human-readable string describing the source of this diagnostic, e.g.
-
#tags ⇒ DiagnosticTag[]
Additional metadata about the diagnostic.
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(range:, severity: nil, code: nil, code_description: nil, source: nil, message:, tags: nil, related_information: nil, data: nil) ⇒ Diagnostic
Returns a new instance of Diagnostic.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 5 def initialize(range:, severity: nil, code: nil, code_description: nil, source: nil, message:, tags: nil, related_information: nil, data: nil) @attributes = {} @attributes[:range] = range @attributes[:severity] = severity if severity @attributes[:code] = code if code @attributes[:codeDescription] = code_description if code_description @attributes[:source] = source if source @attributes[:message] = @attributes[:tags] = if @attributes[:relatedInformation] = if @attributes[:data] = data if data @attributes.freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
98 99 100 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 98 def attributes @attributes end |
Instance Method Details
#code ⇒ string | number
The diagnostic’s code, which might appear in the user interface.
42 43 44 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 42 def code attributes.fetch(:code) end |
#code_description ⇒ CodeDescription
An optional property to describe the error code.
50 51 52 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 50 def code_description attributes.fetch(:codeDescription) end |
#data ⇒ unknown
A data entry field that is preserved between a ‘textDocument/publishDiagnostics` notification and `textDocument/codeAction` request.
94 95 96 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 94 def data attributes.fetch(:data) end |
#message ⇒ string
The diagnostic’s message.
67 68 69 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 67 def attributes.fetch(:message) end |
#range ⇒ Range
The range at which the message applies.
25 26 27 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 25 def range attributes.fetch(:range) end |
#related_information ⇒ DiagnosticRelatedInformation[]
An array of related diagnostic information, e.g. when symbol-names within a scope collide all definitions can be marked via this property.
84 85 86 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 84 def attributes.fetch(:relatedInformation) end |
#severity ⇒ DiagnosticSeverity
The diagnostic’s severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error, warning, info or hint.
34 35 36 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 34 def severity attributes.fetch(:severity) end |
#source ⇒ string
A human-readable string describing the source of this diagnostic, e.g. ‘typescript’ or ‘super lint’.
59 60 61 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 59 def source attributes.fetch(:source) end |
#tags ⇒ DiagnosticTag[]
Additional metadata about the diagnostic.
75 76 77 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 75 def attributes.fetch(:tags) end |
#to_hash ⇒ Object
100 101 102 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 100 def to_hash attributes end |
#to_json(*args) ⇒ Object
104 105 106 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 104 def to_json(*args) to_hash.to_json(*args) end |