KT-24750 Blank line after class header formatter should use user setting
This commit is contained in:
committed by
Dmitry Gridin
parent
e6f527f1d0
commit
3f8ffb5ea7
@@ -153,13 +153,16 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
|
||||
null
|
||||
} else {
|
||||
val minLineFeeds = if (right.requireNode().elementType == FUN || right.requireNode().elementType == PROPERTY)
|
||||
1
|
||||
kotlinCommonSettings.BLANK_LINES_AFTER_CLASS_HEADER + 1
|
||||
else
|
||||
0
|
||||
|
||||
builderUtil.createLineFeedDependentSpacing(
|
||||
1, 1, minLineFeeds,
|
||||
settings.KEEP_LINE_BREAKS, settings.KEEP_BLANK_LINES_IN_DECLARATIONS,
|
||||
1,
|
||||
1,
|
||||
minLineFeeds,
|
||||
commonCodeStyleSettings.KEEP_LINE_BREAKS,
|
||||
commonCodeStyleSettings.KEEP_BLANK_LINES_IN_DECLARATIONS,
|
||||
TextRange(parentPsi.textRange.startOffset, left.requireNode().psi.textRange.startOffset),
|
||||
DependentSpacingRule(DependentSpacingRule.Trigger.HAS_LINE_FEEDS)
|
||||
.registerData(
|
||||
|
||||
@@ -1,23 +1,46 @@
|
||||
class Foo {
|
||||
|
||||
fun bar() {
|
||||
}
|
||||
}
|
||||
|
||||
object Bar {
|
||||
|
||||
fun xyzzy() {
|
||||
}
|
||||
}
|
||||
|
||||
object BarS {
|
||||
|
||||
fun xyzzy() {}
|
||||
}
|
||||
|
||||
val f = object {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class FooCO {
|
||||
|
||||
fun bar() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
class FooM
|
||||
: IFoo {
|
||||
|
||||
fun bar()
|
||||
}
|
||||
|
||||
class FooN : IFoo {
|
||||
|
||||
fun bar()
|
||||
}
|
||||
|
||||
class FooC(
|
||||
val x: String
|
||||
) {
|
||||
@@ -28,6 +51,7 @@ class FooC(
|
||||
enum class Foo { Bar, Baz }
|
||||
|
||||
class Foo {
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,15 +8,30 @@ object Bar {
|
||||
}
|
||||
}
|
||||
|
||||
object BarS { fun xyzzy() {} }
|
||||
|
||||
val f = object {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class FooCO {
|
||||
fun bar() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
class FooM
|
||||
: IFoo {
|
||||
fun bar()
|
||||
}
|
||||
|
||||
class FooN : IFoo {
|
||||
fun bar()
|
||||
}
|
||||
|
||||
class FooC(
|
||||
val x: String
|
||||
) {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
class Foo {
|
||||
|
||||
|
||||
fun bar() {
|
||||
}
|
||||
}
|
||||
|
||||
object Bar {
|
||||
|
||||
|
||||
fun xyzzy() {
|
||||
}
|
||||
}
|
||||
|
||||
object BarS {
|
||||
|
||||
|
||||
fun xyzzy() {}
|
||||
}
|
||||
|
||||
val f = object {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class FooCO {
|
||||
|
||||
|
||||
fun bar() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
class FooM
|
||||
: IFoo {
|
||||
|
||||
|
||||
fun bar()
|
||||
}
|
||||
|
||||
class FooN : IFoo {
|
||||
|
||||
|
||||
fun bar()
|
||||
}
|
||||
|
||||
class FooC(
|
||||
val x: String
|
||||
) {
|
||||
|
||||
|
||||
fun bar()
|
||||
}
|
||||
|
||||
enum class Foo { Bar, Baz }
|
||||
|
||||
class Foo {
|
||||
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
// SET_INT: BLANK_LINES_AFTER_CLASS_HEADER = 2
|
||||
@@ -0,0 +1,45 @@
|
||||
class Foo {
|
||||
fun bar() {
|
||||
}
|
||||
}
|
||||
|
||||
object Bar {
|
||||
fun xyzzy() {
|
||||
}
|
||||
}
|
||||
|
||||
object BarS { fun xyzzy() {} }
|
||||
|
||||
val f = object {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class FooCO {
|
||||
fun bar() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
class FooM
|
||||
: IFoo {
|
||||
fun bar()
|
||||
}
|
||||
|
||||
class FooN : IFoo {
|
||||
fun bar()
|
||||
}
|
||||
|
||||
class FooC(
|
||||
val x: String
|
||||
) {
|
||||
fun bar()
|
||||
}
|
||||
|
||||
enum class Foo{Bar,Baz}
|
||||
|
||||
class Foo{fun bar() {}}
|
||||
|
||||
// SET_INT: BLANK_LINES_AFTER_CLASS_HEADER = 2
|
||||
@@ -95,6 +95,11 @@ public class FormatterTestGenerated extends AbstractFormatterTest {
|
||||
runTest("idea/testData/formatter/BlankLinesAfterClassHeader.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("BlankLinesAfterClassHeader2.after.kt")
|
||||
public void testBlankLinesAfterClassHeader2() throws Exception {
|
||||
runTest("idea/testData/formatter/BlankLinesAfterClassHeader2.after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("BlankLinesBeforeRBrace.after.kt")
|
||||
public void testBlankLinesBeforeRBrace() throws Exception {
|
||||
runTest("idea/testData/formatter/BlankLinesBeforeRBrace.after.kt");
|
||||
|
||||
Reference in New Issue
Block a user