Skip to content

Instantly share code, notes, and snippets.

@dilrajsingh1997
Created November 20, 2021 13:58
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 dilrajsingh1997/5fc2d96dcf85583f8b9f5b722866aa14 to your computer and use it in GitHub Desktop.
Save dilrajsingh1997/5fc2d96dcf85583f8b9f5b722866aa14 to your computer and use it in GitHub Desktop.
file addLine "fun getDestination("
properties.forEach { property ->
val argumentName = property.simpleName.asString()
val resolvedType: KSType = property.type.resolve()
file addPhrase "$argumentName: "
file addPhrase (resolvedType.declaration.qualifiedName?.asString() ?: run {
logger.error("Invalid property type", property)
return
})
file addPhrase if (resolvedType.nullability == Nullability.NULLABLE) "?" else ""
file addPhrase ", "
}
file addPhrase "): String {"
tabs ++
file addLine "return \"$route${if (propertyCount > 0) "?" else ""}\" + "
tabs ++
tabs ++
count = 0
properties.forEach { property ->
count ++
val argumentName = property.simpleName.asString()
file addLine "\"$argumentName="
file addPhrase "$$argumentName"
if (count == propertyCount) {
file addPhrase "\""
} else {
file addPhrase ",\""
}
file addPhrase " + "
}
file addLine "\"\""
tabs --
tabs --
tabs --
file addLine "}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment