Search in sources :

Example 16 with Annotation

use of com.taobao.android.dx.rop.annotation.Annotation in project atlas by alibaba.

the class AnnotationParser method parseAnnotation.

/**
 * Parses a single annotation.
 *
 * @param visibility {@code non-null;} visibility of the parsed annotation
 * @return {@code non-null;} the parsed annotation
 */
private Annotation parseAnnotation(AnnotationVisibility visibility) throws IOException {
    requireLength(4);
    int typeIndex = input.readUnsignedShort();
    int numElements = input.readUnsignedShort();
    CstString typeString = (CstString) pool.get(typeIndex);
    CstType type = new CstType(Type.intern(typeString.getString()));
    if (observer != null) {
        parsed(2, "type: " + type.toHuman());
        parsed(2, "num_elements: " + numElements);
    }
    Annotation annotation = new Annotation(type, visibility);
    for (int i = 0; i < numElements; i++) {
        if (observer != null) {
            parsed(0, "elements[" + i + "]:");
            changeIndent(1);
        }
        NameValuePair element = parseElement();
        annotation.add(element);
        if (observer != null) {
            changeIndent(-1);
        }
    }
    annotation.setImmutable();
    return annotation;
}
Also used : NameValuePair(com.taobao.android.dx.rop.annotation.NameValuePair) CstType(com.taobao.android.dx.rop.cst.CstType) CstString(com.taobao.android.dx.rop.cst.CstString) Annotation(com.taobao.android.dx.rop.annotation.Annotation) CstAnnotation(com.taobao.android.dx.rop.cst.CstAnnotation)

Aggregations

Annotation (com.taobao.android.dx.rop.annotation.Annotation)16 CstAnnotation (com.taobao.android.dx.rop.cst.CstAnnotation)10 NameValuePair (com.taobao.android.dx.rop.annotation.NameValuePair)9 Annotations (com.taobao.android.dx.rop.annotation.Annotations)5 CstArray (com.taobao.android.dx.rop.cst.CstArray)4 CstString (com.taobao.android.dx.rop.cst.CstString)4 CstType (com.taobao.android.dx.rop.cst.CstType)4 AttRuntimeInvisibleAnnotations (com.taobao.android.dx.cf.attrib.AttRuntimeInvisibleAnnotations)3 AttRuntimeInvisibleParameterAnnotations (com.taobao.android.dx.cf.attrib.AttRuntimeInvisibleParameterAnnotations)3 AttRuntimeVisibleAnnotations (com.taobao.android.dx.cf.attrib.AttRuntimeVisibleAnnotations)3 AttRuntimeVisibleParameterAnnotations (com.taobao.android.dx.cf.attrib.AttRuntimeVisibleParameterAnnotations)3 AttributeList (com.taobao.android.dx.cf.iface.AttributeList)2 AnnotationsList (com.taobao.android.dx.rop.annotation.AnnotationsList)2 CstNat (com.taobao.android.dx.rop.cst.CstNat)2 TypeList (com.taobao.android.dx.rop.type.TypeList)2 AttAnnotationDefault (com.taobao.android.dx.cf.attrib.AttAnnotationDefault)1 AttEnclosingMethod (com.taobao.android.dx.cf.attrib.AttEnclosingMethod)1 Method (com.taobao.android.dx.cf.iface.Method)1 MethodList (com.taobao.android.dx.cf.iface.MethodList)1 ParseException (com.taobao.android.dx.cf.iface.ParseException)1