Skip to content

Instantly share code, notes, and snippets.

@drawers
Last active Jun 12, 2021
Embed
What would you like to do?
inner class Visitor : KSVisitorVoid() {
override fun visitClassDeclaration(classDeclaration: KSClassDeclaration, data: Unit) {
val qualifiedName = classDeclaration.qualifiedName?.asString()
if (!classDeclaration.isDataClass()) {
logger.error(
"@IntSummable cannot target non-data class $qualifiedName",
classDeclaration
)
return
}
if (qualifiedName == null) {
logger.error(
"@IntSummable must target classes with qualified names",
classDeclaration
)
return
}
}
private fun KSClassDeclaration.isDataClass() = modifiers.contains(Modifier.DATA)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment