visitInvokeExpression method

  1. @override
StringSink visitInvokeExpression(
  1. InvokeExpression expression, [
  2. StringSink? output
])
inherited

Implementation

@override
StringSink visitInvokeExpression(InvokeExpression expression,
    [StringSink? output]) {
  final out = output ??= StringBuffer();
  return _writeConstExpression(out, expression.isConst, () {
    expression.target.accept(this, out);
    if (expression.name != null) {
      out
        ..write('.')
        ..write(expression.name);
    }
    if (expression.typeArguments.isNotEmpty) {
      out.write('<');
      visitAll<Reference>(expression.typeArguments, out, (type) {
        type.accept(this, out);
      });
      out.write('>');
    }
    out.write('(');
    visitAll<Spec>(expression.positionalArguments, out, (spec) {
      spec.accept(this, out);
    });
    if (expression.positionalArguments.isNotEmpty &&
        expression.namedArguments.isNotEmpty) {
      out.write(', ');
    }
    visitAll<String>(expression.namedArguments.keys, out, (name) {
      out
        ..write(name)
        ..write(': ');
      expression.namedArguments[name]!.accept(this, out);
    });
    final argumentCount = expression.positionalArguments.length +
        expression.namedArguments.length;
    if (argumentCount > 1) {
      out.write(', ');
    }
    return out..write(')');
  });
}