Checkstyle 和 Eclipse; Java 字符串延续
(我知道这是一个懒惰的问题,但奇怪的是很难搜索......特别是因为 checkstyle 做了这么多,并且 Google 搜索结果中充斥着 checkstyle 报告。)
有人可以告诉我哪个 checkstyle 检查报告“+ 应该在 Java 中将长字符串拆分为多行时要换行吗?
另一方面,这个问题以一种迂回的方式询问是否有任何一种让 Eclipse 在为您分割字符串时将“+”符号放在新行上的方法。 有简单的方法吗?
(I know this is a sort of lazy question, but it's oddly hard to search for...especially since checkstyle does so much, and Google search results are littered with checkstyle reports.)
Can someone tell me which checkstyle check reports "+ should be on a new line" when splitting long strings over multiple lines in Java?
On an aside, this SO question in a roundabout way asked if there is any way to get Eclipse to put the "+" symbol on the new line when it splits a string for you. Is there an easy way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能是 操作符换行 检查负责“+ 应该”换行”消息。
它位于“空白”部分。
我知道的唯一方法是格式化刚刚生成的代码:
当您在
String
中间点击“return
”时,它会在第一行末尾输出“+
”。< br>但是您格式化代码时,它确实会在第二个开头放回“
+
”。由于您只能格式化您所在的部分(例如您正在编辑的当前方法),因此该提示并不意味着您可以在任何想要放置 '
+ 的时候格式化所有类
' 在正确的位置。 仅当前代码块。(它是“格式化元素”命令,默认情况下没有快捷键,因此您可以指定一个)
Probably the operator wrap check is responsible for that "+ should be on a new line" message.
It is found in the "Whitespace" section.
The only way I know is to format the code which has just been produced:
when you hit "
return
" in the middle of aString
, it does out the '+
' at the end of the first line.But you format the code, it does put back the '
+
' at the beginning of the second.Since you can only format the section in which you are (like the current method you are editing), that tip does not mean you will format the all class anytime you want to put the '
+
' at its right place. Only the current block of code.(it the the command "Format Element", and it has by default no key shortcut, so you can assign one)