DSLD: Binding to inferred argument type

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

DSLD: Binding to inferred argument type

Peter Niederwieser
Administrator
I'm trying to add DSLD support for Spock's upcoming `Specification.with()` method, which is similar to Groovy's `Object.with()` (unfortunately I can't reuse the latter):

Person person = new Person(name: "fred")

expect:
with(person) {
  name == "fred"
}

My pointcut binds the argument type with `hasArgument(theTypes: type(subType())`, which works fine in the case of a typed variable like above. However, when the variable declaration is changed to `def person = new Person(name: "fred")`, the argument type becomes `java.lang.Object`. Is there a way to get access to the inferred type calculated by Groovy Eclipse?

Cheers,
Peter
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DSLD: Binding to inferred argument type

Andrew Eisenberg
This is another limitation of the enclosingCall pointcut.  I raised an
issue for it:
https://jira.codehaus.org/browse/GRECLIPSE-1461

See also,
https://jira.codehaus.org/browse/GRECLIPSE-1460

The enclosing call pointcut does not have access to inferred types of
its arguments, only statically available types that exist in the AST
(eg- when a variable declaration uses an explicit type as in your
example below) will work.  I'll have a look at this for 2.7.1.

Please let me know if you are having any more troubles with dslds.

On Fri, Jul 6, 2012 at 5:02 PM, Peter Niederwieser <[hidden email]> wrote:

> I'm trying to add DSLD support for Spock's upcoming `Specification.with()`
> method, which is similar to Groovy's `Object.with()` (unfortunately I can't
> reuse the latter):
>
> Person person = new Person(name: "fred")
>
> expect:
> with(person) {
>   name == "fred"
> }
>
> My pointcut binds the argument type with `hasArgument(theTypes:
> type(subType())`, which works fine in the case of a typed variable like
> above. However, when the variable declaration is changed to `def person =
> new Person(name: "fred")`, the argument type becomes `java.lang.Object`. Is
> there a way to get access to the inferred type calculated by Groovy Eclipse?
>
> Cheers,
> Peter
>
> --
> View this message in context: http://groovy-eclipse-plugin.42567.n3.nabble.com/DSLD-Binding-to-inferred-argument-type-tp4025013.html
> Sent from the groovy-eclipse-plugin-user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...