Search

Dark theme | Light theme

October 19, 2009

Use Dynamic Properties in IntelliJ IDEA Community Edition

We can tell IntelliJ IDEA Community Edition that a property is dynamically added to a class or object. If we have told IntelliJ IDEA the type of the object we get complete code completion for the property in the text editor.

For example if we have a Groovlet where we use the request property, then IntelliJ IDEA shows a line under request. This indicates IntelliJ IDEA doesn't know about request, but if we press Alt+Enter when the cursor is on the keyword we get a little popup menu:

We must select the first option Add dynamic property 'request' and IntelliJ IDEA opens a dialog window. Here we must tell which type this property is. The request property is of type javax.servlet.http.HttpServletRequest, so we type in the classname and press OK:

We are back in our editor. We can open the window Dynamic properties to see which properties are defined as dynamic and of which type they are. But we also get complete code completion for our request object: