Class: LanguageServer::Protocol::Interface::Diagnostic

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/diagnostic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(range:, severity: nil, code: nil, source: nil, message:, tags: nil, related_information: nil) ⇒ Diagnostic

Returns a new instance of Diagnostic.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 5

def initialize(range:, severity: nil, code: nil, source: nil, message:, tags: nil, related_information: nil)
  @attributes = {}

  @attributes[:range] = range
  @attributes[:severity] = severity if severity
  @attributes[:code] = code if code
  @attributes[:source] = source if source
  @attributes[:message] = message
  @attributes[:tags] = tags if tags
  @attributes[:relatedInformation] = related_information if related_information

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



78
79
80
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 78

def attributes
  @attributes
end

Instance Method Details

#codestring | number

The diagnostic’s code, which might appear in the user interface.

Returns:

  • (string | number)


40
41
42
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 40

def code
  attributes.fetch(:code)
end

#messagestring

The diagnostic’s message.

Returns:

  • (string)


57
58
59
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 57

def message
  attributes.fetch(:message)
end

#rangeRange

The range at which the message applies.

Returns:



23
24
25
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 23

def range
  attributes.fetch(:range)
end

An array of related diagnostic information, e.g. when symbol-names within a scope collide all definitions can be marked via this property.



74
75
76
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 74

def related_information
  attributes.fetch(:relatedInformation)
end

#severityDiagnosticSeverity

The diagnostic’s severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error, warning, info or hint.

Returns:

  • (DiagnosticSeverity)


32
33
34
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 32

def severity
  attributes.fetch(:severity)
end

#sourcestring

A human-readable string describing the source of this diagnostic, e.g. ‘typescript’ or ‘super lint’.

Returns:

  • (string)


49
50
51
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 49

def source
  attributes.fetch(:source)
end

#tagsDiagnosticTag[]

Additional metadata about the diagnostic.

Returns:

  • (DiagnosticTag[])


65
66
67
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 65

def tags
  attributes.fetch(:tags)
end

#to_hashObject



80
81
82
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 80

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



84
85
86
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 84

def to_json(*args)
  to_hash.to_json(*args)
end