pub struct Location { /* private fields */ }
Expand description
Represents a source location. This location includes spanning lines and columns and the reference compilation unit.
Implementations§
Source§impl Location
impl Location
Sourcepub fn with_offsets(
compilation_unit: &Rc<CompilationUnit>,
first_offset: usize,
last_offset: usize,
) -> Self
pub fn with_offsets( compilation_unit: &Rc<CompilationUnit>, first_offset: usize, last_offset: usize, ) -> Self
Builds a location.
Sourcepub fn with_offset(
compilation_unit: &Rc<CompilationUnit>,
offset: usize,
) -> Self
pub fn with_offset( compilation_unit: &Rc<CompilationUnit>, offset: usize, ) -> Self
Builds a location.
Sourcepub fn combine_with(&self, other: Location) -> Self
pub fn combine_with(&self, other: Location) -> Self
Build a location by combining two locations. self
serves as the first location, while other
serves as the
last location.
Sourcepub fn combine_with_start_of(&self, other: Location) -> Self
pub fn combine_with_start_of(&self, other: Location) -> Self
Build a location by combining two locations. self
serves as the first location, while the first column and first line
of other
serve as the last location.
Sourcepub fn compilation_unit(&self) -> Rc<CompilationUnit>
pub fn compilation_unit(&self) -> Rc<CompilationUnit>
The compilation unit that this location belongs to.
Sourcepub fn first_line_number(&self) -> usize
pub fn first_line_number(&self) -> usize
First line number, counted from one.
Sourcepub fn last_line_number(&self) -> usize
pub fn last_line_number(&self) -> usize
Last line number, counted from one.
pub fn first_offset(&self) -> usize
pub fn last_offset(&self) -> usize
Sourcepub fn first_column(&self) -> usize
pub fn first_column(&self) -> usize
Zero based first column of the location in code points.
Sourcepub fn last_column(&self) -> usize
pub fn last_column(&self) -> usize
Zero based last column of the location in code points.
Sourcepub fn first_column_offset(&self) -> usize
pub fn first_column_offset(&self) -> usize
Zero based first column offset of the location.
Sourcepub fn last_column_offset(&self) -> usize
pub fn last_column_offset(&self) -> usize
Zero based last column offset of the location.
Sourcepub fn cursor_inside(&self, (line, column): (usize, usize)) -> bool
pub fn cursor_inside(&self, (line, column): (usize, usize)) -> bool
Takes (line
, column
).
§Parameters
line
- One-based line number for the cursorcolumn
- Zero-based column number (in code points) for the cursor
pub fn character_count(&self) -> usize
Sourcepub fn line_break(&self, other: &Self) -> bool
pub fn line_break(&self, other: &Self) -> bool
Indicates whether a previous location and a next location have a line break in between.
Sourcepub fn shift_until_eof(&self, count: usize) -> Location
pub fn shift_until_eof(&self, count: usize) -> Location
Shifts a count of characters off this location until end-of-file.
Sourcepub fn shift_whitespace(&self, text: &str) -> Location
pub fn shift_whitespace(&self, text: &str) -> Location
Shifts the count of first whitespace characters in a text off this location.