static <T extends CssNode & HasNodes> String makeExpression(
TreeLogger logger, ResourceContext context, JClassType cssResourceType,
T node, boolean prettyOutput) throws UnableToCompleteException {
// Generate the CSS template
DefaultTextOutput out = new DefaultTextOutput(!prettyOutput);
CssGenerationVisitor v = new CssGenerationVisitor(out);
v.accept(node);
// Generate the final Java expression
String template = out.toString();
StringBuilder b = new StringBuilder();
int start = 0;
/*
* Very large concatenation expressions using '+' cause the GWT compiler to
* overflow the stack due to deep AST nesting. The workaround for now is to
* force it to be more balanced using intermediate concatenation groupings.
*
* This variable is used to track the number of subexpressions within the
* current parenthetical expression.
*/
int numExpressions = 0;
b.append('(');
for (Map.Entry<Integer, List<CssSubstitution>> entry : v.getSubstitutionPositions().entrySet()) {
// Add the static section between start and the substitution point
b.append('"');
b.append(Generator.escape(template.substring(start, entry.getKey())));
b.append('\"');
numExpressions = concatOp(numExpressions, b);