TrailingCommaPostFormatProcessor: convert mapNotNull to filter

#KT-34744
This commit is contained in:
Dmitry Gridin
2020-01-23 17:58:03 +07:00
parent a2b2c47b51
commit 522ae4945e
@@ -42,12 +42,9 @@ class TrailingCommaPostFormatProcessor : PostFormatProcessor {
companion object {
fun findInvalidCommas(commaOwner: KtElement): List<PsiElement> = 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(