Class: LanguageServer::Protocol::Interface::Diagnostic
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::Diagnostic
- Defined in:
- lib/language_server/protocol/interface/diagnostic.rb
Overview
Represents a diagnostic, such as a compiler error or warning. Diagnostic objects are only valid in the scope of a resource.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#code ⇒ integer | string | nil
The diagnostic’s code, which usually appear in the user interface.
-
#code_description ⇒ CodeDescription | nil
An optional property to describe the error code.
-
#data ⇒ LSPAny | nil
A data entry field that is preserved between a
textDocument/publishDiagnosticsnotification andtextDocument/codeActionrequest. -
#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[] | nil
An array of related diagnostic information, e.g.
-
#severity ⇒ DiagnosticSeverity | nil
The diagnostic’s severity.
-
#source ⇒ string | nil
A human-readable string describing the source of this diagnostic, e.g.
-
#tags ⇒ DiagnosticTag[] | nil
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.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 9 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.
109 110 111 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 109 def attributes @attributes end |
Instance Method Details
#code ⇒ integer | string | nil
The diagnostic’s code, which usually appear in the user interface.
46 47 48 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 46 def code attributes.fetch(:code) end |
#code_description ⇒ CodeDescription | nil
An optional property to describe the error code. Requires the code field (above) to be present/not null.
57 58 59 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 57 def code_description attributes.fetch(:codeDescription) end |
#data ⇒ LSPAny | nil
A data entry field that is preserved between a textDocument/publishDiagnostics notification and textDocument/codeAction request.
105 106 107 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 105 def data attributes.fetch(:data) end |
#message ⇒ string
The diagnostic’s message. It usually appears in the user interface
75 76 77 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 75 def attributes.fetch(:message) end |
#range ⇒ Range
The range at which the message applies
29 30 31 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 29 def range attributes.fetch(:range) end |
#related_information ⇒ DiagnosticRelatedInformation[] | nil
An array of related diagnostic information, e.g. when symbol-names within a scope collide all definitions can be marked via this property.
94 95 96 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 94 def attributes.fetch(:relatedInformation) end |
#severity ⇒ DiagnosticSeverity | nil
The diagnostic’s severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error, warning, info or hint.
38 39 40 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 38 def severity attributes.fetch(:severity) end |
#source ⇒ string | nil
A human-readable string describing the source of this diagnostic, e.g. ‘typescript’ or ‘super lint’. It usually appears in the user interface.
67 68 69 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 67 def source attributes.fetch(:source) end |
#tags ⇒ DiagnosticTag[] | nil
Additional metadata about the diagnostic.
85 86 87 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 85 def attributes.fetch(:tags) end |
#to_hash ⇒ Object
111 112 113 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 111 def to_hash attributes end |
#to_json(*args) ⇒ Object
115 116 117 |
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 115 def to_json(*args) to_hash.to_json(*args) end |