Class: LanguageServer::Protocol::Interface::ColorPresentation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, text_edit: nil, additional_text_edits: nil) ⇒ ColorPresentation

Returns a new instance of ColorPresentation.



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

def initialize(label:, text_edit: nil, additional_text_edits: nil)
  @attributes = {}

  @attributes[:label] = label
  @attributes[:textEdit] = text_edit if text_edit
  @attributes[:additionalTextEdits] = additional_text_edits if additional_text_edits

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



45
46
47
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 45

def attributes
  @attributes
end

Instance Method Details

#additional_text_editsTextEdit[]

An optional array of additional [text edits](#TextEdit) that are applied when selecting this color presentation. Edits must not overlap with the main [edit](#ColorPresentation.textEdit) nor with themselves.

Returns:



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

def additional_text_edits
  attributes.fetch(:additionalTextEdits)
end

#labelstring

The label of this color presentation. It will be shown on the color picker header. By default this is also the text that is inserted when selecting this color presentation.

Returns:

  • (string)


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

def label
  attributes.fetch(:label)
end

#text_editTextEdit

An [edit](#TextEdit) which is applied to a document when selecting this presentation for the color. When ‘falsy` the [label](#ColorPresentation.label) is used.

Returns:



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

def text_edit
  attributes.fetch(:textEdit)
end

#to_hashObject



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

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



51
52
53
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 51

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