use of org.codehaus.groovy.control.messages.ExceptionMessage in project groovy by apache.
the class ASTTransformationCollectorCodeVisitor method findCollectedAnnotations.
private void findCollectedAnnotations(AnnotationNode aliasNode, AnnotatedNode origin, Integer index, Map<Integer, AnnotationCollectorMode> modes, Map<Integer, List<AnnotationNode>> existing, Map<Integer, List<AnnotationNode>> replacements) {
ClassNode classNode = aliasNode.getClassNode();
for (AnnotationNode annotation : classNode.getAnnotations()) {
if (annotation.getClassNode().getName().equals(AnnotationCollector.class.getName())) {
AnnotationCollectorMode mode = getMode(annotation);
if (mode == null) {
mode = AnnotationCollectorMode.DUPLICATE;
}
modes.put(index, mode);
Expression processorExp = annotation.getMember("processor");
AnnotationCollectorTransform act = null;
assertStringConstant(processorExp);
if (processorExp != null) {
String className = (String) ((ConstantExpression) processorExp).getValue();
Class klass = loadTransformClass(className, aliasNode);
if (klass != null) {
try {
act = (AnnotationCollectorTransform) klass.newInstance();
} catch (InstantiationException e) {
source.getErrorCollector().addErrorAndContinue(new ExceptionMessage(e, true, source));
} catch (IllegalAccessException e) {
source.getErrorCollector().addErrorAndContinue(new ExceptionMessage(e, true, source));
}
}
} else {
act = new AnnotationCollectorTransform();
}
if (act != null) {
replacements.put(index, act.visit(annotation, aliasNode, origin, source));
return;
}
}
}
if (!replacements.containsKey(index)) {
existing.put(index, Collections.singletonList(aliasNode));
}
}
Aggregations