pub struct SourceText { /* private fields */ }
Expand description
A type representing a single identifier that may be referred to by [Span
]s.
In most cases, an 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 lines(&self) -> &[SourceLine]
pub fn lines(&self) -> &[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.