You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Facundo Farias <fa...@caravelo.com> on 2016/08/08 13:19:06 UTC

Using reserved words on Groovy Config files

Hello there!

Because we have external dependencies, we have to use some reserved words
on a Groovy file that will be parsed by the ConfigSlurper. We had to use
quotation marks, and the strange thing is: in the first level, it works (as
it can be seen on the IntelliJ screenshot, it is taken as a variable), but
then if we have at least one level of nesting, then it fails (as can be sen
on the screenshot, is not underlined).

[image: Inline image 1]
Of course, if we try to parse this file, the first scenario works, and the
second one throws this exception:

Exception in thread "main" java.lang.RuntimeException:
java.lang.NullPointerException: Cannot invoke method call() on null object

We ended up by escaping the nested variable, so now it looks like '*/it*'.
Does anyone knows a better solution? Is this a bug?

Thanks a lot,

Facundo

Re: Using reserved words on Groovy Config files

Posted by Jochen Theodorou <bl...@gmx.org>.

On 08.08.2016 15:19, Facundo Farias wrote:
> Hello there!
>
> Because we have external dependencies, we have to use some reserved
> words on a Groovy file that will be parsed by the ConfigSlurper. We had
> to use quotation marks, and the strange thing is: in the first level, it
> works (as it can be seen on the IntelliJ screenshot, it is taken as a
> variable), but then if we have at least one level of nesting, then it
> fails (as can be sen on the screenshot, is not underlined).

"it" is not a reserved keyword as such. It is the implicit and optional 
parameter for a closure. So on the top level you have no it, in {it}, 
you have the implicit it, {foo->} has no it, it has an explcit foo, 
{foo=null->} has an implicit foo, {->} does not have any parameter and 
then of course no "it" as well. I don't know if using {-> everywhere 
would suit you better?

bye Jochen