8000 Copy non AA annotations in generated class by yDelouis · Pull Request #982 · androidannotations/androidannotations · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Conversation

@yDelouis
Copy link
Contributor
@yDelouis yDelouis commented May 1, 2014

This PR makes AA copy non AA annotations in generated classes as requested in issue #782.
This enables runtime annotations to work as if the class was written by the developer and other annotations processor to process generated class.

Annotations on class, methods and method parameters are copied in
generated class.
SubscribeHandler and ProduceHandler are no longer necessaries.
We are copying all annotations to overriden classes, methods, method
arguments etc, what are not from our package. This commit adds the
ability to AA to copy the annotation parameters, too.
Note that annotation as an annotation parameter is not supported yet.
@WonderCsabo
Copy link
Member

I proposed a PR for copying annotation parameters, yDelouis#1.
All parameter types are supported except annotations as annotation parameters (Inception...).
JAnnotationUse.annotationParam() expects an object of Class<? extends Annotation>. I do not know how we could create a Class object from an AnnotationValue. :S

@WonderCsabo
Copy link
Member

I am wondering, does this help us to integrate with Dagger?

@DayS
Copy link
Contributor
DayS commented May 11, 2014

This may help integrate Dagger only if every annotated method are propagated in the generated class, because Dagger doesn't look at inherited class's methods.

However, this PR was about propagating non-AA annotations on generated methods. And it seems to work great 👍
We should now make another PR to propagate all annotated (coming from AA or not) methods.

DayS added a commit that referenced this pull request May 11, 2014
Copy non AA annotations in generated class
@DayS DayS merged commit de742bd into androidannotations:develop May 11, 2014
@yDelouis yDelouis deleted the 782_otherAnnotations branch May 11, 2014 11:15
@WonderCsabo
Copy link
Member

I cannot understand, Why we should copy AA annotations, too?

@DayS
Copy link
Contributor
DayS commented May 11, 2014

My mistake, as AA annotations should already been processed, we don't have to propagate them :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Override
@UiThread
public void doSomething() {
    // ...
}

after annotation processing, @Override annotated twice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed with #1001

@chpasha
Copy link
chpasha commented Nov 5, 2014

I have a problem with copying non-AA annotations to generated class. I have a custom annotation with parameters , one of them refers to another AA-Generated class. This parameter is not copied to generated class correctly (maybe since the AA-class is generated before the referred AA-class). In the end the Annotation looks like @MyAnnotation(param = ) which obviously breaks the code. Ultimately I had to disable copying of the annotations with parameters (in my aa-fork) to avoid the problem. Can this be fixed? If not, can we find some compromise? For instance - do not copy annotations which are @inherited (since they can sill be discovered) without propagation to generated class?

@yDelouis
Copy link
Contributor Author
yDelouis commented Nov 5, 2014

Your last idea seems good to me (not copying annotations with @Inherited.
Would you contribute and submit a PR for that ?

@chpasha
Copy link
chpasha commented Nov 5, 2014

never done anything like that before, but I could try on weekend and may be post a patch here?

@WonderCsabo
Copy link
Member

What if the annotation is not inherited but still needs a generated class
as a param?

@chpasha
Copy link
chpasha commented Nov 5, 2014

than the aa code has to be fixed to support that. this is an obvious solution but since I have no idea if it is possible (to be honest I looked into the code only to disable annotations with params) - the workaround could be to omit at least @inherited annotations.

@WonderCsabo
Copy link
Member

OK guys, we should a new issue about this.

@chpasha
Copy link
chpasha commented Nov 5, 2014

do you want me to do this?

@WonderCsabo
Copy link
Member

If you don't mind. ;)

@chpasha
Copy link
chpasha commented Nov 5, 2014

well, it won't take long anyway ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

0