addIntlMessage method

bool addIntlMessage(
  1. MethodInvocation node
)

Check that the node looks like an Intl.message invocation, and create the IntlMessage object from it and store it in messages. Return true if we successfully extracted a message and should stop looking. Return false if we didn't, so should continue recursing.

Implementation

bool addIntlMessage(MethodInvocation node) {
  if (!looksLikeIntlMessage(node)) return false;
  try {
    _extractMessage(node);
  } on MessageExtractionException catch (e) {
    if (!extraction.suppressWarnings) {
      var errString =
          (StringBuffer()
                ..write(
                  'Skipping invalid Intl.message invocation\n    <$node>\n',
                )
                ..writeAll([
                  '    reason: ${e.message}\n',
                  extraction.reportErrorLocation(node),
                ]))
              .toString();
      extraction.warnings.add(errString);
      extraction.onMessage(errString);
    }
  }

  // We found a message, valid or not. Stop recursing.
  return true;
}