Sha256: c369280c0795b540a87b81671d57362b87e53d05a7cedb54094cd09aa380729c

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

module LanguageServer
  module Protocol
    module Interfaces
      #
      # 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]
        def range
          attributes.fetch(:range)
        end

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

        #
        # The new text of the range/document.
        #
        # @return [string]
        def text
          attributes.fetch(:text)
        end

        attr_reader :attributes

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

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
language_server-protocol-0.2.0 lib/language_server/protocol/interfaces/text_document_content_change_event.rb
language_server-protocol-0.1.0 lib/language_server/protocol/interfaces/text_document_content_change_event.rb
language_server-0.4.0 lib/language_server/protocol/interfaces/text_document_content_change_event.rb
language_server-0.3.1 lib/language_server/protocol/interfaces/text_document_content_change_event.rb
language_server-0.3.0 lib/language_server/protocol/interfaces/text_document_content_change_event.rb
language_server-0.2.0 lib/language_server/protocol/interfaces/text_document_content_change_event.rb
language_server-0.1.0 lib/language_server/protocol/interfaces/text_document_content_change_event.rb