public class MsgSubstUnitBaseVarNameUtils extends Object
Important: Do not use outside of Soy code (treat as superpackage-private).
Modifier and Type | Method and Description |
---|---|
static String |
genNaiveBaseNameForExpr(ExprRootNode<?> exprRoot,
String fallbackBaseName)
Helper function to generate a base placeholder (or plural/select var) name from an expression,
using the naive algorithm.
|
static List<String> |
genNoncollidingBaseNamesForExprs(List<ExprRootNode<?>> exprRoots,
String fallbackBaseName)
Generates base names for all the expressions in a list, where for each expression, we use the
shortest candidate base name that does not collide with any of the candidate base names
generated from other expressions in the list.
|
static String |
genShortestBaseNameForExpr(ExprRootNode<?> exprRoot,
String fallbackBaseName)
The equivalent of
genNaiveBaseNameForExpr() in our new algorithm for generating base
name. |
public static String genNaiveBaseNameForExpr(ExprRootNode<?> exprRoot, String fallbackBaseName)
exprRoot
- The root node for an expression.fallbackBaseName
- The fallback base name.public static String genShortestBaseNameForExpr(ExprRootNode<?> exprRoot, String fallbackBaseName)
genNaiveBaseNameForExpr()
in our new algorithm for generating base
name.
Examples: $aaaBbb -> AAA_BBB; $aaa_bbb -> AAA_BBB; $aaa.bbb -> BBB; $ij.aaa -> AAA;
aaa.BBB -> BBB; $aaa.0 -> AAA_0; $aaa[0] -> AAA_0; $aaa[0].bbb -> BBB; length($aaa) ->
fallback; $aaa + 1 -> fallbackexprRoot
- The expr root of the expression to generate the shortest base name for.fallbackBaseName
- The fallback base name to use if the given expression doesn't generate
any base names.public static List<String> genNoncollidingBaseNamesForExprs(List<ExprRootNode<?>> exprRoots, String fallbackBaseName) throws SoySyntaxException
exprRoots
- The expr roots of the expressions to generate noncolliding base names for.fallbackBaseName
- The fallback base name.SoySyntaxException
- If it is impossible to generate noncolliding base names.