Add option for wrapping closing paren in multiline if conditions
This commit is contained in:
+1
@@ -49,6 +49,7 @@ public class KotlinCodeStyleSettings extends CustomCodeStyleSettings {
|
||||
public int BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES = 0;
|
||||
public int WRAP_EXPRESSION_BODY_FUNCTIONS = 0;
|
||||
public int WRAP_ELVIS_EXPRESSIONS = 1;
|
||||
public boolean IF_RPAREN_ON_NEW_LINE = false;
|
||||
|
||||
public KotlinCodeStyleSettings(CodeStyleSettings container) {
|
||||
super("JetCodeStyleSettings", container);
|
||||
|
||||
@@ -30,6 +30,7 @@ class KotlinStyleGuideCodeStyle : PredefinedCodeStyle("Kotlin style guide", Kotl
|
||||
CONTINUATION_INDENT_IN_SUPERTYPE_LISTS = false
|
||||
CONTINUATION_INDENT_IN_IF_CONDITIONS = false
|
||||
WRAP_EXPRESSION_BODY_FUNCTIONS = CodeStyleSettings.WRAP_AS_NEEDED
|
||||
IF_RPAREN_ON_NEW_LINE = true
|
||||
}
|
||||
|
||||
settings.kotlinCommonSettings.apply {
|
||||
|
||||
@@ -185,6 +185,18 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
|
||||
createSpacing(0)
|
||||
}
|
||||
}
|
||||
|
||||
inPosition(left = CONDITION, right = RPAR).customRule { parent, _, _ ->
|
||||
if (kotlinCustomSettings.IF_RPAREN_ON_NEW_LINE) {
|
||||
Spacing.createDependentLFSpacing(0, 0,
|
||||
excludeLambdasAndObjects(parent),
|
||||
commonCodeStyleSettings.KEEP_LINE_BREAKS,
|
||||
commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE)
|
||||
}
|
||||
else {
|
||||
createSpacing(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
simple {
|
||||
|
||||
Reference in New Issue
Block a user