Ident elvis with normal ident in Kotlin code style (KT-25008)

#KT-25008 Fixed
This commit is contained in:
Nikolay Krasko
2018-06-21 20:47:06 +03:00
parent 341e7746a2
commit 8e31113a4f
9 changed files with 61 additions and 1 deletions
@@ -53,6 +53,7 @@ public class KotlinCodeStyleSettings extends CustomCodeStyleSettings {
public boolean CONTINUATION_INDENT_FOR_CHAINED_CALLS = true;
public boolean CONTINUATION_INDENT_IN_SUPERTYPE_LISTS = true;
public boolean CONTINUATION_INDENT_IN_IF_CONDITIONS = true;
public boolean CONTINUATION_INDENT_IN_ELVIS = true;
public int BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES = 0;
public int WRAP_EXPRESSION_BODY_FUNCTIONS = 0;
public int WRAP_ELVIS_EXPRESSIONS = 1;
@@ -193,9 +193,15 @@ abstract class KotlinCommonBlock(
private fun splitSubBlocksOnElvis(nodeSubBlocks: List<ASTBlock>): List<ASTBlock> {
val elvisIndex = nodeSubBlocks.indexOfBlockWithType(ELVIS_SET)
if (elvisIndex >= 0) {
val indent = if (settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_ELVIS) {
Indent.getContinuationIndent()
} else {
Indent.getNormalIndent()
}
return nodeSubBlocks.splitAtIndex(
elvisIndex,
Indent.getContinuationIndent(),
indent,
null
)
}
@@ -48,6 +48,7 @@ class KotlinStyleGuideCodeStyle : PredefinedCodeStyle("Kotlin style guide", Kotl
CONTINUATION_INDENT_FOR_CHAINED_CALLS = false
CONTINUATION_INDENT_IN_SUPERTYPE_LISTS = false
CONTINUATION_INDENT_IN_IF_CONDITIONS = false
CONTINUATION_INDENT_IN_ELVIS = false
WRAP_EXPRESSION_BODY_FUNCTIONS = CodeStyleSettings.WRAP_AS_NEEDED
IF_RPAREN_ON_NEW_LINE = true
}