Search in sources :

Example 6 with IAnnotation

use of jadx.api.plugins.input.data.annotations.IAnnotation in project jadx by skylot.

the class PrepareForCodeGen method checkEncodedValue.

@SuppressWarnings("unchecked")
private void checkEncodedValue(MethodNode mth, EncodedValue encodedValue) {
    switch(encodedValue.getType()) {
        case ENCODED_FIELD:
            Object fieldData = encodedValue.getValue();
            FieldInfo fieldInfo;
            if (fieldData instanceof IFieldRef) {
                fieldInfo = FieldInfo.fromRef(mth.root(), (IFieldRef) fieldData);
            } else {
                fieldInfo = (FieldInfo) fieldData;
            }
            FieldNode fieldNode = mth.root().resolveField(fieldInfo);
            if (fieldNode != null) {
                fieldNode.addUseIn(mth);
            }
            break;
        case ENCODED_ANNOTATION:
            IAnnotation annotation = (IAnnotation) encodedValue.getValue();
            annotation.getValues().forEach((k, v) -> checkEncodedValue(mth, v));
            break;
        case ENCODED_ARRAY:
            List<EncodedValue> valueList = (List<EncodedValue>) encodedValue.getValue();
            valueList.forEach(v -> checkEncodedValue(mth, v));
            break;
    }
}
Also used : IAnnotation(jadx.api.plugins.input.data.annotations.IAnnotation) EncodedValue(jadx.api.plugins.input.data.annotations.EncodedValue) FieldNode(jadx.core.dex.nodes.FieldNode) InsnList(jadx.core.utils.InsnList) List(java.util.List) IFieldRef(jadx.api.plugins.input.data.IFieldRef) FieldInfo(jadx.core.dex.info.FieldInfo)

Aggregations

IAnnotation (jadx.api.plugins.input.data.annotations.IAnnotation)6 AnnotationsAttr (jadx.api.plugins.input.data.attributes.types.AnnotationsAttr)4 EncodedValue (jadx.api.plugins.input.data.annotations.EncodedValue)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Nullable (org.jetbrains.annotations.Nullable)2 IClassData (jadx.api.plugins.input.data.IClassData)1 IFieldRef (jadx.api.plugins.input.data.IFieldRef)1 AnnotationVisibility (jadx.api.plugins.input.data.annotations.AnnotationVisibility)1 EncodedType (jadx.api.plugins.input.data.annotations.EncodedType)1 IJadxAttribute (jadx.api.plugins.input.data.attributes.IJadxAttribute)1 AnnotationDefaultClassAttr (jadx.api.plugins.input.data.attributes.types.AnnotationDefaultClassAttr)1 ExceptionsAttr (jadx.api.plugins.input.data.attributes.types.ExceptionsAttr)1 InnerClassesAttr (jadx.api.plugins.input.data.attributes.types.InnerClassesAttr)1 InnerClsInfo (jadx.api.plugins.input.data.attributes.types.InnerClsInfo)1 MethodParametersAttr (jadx.api.plugins.input.data.attributes.types.MethodParametersAttr)1 SignatureAttr (jadx.api.plugins.input.data.attributes.types.SignatureAttr)1 Utils (jadx.api.plugins.utils.Utils)1 ClsAliasPair (jadx.core.deobf.ClsAliasPair)1 AttributeStorage (jadx.core.dex.attributes.AttributeStorage)1