Codestyle / formatter在超过一定长度时自动拆分/包装Eclipse中的字符串

时间:2016-06-09 12:16:48

标签: java eclipse eclipse-plugin checkstyle formatter

我知道我们有this question from 2008this question from 2012,两者都声明我们可以在长字符串中输入,并且它会自动在其间放置"newline indent + "。但是,由于我们还有四年,我想知道是否有任何新功能/设置可以实现这一点。 (所以,是的,这在技术上是重复的,但是因为自从关于这个问题的最后一个问题以来它已经四年了,所以我决定再次提出它。

目前我的代码中有字符串( duh )。例如:

throw new UnsupportedOperationException(
    "Some random text with a length like" + " this, but also not very long");

或者这个:

String test =
    "Another text, this time a bit longer so we should split it" + " after it has surpassed a certain"
    + " length");

我正在手动删除单行上的所有" + "因为它只是看起来很流行,然后希望我可以保存文件而Checkstyle / formatter会自动重新应用" + " ,但这次是在适当的地方(例如,120行长)。

然后会产生以下结果:

throw new UnsupportedOperationException(
    "Some random text with a length like this, but also not very long");

或者这个:

String test =
    "Another text, this time a bit longer so we should split it after it has surpassed"
        + " a certain length");

不幸的是,就我所见,似乎没有代码样式格式设置允许此行为。在过去四年中是否添加了一些在超过一定长度后允许在Eclipse中进行String换行的内容?

0 个答案:

没有答案