title: GDSL for defining the delegate of Closures in annotations
body: <p>Spock has some annotations that take a closure as argument, e.g., <code>@Requires({ os.windows })</code>. The annotations are defined as follows (omitting irrelevant information):</p>
  <pre class="lang-java prettyprint-override"><code>public @interface Requires {
    Class&lt;? extends Closure&gt; value();
  }
  </code></pre>
  <p>When evaluating the annotation Spock sets a <code>PreconditionContext</code> as delegate for the closure before evaluating it. So if it where a normal method we could define it as</p>
  <pre><code>boolean checkCondition(@DelegatesTo(PreconditionContext) Closure condition) {
   // ...
  }
  </code></pre>
  <p>but we can't use the <code>@DelegatesTo</code> annotation for <code>METHOD</code>/<code>TYPE_USE</code> targets.</p>
  <p>Unfortunately, IntelliJ's GDSL is sparsely documented, I found a <a href="https://www.tothenew.com/blog/gdsl-awesomeness-introduction-to-gdsl-in-intellij-idea/" rel="nofollow noreferrer">nice blog series</a> and the &quot;official&quot; <a href="https://confluence.jetbrains.com/display/GRVY/Scripting+IDE+for+DSL+awareness" rel="nofollow noreferrer">documentation</a>, but all I could find therein are examples for closures as method arguments.</p>
  <p>So, is it possible do define the delegate of an annotation closure with a gdsl script and how do you do it?</p>