From 522ae4945e263d2b0718ae182af424beb41b712d Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Thu, 23 Jan 2020 17:58:03 +0700 Subject: [PATCH] TrailingCommaPostFormatProcessor: convert `mapNotNull` to `filter` #KT-34744 --- .../idea/formatter/TrailingCommaPostFormatProcessor.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt index b885066e7f8..3b532bf08f7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/TrailingCommaPostFormatProcessor.kt @@ -42,12 +42,9 @@ class TrailingCommaPostFormatProcessor : PostFormatProcessor { companion object { fun findInvalidCommas(commaOwner: KtElement): List = commaOwner.firstChild ?.siblings(withItself = false) - ?.mapNotNull { element -> - if (!element.isComma) return@mapNotNull null - element.takeIf { - it.prevLeaf(true)?.isLineBreak() == true || - it.leafIgnoringWhitespace(false) != it.leafIgnoringWhitespaceAndComments(false) - } + ?.filter { it.isComma } + ?.filter { + it.prevLeaf(true)?.isLineBreak() == true || it.leafIgnoringWhitespace(false) != it.leafIgnoringWhitespaceAndComments(false) }?.toList().orEmpty() fun needComma(