fix(gui): resolve some minor rename issues
- correct variable definition in method arguments - refresh current class if rename interface method
This commit is contained in:
@@ -228,7 +228,7 @@ public class MethodGen {
|
||||
}
|
||||
code.add(' ');
|
||||
if (code.isMetadataSupported() && ssaVar != null) {
|
||||
code.attachAnnotation(VarDeclareRef.get(mth, var));
|
||||
code.attachDefinition(VarDeclareRef.get(mth, var));
|
||||
}
|
||||
code.add(nameGen.assignArg(var));
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ public class RegionGen extends InsnGen {
|
||||
} else if (arg instanceof RegisterArg) {
|
||||
CodeVar codeVar = ((RegisterArg) arg).getSVar().getCodeVar();
|
||||
if (code.isMetadataSupported()) {
|
||||
code.attachAnnotation(VarDeclareRef.get(mth, codeVar));
|
||||
code.attachDefinition(VarDeclareRef.get(mth, codeVar));
|
||||
}
|
||||
code.add(mgen.getNameGen().assignArg(codeVar));
|
||||
} else if (arg instanceof NamedArg) {
|
||||
|
||||
@@ -717,19 +717,15 @@ public class MainWindow extends JFrame {
|
||||
}
|
||||
}
|
||||
|
||||
private void rename(JNode node) {
|
||||
RenameDialog.rename(this, node);
|
||||
}
|
||||
|
||||
private void treeRightClickAction(MouseEvent e) {
|
||||
JNode obj = getJNodeUnderMouse(e, false);
|
||||
if (obj instanceof JPackage) {
|
||||
JPackagePopupMenu menu = new JPackagePopupMenu(this, (JPackage) obj);
|
||||
menu.show(e.getComponent(), e.getX(), e.getY());
|
||||
} else if (obj instanceof JClass || obj instanceof JField || obj instanceof JMethod) {
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
JMenuItem jmi = new JMenuItem(NLS.str("popup.rename"));
|
||||
jmi.addActionListener(action -> rename(obj));
|
||||
jmi.addActionListener(action -> RenameDialog.rename(this, obj));
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
menu.add(jmi);
|
||||
menu.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class RenameAction extends JNodeMenuAction<JNode> {
|
||||
LOG.warn("Can't rename node: {}", node);
|
||||
return;
|
||||
}
|
||||
RenameDialog.rename(codeArea.getMainWindow(), node);
|
||||
RenameDialog.rename(codeArea.getMainWindow(), codeArea.getNode(), node);
|
||||
node = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,19 +68,25 @@ public class RenameDialog extends JDialog {
|
||||
|
||||
private final transient MainWindow mainWindow;
|
||||
private final transient CacheObject cache;
|
||||
private final transient JNode source;
|
||||
private final transient JNode node;
|
||||
private transient JTextField renameField;
|
||||
|
||||
public static boolean rename(MainWindow mainWindow, JNode node) {
|
||||
RenameDialog renameDialog = new RenameDialog(mainWindow, node);
|
||||
return rename(mainWindow, node, node);
|
||||
}
|
||||
|
||||
public static boolean rename(MainWindow mainWindow, JNode source, JNode node) {
|
||||
RenameDialog renameDialog = new RenameDialog(mainWindow, source, node);
|
||||
renameDialog.setVisible(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
private RenameDialog(MainWindow mainWindow, JNode node) {
|
||||
private RenameDialog(MainWindow mainWindow, JNode source, JNode node) {
|
||||
super(mainWindow);
|
||||
this.mainWindow = mainWindow;
|
||||
this.cache = mainWindow.getCacheObject();
|
||||
this.source = source;
|
||||
this.node = node;
|
||||
initUI();
|
||||
}
|
||||
@@ -158,6 +164,9 @@ public class RenameDialog extends JDialog {
|
||||
JavaNode javaNode = node.getJavaNode();
|
||||
|
||||
List<JavaNode> toUpdate = new ArrayList<>();
|
||||
if (source != null && source != node) {
|
||||
toUpdate.add(source.getJavaNode());
|
||||
}
|
||||
if (javaNode != null) {
|
||||
toUpdate.add(javaNode);
|
||||
toUpdate.addAll(javaNode.getUseIn());
|
||||
@@ -171,8 +180,8 @@ public class RenameDialog extends JDialog {
|
||||
}
|
||||
Set<JClass> updatedTopClasses = toUpdate
|
||||
.stream()
|
||||
.map(JavaNode::getTopParentClass)
|
||||
.map(nodeCache::makeFrom)
|
||||
.map(JNode::getRootClass)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user