Last active
August 12, 2021 05:10
-
-
Save Morfly/a1c5349c424d0dde68a2e541b7c883f6 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
override fun visitClassDeclaration(classDeclaration: KSClassDeclaration, data: Unit) { | |
... | |
// Getting the list of member properties of the annotated interface. | |
val properties: Sequence<KSPropertyDeclaration> = classDeclaration.getAllProperties() | |
.filter { it.validate() } | |
// Generating function signature. | |
file += "\n" | |
if (properties.iterator().hasNext()) { | |
file += "fun $functionName(\n" | |
// Iterating through each property to translate them to function arguments. | |
properties.forEach { prop -> | |
visitPropertyDeclaration(prop, Unit) | |
} | |
file += ") {\n" | |
} else { | |
// Otherwise, generating function with no args. | |
file += "fun $functionName() {\n" | |
} | |
// Generating function body | |
file += " println(\"Hello from $functionName\")\n" | |
file += "}\n" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment