I'm trying to convert a library from kapt to ksp. ...
# ksp
m
I'm trying to convert a library from kapt to ksp. In kapt I had a very useful kotlinpoet
TypeElement.toTypeSpec(ClassInspector)
extension. Then generating the code from the original TypeSpec was a breeze - e.g. just mapping original functions to their modified generated equivalents. I can't find an equivalent in KSP world, I would assume because there is no equivalent ClassInspector. I guess I could modify my generator classes to not rely on TypeSpec but rather something more abstract, but it would be super convenient if there was something similar. What am I missing?
e.g. having such an
originalTypeSpec
I could do sth like this
Copy code
private val functions = originalTypeSpec.funSpecs
        .filter { !it.modifiers.contains(KModifier.PRIVATE) }
        .map { originalFuncSpec ->
            originalFuncSpec.toBuilder(name = originalFuncSpec.name)
                .clearBody()
                .apply {
                    modifiers.add(KModifier.ABSTRACT)
                    modifiers.remove(KModifier.SUSPEND)
                }
        }
z
This doesn't really make sense to have for KSP, we had that API basically because we reused kotlinpoet's API as a sort of IR
m
pity, that would be a nice common interface to switch between kapt and ksp 🙂
thanks for letting me know 🙂