如何配置eclipse以保持这种代码格式?

2024-05-19

以下代码来自 playframework-2.0 的示例:

/**
 * Display the dashboard.
 */
public static Result index() {
    return ok(
        dashboard.render(
            Project.findInvolving(request().username()),
            Task.findTodoInvolving(request().username()),
            User.find.byId(request().username())
        )
    );
}

看起来不错,但是当我使用eclipse的代码格式时,它变成:

/**
 * Display the dashboard.
 */
public static Result index() {
    return ok(dashboard.render(
        Project.findInvolving(request().username()),
        Task.findTodoInvolving(request().username()),
        User.find.byId(request().username())
        ));
}

如何配置 Eclipse 以保持第一种格式样式?我尝试了很多,但没有效果。


你必须使用Code Formatter在日食中。您可以在以下路径中找到它:

  1. windows菜单和在Preferences item.
  2. go to java在左边的树中。
  3. go to code style的子树java.
  4. select Formatter leaf.
  5. click Edit按钮并编辑您的自定义格式并保存。

我建议您保存自定义环境(例如格式化程序)并在其他地方使用它。Eclipse hold formatterxml 文件中的信息。您可以指定该文件的路径。

以下链接很有用:

  • http://www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/ http://www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何配置eclipse以保持这种代码格式? 的相关文章

随机推荐