visitCallExpr method

  1. @override
String visitCallExpr(
  1. CallExpr expr
)
override

Implementation

@override
String visitCallExpr(CallExpr expr) {
  final output = StringBuffer();
  final calleeString = formatAST(expr.callee);
  output.write('$calleeString${_lexicon.groupExprStart}');
  for (var i = 0; i < expr.positionalArgs.length; ++i) {
    final arg = expr.positionalArgs[i];
    final argString = formatAST(arg);
    output.write(argString);
    if ((i < expr.positionalArgs.length - 1) || expr.namedArgs.isNotEmpty) {
      output.write('${_lexicon.comma} ');
    }
  }
  if (expr.namedArgs.isNotEmpty) {
    output.write(expr.namedArgs.entries
        .toList()
        .map((entry) =>
            '${entry.key}${_lexicon.namedArgumentValueIndicator} ${formatAST(entry.value)}')
        .join('${_lexicon.comma} '));
  }
  output.write(_lexicon.groupExprEnd);
  return output.toString();
}