-
Notifications
You must be signed in to change notification settings - Fork 471
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
Support repeatable annotations #1030
Comments
Hm, this would be a breaking change if I'm not mistaken, at least for the non pluralized annotations, the other would need a singular sibling anyway. And for many this would generate a lot more noise IMHO, e.g. I've often seen |
I don't think it is a breaking change if done properly and you don't necessarily need singular siblings. I think you don't need to change the existing annotations at all, besides defining them as You then either have to use the AST rewriting to re-combine the annotations back into one for those where it is possible and do not need to change the evaluation logic, but I think the better and more consistent way would be to then where the annotations are evaluated, just request all annotations of the respective type and iterate over them, applying their effect instead of just requesting the sole annotation. |
Repeatable annotations work by having a separate collector annotation, this cannot be the same as the repeatable annotation itself. So you would have @Retention(RetentionPolicy.RUNTIME)
@Repeatable(Annos.class)
@interface Anno {
String value();
}
@Retention(RetentionPolicy.RUNTIME)
@interface Annos {
Anno[] value();
} having a method annotated like this @Anno('x') @Anno('y')
def foo () {} will be saved in bytecode like this @Annos(value={@Anno(value="x"),@Anno(value="y")})
def foo() {} So you definitely need two separate annotations. And I don't want to write custom AST transformations that won't be recognized by IDEs anyway to work around some of those issues. |
I'm very well aware of how repeatable annotations work and I didn't deny that you need additional collector annotations. |
Groovy 2.5.0 added support for repeatable annotations.
It would be nice if the Spock annotations where it makes sense would be declared repeatable so that you can for example write
instead of
as the former is better readable, better copyable and better commentable individually.
Also for example for
Retry
it would allow to have differentcount
anddelay
settings for different exceptions / conditions.These are the ones I'd say make sense to be repeatable:
UseModules
Use
ConfineMetaClassChanges
Subject
See
Retry
Requires
PendingFeature
PendingFeatureIf
Issue
IgnoreIf
The text was updated successfully, but these errors were encountered: