You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2018/02/19 15:36:00 UTC

[jira] [Updated] (GROOVY-7956) Provide an AST transformation which improves named parameter support

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

Paul King updated GROOVY-7956:
------------------------------
    Summary: Provide an AST transformation which improves named parameter support  (was: Allow @DelegatesTo on named arguments)

> Provide an AST transformation which improves named parameter support
> --------------------------------------------------------------------
>
>                 Key: GROOVY-7956
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7956
>             Project: Groovy
>          Issue Type: New Feature
>          Components: GEP
>            Reporter: Graeme Rocher
>            Priority: Major
>
> In order to aid static compilation for builders we have {{@DelegatesTo}} which allows statically compiled code to know what the delegate of a closure is.
> This proposal is to allow {{@DelegatesTo}} on {{Map}} types such that IDEs and the static compiler can resolve the target type the named arguments are to be used on.
> For example:
> {code}
> class Farm {
>      void animal(@DelegatesTo(Animal) Map arguments, @DelegatesTo(AnimalBuilder) Closure callable) {
>              def animal = new Animal(arguments)
>              // handle closure
>     }
> } 
> class Animal { String name }
> {code}
> The following code would then fail to compile :
> {code}
> def farm = new Farm()
> // compilation failure, no name property on Animal
> farm.animal(nam: "Dog")  { 
> }
> {code}
> It would then be down to IDEs to also provide support for code completion etc.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)