// Don't try to substitute into anything other than idents
continue;
}
String value = v.getIdent();
CssDef def = substitutions.get(value);
if (def == null) {
continue;
} else if (def instanceof CssUrl) {
assert def.getValues().size() == 1;
assert def.getValues().get(0).isIdentValue() != null;
String functionName = def.getValues().get(0).isIdentValue().getIdent();
// Find the method
JMethod method = context.getResourceBundleType().findMethod(
functionName, new JType[0]);
if (method == null) {
logger.log(TreeLogger.ERROR, "Unable to find DataResource method "
+ functionName + " in "
+ context.getResourceBundleType().getQualifiedSourceName());
throw new CssCompilerException("Cannot find data function");
}
String instance = "((" + DataResource.class.getName() + ")("
+ context.getImplementationSimpleSourceName() + ".this."
+ functionName + "()))";
StringBuilder expression = new StringBuilder();
expression.append("\"url('\" + ");
expression.append(instance).append(".getUrl()");
expression.append(" + \"')\"");
i.set(new ExpressionValue(expression.toString()));
} else {
i.remove();
for (Value defValue : def.getValues()) {
i.add(defValue);
}
}
}