[ 
https://issues.apache.org/jira/browse/GROOVY-9266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Sun updated GROOVY-9266:
-------------------------------
    Fix Version/s: 3.0.0-rc-1

> Extension method metaClass lacks closure metadata for IDE/STC
> -------------------------------------------------------------
>
>                 Key: GROOVY-9266
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9266
>             Project: Groovy
>          Issue Type: Improvement
>    Affects Versions: 2.4.17, 2.5.8, 3.0.0-beta-3
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 3.0.0-rc-1
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The two "metaClass" methods of {{DefaultGroovyMethods}} accept a Closure but 
> do not indicate delegate or parameter metadata.
> {code:java}
> public static MetaClass metaClass(Class self, Closure closure) ...
> public static MetaClass metaClass(Object self, Closure closure) ...
> {code}
> Both methods pass the closure to {{ExpandoMetaClass.define}} which also lacks 
> metadata.  Here is the proposed change to that method, which could be 
> propagated to the DGMs:
> {code:java}
>     public ExpandoMetaClass define(@ClosureParams(value=SimpleType.class, 
> options="java.lang.Object")
>             @DelegatesTo(value=DefiningClosure.class, 
> strategy=Closure.DELEGATE_ONLY) Closure closure) {
>         final DefiningClosure definer = new DefiningClosure();
>         Object delegate = closure.getDelegate();
>         closure.setDelegate(definer);
>         closure.setResolveStrategy(Closure.DELEGATE_ONLY);
>         closure.call((Object)null);
>         closure.setDelegate(delegate);
>         closure.setResolveStrategy(Closure.DELEGATE_FIRST);
>         definer.definition = false;
>         return this;
>     }
> {code}
> Note: Not sure exactly how to indicate that the parameter is "null" or if 
> that's important.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to