Add new line after modifier list if last child is comment

#KT-30804 Fixed
This commit is contained in:
Dmitry Gridin
2019-06-06 17:11:07 +07:00
parent fec9ee6408
commit 8b0b135112
15 changed files with 75 additions and 10 deletions
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiWhiteSpace
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.lexer.KtTokens.*
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getNextSiblingIgnoringWhitespace
import org.jetbrains.kotlin.psi.psiUtil.siblings
private fun KtModifierListOwner.addModifierList(newModifierList: KtModifierList): KtModifierList {
@@ -119,6 +120,12 @@ fun removeModifier(owner: KtModifierListOwner, modifier: KtModifierKeywordToken)
it.getModifier(modifier)?.delete()
if (it.firstChild == null) {
it.delete()
return
}
val lastChild = it.lastChild
if (lastChild is PsiComment) {
it.addAfter(KtPsiFactory(owner).createNewLine(), lastChild)
}
}
}