Search in sources :

Example 1 with AnnotationsList

use of jadx.core.dex.attributes.annotations.AnnotationsList in project jadx by skylot.

the class AnnotationsParser method readAnnotationSet.

private AnnotationsList readAnnotationSet(int offset) throws DecodeException {
    if (offset == 0) {
        return AnnotationsList.EMPTY;
    }
    Section section = dex.openSection(offset);
    int size = section.readInt();
    if (size == 0) {
        return AnnotationsList.EMPTY;
    }
    List<Annotation> list = new ArrayList<Annotation>(size);
    for (int i = 0; i < size; i++) {
        Section anSection = dex.openSection(section.readInt());
        Annotation a = readAnnotation(dex, anSection, true);
        list.add(a);
    }
    return new AnnotationsList(list);
}
Also used : ArrayList(java.util.ArrayList) AnnotationsList(jadx.core.dex.attributes.annotations.AnnotationsList) Section(com.android.dex.Dex.Section) Annotation(jadx.core.dex.attributes.annotations.Annotation)

Example 2 with AnnotationsList

use of jadx.core.dex.attributes.annotations.AnnotationsList in project jadx by skylot.

the class AnnotationGen method add.

private void add(IAttributeNode node, CodeWriter code) {
    AnnotationsList aList = node.get(AType.ANNOTATION_LIST);
    if (aList == null || aList.isEmpty()) {
        return;
    }
    for (Annotation a : aList.getAll()) {
        String aCls = a.getAnnotationClass();
        if (aCls.startsWith(Consts.DALVIK_ANNOTATION_PKG)) {
            // skip
            if (Consts.DEBUG) {
                code.startLine("// " + a);
            }
        } else {
            code.startLine();
            formatAnnotation(code, a);
        }
    }
}
Also used : AnnotationsList(jadx.core.dex.attributes.annotations.AnnotationsList) Annotation(jadx.core.dex.attributes.annotations.Annotation)

Example 3 with AnnotationsList

use of jadx.core.dex.attributes.annotations.AnnotationsList in project jadx by skylot.

the class AnnotationGen method addForParameter.

public void addForParameter(CodeWriter code, MethodParameters paramsAnnotations, int n) {
    List<AnnotationsList> paramList = paramsAnnotations.getParamList();
    if (n >= paramList.size()) {
        return;
    }
    AnnotationsList aList = paramList.get(n);
    if (aList == null || aList.isEmpty()) {
        return;
    }
    for (Annotation a : aList.getAll()) {
        formatAnnotation(code, a);
        code.add(' ');
    }
}
Also used : AnnotationsList(jadx.core.dex.attributes.annotations.AnnotationsList) Annotation(jadx.core.dex.attributes.annotations.Annotation)

Aggregations

Annotation (jadx.core.dex.attributes.annotations.Annotation)3 AnnotationsList (jadx.core.dex.attributes.annotations.AnnotationsList)3 Section (com.android.dex.Dex.Section)1 ArrayList (java.util.ArrayList)1