Class: Parser::Source::Range

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
sorbet/rbi/parser@3.3.7.4.rbi

Overview

A range of characters in a particular source buffer.

The range is always exclusive, i.e. a range with begin_pos of 3 and end_pos of 5 will contain the following characters:

example
   ^^

source://parser//lib/parser/source/range.rb#26

Instance Method Summary collapse

Constructor Details

#initialize(source_buffer, begin_pos, end_pos) ⇒ Range

source://parser//lib/parser/source/range.rb#37

Parameters:

  • source_buffer (Buffer)
  • begin_pos (Integer)
  • end_pos (Integer)


5984
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 5984

def initialize(source_buffer, begin_pos, end_pos); end

Instance Method Details

#adjust(begin_pos: T.unsafe(nil), end_pos: T.unsafe(nil)) ⇒ Range

by the given amount(s)

source://parser//lib/parser/source/range.rb#193

Parameters:

  • Endpoint (s)

    [Hash] to change, any combination of :begin_pos or :end_pos

Returns:

  • (Range)

    the same range as this range but with the given end point(s) adjusted



6000
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6000

def adjust(begin_pos: T.unsafe(nil), end_pos: T.unsafe(nil)); end

#beginRange

source://parser//lib/parser/source/range.rb#55

Returns:

  • (Range)

    a zero-length range located just before the beginning of this range.



6007
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6007

def begin; end

#begin_posInteger

source://parser//lib/parser/source/range.rb#30

Returns:

  • (Integer)

    index of the first character in the range



6013
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6013

def begin_pos; end

#columnInteger

source://parser//lib/parser/source/range.rb#92

Returns:

  • (Integer)

    zero-based column number of the beginning of this range.



6019
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6019

def column; end

#column_range::Range

source://parser//lib/parser/source/range.rb#114

Returns:

  • (::Range)

    a range of columns spanned by this range.

Raises:

  • RangeError



6026
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6026

def column_range; end

#contained?(other) ⇒ Boolean

Return other.contains?(self)

Two ranges must be one and only one of ==, disjoint?, contains?, contained? or crossing?

source://parser//lib/parser/source/range.rb#274

Parameters:

Returns:

  • (Boolean)


6037
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6037

def contained?(other); end

#contains?(other) ⇒ Boolean

Returns true iff this range contains (strictly) other.

Two ranges must be one and only one of ==, disjoint?, contains?, contained? or crossing?

source://parser//lib/parser/source/range.rb#262

Parameters:

Returns:

  • (Boolean)


6048
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6048

def contains?(other); end

#crossing?(other) ⇒ Boolean

Returns true iff both ranges intersect and also have different elements from one another.

Two ranges must be one and only one of ==, disjoint?, contains?, contained? or crossing?

source://parser//lib/parser/source/range.rb#286

Parameters:

Returns:

  • (Boolean)


6059
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6059

def crossing?(other); end

#disjoint?(other) ⇒ Boolean

Return true iff this range and other are disjoint.

Two ranges must be one and only one of ==, disjoint?, contains?, contained? or crossing?

source://parser//lib/parser/source/range.rb#236

Parameters:

Returns:

  • (Boolean)


6070
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6070

def disjoint?(other); end

#empty?Boolean

Checks if a range is empty; if it contains no characters

source://parser//lib/parser/source/range.rb#294

Returns:

  • (Boolean)


6078
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6078

def empty?; end

#endRange

source://parser//lib/parser/source/range.rb#63

Returns:

  • (Range)

    a zero-length range located just after the end of this range.



6085
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6085

def end; end

#end_posInteger

source://parser//lib/parser/source/range.rb#30

Returns:

  • (Integer)

    index of the character after the last character in the range



6091
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6091

def end_pos; end

#first_lineInteger

Line number of the beginning of this range. By default, the first line of a buffer is 1; as such, line numbers are most commonly one-based.

source://parser//lib/parser/source/range.rb#83

Returns:

  • (Integer)

    line number of the beginning of this range.

See Also:



6104
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6104

def first_line; end

#intersect(other) ⇒ Range

source://parser//lib/parser/source/range.rb#220

Parameters:

Returns:

  • (Range)

    overlapping region of this range and other, or nil if they do not overlap



6125
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6125

def intersect(other); end

#is?(*what) ⇒ Boolean

is? provides a concise way to compare the source corresponding to this range. For example, r.source == '(' || r.source == 'begin' is equivalent to r.is?('(', 'begin').

source://parser//lib/parser/source/range.rb#141

Returns:

  • (Boolean)


6135
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6135

def is?(*what); end

#join(other) ⇒ Range

source://parser//lib/parser/source/range.rb#209

Parameters:

Returns:

  • (Range)

    smallest possible range spanning both this range and other.



6142
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6142

def join(other); end

#last_columnInteger

source://parser//lib/parser/source/range.rb#106

Returns:

  • (Integer)

    zero-based column number of the end of this range.



6148
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6148

def last_column; end

#last_lineInteger

source://parser//lib/parser/source/range.rb#99

Returns:

  • (Integer)

    line number of the end of this range.



6154
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6154

def last_line; end

#lengthInteger

source://parser//lib/parser/source/range.rb#70

Returns:

  • (Integer)

    amount of characters included in this range.



6160
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6160

def length; end

#lineInteger

Line number of the beginning of this range. By default, the first line of a buffer is 1; as such, line numbers are most commonly one-based.

source://parser//lib/parser/source/range.rb#83

Returns:

  • (Integer)

    line number of the beginning of this range.

See Also:



6170
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6170

def line; end

#overlaps?(other) ⇒ Boolean

Return true iff this range is not disjoint from other.

source://parser//lib/parser/source/range.rb#250

Parameters:

Returns:

  • (Boolean)

    true if this range and other overlap



6179
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6179

def overlaps?(other); end

#resize(new_size) ⇒ Range

source://parser//lib/parser/source/range.rb#201

Parameters:

  • new_size (Integer)

Returns:

  • (Range)

    a range beginning at the same point as this range and length new_size.



6186
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6186

def resize(new_size); end

#sizeInteger

source://parser//lib/parser/source/range.rb#70

Returns:

  • (Integer)

    amount of characters included in this range.



6192
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6192

def size; end

#sourceString

source://parser//lib/parser/source/range.rb#132

Returns:

  • (String)

    all source code covered by this range.



6198
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6198

def source; end

#source_bufferParser::Source::Buffer

source://parser//lib/parser/source/range.rb#29



6204
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6204

def source_buffer; end

#source_lineString

source://parser//lib/parser/source/range.rb#125

Returns:

  • (String)

    a line of source code containing the beginning of this range.



6210
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6210

def source_line; end

#to_aArray<Integer>

source://parser//lib/parser/source/range.rb#148

Returns:

  • (Array<Integer>)

    a set of character indexes contained in this range.



6216
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6216

def to_a; end

#to_rangeRange

source://parser//lib/parser/source/range.rb#155

Returns:

  • (Range)

    a Ruby range with the same begin_pos and end_pos



6222
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6222

def to_range; end

#with(begin_pos: T.unsafe(nil), end_pos: T.unsafe(nil)) ⇒ Range

to the given value(s).

source://parser//lib/parser/source/range.rb#184

Parameters:

  • Endpoint (s)

    [Hash] to change, any combination of :begin_pos or :end_pos

Returns:

  • (Range)

    the same range as this range but with the given end point(s) changed



6248
# File 'sorbet/rbi/parser@3.3.7.4.rbi', line 6248

def with(begin_pos: T.unsafe(nil), end_pos: T.unsafe(nil)); end