Setup spacing rules for primary ctor's parts
This commit is contained in:
@@ -145,6 +145,15 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
|
|||||||
// before LPAR in constructor(): this() {}
|
// before LPAR in constructor(): this() {}
|
||||||
after(CONSTRUCTOR_DELEGATION_REFERENCE).spacing(0, 0, 0, false, 0)
|
after(CONSTRUCTOR_DELEGATION_REFERENCE).spacing(0, 0, 0, false, 0)
|
||||||
|
|
||||||
|
// class A() - no space before LPAR of PRIMARY_CONSTRUCTOR
|
||||||
|
// class A private() - one space before modifier
|
||||||
|
custom {
|
||||||
|
inPosition(right = PRIMARY_CONSTRUCTOR).customRule { p, l, r ->
|
||||||
|
val spacesCount = if (r.getNode().findLeafElementAt(0)?.getElementType() != LPAR) 1 else 0
|
||||||
|
Spacing.createSpacing(spacesCount, spacesCount, 0, true, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
aroundInside(DOT, DOT_QUALIFIED_EXPRESSION).spaces(0)
|
aroundInside(DOT, DOT_QUALIFIED_EXPRESSION).spaces(0)
|
||||||
aroundInside(SAFE_ACCESS, SAFE_ACCESS_EXPRESSION).spaces(0)
|
aroundInside(SAFE_ACCESS, SAFE_ACCESS_EXPRESSION).spaces(0)
|
||||||
|
|
||||||
@@ -183,8 +192,6 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
|
|||||||
aroundInside(ARROW, FUNCTION_TYPE).spaceIf(jetSettings.SPACE_AROUND_FUNCTION_TYPE_ARROW)
|
aroundInside(ARROW, FUNCTION_TYPE).spaceIf(jetSettings.SPACE_AROUND_FUNCTION_TYPE_ARROW)
|
||||||
|
|
||||||
betweenInside(REFERENCE_EXPRESSION, FUNCTION_LITERAL_ARGUMENT, CALL_EXPRESSION).spaces(1)
|
betweenInside(REFERENCE_EXPRESSION, FUNCTION_LITERAL_ARGUMENT, CALL_EXPRESSION).spaces(1)
|
||||||
|
|
||||||
betweenInside(IDENTIFIER, MODIFIER_LIST, CLASS).spaces(1)
|
|
||||||
}
|
}
|
||||||
custom {
|
custom {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
class A1()
|
||||||
|
|
||||||
|
class A2 private ()
|
||||||
|
class A3 private [ann] protected ()
|
||||||
|
class A4 private [ann1] protected [ann2] () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class A5 private [ann]
|
||||||
|
|
||||||
|
()
|
||||||
|
|
||||||
|
class A6 /* faddf */ private ()
|
||||||
|
|
||||||
|
class A7
|
||||||
|
private
|
||||||
|
[ann]
|
||||||
|
()
|
||||||
|
|
||||||
|
class A8 // eol comment
|
||||||
|
private
|
||||||
|
[ann]
|
||||||
|
()
|
||||||
|
|
||||||
|
class A9 // eol comment
|
||||||
|
private // eol comment
|
||||||
|
[ann] // eol comment
|
||||||
|
()
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
class A1 ()
|
||||||
|
|
||||||
|
class A2 private ()
|
||||||
|
class A3 private [ann] protected()
|
||||||
|
class A4 private [ann1] protected [ann2] () {
|
||||||
|
|
||||||
|
}
|
||||||
|
class A5 private [ann]
|
||||||
|
|
||||||
|
()
|
||||||
|
|
||||||
|
class A6 /* faddf */ private ()
|
||||||
|
|
||||||
|
class A7
|
||||||
|
private
|
||||||
|
[ann]
|
||||||
|
()
|
||||||
|
|
||||||
|
class A8 // eol comment
|
||||||
|
private
|
||||||
|
[ann]
|
||||||
|
()
|
||||||
|
|
||||||
|
class A9 // eol comment
|
||||||
|
private // eol comment
|
||||||
|
[ann] // eol comment
|
||||||
|
()
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
open class C0(val x: Any?) {}
|
open class C0(val x: Any?) {}
|
||||||
|
|
||||||
open class C1 (var _x1: Int = 1, _x2: Float?, val _x3: ((Int) -> Int)?) : C0(_x3){
|
open class C1 (var _x1: Int = 1, _x2: Float?, val _x3: ((Int) -> Int)?) : C0(_x3){
|
||||||
fun bar() {
|
fun bar() {
|
||||||
val y1 = _x1;
|
val y1 = _x1;
|
||||||
val y2 = _x2;
|
val y2 = _x2;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
open class C0<X>(val x: X) {}
|
open class C0<X>(val x: X) {}
|
||||||
|
|
||||||
open class C1<T: Any> (var _x1: T? = null, _x2: Double?, val _x3: ((Int) -> Int)?) : C0<((Int) -> Int)?>(_x3){
|
open class C1<T: Any> (var _x1: T? = null, _x2: Double?, val _x3: ((Int) -> Int)?) : C0<((Int) -> Int)?>(_x3){
|
||||||
fun bar() {
|
fun bar() {
|
||||||
val y1 = _x1;
|
val y1 = _x1;
|
||||||
val y2 = _x2;
|
val y2 = _x2;
|
||||||
|
|||||||
@@ -376,6 +376,12 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("PrimaryConstructor.after.kt")
|
||||||
|
public void testPrimaryConstructor() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/PrimaryConstructor.after.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("PropertyWithInference.after.kt")
|
@TestMetadata("PropertyWithInference.after.kt")
|
||||||
public void testPropertyWithInference() throws Exception {
|
public void testPropertyWithInference() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/PropertyWithInference.after.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/PropertyWithInference.after.kt");
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ class B [Anon5(11)]
|
|||||||
()
|
()
|
||||||
|
|
||||||
class C [Anon5(12)]
|
class C [Anon5(12)]
|
||||||
private()
|
private ()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
class C private(arg1: Int, arg2: Int, arg3: Int = 0) {
|
class C private (arg1: Int, arg2: Int, arg3: Int = 0) {
|
||||||
|
|
||||||
public constructor(arg1: Int) : this(arg1, 0, 0) {
|
public constructor(arg1: Int) : this(arg1, 0, 0) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package demo
|
package demo
|
||||||
|
|
||||||
enum class MyEnum private(public val color: Int) {
|
enum class MyEnum private (public val color: Int) {
|
||||||
RED : MyEnum(10)
|
RED : MyEnum(10)
|
||||||
BLUE : MyEnum(20)
|
BLUE : MyEnum(20)
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
enum class Color private(public val code: Int) {
|
enum class Color private (public val code: Int) {
|
||||||
WHITE : Color(21)
|
WHITE : Color(21)
|
||||||
BLACK : Color(22)
|
BLACK : Color(22)
|
||||||
RED : Color(23)
|
RED : Color(23)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
package demo
|
package demo
|
||||||
|
|
||||||
enum class Color private(public val code: Int)
|
enum class Color private (public val code: Int)
|
||||||
Reference in New Issue
Block a user