// figure out where to insert the static modifier
// if there is other modifier, prepend 'static ' in front of class
// else insert 'static ' AFTER public/private/protected and BEFORE final
Fix fix;
ModifiersTree mods = tree.getModifiers();
if (mods.getFlags().isEmpty()) {
fix = SuggestedFix.prefixWith(tree, "static ");
} else {
// Note that the use of .toString() here effectively destroys any special
// formatting, eg if the modifiers previously had multiple spaces or a
// comment between them, after this fix they will all have exactly one
// space between each modifier.
String newmods = mods.toString();
int ind = newmods.indexOf("final");
if (ind < 0) {
// append if 'final' not found
newmods += "static";
fix = SuggestedFix.replace(mods, newmods);