Skip to content

Instantly share code, notes, and snippets.

@Morfly
Last active April 16, 2022 05:45
Embed
What would you like to do?
override fun visitTypeArgument(typeArgument: KSTypeArgument, data: Unit) {
...
val resolvedType: KSType? = typeArgument.type?.resolve()
file += resolvedType?.declaration?.qualifiedName?.asString() ?: run {
logger.error("Invalid type argument", typeArgument)
return
}
// Generating nested generic parameters if any
val genericArguments: List<KSTypeArgument> = typeArgument.type?.element?.typeArguments ?: emptyList()
visitTypeArguments(genericArguments)
// Handling nullability
file += if (resolvedType?.nullability == Nullability.NULLABLE) "?" else ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment