fix(gui): rename class while rename constructor (#1441)
This commit is contained in:
@@ -103,6 +103,9 @@ public class JMethod extends JNode {
|
||||
|
||||
@Override
|
||||
public boolean canRename() {
|
||||
if (mth.isClassInit()) {
|
||||
return false;
|
||||
}
|
||||
return !mth.getMethodNode().contains(AFlag.DONT_RENAME);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,10 +87,24 @@ public class RenameDialog extends JDialog {
|
||||
this.mainWindow = mainWindow;
|
||||
this.cache = mainWindow.getCacheObject();
|
||||
this.source = source;
|
||||
this.node = node;
|
||||
this.node = replaceNode(node);
|
||||
initUI();
|
||||
}
|
||||
|
||||
private JNode replaceNode(JNode node) {
|
||||
if (node instanceof JMethod) {
|
||||
JavaMethod javaMethod = ((JMethod) node).getJavaMethod();
|
||||
if (javaMethod.isClassInit()) {
|
||||
throw new JadxRuntimeException("Can't rename class init method: " + node);
|
||||
}
|
||||
if (javaMethod.isConstructor()) {
|
||||
// rename class instead constructor
|
||||
return node.getJParent();
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private void rename() {
|
||||
try {
|
||||
updateCodeRenames(set -> processRename(node, renameField.getText(), set));
|
||||
|
||||
Reference in New Issue
Block a user