class Prism::Location
Experimental RBS support (using type sampling data from the type_fusion project).
# sig/prism/parse_result.rbs class Prism::Location def initialize: (Prism::Source source, Integer start_offset, Integer length) -> void def slice: () -> String def start_line: () -> Integer end
This represents a location in the source.
def self.null
the beginning of the file. Useful for when you want a location object but
Returns a null location that does not correspond to a source and points to
def self.null new(nil, 0, 0) end
def ==(other)
def ==(other) other.is_a?(Location) && other.start_offset == start_offset && other.end_offset == end_offset end
def copy(**options)
def copy(**options) Location.new( options.fetch(:source) { source }, options.fetch(:start_offset) { start_offset }, options.fetch(:length) { length } ) end
def deconstruct_keys(keys)
def deconstruct_keys(keys) { start_offset: start_offset, end_offset: end_offset } end
def end_character_column
The column number in characters where this location ends from the start of
def end_character_column source.character_column(end_offset) end
def end_character_offset
The character offset from the beginning of the source where this location
def end_character_offset source.character_offset(end_offset) end
def end_column
The column number in bytes where this location ends from the start of the
def end_column source.column(end_offset) end
def end_line
def end_line source.line(end_offset) end
def end_offset
def end_offset start_offset + length end
def initialize(source, start_offset, length)
Experimental RBS support (using type sampling data from the type_fusion project).
def initialize: (Prism::Source source, Integer start_offset, Integer length) -> void
This signature was generated using 676 samples from 1 application.
Create a new location object with the given source, start byte offset, and
def initialize(source, start_offset, length) @source = source @start_offset = start_offset @length = length @comments = [] end
def inspect
def inspect "#<Prism::Location @start_offset=#{@start_offset} @length=#{@length} start_line=#{start_line}>" end
def join(other)
other location. Raises an error if this location is not before the other
Returns a new location that stretches from this location to the given
def join(other) raise "Incompatible sources" if source != other.source raise "Incompatible locations" if start_offset > other.start_offset Location.new(source, start_offset, other.end_offset - start_offset) end
def pretty_print(q)
def pretty_print(q) q.text("(#{start_line},#{start_column})-(#{end_line},#{end_column})") end
def slice
Experimental RBS support (using type sampling data from the type_fusion project).
def slice: () -> String
This signature was generated using 59 samples from 1 application.
def slice source.slice(start_offset, length) end
def start_character_column
The column number in characters where this location ends from the start of
def start_character_column source.character_column(start_offset) end
def start_character_offset
The character offset from the beginning of the source where this location
def start_character_offset source.character_offset(start_offset) end
def start_column
The column number in bytes where this location starts from the start of
def start_column source.column(start_offset) end
def start_line
Experimental RBS support (using type sampling data from the type_fusion project).
def start_line: () -> Integer
This signature was generated using 62 samples from 1 application.
def start_line source.line(start_offset) end
def start_line_slice
def start_line_slice offset = source.line_start(start_offset) source.slice(offset, start_offset - offset) end