如何设置IntelliJ IDEA以防止在自动重新格式化(CTRL+ ALT+ L)期间将在一行上声明的匿名类拆分为多行?
例如,防止分裂
x = foo(new Boo() {});
Run Code Online (Sandbox Code Playgroud)
分为两行:
x = foo(new Boo() {
});
Run Code Online (Sandbox Code Playgroud)
"File" [menu]/"Settings"/"Code Style"/"Alignment and Braces":
==> "Keep when Reformatting" Field Set:
Check: "Simple methods in one line"
Check: "Simple blocks in one line"
Run Code Online (Sandbox Code Playgroud)
在搜索相同问题时偶然发现了这个老问题。此后,IntelliJ 中添加了“一行中的简单类”选项。
它可以在Editor > Code Style > Java > Wrapping and Braces下的设置中的Keep when reformatting字段集中找到。
| 归档时间: |
|
| 查看次数: |
5784 次 |
| 最近记录: |