printParamDecls method

String printParamDecls(
  1. List<ParamDecl> params
)

Implementation

String printParamDecls(List<ParamDecl> params) {
  final output = StringBuffer();
  var isOptional = false;
  var isNamed = false;
  output.write(_lexicon.groupExprStart);
  for (var i = 0; i < params.length; ++i) {
    final param = params[i];
    if (param.isOptional) {
      if (!isOptional) {
        isOptional = true;
        output.write(_lexicon.optionalPositionalParameterStart);
      }
      if (param.isVariadic) {
        output.write('${_lexicon.variadicArgs} ');
      }
    } else if (param.isNamed && !isNamed) {
      isNamed = true;
      output.write(_lexicon.optionalPositionalParameterStart);
    }
    final paramString = visitParamDecl(param);
    output.write(paramString);
    if (i < params.length - 1) {
      output.write('${_lexicon.comma} ');
    }
  }
  output.write(_lexicon.groupExprEnd);
  return output.toString();
}