[apt-jelly-users] [APT-JELLY] Bug report on tag @ForAllTypes with option 'annotation'
Brought to you by:
stoicflame
|
From: Nicolas L. <nic...@va...> - 2006-06-23 16:13:06
|
Hi Ryan,
=20
Here is the situation.
A problem appeared when I use the tag @forAllTypes with the annotation
parameter.
The template should iterate over the list of type filtered with the
annotation set in option.
It's work fine unless the annotation is not in the first position.
=20
For example :
=20
@AnAnnotation
@AnotherAnnotation
Public class MyClass{
//...//
}
=20
If the template starts with :=20
<@forAllTypes var=3D"type" annotation=3D"AnAnnotation">
You can parse your class declaration.
=20
But if the template starts with :
<@forAllTypes var=3D"type" annotation=3D" AnotherAnnotation ">
You can not parse the class declaration.
=20
=20
=20
The source code problem is located in the class :
net.sf.jelly.apt.strategies
and in the method :
protected boolean hasAnnotation(D declaration, String annotationName)
=20
I give you, one possible solution (the one I carry out for my project) :
Replace the code by :
@Override
protected boolean hasAnnotation(TypeDeclaration declaration,
String annotationName) {
for (AnnotationMirror mirror :
declaration.getAnnotationMirrors()) {
AnnotationTypeDeclaration
annotation =3D mirror.getAnnotationType().getDeclaration();
if
(annotation.getQualifiedName().equals(annotationName)) {
return true;
}
}
return false;
}=20
=20
=20
=20
I hope it is enough clear. I don t have enough time at this moment to
give you more detailed explanations.
But don't hesitate to contact me for more details.
=20
Nicolas.
|