Class: LanguageServer::Protocol::Interface::Range

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/range.rb

Overview

A range in a text document expressed as (zero-based) start and end positions.

If you want to specify a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line. For example: “‘ts {

start: { line: 5, character: 23 }
end : { line 6, character : 0 }

} “‘

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start:, end:) ⇒ Range

Returns a new instance of Range.



18
19
20
21
22
23
24
25
# File 'lib/language_server/protocol/interface/range.rb', line 18

def initialize(start:, end:)
  @attributes = {}

  @attributes[:start] = start
  @attributes[:end] = binding.local_variable_get(:end)

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



43
44
45
# File 'lib/language_server/protocol/interface/range.rb', line 43

def attributes
  @attributes
end

Instance Method Details

#endPosition

The range’s end position.

Returns:



39
40
41
# File 'lib/language_server/protocol/interface/range.rb', line 39

def end
  attributes.fetch(:end)
end

#startPosition

The range’s start position.

Returns:



31
32
33
# File 'lib/language_server/protocol/interface/range.rb', line 31

def start
  attributes.fetch(:start)
end

#to_hashObject



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

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



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

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