You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2019/10/02 16:24:00 UTC
[jira] [Created] (GROOVY-9266) Extension method metaClass lacks
closure metadata for IDE/STC
Eric Milles created GROOVY-9266:
-----------------------------------
Summary: 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
Reporter: Eric Milles
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)