Skip to main content

SourceFile

Struct SourceFile 

Source
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

Source

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

Source

pub const fn id(&self) -> NodeId

Source

pub const fn kind(&self) -> NodeKind

Source

pub const fn syntax_kind(&self) -> SyntaxKind

Source

pub const fn range(&self) -> TextRange

Source

pub const fn source_id(&self) -> SourceId

Source

pub const fn script_kind(&self) -> ScriptKind

Source

pub fn source_text(&self) -> &SourceText

Source

pub fn tokens(&self) -> &[Token]

Non-EOF source tokens in lexical order.

Source

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.

Source

pub fn eof(&self) -> &Token

Source

pub fn statements(&self) -> &[Stmt]

Source

pub fn diagnostics(&self) -> &[Diagnostic]

Parser diagnostics in the parser’s stable source order.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.