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:, related_information: nil) ⇒ Diagnostic

Returns a new instance of Diagnostic.



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

def initialize(range:, severity: nil, code: nil, source: nil, message:, 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[:relatedInformation] = related_information if related_information

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



69
70
71
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 69

def attributes
  @attributes
end

Instance Method Details

#codestring | number

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

Returns:

  • (string | number)


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

def code
  attributes.fetch(:code)
end

#messagestring

The diagnostic’s message.

Returns:

  • (string)


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

def message
  attributes.fetch(:message)
end

#rangeRange

The range at which the message applies.

Returns:



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

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.



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

def related_information
  attributes.fetch(:relatedInformation)
end

#severitynumber

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:

  • (number)


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

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)


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

def source
  attributes.fetch(:source)
end

#to_hashObject



71
72
73
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 71

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



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

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