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.
      var extracted = _extractFromIntlCallWithInterpolation(
        message,
        arguments.first,
      );
      message.addPieces(extracted);
    } on MessageExtractionException catch (e) {
      var errString = (StringBuffer()
            ..writeAll(['Error ', e, '\nProcessing <', node, '>\n'])
            ..write(extraction.reportErrorLocation(node)))
          .toString();
      extraction.onMessage(errString);
      extraction.warnings.add(errString);
      return null;
    }
    return message;
  }

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

  return _messageFromNode(node, extractFromIntlCall, setValue);
}