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:) ⇒ 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] = message

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (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

#codestring | number

The diagnostic’s code. Can be omitted.

Returns:

  • (string | number)


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

def code
  attributes.fetch(:code)
end

#messagestring

The diagnostic’s message.

Returns:

  • (string)


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

def message
  attributes.fetch(:message)
end

#rangeRange

The range at which the message applies.

Returns:



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

def range
  attributes.fetch(:range)
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)


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

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)


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

def source
  attributes.fetch(:source)
end

#to_hashObject



61
62
63
# File 'lib/language_server/protocol/interface/diagnostic.rb', line 61

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



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

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