Search in sources :

Example 1 with JavaVariable

use of jadx.api.JavaVariable in project jadx by skylot.

the class JNodeCache method convert.

private JNode convert(JavaNode node) {
    if (node == null) {
        return null;
    }
    if (node instanceof JavaClass) {
        return convert(((JavaClass) node));
    }
    if (node instanceof JavaMethod) {
        return new JMethod((JavaMethod) node, makeFrom(node.getDeclaringClass()));
    }
    if (node instanceof JavaField) {
        return new JField((JavaField) node, makeFrom(node.getDeclaringClass()));
    }
    if (node instanceof JavaVariable) {
        JavaVariable javaVar = (JavaVariable) node;
        JMethod jMth = (JMethod) makeFrom(javaVar.getMth());
        return new JVariable(jMth, javaVar);
    }
    throw new JadxRuntimeException("Unknown type for JavaNode: " + node.getClass());
}
Also used : JVariable(jadx.gui.treemodel.JVariable) JField(jadx.gui.treemodel.JField) JavaField(jadx.api.JavaField) JavaClass(jadx.api.JavaClass) JavaVariable(jadx.api.JavaVariable) JavaMethod(jadx.api.JavaMethod) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) JMethod(jadx.gui.treemodel.JMethod)

Example 2 with JavaVariable

use of jadx.api.JavaVariable in project jadx by skylot.

the class RenameDialog method buildRename.

@NotNull
private JadxCodeRename buildRename(JNode node, String newName, Set<ICodeRename> renames) {
    if (node instanceof JMethod) {
        JavaMethod javaMethod = ((JMethod) node).getJavaMethod();
        List<JavaMethod> relatedMethods = javaMethod.getOverrideRelatedMethods();
        if (!relatedMethods.isEmpty()) {
            for (JavaMethod relatedMethod : relatedMethods) {
                renames.remove(new JadxCodeRename(JadxNodeRef.forMth(relatedMethod), ""));
            }
        }
        return new JadxCodeRename(JadxNodeRef.forMth(javaMethod), newName);
    }
    if (node instanceof JField) {
        return new JadxCodeRename(JadxNodeRef.forFld(((JField) node).getJavaField()), newName);
    }
    if (node instanceof JClass) {
        return new JadxCodeRename(JadxNodeRef.forCls(((JClass) node).getCls()), newName);
    }
    if (node instanceof JPackage) {
        return new JadxCodeRename(JadxNodeRef.forPkg(((JPackage) node).getFullName()), newName);
    }
    if (node instanceof JVariable) {
        JavaVariable javaVar = ((JVariable) node).getJavaVarNode();
        return new JadxCodeRename(JadxNodeRef.forMth(javaVar.getMth()), JadxCodeRef.forVar(javaVar), newName);
    }
    throw new JadxRuntimeException("Failed to build rename node for: " + node);
}
Also used : JVariable(jadx.gui.treemodel.JVariable) JField(jadx.gui.treemodel.JField) JavaVariable(jadx.api.JavaVariable) JClass(jadx.gui.treemodel.JClass) JPackage(jadx.gui.treemodel.JPackage) JavaMethod(jadx.api.JavaMethod) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) JMethod(jadx.gui.treemodel.JMethod) JadxCodeRename(jadx.api.data.impl.JadxCodeRename) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JavaMethod (jadx.api.JavaMethod)2 JavaVariable (jadx.api.JavaVariable)2 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)2 JField (jadx.gui.treemodel.JField)2 JMethod (jadx.gui.treemodel.JMethod)2 JVariable (jadx.gui.treemodel.JVariable)2 JavaClass (jadx.api.JavaClass)1 JavaField (jadx.api.JavaField)1 JadxCodeRename (jadx.api.data.impl.JadxCodeRename)1 JClass (jadx.gui.treemodel.JClass)1 JPackage (jadx.gui.treemodel.JPackage)1 NotNull (org.jetbrains.annotations.NotNull)1