1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
module LanguageServer
module Protocol
module Interface
#
# An event describing a change to a text document. If only a text is provided
# it 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
|