[
https://issues.apache.org/jira/browse/GROOVY-9510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17751176#comment-17751176
]
Leonard Brünings edited comment on GROOVY-9510 at 8/4/23 5:13 PM:
------------------------------------------------------------------
Does your DSLD version also work for class-level annotations?
{code:groovy}
import spock.lang.IgnoreIf
import spock.lang.Requires
import spock.lang.Specification
@Requires({ jvm.java8Compatible })
@IgnoreIf(value = { jvm.isJava18Compatible() }, reason = "qed")
class Foo extends Specification{
@Requires({ jvm.java8Compatible })
@IgnoreIf(value = { jvm.isJava18Compatible() }, reason = "qed")
def "feature"() {
def cls = {
// shouldn't work here
true
}
expect:
cls() == true
with("example") {
// shouldn't work here as well
it.size() == 7
}
}
}
{code}
This is the example I was testing with. We have {{@Requires}}, {{@IgnoreIf}},
and {{@PendingFeatureIf}}.
was (Author: leonard84):
Does your DSLD version also work for class-level annotations?
{code:groovy}
import spock.lang.IgnoreIf
import spock.lang.Requires
import spock.lang.Specification
@Requires({ jvm.java8Compatible })
@IgnoreIf(value = { jvm.isJava18Compatible() }, reason = "qed")
class Foo extends Specification{
@Requires({ jvm.java8Compatible })
@IgnoreIf(value = { jvm.isJava18Compatible() }, reason = "qed")
def "feature"() {
def cls = {
// shouldn't work here
true
}
expect:
cls() == true
}
}
{code}
This is the example I was testing with. We have {{@Requires}}, {{@IgnoreIf}},
and {{@PendingFeatureIf}}.
> DelegatesTo and similar for annotation member methods
> -----------------------------------------------------
>
> Key: GROOVY-9510
> URL: https://issues.apache.org/jira/browse/GROOVY-9510
> Project: Groovy
> Issue Type: Bug
> Reporter: Björn Kautler
> Priority: Major
> Labels: annotations
> Attachments: image-2023-08-04-11-04-29-834.png
>
>
> If you have an annotation with a closure field like for example this in Spock:
> {code:java}
> @Retention(RetentionPolicy.RUNTIME)
> @Target({ElementType.TYPE, ElementType.METHOD})
> @ExtensionAnnotation(RequiresExtension.class)
> public @interface Requires {
> Class<? extends Closure> value();
> }{code}
> you can use it like
> {code:java}
> @Requires({ os.windows }){code}
> But I see no way to add IDE-hints for that closure like
> {{@DelegatesTo(PreconditionContext.class)}} as it is restriced to parameters.
> It would be nice if you could also annotate annotation member methods (and if
> IDEs would then support that too).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)