Skip to content

Commit

Permalink
Remove support of continuation index in secondary constructor
Browse files Browse the repository at this point in the history
This aligns the formatting with the default IntelliJ formatting of secondary
constructors.

Closes pinterest#1222
  • Loading branch information
Paul Dingemans committed Dec 13, 2021
1 parent 222dd50 commit d8179bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,10 @@ class IndentationRule : Rule("indent"), Rule.Modifier.RestrictToRootLast {
ctx.exitAdjBy(returnType!!, -1)
}
n.treeParent.isPartOf(SECONDARY_CONSTRUCTOR) -> {
expectedIndent += 2
expectedIndent++
debug { "++after(COLON IN CONSTRUCTOR) -> $expectedIndent" }
val returnType = n.nextCodeSibling()
ctx.exitAdjBy(returnType!!, -2)
val nextCodeSibling = n.nextCodeSibling()
ctx.exitAdjBy(nextCodeSibling!!, -1)
}
else -> {
expectedIndent++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ internal class IndentationRuleTest {
"""
class Issue1222 {
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) :
super(context, attrs, defStyleAttr, defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes) {
init(attrs, defStyleAttr, defStyleRes)
}
}
Expand All @@ -1358,14 +1358,14 @@ internal class IndentationRuleTest {
"""
class Issue1222 {
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) :
super(context, attrs, defStyleAttr, defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes) {
init(attrs, defStyleAttr, defStyleRes)
}
}
""".trimIndent()
assertThat(IndentationRule().lint(code))
.containsExactly(
LintError(3, 1, "indent", "Unexpected indentation (8) (should be 12)"),
LintError(3, 1, "indent", "Unexpected indentation (12) (should be 8)"),
)
assertThat(IndentationRule().format(code)).isEqualTo(formattedCode)
}
Expand All @@ -1387,18 +1387,16 @@ internal class IndentationRuleTest {
"""
class Issue1222 {
constructor(string1: String, string2: String2) :
super(
string1, string2
) {
super(
string1, string2
) {
// do something
}
}
""".trimIndent()
assertThat(IndentationRule().lint(code))
.containsExactly(
LintError(3, 1, "indent", "Unexpected indentation (8) (should be 12)"),
LintError(4, 1, "indent", "Unexpected indentation (8) (should be 16)"),
LintError(5, 1, "indent", "Unexpected indentation (8) (should be 12)"),
LintError(4, 1, "indent", "Unexpected indentation (8) (should be 12)"),
)
assertThat(IndentationRule().format(code)).isEqualTo(formattedCode)
}
Expand Down

0 comments on commit d8179bb

Please # to comment.