parse method

PluralMessage parse(
  1. Node node,
  2. List<String> arguments, [
  3. bool addId = false,
  4. String? name,
])

Implementation

PluralMessage parse(Node node, List<String> arguments,
    [bool addId = false, String? name]) {
  final identifier = node.children
      .firstWhere((element) => element.type == ST.identifier)
      .value!;

  if (!arguments.contains(identifier)) arguments.add(identifier);

  final parts = node.children
      .firstWhere((element) => element.type == ST.pluralParts)
      .children;

  final numberCases = getNumberCases(parts, arguments);
  final wordCases = getWordCases(parts, arguments);
  return PluralMessage(
    numberCases: numberCases,
    wordCases: wordCases,
    few: getNamed(parts, 'few', arguments),
    many: getNamed(parts, 'many', arguments),
    other: getOther(parts, arguments)!,
    argIndex: arguments.indexOf(identifier),
    id: addId ? name : null,
  );
}