[
https://issues.apache.org/jira/browse/GROOVY-9510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17751378#comment-17751378
]
Leonard Brünings edited comment on GROOVY-9510 at 8/6/23 10:48 AM:
-------------------------------------------------------------------
{{@Retry}} delegates to
[org.spockframework.runtime.extension.builtin.RetryConditionContext|https://github.com/spockframework/spock/blob/3a9b830ded6ba95f10f51e971ca00e2fa10bccf3/spock-core/src/main/java/org/spockframework/runtime/extension/builtin/RetryConditionContext.java]
which has a {{getInstance()}} method returning the specification instance as
well.
Is the method {{isInClosure}} missing its body, or does it work by some magic
due do its argument declaration when it is called without in the {{contribute}}
clause?
{quote}I can’t think of a way to indicate those methods return type is the
containing spec class, besides DSLD/GDSL.{quote}
Yeah, that's what I expected and not a problem. The this goes beyond the simple
type annotation proposal.
However, it might work by introducing helper annotations to put on those
methods that help the IDE to figure it out. {{@ReturnsEnclosingClass}}, or
something.
Although, that might be too special cased.
Thank you for this productive collaboration.
was (Author: leonard84):
{{@Retry}} delegates to
[org.spockframework.runtime.extension.builtin.RetryConditionContext|https://github.com/spockframework/spock/blob/3a9b830ded6ba95f10f51e971ca00e2fa10bccf3/spock-core/src/main/java/org/spockframework/runtime/extension/builtin/RetryConditionContext.java]
which has a {{getInstance()}} method returning the specification instance as
well.
Is the method {{isInClosure}} missing its body, or does it work by some magic
due do its argument declaration when it is called without in the {{contribute}}
clause?
{quote}I can’t think of a way to indicate those methods return type is the
containing spec class, besides DSLD/GDSL.{quote}
Yeah, that's what I expected and not a problem. The this goes beyond the simple
type annotation proposal.
However, it might work by introducing helper annotations to put on those
methods that help the IDE to figure it out. {{@ReturnsEnclosingClass}}, or
something.
Although, that might be too special cased.
Thank you for this productive interaction.
> 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, screenshot-1.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)