Skip to main content

AstWalker

Struct AstWalker 

Source
pub struct AstWalker<'a> { /* private fields */ }
Expand description

Walks the AST while tracking scope context via node_to_scope.

Implementations§

Source§

impl<'a> AstWalker<'a>

Source

pub fn new(scope_info: &'a ScopeInfo) -> Self

Source

pub fn with_initial_scope( scope_info: &'a ScopeInfo, initial_scope: ScopeId, ) -> Self

Create a walker with an initial scope already on the stack.

Source

pub fn scope_stack(&self) -> &[ScopeId]

Source

pub fn loop_expression_depth(&self) -> usize

Returns the current loop-expression depth. Non-zero when the walker is inside a loop’s test/right expression (while.test, do-while.test, for-in.right, for-of.right). Visitors can use this to implement Babel-compatible scope checks in ‘all’ compilation mode.

Source

pub fn walk_program<'ast>( &mut self, v: &mut impl Visitor<'ast>, node: &'ast Program, )

Source

pub fn walk_block_statement<'ast>( &mut self, v: &mut impl Visitor<'ast>, node: &'ast BlockStatement, )

Source

pub fn walk_statement<'ast>( &mut self, v: &mut impl Visitor<'ast>, stmt: &'ast Statement, )

Source

pub fn walk_expression<'ast>( &mut self, v: &mut impl Visitor<'ast>, expr: &'ast Expression, )

Source

pub fn walk_pattern<'ast>( &mut self, v: &mut impl Visitor<'ast>, pat: &'ast PatternLike, )

Auto Trait Implementations§

§

impl<'a> Freeze for AstWalker<'a>

§

impl<'a> RefUnwindSafe for AstWalker<'a>

§

impl<'a> Send for AstWalker<'a>

§

impl<'a> Sync for AstWalker<'a>

§

impl<'a> Unpin for AstWalker<'a>

§

impl<'a> UnsafeUnpin for AstWalker<'a>

§

impl<'a> UnwindSafe for AstWalker<'a>

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.