Is there an easy way to sort methods within a class in Eclipse?
Sorting methods in Eclipse
Asked Answered
Why would you want to sort the methods? –
Clockwork
I've got a couple of versions of the class to merge; this will make merging more straightforward, because some methods wound up at different places and diff doesn't resolve them nicely. –
Thomasina
By name is sufficient, but by protection, static-ness, and name is probably better. –
Thomasina
select the class, Source > Sort Members
you can set the order in Java preferences
via Eclipe forums
Sometimes this gives compilation error.Say if one variable is instantiated based on the other and it on sort the variable goes above. I was wondering if this can be handled in any way –
Timaru
@Timaru I usually handle this by hacking the variable name to force alphabetic order OR simply by not using sort members on that file... –
Gain
Found it on the Eclipse newsgroup:
select the class, Source > Sort Members
This answer was actually added one minute earlier than the selected one. –
Kanishakanji
First isn't always best, and generally it's better to have an answer from someone other than the OP. The accepted answer also includes some useful information about settings which my answer here is missing. –
Thomasina
Oh, I didn't noticed you were the OP. I understand now your decision. –
Kanishakanji
© 2022 - 2024 — McMap. All rights reserved.