Sha256: 7fcab61d0eb6f449bea51d9fd945e2a7f1e424bcd43cc79e5b1e4ebcc25dc136

Contents?: true

Size: 1.59 KB

Versions: 4

Compression:

Stored size: 1.59 KB

Contents

module LanguageServer
  module Protocol
    module Interface
      class ColorPresentation
        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

        #
        # 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.
        #
        # @return [string]
        def label
          attributes.fetch(:label)
        end

        #
        # An [edit](#TextEdit) which is applied to a document when selecting
        # this presentation for the color.  When `falsy` the
        # [label](#ColorPresentation.label) is used.
        #
        # @return [TextEdit]
        def text_edit
          attributes.fetch(:textEdit)
        end

        #
        # 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.
        #
        # @return [TextEdit[]]
        def additional_text_edits
          attributes.fetch(:additionalTextEdits)
        end

        attr_reader :attributes

        def to_hash
          attributes
        end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
language_server-protocol-3.16.0.3 lib/language_server/protocol/interface/color_presentation.rb
language_server-protocol-3.16.0.2 lib/language_server/protocol/interface/color_presentation.rb
language_server-protocol-3.16.0.1 lib/language_server/protocol/interface/color_presentation.rb
language_server-protocol-3.16.0.0 lib/language_server/protocol/interface/color_presentation.rb