【问题标题】:Eclipse code formatting: is there a way to add "section lines"Eclipse代码格式化:有没有办法添加“节线”
【发布时间】:2012-01-17 20:46:14
【问题描述】:

我使用 jalopy(免费版)进行代码格式化,但我想转换为 eclipse。 jalopy 有两个功能,不过我很喜欢,eclipse 中能有吗?

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

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 关键字添加到参数列表中。

【问题讨论】:

    标签: java eclipse formatting jalopy


    【解决方案1】:

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

    Window -&gt; Preference -&gt; Java -&gt; Code Style -&gt; Clean Up -&gt; Edit -&gt; Code Style

    它会引导你到Variable Declarations -&gt; Use final where possible

    如果在保存文件时执行这样的操作:

    Window -&gt; Preference -&gt; Java -&gt; Editor -&gt; Save Action -&gt; Edit

    启用Perform the selected on save -&gt; Additional Actions -&gt; Configure -&gt; Code Style

    和以前一样。

    【讨论】:

      猜你喜欢
      • 2010-09-18
      • 1970-01-01
      • 2012-07-17
      • 2014-06-17
      • 1970-01-01
      • 2013-03-11
      • 2011-01-11
      • 2011-10-12
      • 1970-01-01
      相关资源
      最近更新 更多