Skip to main content

WriteJs

Trait WriteJs 

Source
pub trait WriteJs {
Show 23 methods // Required methods fn increase_indent(&mut self) -> Result; fn decrease_indent(&mut self) -> Result; fn write_semi(&mut self, span: Option<Span>) -> Result; fn write_space(&mut self) -> Result; fn write_keyword(&mut self, span: Option<Span>, s: &'static str) -> Result; fn write_operator(&mut self, span: Option<Span>, s: &str) -> Result; fn write_param(&mut self, s: &str) -> Result; fn write_property(&mut self, s: &str) -> Result; fn write_line(&mut self) -> Result; fn write_lit(&mut self, span: Span, s: &str) -> Result; fn write_comment(&mut self, s: &str) -> Result; fn write_str_lit(&mut self, span: Span, s: &str) -> Result; fn write_str(&mut self, s: &str) -> Result; fn write_symbol(&mut self, span: Span, s: &str) -> Result; fn write_punct( &mut self, span: Option<Span>, s: &'static str, commit_pending_semi: bool, ) -> Result; fn care_about_srcmap(&self) -> bool; fn add_srcmap(&mut self, pos: BytePos) -> Result; fn commit_pending_semi(&mut self) -> Result; // Provided methods fn can_ignore_invalid_unicodes(&mut self) -> bool { ... } fn has_scope_tracking(&self) -> bool { ... } fn start_scope( &mut self, _name: Option<&str>, _kind: ScopeKind, _is_stack_frame: bool, _is_hidden: bool, _original_span: Option<Span>, ) -> Result { ... } fn end_scope(&mut self) -> Result { ... } fn add_scope_variable( &mut self, _name: &str, _expression: Option<&str>, _storage: BindingStorage, ) -> Result { ... }
}
Expand description

Ecmascript writer.

Ported from EmitWriteJs.

Required Methods§

Source

fn increase_indent(&mut self) -> Result

Source

fn decrease_indent(&mut self) -> Result

Source

fn write_semi(&mut self, span: Option<Span>) -> Result

This may write semicolon.

Source

fn write_space(&mut self) -> Result

Source

fn write_keyword(&mut self, span: Option<Span>, s: &'static str) -> Result

Source

fn write_operator(&mut self, span: Option<Span>, s: &str) -> Result

Source

fn write_param(&mut self, s: &str) -> Result

Source

fn write_property(&mut self, s: &str) -> Result

Source

fn write_line(&mut self) -> Result

Source

fn write_lit(&mut self, span: Span, s: &str) -> Result

Source

fn write_comment(&mut self, s: &str) -> Result

Source

fn write_str_lit(&mut self, span: Span, s: &str) -> Result

Source

fn write_str(&mut self, s: &str) -> Result

Source

fn write_symbol(&mut self, span: Span, s: &str) -> Result

Source

fn write_punct( &mut self, span: Option<Span>, s: &'static str, commit_pending_semi: bool, ) -> Result

commit_pending_semi should be true if the punctuation requires a preceding semicolon to be committed before writing. This is typically needed for punctuation like ", ', [, !, /, {, (, ~, -, +, #, `, * where ASI (Automatic Semicolon Insertion) could cause issues.

Source

fn care_about_srcmap(&self) -> bool

Source

fn add_srcmap(&mut self, pos: BytePos) -> Result

Source

fn commit_pending_semi(&mut self) -> Result

Provided Methods§

Source

fn can_ignore_invalid_unicodes(&mut self) -> bool

If true, the code generator will skip modification of invalid unicode characters.

Defaults to `false``

Source

fn has_scope_tracking(&self) -> bool

Returns true if scope tracking hooks should be emitted.

This is used to avoid scope-tracking overhead on the hot codegen path when source map scopes are disabled.

Source

fn start_scope( &mut self, _name: Option<&str>, _kind: ScopeKind, _is_stack_frame: bool, _is_hidden: bool, _original_span: Option<Span>, ) -> Result

Starts a new scope in the generated output.

This is used for source map scope tracking (ECMA-426).

Source

fn end_scope(&mut self) -> Result

Ends the current scope.

This is used for source map scope tracking (ECMA-426).

Source

fn add_scope_variable( &mut self, _name: &str, _expression: Option<&str>, _storage: BindingStorage, ) -> Result

Adds a variable binding to the current scope or its hoist target.

This is used for source map scope tracking (ECMA-426).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<W> WriteJs for &mut W
where W: ?Sized + WriteJs,

Source§

fn increase_indent(&mut self) -> Result

Source§

fn decrease_indent(&mut self) -> Result

Source§

fn write_semi(&mut self, span: Option<Span>) -> Result

Source§

fn write_space(&mut self) -> Result

Source§

fn write_keyword(&mut self, span: Option<Span>, s: &'static str) -> Result

Source§

fn write_operator(&mut self, span: Option<Span>, s: &str) -> Result

Source§

fn write_param(&mut self, s: &str) -> Result

Source§

fn write_property(&mut self, s: &str) -> Result

Source§

fn write_line(&mut self) -> Result

Source§

fn write_lit(&mut self, span: Span, s: &str) -> Result

Source§

fn write_comment(&mut self, s: &str) -> Result

Source§

fn write_str_lit(&mut self, span: Span, s: &str) -> Result

Source§

fn write_str(&mut self, s: &str) -> Result

Source§

fn write_symbol(&mut self, span: Span, s: &str) -> Result

Source§

fn write_punct( &mut self, span: Option<Span>, s: &'static str, commit_pending_semi: bool, ) -> Result

Source§

fn care_about_srcmap(&self) -> bool

Source§

fn add_srcmap(&mut self, pos: BytePos) -> Result

Source§

fn commit_pending_semi(&mut self) -> Result

Source§

fn can_ignore_invalid_unicodes(&mut self) -> bool

Source§

fn has_scope_tracking(&self) -> bool

Source§

fn start_scope( &mut self, name: Option<&str>, kind: ScopeKind, is_stack_frame: bool, is_hidden: bool, original_span: Option<Span>, ) -> Result

Source§

fn end_scope(&mut self) -> Result

Source§

fn add_scope_variable( &mut self, name: &str, expression: Option<&str>, storage: BindingStorage, ) -> Result

Source§

impl<W> WriteJs for Box<W>
where W: ?Sized + WriteJs,

Source§

fn increase_indent(&mut self) -> Result

Source§

fn decrease_indent(&mut self) -> Result

Source§

fn write_semi(&mut self, span: Option<Span>) -> Result

Source§

fn write_space(&mut self) -> Result

Source§

fn write_keyword(&mut self, span: Option<Span>, s: &'static str) -> Result

Source§

fn write_operator(&mut self, span: Option<Span>, s: &str) -> Result

Source§

fn write_param(&mut self, s: &str) -> Result

Source§

fn write_property(&mut self, s: &str) -> Result

Source§

fn write_line(&mut self) -> Result

Source§

fn write_lit(&mut self, span: Span, s: &str) -> Result

Source§

fn write_comment(&mut self, s: &str) -> Result

Source§

fn write_str_lit(&mut self, span: Span, s: &str) -> Result

Source§

fn write_str(&mut self, s: &str) -> Result

Source§

fn write_symbol(&mut self, span: Span, s: &str) -> Result

Source§

fn write_punct( &mut self, span: Option<Span>, s: &'static str, commit_pending_semi: bool, ) -> Result

Source§

fn care_about_srcmap(&self) -> bool

Source§

fn add_srcmap(&mut self, pos: BytePos) -> Result

Source§

fn commit_pending_semi(&mut self) -> Result

Source§

fn can_ignore_invalid_unicodes(&mut self) -> bool

Source§

fn has_scope_tracking(&self) -> bool

Source§

fn start_scope( &mut self, name: Option<&str>, kind: ScopeKind, is_stack_frame: bool, is_hidden: bool, original_span: Option<Span>, ) -> Result

Source§

fn end_scope(&mut self) -> Result

Source§

fn add_scope_variable( &mut self, name: &str, expression: Option<&str>, storage: BindingStorage, ) -> Result

Implementors§

Source§

impl<W: Write> WriteJs for JsWriter<'_, W>