Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting methods in the same order as an implementing interface in Eclipse

Tags:

java

eclipse

I'm looking for a way to sort the methods in a class in the same way as they are ordered in the interface they are overriding.

It's a class only implementing methods from one interface so they shouldn't be any problems.

I found the basic sorting functionality from Eclipse, but, as far as I found out, it can only sort with respect to the method type and the method name.

Any ideas? Eclipse plugins?

Thanks!

like image 531
Steven Roose Avatar asked Nov 14 '22 05:11

Steven Roose


1 Answers

If you can modify the interface source also, use Source->Sort members on both the interface and the class. Afterwards they have the same order of methods.

I'm still wondering what you are trying to reach by sorting the code, as I see no necessity for that, because

  • You can have the outline sorted, so the logical structure can be shown as you want it, independent of the file content.
  • I can also not see a need to compare the two files textually, as the compiler will always tell you whether or not they match.
like image 63
Bananeweizen Avatar answered Nov 16 '22 03:11

Bananeweizen