Open vlsi opened 4 years ago
If I'm right, this code is about adding extension-properties to Strings and Specs, such that it will be easier to compose the codeblock. If this is the case, I think this it is more useful if you would add it to KotlinPoet. When this is added, it automatically works in KotlinPoetDSL.
Ok. Let me try that.
However, I think it won't be added to KotlinPoet judging by https://github.com/square/kotlinpoet/pull/496#issuecomment-441340885
As you can see, https://github.com/square/kotlinpoet/issues/877 was closed, so WDYT regarding extended blocks in KotlinPoetDSL?
I personally would have something more reflection-like... Don't know how, but something more like the following:
val j = "j" valOf Int::class
val hello = strVal("""Hello, "world", \n test""")
cb {
addLazy(::println, hello+j)
}
fun <R> CodeBlock.addLazy(func : KFunction1<String, R>, stringValue : StringValue){
add(func.name+"("+stringValue+")")
}
But I have to investigate it more...
See https://github.com/square/javapoet/issues/761#issuecomment-581057940
For instance:
==>