groovyintellij-ideagriffon

IntelliJ highlights as error a working code in Griffon


Below is a snippet from a working code taken from the Groovy in Action book. As you see below, IntelliJ sees it as error.

Why?

See picture below:

enter image description here


Solution

  • I don't think IDEA is to blame here. Griffon is exploiting a trick that Groovy brings to the table: using closures as annotation values. However @PropertyListener goes a bit further by allowing closure properties to be used too, but in order to do it converts invalid code (a property name cannot be used as an annotation value) into valid code (changes the annotation value into an empty String).

    There is no way IDEA can be aware that the Griffon compiler is using this trick, hence the red squiggles. Regardless of this, don't be alarmed, the Griffon compiler will do the right thing.