class RubyLsp::Document::Utf32Scanner

For the UTF-32 encoding, positions correspond directly to codepoints

def find_char_position(position)

: (Hash[Symbol, untyped] position) -> Integer
@override
def find_char_position(position)
  # Find the character index for the beginning of the requested line
  until @current_line == position[:line]
    codepoint = @codepoints[@pos] #: Integer?
    raise InvalidLocationError unless codepoint
    until LINE_BREAK == @codepoints[@pos]
      @pos += 1
      codepoint = @codepoints[@pos] #: Integer?
      raise InvalidLocationError unless codepoint
    end
    @pos += 1
    @current_line += 1
  end
  @pos + position[:character]
end

def initialize(source)

: (String) -> void
def initialize(source)
  super()
  @codepoints = source.codepoints #: Array[Integer]
end