-
-
Save dilrajsingh1997/70a4cac1f808ab23fd7585fbafa3b90a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file addLine "val argumentList" | |
file addPhrase ": MutableList<NamedNavArgument> " | |
tabs ++ | |
file addLine "get() = mutableListOf(" | |
count = 0 | |
properties.forEach { property -> | |
count ++ | |
val argumentName = property.simpleName.asString() | |
val resolvedType: KSType = property.type.resolve() | |
fun getElementNavType(): String { | |
return try { | |
when (resolver.getClassDeclarationByName(resolvedType.declaration.qualifiedName!!) | |
?.toString()) { | |
"Boolean" -> "NavType.BoolType" | |
"String" -> "NavType.StringType" | |
"Float" -> "NavType.FloatType" | |
"Int" -> "NavType.IntType" | |
"Long" -> "NavType.LongType" | |
else -> { | |
logger.error("complex data types not yet supported", property) | |
"" | |
} | |
} | |
} catch (e: Exception) { | |
"" | |
} | |
} | |
tabs ++ | |
file addLine "navArgument(\"$argumentName\") {" | |
tabs ++ | |
file addLine "type = ${getElementNavType()}" | |
tabs -- | |
file addLine "}," | |
tabs -- | |
argumentString += "$argumentName={$argumentName}" | |
if (count != propertyCount) { | |
argumentString += "," | |
} | |
} | |
file addLine ")" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment