Reduce unneeded parentheses in JS and Python.

This commit is contained in:
Neil Fraser
2016-06-20 17:34:36 -07:00
parent 6502ea5026
commit 4b319d461d
8 changed files with 107 additions and 68 deletions

View File

@@ -79,6 +79,16 @@ Blockly.Python.ORDER_CONDITIONAL = 15; // if else
Blockly.Python.ORDER_LAMBDA = 16; // lambda
Blockly.Python.ORDER_NONE = 99; // (...)
/**
* List of outer-inner pairings that do NOT require parentheses.
* @type {!Array.<!Array.<number>>}
*/
Blockly.Python.ORDER_OVERRIDES = [
// (foo()).bar() -> foo().bar()
// (foo())[0] -> foo()[0]
[Blockly.Python.ORDER_FUNCTION_CALL, Blockly.Python.ORDER_MEMBER]
];
/**
* Initialise the database of variable names.
* @param {!Blockly.Workspace} workspace Workspace to generate code from.