New J2K: Move comments from primary constructor to init section
This commit is contained in:
committed by
Ilya Kirillov
parent
481b2feda3
commit
99f3af9e85
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user