parseContent method
Parse the source of the Dart program from a file with content
fileContent
and path path
and return a Map from message
names to IntlMessage
instances.
If transformer
is true, assume the transformer will supply any "name"
and "args" parameters required in Intl.message calls.
Implementation
Map<String, MainMessage> parseContent(
String fileContent,
String filepath,
bool transformer,
) {
var contents = fileContent;
origin = filepath;
// Optimization to avoid parsing files we're sure don't contain any messages.
if (contents.contains('Intl.')) {
root = _parseCompilationUnit(contents, origin!);
} else {
return {};
}
var visitor = MessageFindingVisitor(
this,
generateNameAndArgs: transformer,
);
root.accept(visitor);
return visitor.messages;
}