String functionName = x.getResourceFunction();
if (functionName == null) {
logger.log(TreeLogger.ERROR, "The @sprite rule " + x.getSelectors()
+ " must specify the " + CssSprite.IMAGE_PROPERTY_NAME + " property");
throw new CssCompilerException("No image property specified");
}
// Find the image accessor method
JMethod imageMethod = null;
JMethod[] allMethods = bundleType.getOverridableMethods();
for (int i = 0; imageMethod == null && i < allMethods.length; i++) {
JMethod candidate = allMethods[i];
// If the function name matches and takes no parameters
if (candidate.getName().equals(functionName)
&& candidate.getParameters().length == 0) {
// We have a match
imageMethod = candidate;
}
}
// Method unable to be located
if (imageMethod == null) {
logger.log(TreeLogger.ERROR, "Unable to find ImageResource method "
+ functionName + " in " + bundleType.getQualifiedSourceName());
throw new CssCompilerException("Cannot find image function");
}
JClassType imageResourceType = context.getGeneratorContext().getTypeOracle().findType(
ImageResource.class.getName());
assert imageResourceType != null;
if (!imageResourceType.isAssignableFrom(imageMethod.getReturnType().isClassOrInterface())) {
logger.log(TreeLogger.ERROR, "The return type of " + functionName
+ " is not assignable to " + imageResourceType.getSimpleSourceName());
throw new CssCompilerException("Incorrect return type for "
+ CssSprite.IMAGE_PROPERTY_NAME + " method");
}
ImageOptions options = imageMethod.getAnnotation(ImageOptions.class);
RepeatStyle repeatStyle;