Formatter: support trailing comma in lambda parameters

#KT-34744
This commit is contained in:
Dmitry Gridin
2019-12-27 16:19:11 +07:00
parent 07bda5a759
commit 4adfaab3ec
12 changed files with 711 additions and 37 deletions
@@ -681,5 +681,6 @@ fun getTrailingCommaByClosingElement(closingElement: PsiElement?): PsiElement? {
}
fun getTrailingCommaByElementsList(elementList: PsiElement?): PsiElement? {
return elementList?.lastChild?.run { if (node.elementType == KtTokens.COMMA) this else null }
val lastChild = elementList?.lastChild?.let { if (it !is PsiComment) it else it.getPrevSiblingIgnoringWhitespaceAndComments() }
return lastChild?.run { if (node.elementType == KtTokens.COMMA) this else null }
}