Fix formatting of class headers when "blank lines after class

header" is enabled
This commit is contained in:
Dmitry Jemerov
2017-09-06 10:00:53 +02:00
parent f4b329a055
commit 4e4291c586
3 changed files with 20 additions and 4 deletions
@@ -123,12 +123,18 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
null
}
else {
Spacing.createDependentLFSpacing(
0, 0,
TextRange(parentPsi.textRange.startOffset, left.node.psi.textRange.startOffset),
val minLineFeeds = if (right.node.elementType == FUN || right.node.elementType == PROPERTY)
1
else
0
builderUtil.createLineFeedDependentSpacing(
1, 1, minLineFeeds,
settings.KEEP_LINE_BREAKS, settings.KEEP_BLANK_LINES_IN_DECLARATIONS,
TextRange(parentPsi.textRange.startOffset, left.node.psi.textRange.startOffset),
DependentSpacingRule(DependentSpacingRule.Trigger.HAS_LINE_FEEDS)
.registerData(DependentSpacingRule.Anchor.MIN_LINE_FEEDS, commonCodeStyleSettings.BLANK_LINES_AFTER_CLASS_HEADER + 1))
.registerData(DependentSpacingRule.Anchor.MIN_LINE_FEEDS, commonCodeStyleSettings.BLANK_LINES_AFTER_CLASS_HEADER + 1)
)
}
}
@@ -25,4 +25,10 @@ class FooC(
fun bar()
}
enum class Foo { Bar, Baz }
class Foo {
fun bar() {}
}
// SET_INT: BLANK_LINES_AFTER_CLASS_HEADER = 1
+4
View File
@@ -23,4 +23,8 @@ class FooC(
fun bar()
}
enum class Foo{Bar,Baz}
class Foo{fun bar() {}}
// SET_INT: BLANK_LINES_AFTER_CLASS_HEADER = 1