Fix formatting of class headers when "blank lines after class
header" is enabled
This commit is contained in:
@@ -123,12 +123,18 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Spacing.createDependentLFSpacing(
|
val minLineFeeds = if (right.node.elementType == FUN || right.node.elementType == PROPERTY)
|
||||||
0, 0,
|
1
|
||||||
TextRange(parentPsi.textRange.startOffset, left.node.psi.textRange.startOffset),
|
else
|
||||||
|
0
|
||||||
|
|
||||||
|
builderUtil.createLineFeedDependentSpacing(
|
||||||
|
1, 1, minLineFeeds,
|
||||||
settings.KEEP_LINE_BREAKS, settings.KEEP_BLANK_LINES_IN_DECLARATIONS,
|
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)
|
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()
|
fun bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class Foo { Bar, Baz }
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
fun bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
// SET_INT: BLANK_LINES_AFTER_CLASS_HEADER = 1
|
// SET_INT: BLANK_LINES_AFTER_CLASS_HEADER = 1
|
||||||
|
|||||||
@@ -23,4 +23,8 @@ class FooC(
|
|||||||
fun bar()
|
fun bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class Foo{Bar,Baz}
|
||||||
|
|
||||||
|
class Foo{fun bar() {}}
|
||||||
|
|
||||||
// SET_INT: BLANK_LINES_AFTER_CLASS_HEADER = 1
|
// SET_INT: BLANK_LINES_AFTER_CLASS_HEADER = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user