Skip to content

Instantly share code, notes, and snippets.

@Morfly
Last active April 16, 2022 05:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Morfly/75f8bb1bfaeaf47c1b94dcf901b50da8 to your computer and use it in GitHub Desktop.
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