From e7038be002c57079c1e30435cb79f7a3e822c19e Mon Sep 17 00:00:00 2001 From: Stanley Shyiko Date: Tue, 28 Feb 2017 13:38:06 -0800 Subject: [PATCH] Fixed #34 - unnecessary spacing around angle brackets in case of super --- .../ktlint/ruleset/standard/SpacingAroundOperatorsRule.kt | 4 +++- .../ruleset/standard/SpacingAroundOperatorsRuleTest.kt | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ktlint-ruleset-standard/src/main/kotlin/com/gihub/shyiko/ktlint/ruleset/standard/SpacingAroundOperatorsRule.kt b/ktlint-ruleset-standard/src/main/kotlin/com/gihub/shyiko/ktlint/ruleset/standard/SpacingAroundOperatorsRule.kt index 62a92afb5c..369fc9c81e 100644 --- a/ktlint-ruleset-standard/src/main/kotlin/com/gihub/shyiko/ktlint/ruleset/standard/SpacingAroundOperatorsRule.kt +++ b/ktlint-ruleset-standard/src/main/kotlin/com/gihub/shyiko/ktlint/ruleset/standard/SpacingAroundOperatorsRule.kt @@ -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 @@ -48,7 +49,8 @@ class SpacingAroundOperatorsRule : Rule("op-spacing") { !node.isPartOf(KtTypeParameterList::class) && // fun fn(): T {} !node.isPartOf(KtTypeArgumentList::class) && // C !node.isPartOf(KtValueArgument::class) && // fn(*array) - !node.isPartOf(KtImportDirective::class) // import * + !node.isPartOf(KtImportDirective::class) && // import * + !node.isPartOf(KtSuperExpression::class) // super ) { val spacingBefore = PsiTreeUtil.prevLeaf(node, true) is PsiWhiteSpace val spacingAfter = PsiTreeUtil.nextLeaf(node, true) is PsiWhiteSpace diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundOperatorsRuleTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundOperatorsRuleTest.kt index 183aa21db0..4da1bccd84 100644 --- a/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundOperatorsRuleTest.kt +++ b/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundOperatorsRuleTest.kt @@ -30,6 +30,12 @@ class SpacingAroundOperatorsRuleTest { val a= "" d *= 1 call(*v) + open class A { + open fun x() {} + } + class B : A() { + override fun x() = super.x() + } } """.trimIndent() )).isEqualTo(listOf(