You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/02/20 01:20:04 UTC
[jira] [Commented] (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:comment-tabpanel&focusedCommentId=16369629#comment-16369629 ]
ASF GitHub Bot commented on GROOVY-7956:
----------------------------------------
GitHub user paulk-asert opened a pull request:
https://github.com/apache/groovy/pull/664
GROOVY-7956: Provide an AST transformation which improves named param…
…eter support
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/paulk-asert/groovy groovy7956
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/groovy/pull/664.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #664
----
commit 43f2c8e47b2072e2c0e42097c4462180af30efdb
Author: paulk <pa...@...>
Date: 2018-02-20T00:09:59Z
GROOVY-7956: Provide an AST transformation which improves named parameter support
----
> 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)