Sha256: 4ddc04ce9f97fc1c0444f985fbc700ab9482b02b3ca9d2870b099fb284c75a28

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

module LanguageServer
  module Protocol
    module Interface
      #
      # An event describing a change to a text document. If range and rangeLength are
      # omitted the new text is considered to be the full content of the document.
      #
      class TextDocumentContentChangeEvent
        def initialize(range: nil, range_length: nil, text:)
          @attributes = {}

          @attributes[:range] = range if range
          @attributes[:rangeLength] = range_length if range_length
          @attributes[:text] = text

          @attributes.freeze
        end

        #
        # The range of the document that changed.
        #
        # @return [Range, nil]
        def range
          attributes.fetch(:range)
        end

        #
        # The optional length of the range that got replaced.
        #
        # @return [number, nil]
        def range_length
          attributes.fetch(:rangeLength)
        end

        #
        # The new text for the provided range.
        #
        # --- OR ---
        #
        # The new text of the whole document.
        #
        # @return [string]
        def text
          attributes.fetch(:text)
        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/text_document_content_change_event.rb
language_server-protocol-3.16.0.2 lib/language_server/protocol/interface/text_document_content_change_event.rb
language_server-protocol-3.16.0.1 lib/language_server/protocol/interface/text_document_content_change_event.rb
language_server-protocol-3.16.0.0 lib/language_server/protocol/interface/text_document_content_change_event.rb