pocmo / recompose

recompose is a tool for converting Android layouts in XML to Kotlin code using Jetpack Compose.
Apache License 2.0
783 stars 49 forks source link

Refactored AST and Parser to be more extensible and structured. #113

Closed Ditscheridou closed 1 year ago

Ditscheridou commented 2 years ago

Introduced an API to for defining how an Attribute and a View Element can be parsed from XML to AST. This API has two Key interfaces, AttributeTransformer to define how an XML-Attribute is converted and Node Transformer to define how an entire XML-Element in is transformed. A Node Transformer can contain multiple AttributeTransformer, and will be automatically picked up by the NodeMatcher class, that scans the classpath for classes implementing the NodeTransformer interface and uses them to match a node name on a fitting NodeTransformer. The generated AST from that can be consumed by any class implementing the Visitor interface.

This work is just the first step for future optimizations. I am planning to enhance the AST to be able to apply an optimiser that can eliminate some nodes on the attributes (e.g. you can eliminate fillMaxHeight and fillMaxWidth and replace it with fillParent if both are present).

Ditscheridou commented 2 years ago

there was a mistake made by me by committing the version upgrade to the main branch....guess I was to tired yesterday. please ignore the IntelliJ plugin part for now, I will revert this commit until its stable. The other changes still standing.

pocmo commented 1 year ago

Closing the PR: It has been a while (Sorry!). If you are still interested in getting some of those things merged, let's chat about them. Tbh. there are too many changes lumped together in this PR to reasonably review it.