-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dart & Henson 3 Specs draft. RFC #164
Comments
Thanks for writing this up, seems like you have a good plan here, so go ahead! The Dart API changes look great to me :) |
if dart3.0 support custom annotation?
|
@fansmc can we discuss the topic in a new issue. We are not against the idea, but we would like to understand / discuss things more in-depth. This will not be addressed in 3.0, but could be done quickly after. And even faster if you contribute a PR ;) |
We also want to switch to gradle. |
@f2prateek I am gonna merge a PR that will transform master into a new Dart 3 master. |
@dlemures @f2prateek There is a problem in the proposal above: we don't address (relatively rare) cases where 2 classes inherit from each other and live in different modules:
In this case, activity B's intent builder should include the field foo & bar in its DSL. But the problem is that there is no way for the current compiler to detect the fields of A. The compiler expects all classes to be compiled at once, and this will not be true anymore in the case of multiple modules (and also in the case of incremental compilation...). We need to make this work, not only to solve the case of inheritance across module, but more importantly for the upcoming incremental annotation processing on Android. On ButterKnife, this is still a work in progress, the idea of the current PR is to use the generated code for a super class, and actually use it, when processing a subclass in a different module. In Butterknife, the super class is used in 2 ways:
The second point is a very nice feature, because it prevents from re-processing the super class, ButterKnife's annotation processor just uses the processing that was performed when the super class was compiled. Indeed, re-processing the super class when processing the subclass would be even more costly than just processing the super class (when compiling the super class): ButterKnife would even have to scan the annotations of the super class, whereas they are passed by javac to the annotation processor when compiling the super class itself. We could use the same mechanism, but it's quite unlikely that we will be able to re-use the intent builder of the super class when generating the intent builder of the subclass. There are a few things that would break (namely 1) alphabetical ordering of the fields in the DSL, 2) the optional fields would have to be filled in a non natural order, and 3) there are some edge cases like when the subclass has no annotated fields of its own but only inherits annotated fields). |
Ideas have evolved a bit: Thx to @melix for our latest chat on source sets and compilation units. We still have to figure out a solution for inheritance accross modules, but here is what a typical dart & henson 3 project will look like: This project illustrates how henson will work with respect to modularization:
|
Here is a repo that demonstrates a solution to the issue of inheritance across modules: It should not be so hard to implement. This is basically using the same trick as ButterKnife to reuse the code generated for super classes. The main idea was to split the intent builder into 2 parts that can be merged easily (required fields by composition, optional fields by inheritance). Thx to @code-twister for the exchanges on this. |
There is now a more complete implementation of the DSL + a design document: |
Hi @f2prateek , we wanna change Henson and release a new version. Dart would be changed optionally as well, see below.
The problem we are facing is that Henson doesn't, and cannot in its current form, work well with modules:
We have found a work around, and we ask for your comments on this. We want to move fast.
Proposed Henson API changes
We are gonna change Henson to work completely the opposite of its actual state:
Henson
class will be generated in the same way as before and will contain methods to obtain all intent buildersHenson
classes$$IntentBuilders
will be renamed to__IntentBuilders
to follow ButterKnife conventions and remove the ambiguity with inner classesProposed Dart API changes
@InjectExta
annotation to@BindExtra
in the same release. It will follow more closely the evolution of Butterknife and will disambiguate with DI annotations which are confusing for junior devs.$$ExtraInjectors
will be renamed to__ExtraBinders
and remove the ambiguity with inner classesPlease note that all this work will also make it easier to work on an incremental version of Dart & Henson.
The text was updated successfully, but these errors were encountered: