Formatter: Add blank line before class/object declaration inside of declaration body

This commit is contained in:
Alexey Sedunov
2015-07-17 17:41:11 +03:00
parent 16ec066437
commit d23da408a8
6 changed files with 116 additions and 1 deletions
@@ -100,9 +100,10 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
between(ENUM_ENTRY, DECLARATIONS).blankLines(1)
beforeInside(FUN, TokenSet.create(BODY, CLASS_BODY)).lineBreakInCode()
beforeInside(CLASS, TokenSet.create(BODY, CLASS_BODY)).lineBreakInCode()
beforeInside(OBJECT_DECLARATION, TokenSet.create(BODY, CLASS_BODY)).lineBreakInCode()
before(PROPERTY).lineBreakInCode()
after(DOC_COMMENT).lineBreakInCode()
// =============== Spacing ================
+28
View File
@@ -0,0 +1,28 @@
class A { // abc
class B
}
class A {
class B {}
}
class A {
class B {
}
}
fun foo() {
// abc
class B
}
fun foo() {
class B {}
}
fun foo() {
class B {
}
}
+23
View File
@@ -0,0 +1,23 @@
class A { // abc
class B
}
class A { class B {}
}
class A { class B {
}
}
fun foo() { // abc
class B
}
fun foo() { class B {}
}
fun foo() { class B {
}
}
+28
View File
@@ -0,0 +1,28 @@
class A { // abc
object B
}
class A {
object B {}
}
class A {
object B {
}
}
fun foo() {
// abc
object B
}
fun foo() {
object B {}
}
fun foo() {
object B {
}
}
+23
View File
@@ -0,0 +1,23 @@
class A { // abc
object B
}
class A { object B {}
}
class A { object B {
}
}
fun foo() { // abc
object B
}
fun foo() { object B {}
}
fun foo() { object B {
}
}
@@ -97,6 +97,12 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
doTest(fileName);
}
@TestMetadata("ClassInBody.after.kt")
public void testClassInBody() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/ClassInBody.after.kt");
doTest(fileName);
}
@TestMetadata("ClassLineBreak.after.kt")
public void testClassLineBreak() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/ClassLineBreak.after.kt");
@@ -355,6 +361,12 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
doTest(fileName);
}
@TestMetadata("ObjectInBody.after.kt")
public void testObjectInBody() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/ObjectInBody.after.kt");
doTest(fileName);
}
@TestMetadata("ParameterDocComments.after.kt")
public void testParameterDocComments() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/ParameterDocComments.after.kt");