Automatically tries to remove superfluous parens which are sometimes added for more clearance and readability but which are not required for parsing and just produce overhead.
Combines then and else expression to one assignment when they both assign to the same target node and using the same operator.
Combines then and else expression using a hook statement.
This method tries to combine a block with multiple statements into one semicolon statement with a comma expression containing all expressions from the previous block. This only works when the block exclusively consists of expressions as this do not work with other statements. Still this conversion reduces the size impact of many blocks and leads to the removal of a lot of curly braces in the result code.
Example: {x++;y+=3} => x++,x+=3
Reduces the size of a if statement (without elsePart) using boolean operators instead of the typical keywords e.g. “if(something)make()” is translated to “something&&make()” which is two characters shorter. This however only works when the thenPart is only based on expressions and does not contain other statements.
Checks whether the given node contains another if-statement
Checks whether the given node contains another if-else-statement
Creates a hook expression with the given then/else parts
Creates a return statement with the given value
Used by the automatic elsePart removal logic to find out whether the given node ends with a return or throw which is bascially the allowance to remove the else keyword as this is not required to keep the logic intact.
Automatically wraps the given node into parens when it was moved into another block and is not parsed there in the same way as it was the case previously. The method needs to be called after the node has been moved to the target node.
Merges if statement with a elsePart using a hook. Supports two different ways of doing this: using a hook expression outside, or using a hook expression inside an assignment.
Example: if(test) first(); else second() => test ? first() : second(); if(foo) x=1; else x=2 => x = foo ? 1 : 2;