Skip to main content

JsEmitContext

Struct JsEmitContext 

Source
pub struct JsEmitContext {
    pub indent_level: usize,
    pub indent_str: String,
    pub source_map: JsSourceMap,
    pub current_line: u32,
    pub current_col: u32,
    pub in_async: bool,
}
Expand description

Context maintained during JS code emission.

Fields§

§indent_level: usize

Current indentation level.

§indent_str: String

Indentation string per level.

§source_map: JsSourceMap

Source map being built.

§current_line: u32

Current output line number.

§current_col: u32

Current output column.

§in_async: bool

Whether we are inside an async function.

Implementations§

Source§

impl JsEmitContext

Source

pub fn new(indent: &str) -> Self

Create a new emit context.

Source

pub fn indent(&self) -> String

Get the current indentation string.

Source

pub fn push_indent(&mut self)

Increase indentation.

Source

pub fn pop_indent(&mut self)

Decrease indentation.

Source

pub fn newline(&mut self)

Emit a newline, updating line/column counters.

Source

pub fn record_mapping(&mut self, fn_name: &str, source_line: u32)

Record a source map entry for the current position.

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.