我很好奇是否可以通过可见性对字段,方法等不同类型进行排序,但不是按字母。我知道我可以使用Source -> Cleanup
对成员进行排序。但它仍然按字母顺序排序。我只想按可见性进行排序,并保留旧订单的其余部分。
示例:
public class Person {
private Person(final Long id, final String name, final String surname) {
}
public Person() {
}
private Long id;
private String surname;
private String name;
public final static String SOME_CONSTANT = "SOME_CONSTANT";
}
排序后应如下所示:
public class Person {
public final static String SOME_CONSTANT = "SOME_CONSTANT";
private Long id;
private String surname;
private String name;
public Person() {
}
private Person(final Long id, final String name, final String surname) {
}
}
但我明白了:
public class Person {
public final static String SOME_CONSTANT = "SOME_CONSTANT";
private Long id;
private String name;
private String surname;
public Person() {
}
private Person(final Long id, final String name, final String surname) {
}
}
答案 0 :(得分:2)
没有插件的Eclipse中不可能进行纯字母排序。 您是否尝试过设置自定义Source-> Sort Members选项(Preferences-> Java-> Appearance-> Members Sort Order)?
但是,您可以在这篇文章中找到一些替代方案:Eclipse organize methods in alphabetical order