Java Formatting - Continuation Indent in Chained Method Calls

已回答

I would like IntelliJ to format my code like the following:

Book myBook = Book.builder()
.name("hello")
.author("bob")
.description("a book")
.build();

Instead, it does this:

Book myBook = Book.builder()
.name("hello")
.author("bob")
.description("a book")
.build();

I am using indents set to 4 spaces with a continuation indent of 2. I have "chained method calls" set to "wrap always".

The issue is that it will start counting continuation indent not from the beginning of the line, but rather from the beginning of the first method call (".builder()" in this case). Is there any way I can modify this behavior?

3
Avatar
Permanently deleted user

Figured it out right after posting, of course.

For anyone with similar issue: under "Tabs and Indents" tab in Java Code Style, uncheck "Use indents relative to expression start".

3
Avatar
Permanently deleted user

It doesn't look like this setting exists for Kotlin. Would it be possible to add that?

0

Please follow the related request on YouTrack: https://youtrack.jetbrains.com/issue/KTIJ-2414

0

请先登录再写评论。