generateUtil: cleanup code
This commit is contained in:
@@ -241,16 +241,16 @@ fun <T : KtDeclaration> insertMembersAfter(
|
|||||||
otherMembers.mapTo(insertedMembers) {
|
otherMembers.mapTo(insertedMembers) {
|
||||||
if (classOrObject is KtClass && classOrObject.isEnum()) {
|
if (classOrObject is KtClass && classOrObject.isEnum()) {
|
||||||
val enumEntries = classOrObject.declarations.filterIsInstance<KtEnumEntry>()
|
val enumEntries = classOrObject.declarations.filterIsInstance<KtEnumEntry>()
|
||||||
val bound = (enumEntries.lastOrNull() ?: classOrObject.allChildren.firstOrNull { it.node.elementType == KtTokens.SEMICOLON })
|
val bound = (enumEntries.lastOrNull() ?: classOrObject.allChildren.firstOrNull { element ->
|
||||||
|
element.node.elementType == KtTokens.SEMICOLON
|
||||||
|
})
|
||||||
if (it !is KtEnumEntry) {
|
if (it !is KtEnumEntry) {
|
||||||
if (bound != null && afterAnchor.startOffset <= bound.startOffset) {
|
if (bound != null && afterAnchor.startOffset <= bound.startOffset) {
|
||||||
afterAnchor = bound
|
afterAnchor = bound
|
||||||
}
|
}
|
||||||
}
|
} else if (bound == null && body.declarations.isNotEmpty()) {
|
||||||
else if (bound == null && body.declarations.isNotEmpty()) {
|
|
||||||
afterAnchor = body.lBrace!!
|
afterAnchor = body.lBrace!!
|
||||||
}
|
} else if (bound != null && afterAnchor.startOffset > bound.startOffset) {
|
||||||
else if (bound != null && afterAnchor.startOffset > bound.startOffset) {
|
|
||||||
afterAnchor = bound.prevSibling!!
|
afterAnchor = bound.prevSibling!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user