Class: LanguageServer::Protocol::Interface::TextDocumentContentChangeEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/text_document_content_change_event.rb,
sig/language_server/protocol/interface/text_document_content_change_event.rbs

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(range: nil, range_length: nil, text:) ⇒ TextDocumentContentChangeEvent

Returns a new instance of TextDocumentContentChangeEvent.

Parameters:

  • range: (Object) (defaults to: nil)
  • range_length: (Integer) (defaults to: nil)
  • text: (String)


9
10
11
12
13
14
15
16
17
# File 'lib/language_server/protocol/interface/text_document_content_change_event.rb', line 9

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

Instance Attribute Details

#attributesHash[Symbol, untyped] (readonly)

Returns the value of attribute attributes.

Returns:

  • (Hash[Symbol, untyped])


49
50
51
# File 'lib/language_server/protocol/interface/text_document_content_change_event.rb', line 49

def attributes
  @attributes
end

Instance Method Details

#rangeRange

The range of the document that changed.

Returns:



23
24
25
# File 'lib/language_server/protocol/interface/text_document_content_change_event.rb', line 23

def range
  attributes.fetch(:range)
end

#range_lengthuinteger

Deprecated.

use range instead.

The optional length of the range that got replaced.

Returns:

  • (uinteger)


33
34
35
# File 'lib/language_server/protocol/interface/text_document_content_change_event.rb', line 33

def range_length
  attributes.fetch(:rangeLength)
end

#textstring

The new text for the provided range.

--- OR ---

The new text of the whole document.

Returns:

  • (string)


45
46
47
# File 'lib/language_server/protocol/interface/text_document_content_change_event.rb', line 45

def text
  attributes.fetch(:text)
end

#to_hashHash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


51
52
53
# File 'lib/language_server/protocol/interface/text_document_content_change_event.rb', line 51

def to_hash
  attributes
end

#to_json(*args) ⇒ String

Parameters:

  • (Object)

Returns:

  • (String)


55
56
57
# File 'lib/language_server/protocol/interface/text_document_content_change_event.rb', line 55

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