I have a `FirDeclarationGenerationExtension` that ...
# compiler
f
I have a
FirDeclarationGenerationExtension
that I am using to generate a nested class with the same params as a data class plus custom setters, flows for each property and and all flow. Is the correct process to generate callables for each method/property in
getCallableNamesForClass
and the generate properties and functions in
generateProperties
and
generateFunctions?
To do this I have to parse the constructor for the supertype twice or cache callable information in the extensions and to generate the method signatures I need? Am I missing something about how this extension should work? If anyone has similar work. I could read I would really appreciate it too!
b
You are correct. But, you can do some tricks to make finding the constructor very performant in the
generate*
functions. Namely, creating a custom origin key for the nested class which holds onto the constructor. I built out a sample compiler-plugin recently doing something very similar to what you are describing, and you can find the pattern I described used here: https://github.com/bnorm/buildable/blob/main/compiler-plugin/src/dev/bnorm/buildable/plugin/fir/BuildableFirDeclarationGenerationExtension.kt
🙌 1
f
Thanks a lot @bnorm that got me going!