-
Notifications
You must be signed in to change notification settings - Fork 889
Organize Members hint: don't rearrange record components #8220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
if the formatter is configured to sort members alphabetically, the hint should not rearrange record components.
646d9ba
to
75199a9
Compare
for (Tree tree : clazz.getMembers()) { | ||
if (copy.getTreeUtilities().isSynthetic(new TreePath(path, tree))) { | ||
// isSynthetic does not consider record components to be synthetic | ||
if (copy.getTreeUtilities().isSynthetic(new TreePath(path, tree)) | ||
&& !(tree.getKind() == Kind.VARIABLE && copy.getTreeUtilities().isRecordComponent((VariableTree)tree))) { | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought this is lower risk than updating isSynthetic()
although it probably should be updated at some point.
inserting
if (path.getLeaf().getKind() == Kind.VARIABLE &&
path.getParentPath() != null &&
path.getParentPath().getLeaf().getKind() == Kind.RECORD) {
Set<Modifier> mods = ((VariableTree) path.getLeaf()).getModifiers().getFlags();
if (!mods.contains(Modifier.STATIC)) {
return true; // all non static record fields are synthetic
}
}
at
would work@Override | ||
protected boolean runInEQ() { | ||
// without it, hint markers are sometimes not found | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know why this is needed. OrganizeMembers
invokes runModificationTask
which calls copy.rewrite()
at some point.
result.getDifferences(source.getFileObject())
is sometimes null if tests don't run on EDT.
if the formatter is configured to sort members alphabetically, the hint should not rearrange record components.
The fix reuses the existing special case for enums, which holds the enum "members" in place and does the same for synthetic record members.