Dynamic properties in Groovy/Grails


the example described here: http://www.jetbrains.net/confluence/display/GRVY/Dynamic+Methods+and+Properties
suggests, that the IDE understands the assignment of dynamic props to the metaclass. I tried this out, but without success. Am I doing something wrong or do I misunderstand the description/example?
To add confusion, in the context of a metaclass assignment, the IDE suggests to add this property to the metaclass itself, which is not what I wanted to have.

I tried this with version 8.1.3 and 9.0beta (Maia IU-90.137).


Comment actions Permalink

Hi Klaus,

I just tried it in IntelliJ 8.1.3, and I can see the dynamic properties by typing in a variable or method which does not exist, and then pressing Alt+Enter. A popup will show (see screenshots) and there you can add the dynamic properties.

Hope that helps,

Erik Pragt

Screen shot 2009-11-11 at 07.49.32.png
Screen shot 2009-11-11 at 07.51.11.png
Comment actions Permalink

Hi Erik,

I can also add the dynamic property the way you did.
My point was, that the example with the String class suggests, that this goes automatically. And that the IDE is aware of the metaclass assignment.


Comment actions Permalink

Well, the IDE is aware after you've added it to the Dynamic Properties view in IntelliJ. This doesn't go automatically (nor do I see that in the documentation), but after you've made IntelliJ aware of the Groovy dynamic property, IntelliJ does automatically recognize future invocations of those methods.

Btw, I don't see where the String example where this goes automatically. The documentation you're pointing to clearly states that you have to press Alt+Enter to make this work (the first time). After that, IntelliJ will recognize the method/property (automatically).

Am I missing something here?


Comment actions Permalink


I might be misleaded by this example:

With this text below:
   >>   Notice how the "".greetings is not underlined, whereas before it would have been. Also, the expression is now available for code completion: <<

It looks like the metaclass statement is understodd by the IDE.

Btw, have you been able to export the dynamic properties available for import into another IDE instance?
This would help my coworkers.



Please sign in to leave a comment.