pub struct SourceFile { /* private fields */ }Implementations§
Source§impl SourceFile
impl SourceFile
pub fn parse(source: &str) -> Self
pub fn source(&self) -> &str
pub const fn module(&self) -> &Module
pub fn diagnostics(&self) -> &[Diagnostic]
pub const fn line_index(&self) -> &LineIndex
pub fn tokens(&self) -> &[Token]
pub fn trivia(&self) -> &[Trivia]
pub fn laid_out_tokens(&self) -> &[Token]
Sourcepub fn parser_span_to_text_range(&self, span: ParserSpan) -> TextRange
pub fn parser_span_to_text_range(&self, span: ParserSpan) -> TextRange
Convert a parser span from this source into a text-size byte range.
This is the convenience API for spans that originate from this source file and are expected to be valid.
§Panics
Panics when span does not map to valid UTF-8 source bytes in this
source.
Sourcepub fn try_parser_span_to_text_range(
&self,
span: ParserSpan,
) -> Result<TextRange, ParserSpanToTextRangeError>
pub fn try_parser_span_to_text_range( &self, span: ParserSpan, ) -> Result<TextRange, ParserSpanToTextRangeError>
Try to convert a parser span from this source into a text-size byte
range.
This fallible API is the preferred choice for spans from external or
untrusted sources where offsets may be invalid. Use
SourceFile::parser_span_to_text_range for spans that originate from
this source and are expected to map to valid UTF-8 bytes.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SourceFile
impl RefUnwindSafe for SourceFile
impl Send for SourceFile
impl Sync for SourceFile
impl Unpin for SourceFile
impl UnsafeUnpin for SourceFile
impl UnwindSafe for SourceFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more