A few weeks back we published a blog post and video about Code Completion. Now we're going to look at Code Generation, which compliments the completion features so nicely that in the past we put both sets of features into a single video. Code Generation is a really helpful feature in IntelliJ IDEA, particularly for Java programmers. Although Java as a language is steadily reducing the amount of boilerplate and typing that developers need to do, there are still plenty of common patterns of code that we simply shouldn't have to type character by character. Indeed, in IntelliJ IDEA, we do not
IntelliJ IDEA 14.1 Ships with Nextgen of Code Generation
IntelliJ IDEA already has impressive code generation capabilities: it can create getters and setters, equals(), hashCode(), toString(), and other methods, some of which are really simple to generate, and some are quite not. That's why the toString() method generator included the support for Velocity templates that could be modified and tailored to your needs. In IntelliJ IDEA 14.1 we're extending this support to all other generated methods. To fully support this new feature, the Template Editor has been upgraded with complete Velocity coding assistance. Note that this particul
Maven Generate actions for pom.xml editor
Try the last EAP of IntelliJ IDEA 9.0.2 to test new 'Generate' actions for Maven pom.xml editor. Type "Alt+Insert" to invoke the "Generate..." popup menu and select an action to run. IntelliJ IDEA actually runs live template inside to complete the code generation Let us know what you think about.
More intelligence for web.xml editor
With IntelliJ IDEA 9.0.2 you can enjoy editing web.xml with the new initial parameters support. IntelliJ IDEA now collects parameter names and is also aware of parameter values types. This allows the IDE to generate (with Alt-Insert), complete, highlight and validate them appropriately. Grab the latest EAP of IntelliJ IDEA 9.0.2 to try it today. If you are a plugin writer, you can provide your specific context parameters through the special com.intellij.javaee.model.xml.converters.ContextParamsProvider extention point.
Generate Persistence Mappings by Database Schema
The upcoming IntelliJ IDEA 8.1.1 includes a new option to generate separate XML mapping per entity.
Generating Bean Properties in Spring Contexts
With IntelliJ IDEA you can easily generate multiple properties in your Spring application contexts. Just invoke Generate action by pressing Alt+Insert inside of a bean tag and select properties you want to generate.IntelliJ IDEA analyzes property types and invokes an appropriate Live Template for each of the properties you selected.
Generating Persistence Mappings from Database Schema
With IntelliJ IDEA you can quickly generate persistence mappings from any database schema. This feature is not so easy to find, so here's the tip:
HQL Console with Pure JPA Facets
In IntelliJ IDEA HQL console can be used with pure JPA facets (as well as with Hibernate facets) to run JPAQL and HQL queries. All you need is Hibernate libraries and JDBC driver in a module classpath. If persistence.xml contains no Hibernate-specific database connection options, it should be mapped to an existing data source via JPA facet settings. Tip: HQL console can also be used to generate DDL statements for JPA and Hibernate mappings via its Generate DDL command. Update: If a Persistence Unit or Session Factory is mapped to a valid local Data Source there is no need to specify JDBC d
Generating Spring Bean Dependencies
You can easily generate setter or constructor dependency to any Spring Bean from your application contexts. Just press Alt+Insert or select Generate from the Code menu, then select appropriate dependency type, and then select a bean.IntelliJ IDEA will correctly update your application context file and, if needed, invoke a Live Template to generate a proper constructor or setter method in your class file.