Class: LanguageServer::Protocol::Interface::ColorPresentation
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::ColorPresentation
- Defined in:
- lib/language_server/protocol/interface/color_presentation.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#additional_text_edits ⇒ TextEdit[] | nil
An optional array of additional [text edits](#TextEdit) that are applied when selecting this color presentation.
-
#initialize(label:, text_edit: nil, additional_text_edits: nil) ⇒ ColorPresentation
constructor
A new instance of ColorPresentation.
-
#label ⇒ string
The label of this color presentation.
-
#text_edit ⇒ TextEdit | nil
An [edit](#TextEdit) which is applied to a document when selecting this presentation for the color.
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
44 45 46 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 44 def attributes @attributes end |
Instance Method Details
#additional_text_edits ⇒ TextEdit[] | nil
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.
40 41 42 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 40 def additional_text_edits attributes.fetch(:additionalTextEdits) end |
#label ⇒ string
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.
21 22 23 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 21 def label attributes.fetch(:label) end |
#text_edit ⇒ TextEdit | nil
An [edit](#TextEdit) which is applied to a document when selecting this presentation for the color. When falsy the [label](#ColorPresentation.label) is used.
31 32 33 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 31 def text_edit attributes.fetch(:textEdit) end |
#to_hash ⇒ Object
46 47 48 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 46 def to_hash attributes end |
#to_json(*args) ⇒ Object
50 51 52 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 50 def to_json(*args) to_hash.to_json(*args) end |