Help with Dynamic properties

I made a reference to a nonexistent method in a Groovy class, clicked on the light bulb in the margin to have IDEA create the method for me. I saw an "Add Dynamic Method" entry and tried it out. What exactly happens when I add a Dynamic Method to the Dynamic properties panel? Is a method actually created in the class' ExpandoMetaClass? Also, I couldn't find a way to delete the Dynamic method once added. How do I do that? Finally, what artifact(s) gets changed in the project when dynamic methods are added this way?

Thanks for helping this old Java guy who's new to Groovy/Grails and JetGroovy. Thanks for a really helpful plug-in.

Jack

3 comments

To answer your questions:
1) no, it's not added to the expandometaclass. The ExpandoMetaClass is a class with which you can change the runtime behaviour of your classes. IntelliJ doesn't use that, but uses an internal reference of methods which IntelliJ can't detect itself, but of which you know the existence. For example: the User.save() method doesn't really exist in the User class, but when you tell IntelliJ Grails added it for you and it returns User instances, it's added to the list of dynamic methods to be used in future code completion.
2) You can remove the methods (which is a bit annoying), by selecting the method in the Dynamic Method panel, and pressing 'delete' on your keyboard.
3) No artifacts get changed. See point 1.

Erik

0

When you use "add dynamic method/property" nothing creates in you project source files. It is just utility to you could see methods, which will create on runtime dynamically.
If you know exactly what the name of such method will be and you know parameters as well, you just can add dynamic method to panel to avoid untyped underline and make navigation. These dynamic elements saves in project settings
To delete it press 'delete' button on the panel
To change the name/type click on element on th panel
So, no one aftefact is changed

0

Is there any chance of finding some kind of Grails GORM dynamic mappings as predefined in JetGroovy?

0

Please sign in to leave a comment.