-
Notifications
You must be signed in to change notification settings - Fork 7
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
Do not change visibility when sorting #142
Conversation
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.
Thanks!
I like the 2 pass solution. Although it was hard to understand at first, it may be useful to extract the core sorting logic to its own method (L37-L46). What do you think?
I think there is a better way to do this by using |
The SortNodes visitor also sorts Private and Protected nodes. This can cause the visibility of methods to change. For example, a private method called "a_thing" will always be moved before the private specifier, thus becoming public. This change extends the SortNodes visitor to individually sort the public, private, and protected nodes to preserve their visibility.
After looking into It does increase allocations, but perhaps that is a good tradeoff here, since this isn't runtime code? @KaanOzkan the code is now much shorter, so perhaps the helper method is not needed? I am on the fence, but leaned towards keeping it inline so that the flow is clear and matches the existing structure more closely. |
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.
This is definitely simpler thank you!
Hopefully fixes #141 . Updates the
SortNodes
visitor to preserve visibility of nodes. So, a file that looks likewill get sorted as
rather than as