Skip to content

Instantly share code, notes, and snippets.

@drawers
Last active June 12, 2021 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drawers/3052e618b688469e1d093df9cf6f89a7 to your computer and use it in GitHub Desktop.
Save drawers/3052e618b688469e1d093df9cf6f89a7 to your computer and use it in GitHub Desktop.
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