Skip to content

Commit

Permalink
Disabled intent check inside where <type constraint list> (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
shyiko committed Mar 29, 2018
1 parent f5ec14f commit d06f10f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.psi.KtSafeQualifiedExpression
import org.jetbrains.kotlin.psi.KtSecondaryConstructor
import org.jetbrains.kotlin.psi.KtSuperTypeList
import org.jetbrains.kotlin.psi.KtSuperTypeListEntry
import org.jetbrains.kotlin.psi.KtTypeConstraintList
import org.jetbrains.kotlin.psi.KtTypeProjection
import org.jetbrains.kotlin.psi.KtValueArgumentList
import org.jetbrains.kotlin.psi.psiUtil.getPrevSiblingIgnoringWhitespaceAndComments
Expand All @@ -39,9 +40,9 @@ class IndentationRule : Rule("indent") {
if (indentSize <= 0 || continuationIndentSize <= 0) {
return
}
if (node is PsiWhiteSpace && !node.isPartOf(PsiComment::class)) {
if (node is PsiWhiteSpace) {
val lines = node.getText().split("\n")
if (lines.size > 1) {
if (lines.size > 1 && !node.isPartOf(PsiComment::class) && !node.isPartOf(KtTypeConstraintList::class)) {
var offset = node.startOffset + lines.first().length + 1
val previousIndentSize = node.previousIndentSize()
val expectedIndentSize = if (continuationIndentSize == indentSize || shouldUseContinuationIndent(node))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,19 @@ class IndentationRuleTest {
LintError(7, 1, "indent", "Unexpected indentation (1) (it should be 8)")
))
}

@Test(description = "https://github.com/shyiko/ktlint/issues/180")
fun testLintWhereClause() {
assertThat(IndentationRule().lint(
"""
class BiAdapter<C : RecyclerView.ViewHolder, V1 : C, V2 : C, out A1, out A2>(
val adapter1: A1,
val adapter2: A2
) : RecyclerView.Adapter<C>()
where A1 : RecyclerView.Adapter<V1>, A1 : ComposableAdapter.ViewTypeProvider,
A2 : RecyclerView.Adapter<V2>, A2 : ComposableAdapter.ViewTypeProvider {
}
""".trimIndent()
)).isEmpty()
}
}

0 comments on commit d06f10f

Please # to comment.