if (script.hasTransform(targetClass)) {
List<Transform> transforms = script.getTransformed();
int numTransforms = transforms.size();
for (Transform transform : transforms) {
Throwable throwable = transform.getThrowable();
Rule rule = transform.getRule();
String methodName = transform.getTriggerMethodName();
if (throwable != null) {
if (throwable instanceof ParseException) {
parseError("ERROR : Failed to parse rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine(), throwable);
} else if (throwable instanceof TypeWarningException) {
typeWarning("WARNING : Problem type checking rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName), throwable);
} else if (throwable instanceof TypeException) {
typeError("ERROR : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName), throwable);
} else {
error("ERROR : Unexpected exception transforming class " + targetClassName + " using rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName), throwable);
}
continue;
}
infoMessage = "Parsed rule \"" + script.getName() + "\" for class " + transform.getInternalClassName();
if (verbose) {
infoMessage += "# File " + script.getFile() + " line " + script.getLine() + "\n";
infoMessage += rule;
}
info(infoMessage);
// ok, now see if we can type check the rule
try {
rule.typeCheck();
rule.compile();
} catch (TypeWarningException te) {
typeWarning("WARNING : Unable to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName), te);
continue;
} catch (TypeException te) {
typeError("ERROR : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName), te);
continue;
} catch (CompileException ce) {
typeError("ERROR : Failed to compile rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine() + (methodName == null ? "" : " against method " + methodName), ce);
continue;
}
if (script.isOverride()) {
info("Type checked overriding rule \"" + script.getName() + "\" against method in declared class");
} else {
info("Type checked rule \"" + script.getName() + "\"");
}
}
} else if (targetClass.isInterface() || script.isOverride()) {
// ok, not necessarily a surprise - let's see if we can create a rule and parse/type check it
final Rule rule;
try {
rule = Rule.create(script, loader, null);
} catch (ParseException pe) {
parseError("ERROR : Failed to type check rule \"" + script.getName() + "\" loaded from " + script.getFile() + " line " + script.getLine(), pe);
continue;