parse static method

MethodNode? parse(
  1. String str,
  2. Status status
)

Implementation

static MethodNode? parse(String str, Status status) {
  var matches = _regExp.allMatches(str);
  if (matches.length > 0) {
    var match = matches.first;
    MethodNode method = MethodNode._();
    method.name = match.group(1)!;
    method.arguments = [];
    String param = match.group(2)!.trim();
    List<int> dots = _dots(param);

    void insertParam(String param) {
      method.arguments.add(status.execute(param));
    }
    if (dots.length > 0) {
      int off = 0;
      dots.forEach((i) {
        insertParam(param.substring(off, i).trim());
        off = i + 1;
      });
      insertParam(param.substring(off).trim());
    } else if (param.isNotEmpty) {
      insertParam(param.trim());
    }
    return method;
  } else
    return null;
}