collector.accept(cssStylesheet);
String name = toImplement.getName();
// TODO: Annotation for override
CssDef def = collector.getSubstitutions().get(name);
if (def == null) {
logger.log(TreeLogger.ERROR, "No @def rule for name " + name);
throw new UnableToCompleteException();
}
JClassType classReturnType = toImplement.getReturnType().isClass();
if (def.getValues().size() != 1 && !isReturnTypeString(classReturnType)) {
logger.log(TreeLogger.ERROR, "@def rule " + name
+ " must define exactly one value or return type must be String");
throw new UnableToCompleteException();
}
String returnExpr = "";
if (isReturnTypeString(classReturnType)) {
List<String> returnValues = new ArrayList<String>();
for (Value val : def.getValues()) {
returnValues.add(Generator.escape(val.toString()));
}
returnExpr = "\"" + Joiner.on(" ").join(returnValues) + "\"";
} else {
JPrimitiveType returnType = toImplement.getReturnType().isPrimitive();
if (returnType == null) {
logger.log(TreeLogger.ERROR, toImplement.getName()
+ ": Return type must be primitive type or String for "
+ "@def accessors");
throw new UnableToCompleteException();
}
NumberValue numberValue = def.getValues().get(0).isNumberValue();
if (returnType == JPrimitiveType.INT || returnType == JPrimitiveType.LONG) {
returnExpr = "" + Math.round(numberValue.getValue());
} else if (returnType == JPrimitiveType.FLOAT) {
returnExpr = numberValue.getValue() + "F";
} else if (returnType == JPrimitiveType.DOUBLE) {