Skip to content

Commit

Permalink
Merge pull request #62 from aem/aem/patch/named-blocks
Browse files Browse the repository at this point in the history
allow for named blocks
  • Loading branch information
shyiko authored Jun 30, 2017
2 parents 6295a13 + ef3f436 commit 4ec4d7d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SpacingAroundCurlyRule : Rule("curly-spacing") {
val spacingBefore: Boolean
val spacingAfter: Boolean
if (node.textMatches("{")) {
spacingBefore = prevLeaf is PsiWhiteSpace || (prevLeaf?.node?.elementType == KtTokens.LPAR &&
spacingBefore = prevLeaf is PsiWhiteSpace || prevLeaf?.node?.elementType == KtTokens.AT || (prevLeaf?.node?.elementType == KtTokens.LPAR &&
(node.parent is KtLambdaExpression || node.parent.parent is KtLambdaExpression))
spacingAfter = nextLeaf is PsiWhiteSpace || nextLeaf?.node?.elementType == KtTokens.RBRACE
} else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.github.shyiko.ktlint.ruleset.standard

import com.github.shyiko.ktlint.core.LintError
import com.github.shyiko.ktlint.test.lint
import com.github.shyiko.ktlint.test.format
import com.github.shyiko.ktlint.test.lint
import org.assertj.core.api.Assertions.assertThat
import org.testng.annotations.Test

Expand All @@ -11,6 +11,7 @@ class SpacingAroundCurlyRuleTest {
@Test
fun testLint() {
assertThat(SpacingAroundCurlyRule().lint("fun emit() { }")).isEmpty()
assertThat(SpacingAroundCurlyRule().lint("fun emit() { val a = a@{ } }")).isEmpty()
assertThat(SpacingAroundCurlyRule().lint("fun emit() {}")).isEmpty()
assertThat(SpacingAroundCurlyRule().lint("fun main() { val v = if (true){return 0} }"))
.isEqualTo(listOf(
Expand Down

0 comments on commit 4ec4d7d

Please sign in to comment.