Automatically rearrange methods in Alphabetical order

Issue #2124 new
Wim Velzeboer created an issue

I found a plugin for IntelliJ/WebStorm named "Save Actions" by Alexandre DuBreuil, which should be able to rearrange method in alphabetical order, but the Apex code is missing a "Arrangement" tab in set for it to function properly.

I found that having methods in a certain order helps resolving merge conflicts and prevents duplication when another branch adds a method with the same name but in a different location in an Apex class.

It would help a great deal if I could re-arrange an Apex Class, in this order:

  • Constants at the top

  • Class variables

  • Constructors

  • Methods

  • Subclasses

  • Exception classes

All in the order of the their access modifiers: Global, Public, Protected, Private

And every method per access modifier alphabetically ordered. 

Having all this with one button click, would be fantastic! 

Could this be added to Illuminated Cloud?

Comments (4)

  1. Adam Stepanek

    @Wim Velzeboer in IDEA this comes out of the box without any plugin, so not sure if the arrangement tab you are referring to is really coming from the plugin.

    For JavaScript, it works just fine.

    IDEA have this tab for JavaScript and for Java, therefore I thought @Scott Wells that it could be easily adopted. As with other Java-specific features in IDEA, when I change the extension from .cls to .java the arrangement action works, but does terrible job.

  2. Scott Wells repo owner

    Adam, what’s being requested here is support for that feature specifically in Apex, and things like this have to be implemented for any custom language. The IDE already has the general concept, but it has no idea (no pun intended) how to apply that concept to a new language. That’s pretty much true of almost all of the core language features in the IDE. The “shell” of the feature is present, but the actual details have to be provided by the plugin implementing a custom language.

  3. Log in to comment