lib/util/removeUnnecessaryParens.js
// tree should always have an operator node or unary minus as its child.
tree should always have an operator node or unary minus as its child.
tree should always have an operator node or unary minus as its child .
function removeUnnecessaryParensSearch(node) {
  if (Node.Type.isOperator(node)) {
    return removeUnnecessaryParensInOperatorNode(node);
  }
  else if (Node.Type.isFunction(node)) {
    return removeUnnecessaryParensInFunctionNode(node);
  }
  else if (Node.Type.isParenthesis(node)) {
    return removeUnnecessaryParensInParenthesisNode(node);
  }
  else if (Node.Type.isConstant(node, true) || Node.Type.isSymbol(node)) {
    return node;
  }
  else if (Node.Type.isUnaryMinus(node)) {
    const content = node.args[0];
    node.args[0] = removeUnnecessaryParensSearch(content);
    return node;
  }
  else {
    throw Error('Unsupported node type: ' + node.type);
  }
}
function removeUnnecessaryParensSearch ( node ) { if ( Node . Type . isOperator ( node ) ) { return removeUnnecessaryParensInOperatorNode ( node ) ; } else if ( Node . Type . isFunction ( node ) ) { return removeUnnecessaryParensInFunctionNode ( node ) ; } else if ( Node . Type . isParenthesis ( node ) ) { return removeUnnecessaryParensInParenthesisNode ( node ) ; } else if ( Node . Type . isConstant ( node , true ) || Node . Type . isSymbol ( node ) ) { return node ; } else if ( Node . Type . isUnaryMinus ( node ) ) { const content = node . args [ 0 ] ; node . args [ 0 ] = removeUnnecessaryParensSearch ( content ) ; return node ; } else { throw Error ( 'Unsupported node type: ' + node . type ) ; } }
tree should always have an operator node or unary minus as its child.
tree should always have an operator node or unary minus as its child .