Struct source_cache::SourceText
source · pub struct SourceText { /* private fields */ }
Expand description
A type representing a single identifier that may be referred to by [Span
]s.
In most cases, a identifier is a single input file.
Implementations§
source§impl SourceText
impl SourceText
sourcepub fn get_length(&self) -> usize
pub fn get_length(&self) -> usize
Get the length of the total number of characters in the identifier.
sourcepub fn get_line(&self, idx: usize) -> Option<&SourceLine>
pub fn get_line(&self, idx: usize) -> Option<&SourceLine>
Get access to a specific, zero-indexed SourceLine
.
sourcepub fn get_source(&self) -> &SourcePath
pub fn get_source(&self) -> &SourcePath
Get the length of the total number of characters in the identifier.
sourcepub fn set_source(&mut self, path: SourcePath)
pub fn set_source(&mut self, path: SourcePath)
Set path name of identifier
sourcepub fn set_remote(&mut self, url: Url) -> bool
pub fn set_remote(&mut self, url: Url) -> bool
Set path name of identifier
sourcepub fn with_remote(self, url: Url) -> Self
pub fn with_remote(self, url: Url) -> Self
Get path name of identifier
sourcepub fn chars(&self) -> impl Iterator<Item = char> + '_
pub fn chars(&self) -> impl Iterator<Item = char> + '_
Return an iterator over the characters in the identifier.
sourcepub fn lines(&self) -> impl ExactSizeIterator<Item = &SourceLine> + '_
pub fn lines(&self) -> impl ExactSizeIterator<Item = &SourceLine> + '_
Return an iterator over the SourceLine
s in this identifier.
source§impl SourceText
impl SourceText
sourcepub fn get_offset_line(&self, offset: u32) -> Option<(&SourceLine, usize, u32)>
pub fn get_offset_line(&self, offset: u32) -> Option<(&SourceLine, usize, u32)>
Get the line that the given offset appears on, and the line/column numbers of the offset.
Note that the line/column numbers are zero-indexed.
sourcepub fn get_line_range(&self, span: &Range<u32>) -> Range<usize>
pub fn get_line_range(&self, span: &Range<u32>) -> Range<usize>
Get the range of lines that this source_text runs across.
The resulting range is guaranteed to contain valid line indices (i.e: those that can be used for
SourceText::get_line
).
Trait Implementations§
source§impl Clone for SourceText
impl Clone for SourceText
source§fn clone(&self) -> SourceText
fn clone(&self) -> SourceText
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SourceText
impl Debug for SourceText
source§impl<S: Into<String>> From<S> for SourceText
impl<S: Into<String>> From<S> for SourceText
source§fn from(source: S) -> Self
fn from(source: S) -> Self
Generate a SourceText
from the given str
.
Note that this function can be expensive for long strings. Use an implementor of [Cache
] where possible.
source§impl Hash for SourceText
impl Hash for SourceText
source§impl PartialEq for SourceText
impl PartialEq for SourceText
source§fn eq(&self, other: &SourceText) -> bool
fn eq(&self, other: &SourceText) -> bool
self
and other
values to be equal, and is used
by ==
.