Search in sources :

Example 16 with NameValuePair

use of com.android.dx.rop.annotation.NameValuePair in project buck by facebook.

the class AnnotationItem method annotateTo.

/**
     * Write a (listing file) annotation for this instance to the given
     * output, that consumes no bytes of output. This is for annotating
     * a reference to this instance at the point of the reference.
     *
     * @param out {@code non-null;} where to output to
     * @param prefix {@code non-null;} prefix for each line of output
     */
public void annotateTo(AnnotatedOutput out, String prefix) {
    out.annotate(0, prefix + "visibility: " + annotation.getVisibility().toHuman());
    out.annotate(0, prefix + "type: " + annotation.getType().toHuman());
    for (NameValuePair pair : annotation.getNameValuePairs()) {
        CstString name = pair.getName();
        Constant value = pair.getValue();
        out.annotate(0, prefix + name.toHuman() + ": " + ValueEncoder.constantToHuman(value));
    }
}
Also used : NameValuePair(com.android.dx.rop.annotation.NameValuePair) Constant(com.android.dx.rop.cst.Constant) CstString(com.android.dx.rop.cst.CstString)

Example 17 with NameValuePair

use of com.android.dx.rop.annotation.NameValuePair in project buck by facebook.

the class AnnotationUtils method makeMemberClasses.

/**
     * Constructs a standard {@code MemberClasses} annotation.
     *
     * @param types {@code non-null;} the list of (the types of) the member classes
     * @return {@code non-null;} the annotation
     */
public static Annotation makeMemberClasses(TypeList types) {
    CstArray array = makeCstArray(types);
    Annotation result = new Annotation(MEMBER_CLASSES_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, array));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.android.dx.rop.annotation.NameValuePair) CstArray(com.android.dx.rop.cst.CstArray) Annotation(com.android.dx.rop.annotation.Annotation) CstAnnotation(com.android.dx.rop.cst.CstAnnotation)

Example 18 with NameValuePair

use of com.android.dx.rop.annotation.NameValuePair in project buck by facebook.

the class AnnotationUtils method makeEnclosingMethod.

/**
     * Constructs a standard {@code EnclosingMethod} annotation.
     *
     * @param method {@code non-null;} the enclosing method
     * @return {@code non-null;} the annotation
     */
public static Annotation makeEnclosingMethod(CstMethodRef method) {
    Annotation result = new Annotation(ENCLOSING_METHOD_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, method));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.android.dx.rop.annotation.NameValuePair) Annotation(com.android.dx.rop.annotation.Annotation) CstAnnotation(com.android.dx.rop.cst.CstAnnotation)

Example 19 with NameValuePair

use of com.android.dx.rop.annotation.NameValuePair in project buck by facebook.

the class AnnotationUtils method makeThrows.

/**
     * Constructs a standard {@code Throws} annotation.
     *
     * @param types {@code non-null;} the list of thrown types
     * @return {@code non-null;} the annotation
     */
public static Annotation makeThrows(TypeList types) {
    CstArray array = makeCstArray(types);
    Annotation result = new Annotation(THROWS_TYPE, SYSTEM);
    result.put(new NameValuePair(VALUE_STRING, array));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.android.dx.rop.annotation.NameValuePair) CstArray(com.android.dx.rop.cst.CstArray) Annotation(com.android.dx.rop.annotation.Annotation) CstAnnotation(com.android.dx.rop.cst.CstAnnotation)

Example 20 with NameValuePair

use of com.android.dx.rop.annotation.NameValuePair in project buck by facebook.

the class AnnotationUtils method makeInnerClass.

/**
     * Constructs a standard {@code InnerClass} annotation.
     *
     * @param name {@code null-ok;} the original name of the class, or
     * {@code null} to represent an anonymous class
     * @param accessFlags the original access flags
     * @return {@code non-null;} the annotation
     */
public static Annotation makeInnerClass(CstString name, int accessFlags) {
    Annotation result = new Annotation(INNER_CLASS_TYPE, SYSTEM);
    Constant nameCst = (name != null) ? name : CstKnownNull.THE_ONE;
    result.put(new NameValuePair(NAME_STRING, nameCst));
    result.put(new NameValuePair(ACCESS_FLAGS_STRING, CstInteger.make(accessFlags)));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.android.dx.rop.annotation.NameValuePair) Constant(com.android.dx.rop.cst.Constant) Annotation(com.android.dx.rop.annotation.Annotation) CstAnnotation(com.android.dx.rop.cst.CstAnnotation)

Aggregations

NameValuePair (com.android.dx.rop.annotation.NameValuePair)29 Annotation (com.android.dx.rop.annotation.Annotation)20 CstAnnotation (com.android.dx.rop.cst.CstAnnotation)17 CstString (com.android.dx.rop.cst.CstString)10 Constant (com.android.dx.rop.cst.Constant)8 CstArray (com.android.dx.rop.cst.CstArray)6 CstType (com.android.dx.rop.cst.CstType)6 AttAnnotationDefault (com.android.dx.cf.attrib.AttAnnotationDefault)2 AttEnclosingMethod (com.android.dx.cf.attrib.AttEnclosingMethod)2 AttributeList (com.android.dx.cf.iface.AttributeList)2 Method (com.android.dx.cf.iface.Method)2 MethodList (com.android.dx.cf.iface.MethodList)2 TypeList (com.android.dx.rop.type.TypeList)2 ArrayList (java.util.ArrayList)2 ClassDefItem (com.android.dx.dex.file.ClassDefItem)1 Annotations (com.android.dx.rop.annotation.Annotations)1