visitExpressions method

  1. @override
void visitExpressions(
  1. Expressions node
)
override

Implementation

@override
void visitExpressions(Expressions node) {
  var expressions = node.expressions;
  var expressionsLength = expressions.length;
  for (var i = 0; i < expressionsLength; i++) {
    // Add space seperator between terms without an operator.
    // TODO(terry): Should have a BinaryExpression to solve this problem.
    var expression = expressions[i];
    if (i > 0 &&
        !(expression is OperatorComma || expression is OperatorSlash)) {
      // If the previous expression is an operator, use `_sp` so the space is
      // collapsed when emitted in compact mode. If the previous expression
      // isn't an operator, the space is significant to delimit the two
      // expressions and can't be collapsed.
      var previous = expressions[i - 1];
      if (previous is OperatorComma || previous is OperatorSlash) {
        emit(_sp);
      } else {
        emit(' ');
      }
    }
    expression.visit(this);
  }
}