messageFromIntlMessageCall method

MainMessage? messageFromIntlMessageCall(
  1. MethodInvocation node
)

Create a MainMessage from node using the name and parameters of the last function/method declaration we encountered and the parameters to the Intl.message call.

Implementation

MainMessage? messageFromIntlMessageCall(MethodInvocation node) {
  MainMessage? extractFromIntlCall(
      MainMessage? message, List<AstNode> arguments) {
    try {
      // The pieces of the message, either literal strings, or integers
      // representing the index of the argument to be substituted.
      List<Object> extracted =
          _extractFromIntlCallWithInterpolation(message, arguments);
      message?.addPieces(extracted);
    } on IntlMessageExtractionException catch (e) {
      message = null;
      var err = new StringBuffer()
        ..writeAll(["Error ", e, "\nProcessing <", node, ">\n"])
        ..write(extraction._reportErrorLocation(node));
      var errString = err.toString();
      extraction.onMessage(errString);
      extraction.warnings.add(errString);
    }
    return message;
  }

  void setValue(MainMessage message, String fieldName, Object? fieldValue) {
    message[fieldName] = fieldValue;
  }

  return _messageFromNode(node, extractFromIntlCall, setValue);
}