Chained methods and continuation indent in Intellij

老子叫甜甜 提交于 2019-12-08 15:00:35

问题


I've never figured out how to make Intellij handle continuation indent for chained methods properly, and apparently today is the day it's annoyed me enough to consult you lovely people.

What I want is this:

makeAThing(
  "with",  
  "params"
)
.setProperty("with some more params")
.start();

What I get is this:

makeAThing(
  "with", 
  "params"
)
  .setProperty("with some more params")
  .start();

I get this in Java, Groovy, JavaScript and a bunch of other places. How can I persuade Intellij not to add continuation indent after a chained method call?


回答1:


I just switched to intellij and also have found this rather annoying.

Only found two solutions:

  1. forcing the coding style to have 0 for "continuation indent" which I'm starting to like anyway albeit not very canonical Java.
  2. Turing off the formatter for blocks of code and press shift tab

Works for Java not sure for JS:

// @formatter:off
...
// @formatter:on


来源:https://stackoverflow.com/questions/24455513/chained-methods-and-continuation-indent-in-intellij

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!