Sha256: 6dd60bca605cc0d18ab163a4ad456e26c236fa2fa4add922b0e24e1ad479a691

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 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]
        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_hash
          attributes
        end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
language_server-protocol-3.14.0.2 lib/language_server/protocol/interface/text_document_content_change_event.rb
language_server-protocol-3.14.0.1 lib/language_server/protocol/interface/text_document_content_change_event.rb
language_server-protocol-3.14.0.0 lib/language_server/protocol/interface/text_document_content_change_event.rb
language_server-protocol-3.12.0.0 lib/language_server/protocol/interface/text_document_content_change_event.rb
language_server-protocol-3.7.0.0 lib/language_server/protocol/interface/text_document_content_change_event.rb
language_server-protocol-0.5.0 lib/language_server/protocol/interface/text_document_content_change_event.rb