Add space after a semicolon only if there's another child at the same line

This commit is contained in:
Nikolay Krasko
2016-06-21 11:56:22 +03:00
committed by Nikolay Krasko
parent b560aab06d
commit f8196d8331
3 changed files with 17 additions and 1 deletions
@@ -220,7 +220,6 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
afterInside(ANNOTATION_ENTRY, ANNOTATED_EXPRESSION).spaces(1)
before(SEMICOLON).spaces(0)
after(SEMICOLON).spaces(1)
beforeInside(INITIALIZER_LIST, ENUM_ENTRY).spaces(0)
@@ -323,6 +322,17 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
Spacing.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, settings.KEEP_LINE_BREAKS, kotlinCommonSettings.KEEP_BLANK_LINES_IN_CODE))
}
// Add space after a semicolon if there is another child at the same line
inPosition(left = SEMICOLON).customRule { parent, left, right ->
val nodeAfterLeft = left.node.treeNext
if (nodeAfterLeft is PsiWhiteSpace && !nodeAfterLeft.textContains('\n')) {
Spacing.createSpacing(1, 1, 0, settings.KEEP_LINE_BREAKS, settings.KEEP_BLANK_LINES_IN_CODE)
}
else {
null
}
}
inPosition(parent = IF, right = THEN).customRule(leftBraceRuleIfBlockIsWrapped)
inPosition(parent = IF, right = ELSE).customRule(leftBraceRuleIfBlockIsWrapped)
+3
View File
@@ -1,3 +1,6 @@
fun foo() {
""; ""
"";
// var = 1
}
+3
View File
@@ -1,3 +1,6 @@
fun foo() {
"" ; ""
"";
// var = 1
}