[英]How to configure IntelliJ's Java Code Style so to wrap right hand of the assigment when long taking priority over chained method call
I've been having an issue to configure IntelliJ's Java code style to my liking.我在根据自己的喜好配置 IntelliJ 的 Java 代码样式时遇到了问题。 When I type some operation with streams I have something like this:
当我用流输入一些操作时,我有这样的东西:
VeryVeryVeryLongNamedClazz instance = container.getList()
.stream()
.filter(element -> element.getRole()
.equals("CFG"))
.findFirst()
.get();
When class names and variable names are quite long, and if the code is quite nested, the whole code block gets shifted far too right to the right for my liking.当 class 名称和变量名称很长时,如果代码非常嵌套,则整个代码块会因我的喜好而向右移动太多。
Something like this would be much more to my liking:我更喜欢这样的东西:
VeryVeryVeryLongNamedClazz instance =
container.getList()
.stream()
.filter(element -> element.getRole()
.equals("CFG"))
.findFirst()
.get();
Is there a way to configure the Java code style so that right hand of the assignment gets wrapped to the next line when the line is too long, or that the assignment rule takes priority over method call rule?有没有办法配置 Java 代码样式,以便当行太长时赋值的右手被换行到下一行,或者赋值规则优先于方法调用规则?
EDIT: To be more clear, what I'm looking for is that on wrapping, the assignment rule is done before chained method rule.编辑:更清楚地说,我正在寻找的是在包装时,分配规则在链式方法规则之前完成。
Is there a way to configure the Java code style so that right hand of the assignment gets wrapped to the next line when the line is too long
有没有办法配置 Java 代码样式,以便当行太长时赋值的右手被换行到下一行
With 'Hard Wrap' at 60 and your code sample, I was able to achieve the desired result on hitting Ctrl+Alt+L
using the following settings under File |使用 60 的“Hard
Ctrl+Alt+L
”和您的代码示例,我能够使用File | Settings |设置 | Editor |
编辑 | Code Style |
代码风格 | Java > Wrapping and Braces :
Java > 包装和大括号:
I would prefer that chained method calls are wrapped always only for streams, and that other methods are allowed to exist in the same line until end of line is reached
我希望链式方法调用始终只为流包装,并且允许其他方法存在于同一行中,直到到达行尾
Don't think it's possible with current settings.不要认为目前的设置是可能的。 But you can always submit a new feature request to the IntelliJ IDEA developers on YouTrack.
但您始终可以在 YouTrack 上向 IntelliJ IDEA 开发人员提交新功能请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.