Eclipse代码格式化:有没有办法添加“section lines”

时间:2011-12-11 13:54:31

标签: java eclipse formatting jalopy

我使用jalopy(免费版)来进行代码格式化,但我想转换为eclipse。但是,有两个jalopy功能,我非常喜欢,是否有可能让它们进入日食?

首先是能够创建这样的部分:

public final class Credit extends ArticleAccountingentry implements Serializable {

//~ Enumerations ---------------------------------------------------------------------------------------------------

public enum Status {CREATED, CANCELLED;
}

//~ Static fields/initializers -------------------------------------------------------------------------------------

private static final long serialVersionUID = 1L;

//~ Instance fields ------------------------------------------------------------------------------------------------

private final Invoice invoice;
private final ImmutableSet<StatusChange<Status>> statushistory;

//~ Constructors ---------------------------------------------------------------------------------------------------

public Credit() {
}

//~ Methods --------------------------------------------------------------------------------------------------------

public StatusChange<Status> getLatestStatusChange() {
}

第二个功能是自动将final关键字添加到参数列表中。

1 个答案:

答案 0 :(得分:1)

至少可以使用以下方式启用自动插入final关键字:

Window -> Preference -> Java -> Code Style -> Clean Up -> Edit -> Code Style

它会引导您Variable Declarations -> Use final where possible

如果在保存文件时执行此类操作:

Window -> Preference -> Java -> Editor -> Save Action -> Edit

启用Perform the selected on save -> Additional Actions -> Configure -> Code Style

与以前相同。