public void visit(ASTNode[] nodes, SourceUnit source) {
init(nodes, source);
AnnotatedNode parent = (AnnotatedNode) nodes[1];
AnnotationNode node = (AnnotationNode) nodes[0];
if (parent instanceof FieldNode) {
FieldNode fieldNode = (FieldNode) parent;
final ClassNode type = fieldNode.getType();
final ClassNode owner = fieldNode.getOwner();
if (type.equals(ClassHelper.OBJECT_TYPE) || type.equals(GROOVYOBJECT_TYPE)) {
addError(MY_TYPE_NAME + " field '" + fieldNode.getName() + "' has an inappropriate type: " + type.getName() +
". Please add an explicit type but not java.lang.Object or groovy.lang.GroovyObject.", parent);
return;
}
if (type.equals(owner)) {
addError(MY_TYPE_NAME + " field '" + fieldNode.getName() + "' has an inappropriate type: " + type.getName() +
". Delegation to own type not supported. Please use a different type.", parent);
return;
}
final List<MethodNode> fieldMethods = getAllMethods(type);
for (ClassNode next : type.getAllInterfaces()) {
fieldMethods.addAll(getAllMethods(next));
}
final boolean skipInterfaces = hasBooleanValue(node.getMember(MEMBER_INTERFACES), false);
final boolean includeDeprecated = hasBooleanValue(node.getMember(MEMBER_DEPRECATED), true) || (type.isInterface() && !skipInterfaces);
List<String> excludes = getMemberList(node, MEMBER_EXCLUDES);
List<String> includes = getMemberList(node, MEMBER_INCLUDES);
List<ClassNode> excludeTypes = getClassList(node, MEMBER_EXCLUDE_TYPES);
List<ClassNode> includeTypes = getClassList(node, MEMBER_INCLUDE_TYPES);
checkIncludeExclude(node, excludes, includes, excludeTypes, includeTypes, MY_TYPE_NAME);