// TODO: Pass renaming rules to this method. public Remapper rename(Map<String, LinkedInterfaceNode> tree) { for (LinkedInterfaceNode node : tree.values()) { boolean cont; do { cont = false; if (node.rename("Class" + classPostfix) && !node.external) { ++classPostfix; cont = true; } } while (cont); } NameRemapper remapper = new NameRemapper(tree); for (LinkedInterfaceNode node : tree.values()) { if (node.name.startsWith("jag") && node.name.startsWith("jac")) { continue; } if (!node.external) { for (MemberNode field : node.getFields()) { if (node.renameField(field, getFieldName(remapper, field.desc, fieldPostfix))) { ++fieldPostfix; } } for (MemberNode method : node.getMethods()) { if (method.name.length() < 3) { if (node.renameMethod(method, "method" + methodPostfix)) { ++methodPostfix; } } } } } return remapper; }
public static void dumpMappings(Map<String, LinkedInterfaceNode> tree, File out) throws IOException { BufferedWriter writer = new BufferedWriter(new FileWriter(out)); for (LinkedInterfaceNode node : tree.values()) { if (!node.external) { String newName = node.getNewName(); if (newName != null) { writer.newLine(); writer.write(" Old Class:" + node.name + " New Class:" + node.getNewName()); writer.newLine(); writer.write("Fields Renamed \n"); writer.newLine(); for (MemberNode field : node.getFields()) { String desc = field.desc; String name_old = field.name; String name_new = node.getFieldName(name_old, desc); if (!name_old.equals(name_new)) { writer.write( " Old Field: " + name_old + " New: " + name_new + " Field Signature: " + desc); writer.newLine(); } } writer.newLine(); writer.write("Methods Renamed \n"); writer.newLine(); for (MemberNode method : node.getMethods()) { String desc = method.desc; String name_old = method.name; String name_new = node.getMethodName(name_old, method.desc); if (!name_old.equals(name_new)) { writer.write( " Old Method Name: " + name_old + " New Name: " + name_new + " Method Signature: " + desc); writer.newLine(); } } } else { writer.newLine(); writer.write(" Class:" + node.name); writer.newLine(); writer.write("Fields Renamed \n"); writer.newLine(); for (MemberNode field : node.getFields()) { String desc = field.desc; String name_old = field.name; String name_new = node.getFieldName(name_old, desc); if (!name_old.equals(name_new)) { writer.write( " Old Field: " + name_old + " New: " + name_new + " Field Signature: " + desc); writer.newLine(); } } writer.newLine(); writer.write("Methods Renamed \n"); writer.newLine(); for (MemberNode method : node.getMethods()) { String desc = method.desc; String name_old = method.name; String name_new = node.getMethodName(name_old, method.desc); if (!name_old.equals(name_new)) { writer.write( " Old Method Name: " + name_old + " New Name: " + name_new + " Method Signature: " + desc); writer.newLine(); } } } } } writer.flush(); }