Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
override fun visitPropertyDeclaration(property: KSPropertyDeclaration, data: Unit) {
// Generating argument name.
val argumentName = property.simpleName.asString()
file += " $argumentName: "
// Generating argument type.
val resolvedType: KSType = property.type.resolve()
file += resolvedType.declaration.qualifiedName?.asString() ?: run {
logger.error("Invalid property type", property)
return
}
// Generating generic parameters if any.
val genericArguments: List<KSTypeArgument> = property.type.element?.typeArguments ?: emptyList()
visitTypeArguments(genericArguments)
// Handling nullability.
file += if (resolvedType.nullability == Nullability.NULLABLE) "?" else ""
file += ",\n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment