Search in sources :

Example 1 with InfoStorage

use of jadx.core.dex.info.InfoStorage in project jadx by skylot.

the class UserRenames method applyForNodes.

public static void applyForNodes(RootNode root) {
    ICodeData codeData = root.getArgs().getCodeData();
    if (codeData == null || codeData.getRenames().isEmpty()) {
        return;
    }
    InfoStorage infoStorage = root.getInfoStorage();
    codeData.getRenames().stream().filter(r -> r.getCodeRef() == null && r.getNodeRef().getType() != IJavaNodeRef.RefType.PKG).collect(Collectors.groupingBy(r -> r.getNodeRef().getDeclaringClass())).forEach((clsRawName, renames) -> {
        ClassInfo clsInfo = infoStorage.getCls(ArgType.object(clsRawName));
        if (clsInfo != null) {
            ClassNode cls = root.resolveClass(clsInfo);
            if (cls != null) {
                for (ICodeRename rename : renames) {
                    applyRename(cls, rename);
                }
                return;
            }
        }
        LOG.warn("Class info with reference '{}' not found", clsRawName);
    });
    applyPkgRenames(root, codeData.getRenames());
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) ICodeRename(jadx.api.data.ICodeRename) InfoStorage(jadx.core.dex.info.InfoStorage) ICodeData(jadx.api.data.ICodeData) ClassInfo(jadx.core.dex.info.ClassInfo)

Aggregations

ICodeData (jadx.api.data.ICodeData)1 ICodeRename (jadx.api.data.ICodeRename)1 ClassInfo (jadx.core.dex.info.ClassInfo)1 InfoStorage (jadx.core.dex.info.InfoStorage)1 ClassNode (jadx.core.dex.nodes.ClassNode)1