Class: LanguageServer::Protocol::Interface::DocumentHighlight

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

Overview

A document highlight is a range inside a text document which deserves special attention. Usually a document highlight is visualized by changing the background color of its range.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(range:, kind: nil) ⇒ DocumentHighlight

Returns a new instance of DocumentHighlight.



10
11
12
13
14
15
16
17
# File 'lib/language_server/protocol/interface/document_highlight.rb', line 10

def initialize(range:, kind: nil)
  @attributes = {}

  @attributes[:range] = range
  @attributes[:kind] = kind if kind

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



35
36
37
# File 'lib/language_server/protocol/interface/document_highlight.rb', line 35

def attributes
  @attributes
end

Instance Method Details

#kindDocumentHighlightKind

The highlight kind, default is DocumentHighlightKind.Text.

Returns:

  • (DocumentHighlightKind)


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

def kind
  attributes.fetch(:kind)
end

#rangeRange

The range this highlight applies to.

Returns:



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

def range
  attributes.fetch(:range)
end

#to_hashObject



37
38
39
# File 'lib/language_server/protocol/interface/document_highlight.rb', line 37

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



41
42
43
# File 'lib/language_server/protocol/interface/document_highlight.rb', line 41

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