New J2K: Move comments from primary constructor to init section

This commit is contained in:
Ilya Kirillov
2019-03-26 15:46:34 +03:00
committed by Ilya Kirillov
parent 481b2feda3
commit 99f3af9e85
2 changed files with 8 additions and 0 deletions
@@ -33,6 +33,10 @@ class PrimaryConstructorDetectConversion(private val context: ConversionContext)
if (primaryConstructorCandidate.block.statements.isNotEmpty()) {
val initDeclaration = JKKtInitDeclarationImpl(primaryConstructorCandidate.block)
.withNonCodeElementsFrom(primaryConstructorCandidate)
primaryConstructorCandidate.clearNonCodeElements()
for (modifierElement in primaryConstructorCandidate.modifierElements()) {
modifierElement.clearNonCodeElements()
}
element.classBody.declarations =
element.classBody.declarations.replace(primaryConstructorCandidate, initDeclaration)
} else {
@@ -43,6 +43,10 @@ fun JKTreeElement.commentsFromInside(): List<JKCommentElement> {
inline fun <reified T : JKNonCodeElementsListOwner> T.withNonCodeElementsFrom(other: JKNonCodeElementsListOwner): T =
also { it.takeNonCodeElementsFrom(other) }
inline fun JKNonCodeElementsListOwner.clearNonCodeElements() {
leftNonCodeElements = emptyList()
rightNonCodeElements = emptyList()
}
interface JKTokenElement : JKNonCodeElementsListOwner {
val text: String