Hey. Does anyone have a working example of using A...
# arrow-meta
s
Hey. Does anyone have a working example of using Arrow-Meta with Kotlin 1.5.3 I could take a look at? I'm having tremendous build issues trying to get this working. Thanks.
r
Hi Shan, the arrow meta sources itself includes 3 plugins under the plugins folder. Latest version on main targets 1.5.31 https://github.com/arrow-kt/arrow-meta/tree/main/plugins
If you have a sample repo or something minimal that is not working I’ll be happy to take a look. What issues are you experiencing when building?
j
Commenting to follow, I’ve also had issues getting it set up. @raulraja for my use case, I want to create a plugin using Meta, but not use one of the 3 already created. Documentation for that seems to be scarce.
r
@Jeffrey Gulbronson, you are right, we have not made an effort to document it from the moment FIR was announced and therefore all meta apis depending on descriptors and PSI are going to be rewritten after 1.6 and when FIR becomes stable. This is needed because otherwise compiler plugins don’t cooperate with IDEA. We plan on writing docs and providing stables releases of base Meta as soon as K2 FIR makes it to Kotlin hopefully during next year. In the time being to develop a plugin all we can provide is the actual plugins we are building. Some use parts with psi + descriptors that will be removed. More precisely the entire Arrow Meta quote system to build plugins with templates has to change to the new FIR based impl. Once FIR is stable we may wrap it and provide a stable impl of the Kotlin AST and release meta stable for different versions.
There is no way ye to even create a FIR plugin because the extension point is still missing in master but I heard is landing soon. When it lands we’d need help modeling the AST and suggestions as to what kind of apis users expect from Meta in this new FIR model now that PSI and descriptors may go away.
j
Gotcha. For my particular case I just want to rewrite
Copy code
var foo: Int
To
Copy code
var foo: Int
  set(value) {
    trackChange("foo", field, value)
    field = value
  }
But sounds like that’s not really supported, or easy to get set up with right now
r
yes, that is supported and stable
that can be done exclusively as backend IR transformation
because the expression dos not alter the types or the implementation of the property does not affect type checking or other kind of resolution that would require changes to the frontend
j
Oh perfect. Any docs? I’ve been going off of https://medium.com/@heyitsmohit/writing-kotlin-compiler-plugin-with-arrow-meta-cf7b3689aa3e, but when I try to depend on
meta
using `
Copy code
implementation("io.arrow-kt:arrow-meta:1.0.2-SNAPSHOT")
I don’t have access to the
Meta
class
r
that the old Arrow meta based on kapt. Use the kotlin compiler version 1.5.31-SNAPSHOT, or in the next couple of weeks we will push for 1.6.0
Arrow meta follows the compiler version until FIR becomes stable
j
Ah interesting, will try that
r
What you want to do there to change the impl of a property you can do with https://meta.arrow-kt.io/apidocs/arrow-meta/arrow.meta.dsl.codegen.ir/-ir-syntax/ir-property.html
j
Great, I will play around with that a little bit. Seems easy enough to write tests
r
that will intercept all properties, and you may mutate their backing field or body expressions. for examples as to how to use IR in general that is what most compiler plugins use or look inside meta in the proofs plugin. The proofs plugin uses IR to inject dependencies
j
Got it,, will check the Proofs code
r
you can also depend on meta tests if you want as our plugin do to assert small programs or directly in the compiler testing library which we depend underneath, if you run into any issues feel free to ping me 🙂
j
Great, will do! I’m very excited at some potential perf gains this could unlock for us, so will definitely ping you if I run in to issues.
👍 1