Search in sources :

Example 6 with Visitor

use of org.apache.tapestry5.dom.Visitor in project tapestry-5 by apache.

the class AnnotationNode method accept.

/**
 * Makes the given visitor visit a given annotation value.
 *
 * @param annotationVisitor an annotation visitor. Maybe {@literal null}.
 * @param name the value name.
 * @param value the actual value.
 */
public static void accept(final AnnotationVisitor annotationVisitor, final String name, final Object value) {
    if (annotationVisitor != null) {
        if (value instanceof String[]) {
            String[] typeValue = (String[]) value;
            annotationVisitor.visitEnum(name, typeValue[0], typeValue[1]);
        } else if (value instanceof AnnotationNode) {
            AnnotationNode annotationValue = (AnnotationNode) value;
            annotationValue.accept(annotationVisitor.visitAnnotation(name, annotationValue.desc));
        } else if (value instanceof List) {
            AnnotationVisitor arrayAnnotationVisitor = annotationVisitor.visitArray(name);
            if (arrayAnnotationVisitor != null) {
                List<?> arrayValue = (List<?>) value;
                for (int i = 0, n = arrayValue.size(); i < n; ++i) {
                    accept(arrayAnnotationVisitor, null, arrayValue.get(i));
                }
                arrayAnnotationVisitor.visitEnd();
            }
        } else {
            annotationVisitor.visit(name, value);
        }
    }
}
Also used : AnnotationVisitor(org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with Visitor

use of org.apache.tapestry5.dom.Visitor in project tapestry-5 by apache.

the class FieldNode method accept.

/**
 * Makes the given class visitor visit this field.
 *
 * @param classVisitor a class visitor.
 */
public void accept(final ClassVisitor classVisitor) {
    FieldVisitor fieldVisitor = classVisitor.visitField(access, name, desc, signature, value);
    if (fieldVisitor == null) {
        return;
    }
    // Visit the annotations.
    if (visibleAnnotations != null) {
        for (int i = 0, n = visibleAnnotations.size(); i < n; ++i) {
            AnnotationNode annotation = visibleAnnotations.get(i);
            annotation.accept(fieldVisitor.visitAnnotation(annotation.desc, true));
        }
    }
    if (invisibleAnnotations != null) {
        for (int i = 0, n = invisibleAnnotations.size(); i < n; ++i) {
            AnnotationNode annotation = invisibleAnnotations.get(i);
            annotation.accept(fieldVisitor.visitAnnotation(annotation.desc, false));
        }
    }
    if (visibleTypeAnnotations != null) {
        for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) {
            TypeAnnotationNode typeAnnotation = visibleTypeAnnotations.get(i);
            typeAnnotation.accept(fieldVisitor.visitTypeAnnotation(typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, true));
        }
    }
    if (invisibleTypeAnnotations != null) {
        for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) {
            TypeAnnotationNode typeAnnotation = invisibleTypeAnnotations.get(i);
            typeAnnotation.accept(fieldVisitor.visitTypeAnnotation(typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, false));
        }
    }
    // Visit the non standard attributes.
    if (attrs != null) {
        for (int i = 0, n = attrs.size(); i < n; ++i) {
            fieldVisitor.visitAttribute(attrs.get(i));
        }
    }
    fieldVisitor.visitEnd();
}
Also used : FieldVisitor(org.apache.tapestry5.internal.plastic.asm.FieldVisitor)

Example 8 with Visitor

use of org.apache.tapestry5.dom.Visitor in project tapestry-5 by apache.

the class MethodNode method accept.

/**
 * Makes the given class visitor visit this method.
 *
 * @param classVisitor a class visitor.
 */
public void accept(final ClassVisitor classVisitor) {
    String[] exceptionsArray = exceptions == null ? null : exceptions.toArray(new String[0]);
    MethodVisitor methodVisitor = classVisitor.visitMethod(access, name, desc, signature, exceptionsArray);
    if (methodVisitor != null) {
        accept(methodVisitor);
    }
}
Also used : MethodVisitor(org.apache.tapestry5.internal.plastic.asm.MethodVisitor)

Aggregations

AnnotationVisitor (org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 OptionGroupModel (org.apache.tapestry5.OptionGroupModel)1 Element (org.apache.tapestry5.dom.Element)1 Visitor (org.apache.tapestry5.dom.Visitor)1 FieldVisitor (org.apache.tapestry5.internal.plastic.asm.FieldVisitor)1 MethodVisitor (org.apache.tapestry5.internal.plastic.asm.MethodVisitor)1 RecordComponentVisitor (org.apache.tapestry5.internal.plastic.asm.RecordComponentVisitor)1 TraceClassVisitor (org.apache.tapestry5.internal.plastic.asm.util.TraceClassVisitor)1