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 { companion object {
fun findInvalidCommas(commaOwner: KtElement): List<PsiElement> = commaOwner.firstChild fun findInvalidCommas(commaOwner: KtElement): List<PsiElement> = commaOwner.firstChild
?.siblings(withItself = false) ?.siblings(withItself = false)
?.mapNotNull { element -> ?.filter { it.isComma }
if (!element.isComma) return@mapNotNull null ?.filter {
element.takeIf { it.prevLeaf(true)?.isLineBreak() == true || it.leafIgnoringWhitespace(false) != it.leafIgnoringWhitespaceAndComments(false)
it.prevLeaf(true)?.isLineBreak() == true ||
it.leafIgnoringWhitespace(false) != it.leafIgnoringWhitespaceAndComments(false)
}
}?.toList().orEmpty() }?.toList().orEmpty()
fun needComma( fun needComma(