[−][src]Struct resw::Writer
The writer that will take in
RESSA AST and write to the provided
impl Write
provided
Methods
impl<T: Write> Writer<T>
[src]
impl<T: Write> Writer<T>
pub fn new(out: T) -> Self | [src] |
Create a default writer with the provided destination
This will use \n
for new lines, 4 spaces for indenting
and the source text's quote character for quoting
pub fn create( | [src] |
Fully customizable constructor
See builder
for a more ergonomic solution
pub fn builder() -> Builder<T> | [src] |
Create a Builder
for constructing your writer
pub fn write_program(&mut self, program: &Program) -> Result<(), IoError> | [src] |
This will loop over the contents of a Program
and
attempt write them all to the provided impl Write
pub fn write_part(&mut self, part: &ProgramPart) -> Result<(), IoError> | [src] |
This will attempt to write a single ProgramPart
pub fn write_decl(&mut self, decl: &Declaration) -> Result<(), IoError> | [src] |
Attempt to write a Declaration
to the impl Write
pub fn write_variable_decls( | [src] |
Attempt to write a Declaration::Variable
's contents to the impl Write
let a, b, c, d, e = "thing";
const f = "stuff";
var g, h, i, j = "places";
pub fn write_class(&mut self, class: &Class) -> Result<(), IoError> | [src] |
Attempt to write a Class
to the impl Write
, used for both
writing the contents of Declaration::Class
and Expression::Class
// class expression
let x = class {
constructor() {
}
method1() {
}
method2() {
}
}
// class declaration
class Y {
constructor() {
}
method1() {
}
method2() {
}
}
pub fn write_export_decl(&mut self, exp: &ModuleExport) -> Result<(), IoError> | [src] |
Attempt to write the contents of Declaration::Export
to the impl Write
export function Thing() {
}
export * from 'module';
export {Stuff} from 'other_module';
pub fn write_all_export(&mut self, exp: &Literal) -> Result<(), IoError> | [src] |
Attempt to write the contents ModuleExport::All
to the impl Write
export * from 'module'
pub fn write_default_export( | [src] |
Attempt to write the contents ModuleExport::Default
to the impl Write
export default function Thing() {
}
pub fn write_named_export( | [src] |
Attempts to write the contents of ModuleExport::Named
to the impl Write
export function Thing {
}
export {Stuff} from 'module';
pub fn write_export_specifiers( | [src] |
Attempts to write the contents of NamedExportDecl::Specifier
to the impl Write
export {Stuff as Things} from 'module'
export {Places} from 'other_module'
pub fn write_import_decl(&mut self, imp: &ModuleImport) -> Result<(), IoError> | [src] |
Attempts to write the contents of Declaration::Import
to the impl Write
import * as Moment from 'moment';
import {Thing, Place} from 'module';
import Stuff from 'other_module';
pub fn write_import_specificer( | [src] |
Attempts to write a single ImportSpecifier
to the impl Write
import * as Moment from 'moment';
import {Thing, Place} from 'module';
import Stuff from 'other_module';
pub fn write_namespace_import( | [src] |
Attempts to write the contents ofImportSpecifier::Namespace
to the impl Write
import * as Moment from 'moment';
pub fn write_normal_import( | [src] |
Attempts to write the contents ofImportSpecifier::Normal
to the impl Write
import {Thing as Stuff} from 'module';
pub fn write_directive(&mut self, dir: &Directive) -> Result<(), IoError> | [src] |
Attempts to write a directive to the impl Write
'use strict';
pub fn write_variable_decl( | [src] |
Attempts to write a variable declaration
let x = function() {
}
var a, b, c, d = 'things';
pub fn write_variable_kind( | [src] |
Attempts to write the variable keyword (var
/let
/const
)
pub fn write_stmt(&mut self, stmt: &Statement) -> Result<(), IoError> | [src] |
Attempts to write the contents of a Statement
pub fn write_debugger_stmt(&mut self) -> Result<(), IoError> | [src] |
Attempts to write a debugger stmt
debugger;
pub fn write_block_stmt(&mut self, block: &[ProgramPart]) -> Result<(), IoError> | [src] |
Attempts to write a block statement
{
var x = 0;
}
pub fn write_with_stmt(&mut self, expr: &WithStatement) -> Result<(), IoError> | [src] |
Attempts to write a WithStatement
With(Math) {
var y = random() * 100;
}
pub fn write_return_stmt( | [src] |
Attempts to write a ReturnStatement
function one() {
return 'things';
}
function two() {
return;
}
pub fn write_labeled_stmt( | [src] |
Attempts to write a LabeledStatement
label: {
if (true) {
break label;
}
}
pub fn write_break_stmt( | [src] |
Attempts to write a break statement
label: {
if (true) {
break label;
}
}
for (;;) {
break;
}
pub fn write_continue_stmt( | [src] |
Attempts to write a continue statement
for (;;) continue;
outer: for (;;) {
inner: for (;;) {
if ((Math.random() * 100) > 50) {
continue outer;
} else {
continue inner;
}
}
}
pub fn write_if_stmt(&mut self, expr: &IfStatement) -> Result<(), IoError> | [src] |
Attempts to write an IfStatement
if ((Math.random() * 100) > 50) {
} else if ((Math.random() * 100) < 25) {
} else {
}
pub fn write_switch_stmt( | [src] |
Attempts to write a SwitchStatement
switch (Math.floor(Math.random() * 5)) {
case 0:
default:
}
pub fn write_switch_case(&mut self, case: &SwitchCase) -> Result<(), IoError> | [src] |
Attempts to write a SwitchCase
switch (Math.floor(Math.random() * 5)) {
case 0:
break;
default:
return 100;
}
pub fn write_throw_stmt(&mut self, expr: &Expression) -> Result<(), IoError> | [src] |
Attempts to write a throw statement
function one() {
throw 'Things'
}
function two() {
throw new Error('Things');
}
pub fn write_try_stmt(&mut self, stmt: &TryStatement) -> Result<(), IoError> | [src] |
Attempts to write a try statement
try {
} catch (e) {
} finally {
}
pub fn write_while_stmt( | [src] |
Attempts to write a while statement
while (true) {
}
pub fn write_do_while_stmt( | [src] |
Attempts to write a do while statement
do {
} while(true)
pub fn write_for_stmt(&mut self, stmt: &ForStatement) -> Result<bool, IoError> | [src] |
Attempts to write a c-style for loop for (var i = 0; i < 100; i++) console.log(i); for (;;) { break; }
pub fn write_loop_init(&mut self, init: &LoopInit) -> Result<(), IoError> | [src] |
Attempts to write the first part of a c-style for loop's parenthetical
pub fn write_for_in_stmt( | [src] |
Attempts to write a for in loop
for (var x in []) {
}
pub fn write_for_of_stmt( | [src] |
Attempts to write a for of loop
for (let x of []) {
}
pub fn write_loop_left(&mut self, left: &LoopLeft) -> Result<(), IoError> | [src] |
Attempts to write for first part of a for of or for in loop's parenthetical
pub fn write_var_stmt(&mut self, expr: &[VariableDecl]) -> Result<(), IoError> | [src] |
write a variable statment
var x;
var y = x;
var q, w, e, r = Infinity;
pub fn write_pattern(&mut self, pattern: &Pattern) -> Result<(), IoError> | [src] |
Write the contents of a pattern
pub fn write_object_pattern( | [src] |
Write an object pattern
let {x, y} = {x: 100, y: 0};
pub fn write_property(&mut self, prop: &Property) -> Result<(), IoError> | [src] |
Write an object or class property
pub fn write_init_property(&mut self, prop: &Property) -> Result<(), IoError> | [src] |
Write a property that is not a method or constructor
{
a: 100,
}
pub fn write_get_property(&mut self, prop: &Property) -> Result<(), IoError> | [src] |
Write a get property
{
get thing() {
return 'thing'
}
}
pub fn write_set_property(&mut self, prop: &Property) -> Result<(), IoError> | [src] |
Write a get property
class Stuff {
set thing(value) {
this.thing = value;
}
}
pub fn write_property_method(&mut self, prop: &Property) -> Result<(), IoError> | [src] |
Write a property that is a method
{
thing() {
return 'thing'
}
}
pub fn write_function_args( | [src] |
Write the arguments of a function or method definition
function(arg1, arg2) {
}
pub fn write_function_arg(&mut self, arg: &FunctionArg) -> Result<(), IoError> | [src] |
Write a single function arg
pub fn write_function_body( | [src] |
Write the block statement that makes up a function's body
pub fn write_ctor_property(&mut self, prop: &Property) -> Result<(), IoError> | [src] |
Write a property that is a constructor for a class
class Thing {
constructor() {
}
}
pub fn write_property_key( | [src] |
Write a property key, taking into account of it should be wrapped in [] for "computed" properties
pub fn write_property_value( | [src] |
Write the value for a property
pub fn write_rest_pattern_part(&mut self, pat: &Pattern) -> Result<(), IoError> | [src] |
Writes a rest pattern
let x = [...y];
pub fn write_array_pattern( | [src] |
Writes an array literal from a pattern
let [x, y] = [1, 2];
pub fn write_rest_element(&mut self, pat: &Pattern) -> Result<(), IoError> | [src] |
pub fn write_assignment_pattern( | [src] |
Writes a rest pattern
let x = [...y];
pub fn write_wrapped_expr(&mut self, expr: &Expression) -> Result<(), IoError> | [src] |
pub fn write_expr(&mut self, expr: &Expression) -> Result<(), IoError> | [src] |
pub fn write_this_expr(&mut self) -> Result<(), IoError> | [src] |
Write this
pub fn write_super_expr(&mut self) -> Result<(), IoError> | [src] |
Write super
pub fn write_array_expr(&mut self, arr: &ArrayExpression) -> Result<(), IoError> | [src] |
write an array literal
[one,,two,,3, null];
pub fn write_object_expr( | [src] |
Write an object literal
{
a: b,
c: d,
}
pub fn write_function(&mut self, func: &Function) -> Result<(), IoError> | [src] |
Write a function. This is used to write the contents of both a Declaration::Function
and an Expression::Function
pub fn write_unary_expr( | [src] |
Write a unary expression
delete x
typeof y
+9
-10
void 0
~3
!true
pub fn write_unary_operator( | [src] |
pub fn write_update_expr( | [src] |
Write an update expression
a++
--b
pub fn write_update_operator( | [src] |
pub fn write_binary_expr( | [src] |
Writes a binary expression
a == b
c !== d
x instanceof y
x * 100
pub fn write_binary_operator( | [src] |
pub fn write_assignment_expr( | [src] |
Write an assignment expression
a = b
b += 8
q **= 100
pub fn write_assignment_operator( | [src] |
pub fn write_logical_expr( | [src] |
Writes a logical expression
a && b
y || q
pub fn write_logical_operator( | [src] |
pub fn write_member_expr( | [src] |
Writes a member expression
console.log
console['log']
pub fn write_conditional_expr( | [src] |
Writes a conditional expression
let x = isTrue ? 'yes' : 'no';
pub fn write_call_expr(&mut self, call: &CallExpression) -> Result<(), IoError> | [src] |
Writes a call expression
console.log()
(function() {
})()
pub fn write_new_expr(&mut self, new: &NewExpression) -> Result<(), IoError> | [src] |
Writes a new expression
new Uint8Array(100);
pub fn write_sequence_expr( | [src] |
Writes a sequence of sub-expressions
a = b, c = d, q * 100
pub fn write_spread_expr(&mut self, spread: &Expression) -> Result<(), IoError> | [src] |
Writes a spread expression
function(...args) {
}
pub fn write_arrow_function_expr( | [src] |
Writes and arrow function
x => console.log(x);
(x, y) => {
return x * y;
}
pub fn write_yield_expr( | [src] |
Writes a yield expression
function *gen() {
while (true) {
yield 100;
}
}
pub fn write_meta_property( | [src] |
Writes a meta property
function Thing() {
if (new.target) {
this.stuff = 'things'
} else {
return new Thing;
}
}
pub fn write_await_expr(&mut self, expr: &Expression) -> Result<(), IoError> | [src] |
Write an expression preceded by the await keyword
pub fn write_ident(&mut self, ident: &str) -> Result<(), IoError> | [src] |
Write a plain identifier
pub fn write_tagged_template( | [src] |
Write a template preceded by an identifier
tag`things ${0} stuff`;
pub fn write_literal(&mut self, lit: &Literal) -> Result<(), IoError> | [src] |
Write a literal
null
'string'
"string"
0.1e100
0xff
0o77
0b11
false,
true,
/.+/g
`things`
pub fn write_bool(&mut self, boolean: bool) -> Result<(), IoError> | [src] |
Write true or false
pub fn write_string(&mut self, s: &str) -> Result<(), IoError> | [src] |
write a string, re-writes the string if quote configuration is set
pub fn write_regex(&mut self, regex: &RegEx) -> Result<(), IoError> | [src] |
pub fn write_template( | [src] |
pub fn write_empty_stmt(&mut self) -> Result<(), IoError> | [src] |
pub fn write_open_brace(&mut self) -> Result<(), IoError> | [src] |
pub fn write_close_brace(&mut self) -> Result<(), IoError> | [src] |
pub fn write_leading_whitespace(&mut self) -> Result<(), IoError> | [src] |
pub fn write_new_line(&mut self) -> Result<(), IoError> | [src] |
pub fn write_comment(&mut self, comment: Comment) -> Result<(), IoError> | [src] |
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error> | [src] |
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T | [src] |
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error> | [src] |
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId | [src] |