in packages/babel-plugin-fbt/src/fbt-nodes/FbtElementNode.js [151:189]
project: enforceString(rawOptions.project || ''),
subject: enforceBabelNodeCallExpressionArg.orNull(rawOptions.subject),
};
} catch (error) {
throw errorAt(node, error);
}
}
static getArgsForStringVariationCalcForFbtElement(
instance: FbtElementNode | FbtImplicitParamNodeType,
subject: ?BabelNode,
): $ReadOnlyArray<AnyStringVariationArg> {
return (
isNode(subject)
? [new GenderStringVariationArg(instance, subject, [GENDER_ANY])]
: []
).concat(...instance.children.map(c => c.getArgsForStringVariationCalc()));
}
getArgsForStringVariationCalc(): $ReadOnlyArray<AnyStringVariationArg> {
return this.constructor.getArgsForStringVariationCalcForFbtElement(
this,
this.options.subject,
);
}
/**
* Run some sanity checks before producing text
* @throws if some fbt nodes in the tree have duplicate token names
*/
static beforeGetTextSanityCheck(
instance: FbtElementNode | FbtImplicitParamNodeType,
argsMap: StringVariationArgsMap,
): void {
const FbtSameParamNode = require('./FbtSameParamNode');
instance.children.forEach(child => {
const tokenName = child.getTokenName(argsMap);
// FbtSameParamNode token names are allowed to be redundant by design
if (tokenName != null && !(child instanceof FbtSameParamNode)) {