I am thinking about adding the capability of rearranging (grouping and/or sorting) by annotation to the Rearranger plugin. There are several degrees of doing this, and I would appreciate your feedback on what would be useful to you.
Annotations are special kinds of modifiers (like public, static or final). Therefore Rearranger should at a minimum be able to select fields, methods or classes based on the presence or absence of an annotation. For example, a rule
"@Override final methods"
would group all final methods with the @Override annotation.
However, annotations are different from other modifiers in that they can have any number of associated values (called elements). For example, the following annotation has three elements:
Therefore it might be useful to add the ability to select or sort based on annotation elements. For example, a rule
"All methods with annotation @MyAnnotation where doSomething matches "What." sorted by MyAnnotation.count()"*
would group all methods annotated with @MyAnnotation where the doSomething string matched the regular expression "What.*", and would sort them by count.
Doing so would add a new level of complexity to the Rearranger configuration panels. In particular, the current scheme of just checking a box to indicate presence of a modifier won't work for annotations. I think I would have to replace it completely with a new UI control that allows you to add traditional modifiers, marker annotations like @Override, or annotations with values. The sorting checkboxes would also have to be replaced to allow for sorting by modifiers (including annotations), by type, and/or by name. These changes would occur for rule definitions for fields, methods and classes.
I would like to know whether this kind of feature would be useful to you, and why. (What kind of problem would it solve that the current Rearranger can't address?) If yes, which of the following rearrangement rule types would you need:
1) grouping simply by individual annotation name alone (e.g. All methods with @Override annotation)
2) grouping by annotation names matching a pattern or a list (e.g. All methods with annotations matching "@MyAnn."*)
3) grouping by annotation elements (e.g. All methods with @MyAnnotation annotation where MyAnnotation.doSomething matches "some.thing"*)
4) Rules permitting optional sorting by annotation names as well as other modifiers, type and name (e.g. All methods with annotations matching "." sorted by annotation name (ignore case), modifiers, return type, method name(ignore case)*)
Of course I'd like to avoid a complex solution if it won't be used.
Thanks for your time!