【问题标题】:Eclipse does not format this if statement correctlyEclipse 没有正确格式化这个 if 语句
【发布时间】:2010-04-18 16:18:01
【问题描述】:

这应该很容易回答:

我已将 Eclipse 设置为将 Java 代码包装超过 80 个字符以尊重我的余量。

此代码永远不会换行:

    if (expressionItem.type.isTypeCompatibleWith(containingNameLink.type) == false) {
      reportParsingError("expression type incompatible with containing "
          + "context.");
    }

问题:如何设置我的代码格式化程序首选项,以便尊重边距?

【问题讨论】:

    标签: eclipse autoformatting


    【解决方案1】:

    您是否按了 CTRL + SHIFT + F (或右键单击>源>格式)?在这里它工作正常。代码不会在你键入时自动格式化,你需要告诉 eclipse 来格式化它。

    【讨论】:

    • 我做了,但没有用。 Eclipse 版本:伽利略 3.5.1;内部版本号:M20090917-0800。
    【解决方案2】:

    点击Windows > Preferences。转到Java > Editor > Save Action Enable 在保存时执行选定的操作,然后启用 Formatt source code 选项。

    参考下图: 点击 Formatter 链接以编辑 Formatter 的设置。

    【讨论】:

      猜你喜欢
      • 2010-10-07
      • 2011-06-21
      • 1970-01-01
      • 2018-08-03
      • 1970-01-01
      • 1970-01-01
      • 2012-06-08
      • 1970-01-01
      • 2020-01-18
      相关资源
      最近更新 更多