Created
June 12, 2021 20:52
-
-
Save drawers/51dbae9b211cbce6982a7988a635292b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inner class Visitor : KSVisitorVoid() { | |
private lateinit var className: String | |
private lateinit var packageName: String | |
private val summables: MutableList<String> = mutableListOf() | |
override fun visitClassDeclaration(classDeclaration: KSClassDeclaration, data: Unit) { | |
val qualifiedName = classDeclaration.qualifiedName?.asString() | |
className = qualifiedName | |
packageName = classDeclaration.packageName.asString() | |
classDeclaration.getAllProperties() | |
.forEach { | |
it.accept(this, Unit) | |
} | |
if (summables.isEmpty()) { | |
return | |
} | |
} | |
override fun visitPropertyDeclaration(property: KSPropertyDeclaration, data: Unit) { | |
if (property.type.resolve().isAssignableFrom(intType)) { | |
val name = property.simpleName.asString() | |
summables.add(name) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment