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§
fn increase_indent(&mut self) -> Result
fn decrease_indent(&mut self) -> Result
Sourcefn write_semi(&mut self, span: Option<Span>) -> Result
fn write_semi(&mut self, span: Option<Span>) -> Result
This may write semicolon.
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
Sourcefn write_punct(
&mut self,
span: Option<Span>,
s: &'static str,
commit_pending_semi: bool,
) -> Result
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.
fn care_about_srcmap(&self) -> bool
fn add_srcmap(&mut self, pos: BytePos) -> Result
fn commit_pending_semi(&mut self) -> Result
Provided Methods§
Sourcefn can_ignore_invalid_unicodes(&mut self) -> bool
fn can_ignore_invalid_unicodes(&mut self) -> bool
If true, the code generator will skip modification of invalid unicode characters.
Defaults to `false``
Sourcefn has_scope_tracking(&self) -> bool
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.
Sourcefn start_scope(
&mut self,
_name: Option<&str>,
_kind: ScopeKind,
_is_stack_frame: bool,
_is_hidden: bool,
_original_span: Option<Span>,
) -> Result
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).
Sourcefn end_scope(&mut self) -> Result
fn end_scope(&mut self) -> Result
Ends the current scope.
This is used for source map scope tracking (ECMA-426).
Sourcefn add_scope_variable(
&mut self,
_name: &str,
_expression: Option<&str>,
_storage: BindingStorage,
) -> Result
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".