in packages/babel-plugin-fbt/src/index.js [231:285]
CallExpression(path) {
// $FlowFixMe[object-this-reference] Babel transforms run with the plugin context by default
const visitor = this;
const fileSource = visitor.file.code;
const pluginOptions: PluginOptions = visitor.opts;
let root = FbtCommonFunctionCallProcessor.create({
babelTypes: t,
path,
});
if (root) {
path.replaceWith(root.convertToNormalCall());
return;
}
if (isRequireAlias(path.parentPath)) {
FbtEnumRegistrar.registerRequireIfApplicable(path);
return;
}
root = FbtFunctionCallProcessor.create({
babelTypes: t,
defaultFbtOptions: defaultOptions,
fileSource,
path,
pluginOptions,
});
if (!root) {
return;
}
root.throwIfExistsNestedFbtConstruct();
const {callNode, metaPhrases} = root.convertToFbtRuntimeCall();
path.replaceWith(callNode);
if (pluginOptions.collectFbt) {
const initialPhraseCount = allMetaPhrases.length;
metaPhrases.forEach((metaPhrase, index) => {
if (metaPhrase.phrase.doNotExtract) {
return;
}
addMetaPhrase(metaPhrase, pluginOptions);
if (metaPhrase.parentIndex != null) {
addEnclosingString(
index + initialPhraseCount,
metaPhrase.parentIndex + initialPhraseCount,
);
}
});
}
},