pub struct SourceFile { /* private fields */ }Expand description
The immutable parser product. Diagnostics retain parser order by value; callers cannot mutate the tree, token stream, or diagnostics through this API.
Implementations§
Source§impl SourceFile
impl SourceFile
pub fn new( id: NodeId, source_id: SourceId, script_kind: ScriptKind, range: TextRange, source: Arc<SourceText>, tokens: Vec<Token>, statements: Vec<Stmt>, eof: Token, diagnostics: Vec<Diagnostic>, ) -> Self
pub const fn id(&self) -> NodeId
pub const fn kind(&self) -> NodeKind
pub const fn syntax_kind(&self) -> SyntaxKind
pub const fn range(&self) -> TextRange
pub const fn source_id(&self) -> SourceId
pub const fn script_kind(&self) -> ScriptKind
pub fn source_text(&self) -> &SourceText
Sourcepub fn token_text(&self, token: &Token) -> Option<&str>
pub fn token_text(&self, token: &Token) -> Option<&str>
Returns the zero-copy lexeme for a token range in this source file.
None identifies a range that is not a valid UTF-16 slice of this
file, which cannot arise from a parser-produced token.
pub fn eof(&self) -> &Token
pub fn statements(&self) -> &[Stmt] ⓘ
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Parser diagnostics in the parser’s stable source order.
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