Skip to content

Instantly share code, notes, and snippets.

@sasssass
Created June 17, 2024 09:19
Show Gist options
  • Save sasssass/f13f632e54a0534250890c50d938dd23 to your computer and use it in GitHub Desktop.
Save sasssass/f13f632e54a0534250890c50d938dd23 to your computer and use it in GitHub Desktop.
NodeProcessor.kt
private fun generateFunction(): FunSpec {
val funBuilder = FunSpec.builder("testFunction")
funBuilder.addParameter("something", String::class.asTypeName())
val code = buildString {
append("val somethingelse = something {\n")
append("}\n")
append("return somethingElse")
}
funBuilder.returns(String::class).addCode(code)
return funBuilder.build()
}
/**
* fun testFunction(something: String): String {
* val somethingelse = something
* return somethingelse
* }
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment