Continuation indent in conditional statements and chained method calls
Is there a way to keep indentation like Eclipse does?
Eclipse
public boolean isEnabled() {
return tree.getSelectionCount() > 0
&& toolsModel.isDeleteActionAvailable(tree
.getSelectionPaths()); // 2 + 4 + 4 spaces
}
IntelliJ IDEA 2017.3.5
public boolean isEnabled() {
return tree.getSelectionCount() > 0
&& toolsModel.isDeleteActionAvailable(tree
.getSelectionPaths()); // 2 + 4 + 0 spaces
}
Eclipse
IntStream.range(0, getModel().getRowCount())
.filter(row -> !getModel().getObject(row).getExcludedRegions().isEmpty()
&& !Collections.disjoint(getModel().getObject(row).getIncludedRegions(),
getModel().getObject(row).getExcludedRegions())) // 4 + 4 + 4 spaces
.map(row -> row + 1)
.mapToObj(String::valueOf)
.forEach(rowsWithInvalidExcludes::add);
IntelliJ IDEA 2017.3.5
IntStream.range(0, getModel().getRowCount())
.filter(row -> !getModel().getObject(row).getExcludedRegions().isEmpty()
&& !Collections.disjoint(getModel().getObject(row).getIncludedRegions(),
getModel().getObject(row).getExcludedRegions())) // 4 + 4 + 0 spaces
.map(row -> row + 1)
.mapToObj(String::valueOf)
.forEach(rowsWithInvalidExcludes::add);
Eclipse
public static final RowMapper<
CompanyItem> ITEM_MAPPER = (rs, rowNum) -> CompanyItem.builder()
.setId(rs.getString("id")) // 4 + 4 spaces
.setReportId(rs.getString("report_id")) // 4 + 4 spaces
.setName(rs.getString("name")) // 4 + 4 spaces
.setSectorId(rs.getString("sector_id")) // 4 + 4 spaces
.build(); // 4 + 4 spaces
IntelliJ IDEA 2017.3.5
public static final RowMapper<
CompanyItem> ITEM_MAPPER = (rs, rowNum) -> CompanyItem.builder()
.setId(rs.getString("id")) // 4 + 0 spaces
.setReportId(rs.getString("report_id")) // 4 + 0 spaces
.setName(rs.getString("name")) // 4 + 0 spaces
.setSectorId(rs.getString("sector_id")) // 4 + 0 spaces
.build(); // 4 + 0 spaces
Please sign in to leave a comment.
Have you tried Eclipse formatter https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter ?
Petr, thanks for the proposal. It really works but it looks like a short term solution. Is there any way to do such formatting using IntelliJ IDEA's native formatter?
There is a ticket to provide built in Eclipse formatting options, please upvote:
https://youtrack.jetbrains.com/issue/IDEA-166332