String dataJs;
{
StringBuilder js = new StringBuilder();
JsMinimalPrinter tokenConsumer = new JsMinimalPrinter(js);
dataObj.render(new RenderContext(tokenConsumer));
tokenConsumer.noMoreTokens();
dataJs = js.toString();
}
String equivKey = dataJsToKey.get(dataJs);
Expression value = dataObj;
if (equivKey == null) {
dataJsToKey.put(dataJs, data.key);
} else {
value = StringLiteral.valueOf(unk, equivKey);
hasAliases = true;
}
cssSchemaProps.add(new ValueProperty(
unk, StringLiteral.valueOf(unk, data.key), value));
}
ObjectConstructor cssSchema = new ObjectConstructor(unk, cssSchemaProps);
ParseTreeNode js = QuasiBuilder.substV(
""
+ "var cssSchema = (function () {"
+ " @poolDecls?;"
+ " var schema = @cssSchema;"
+ " if (@hasAliases) {"
+ " for (var key in schema) {"
+ " if ('string' === typeof schema[key]"
+ " && Object.hasOwnProperty.call(schema, key)) {"
+ " schema[key] = schema[schema[key]];"
+ " }"
+ " }"
+ " }"
+ " return schema;"
+ "})();",
"poolDecls", poolDecls,
"cssSchema", cssSchema,
"hasAliases", new BooleanLiteral(unk, hasAliases));
TokenConsumer tc = js.makeRenderer(out, null);
js.render(new RenderContext(tc));
tc.noMoreTokens();
out.append(";\n");
}