Skip to content

Commit

Permalink
Fixed #34 - unnecessary spacing around angle brackets in case of supe…
Browse files Browse the repository at this point in the history
…r<T>
  • Loading branch information
shyiko committed Feb 28, 2017
1 parent af7fbb6 commit e7038be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.lexer.KtTokens.PLUS
import org.jetbrains.kotlin.lexer.KtTokens.PLUSEQ
import org.jetbrains.kotlin.psi.KtImportDirective
import org.jetbrains.kotlin.psi.KtPrefixExpression
import org.jetbrains.kotlin.psi.KtSuperExpression
import org.jetbrains.kotlin.psi.KtTypeArgumentList
import org.jetbrains.kotlin.psi.KtTypeParameterList
import org.jetbrains.kotlin.psi.KtValueArgument
Expand All @@ -48,7 +49,8 @@ class SpacingAroundOperatorsRule : Rule("op-spacing") {
!node.isPartOf(KtTypeParameterList::class) && // fun <T>fn(): T {}
!node.isPartOf(KtTypeArgumentList::class) && // C<T>
!node.isPartOf(KtValueArgument::class) && // fn(*array)
!node.isPartOf(KtImportDirective::class) // import *
!node.isPartOf(KtImportDirective::class) && // import *
!node.isPartOf(KtSuperExpression::class) // super<T>
) {
val spacingBefore = PsiTreeUtil.prevLeaf(node, true) is PsiWhiteSpace
val spacingAfter = PsiTreeUtil.nextLeaf(node, true) is PsiWhiteSpace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class SpacingAroundOperatorsRuleTest {
val a= ""
d *= 1
call(*v)
open class A<T> {
open fun x() {}
}
class B<T> : A<T>() {
override fun x() = super<A>.x()
}
}
""".trimIndent()
)).isEqualTo(listOf(
Expand Down

0 comments on commit e7038be

Please sign in to comment.