Skip to content

fix(gui): fix rename package behaviors#2500

Merged
skylot merged 2 commits intoskylot:masterfrom
MrIkso:fix_rename_package_behaviors
May 22, 2025
Merged

fix(gui): fix rename package behaviors#2500
skylot merged 2 commits intoskylot:masterfrom
MrIkso:fix_rename_package_behaviors

Conversation

@MrIkso
Copy link
Copy Markdown
Contributor

@MrIkso MrIkso commented May 20, 2025

Related to #1590 (comment)

renameField.setText(node.getName());
if (node instanceof JRenamePackage) {
JRenamePackage renamePackage = (JRenamePackage) node;
renameField.setText(renamePackage.getTitle());
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if you want to see full name instead short name in editor box, you can just change "name" to "fullName" in JRenamePackage.getName() method.
But, short name used here intentionally, because detecting changed part in full name is much harder. It is unclear if the middle package name was renamed or rest moved into a new package. Also, packages count can change and that complicate things even more.
I am actually implemented a full package rename, but it is just safer and easier to rename only one part.

I will also look into this issue, maybe I will be able to find a root cause.

Copy link
Copy Markdown
Contributor Author

@MrIkso MrIkso May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will also look into this issue, maybe I will be able to find a root cause.

I thik here root cuase or it not bug(?) on pt 2

String name = jPkg.isSynthetic() || javaPkg.isParentRenamed() ? fullName : javaPkg.getName();

@skylot
Copy link
Copy Markdown
Owner

skylot commented May 22, 2025

I checked current code, and have only bad news 🤣 :

  1. current renames serialization approach doesn't support synthetic and default packages renames
  2. packages tree still not refreshed after moving class (or package) into different package

Here "synthetic package" is a package created by user during moving a class to a new package, such package doesn't have a “reference” so it can't be saved with current approach. It is possible to use other nodes as references, I will create a new issue for that. For now, I just disable rename for such packages 😭

Second issue: while your change is fixed tree refresh for simple renames, looks like structural changes to tree still not applied after moving class to different package (I suspect some caching issue). So original #1590 issue still not fixed.

@skylot skylot merged commit 092e897 into skylot:master May 22, 2025
4 checks passed
@MrIkso MrIkso deleted the fix_rename_package_behaviors branch May 23, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants