cashapp / redwood

Multiplatform reactive UI for Android, iOS, and web using Kotlin and Jetpack Compose
https://cashapp.github.io/redwood/0.x/docs/
Apache License 2.0
1.63k stars 70 forks source link

Parse schema using FIR instead of reflection #19

Closed JakeWharton closed 2 months ago

JakeWharton commented 3 years ago

Switch to using FIR so that we can:

JakeWharton commented 3 years ago

UAST would also give us default expressions without requiring an annotation

JakeWharton commented 3 years ago

We could also theoretically use the new FIR of the compiler.

JakeWharton commented 2 years ago

UAST bootstrap can now be copied from the lint support.

JakeWharton commented 1 year ago

I have parsing somewhat working using PSI.

The biggest problem I foresee is that we currently parse the schema in multiple places with reflection and we do that by consuming a jar of the compiled Kotlin on the classpath. With PSI we can only access things like default expressions and comments in source. This means that we do not get them from dependencies.

There's two problems with this:

JakeWharton commented 1 year ago

The only interesting thing from this migration is how to handle the default expression change.

For the first implementation we will respect the @Default annotation and ignore the default expression. This retains the behavior of the reflection parser today.

Then, once that is working, we will delete the @Default annotation and require migration to regular expressions.

JakeWharton commented 2 months ago

Need to switch JSON generation task to be added as a resource-generating task once this is complete. Currently we pack it into the jar which doesn't always work.