Author Archive
Original IntelliJ Cast
Friday, August 14th, 2009Let’s talk about type casts — those things you hardly can avoid in JVM-based code. Being a helpful IDE, IntelliJ IDEA now does all the casting stuff for you when you are using its code completion in Java and Groovy.
To get you started, have a look at this Groovy example. In a dynamic language there’s almost no need in type casting at all — you just invoke any method on any object and hope it won’t fail. IDE can help you here, suggesting a list of acceptable choices based on preceding type checks:

In Java, there’s always a need in explicit casting. It’s easy of course, when you know the type to cast expression to. Smart completion after opening parenthesis has been able to do this for ages:

Imagine you’ve just checked an expression type via instanceof and now you want to invoke a method on the cast expression. Quite a natural wish, isn’t it? A week ago you had to write a cast manually, use a light bulb intention action or inst live template. Now you just invoke code completion after the cast expression and it suggests the members of the cast type. A lot simpler, right? Of course, the cast will be inserted automatically:

This works for both basic (Ctrl+Space) and smart completion (Ctrl+Shift+Space). I’ve been using this feature for 2 days now and I already can’t understand how could I survive without it through all the previous years.
Impressed already? But, there’s more. Say you’ve just checked that a certain expression has certain type. Then, you may want to cast that expression and assign the result to a variable, or pass it to a method. All you need is smart completion:

Moreover, as you know, IntelliJ IDEA has second smart completion feature. It’s now also aware of the run-time type checks that you made. After such a check you can perform cast and method invocation in a single action! Well, actually, you have to press Ctrl+Shift+Space two times, but that still counts:

Initial Griffon Support
Wednesday, July 29th, 2009The next Maia EAP brings you basic Griffon support, similar to Grails integration. You’ll be able to add Griffon library to Groovy facet:

IntelliJ IDEA will then create a Griffon application or plugin directory structure and take all the steps necessary to keep it up-to-date, as you install plugins and add libraries. As with Grails, a dedicated Griffon project view will appear together with a run/debug configuration:

Also, Run Griffon target with target autocompletion action can be found under Tools menu.
Compact Create Class Action
Friday, May 29th, 2009In the upcoming Maia EAP you won’t find separate actions for creating classes, interfaces, enums or @interface anymore. Just one action that does not clutter your desktop — New Java Class.
This does not mean you won’t be able to create interfaces, enums and annotation types, though:
The same functionality will be available for Groovy classes.
Second Smart Completion for Array Elements
Sunday, April 19th, 2009Do you use second smart completion feature? Did you know that it also can help you when you have an array and want an element of it? Just press Ctrl+Shift+Space two times when completing:

Something More About Generics Folding
Wednesday, April 8th, 2009Looking back at constructor type parameters folding, you may wonder why don’t we fold another verbose construct with generics — method type parameters like this:fillMap(Collections.<String, List<Integer>>emptyMap());
In Maia, we will:![]()
Easy Exclusion of Classes
Tuesday, April 7th, 2009You should already know that you can exclude certain classes from auto-import and code completion in IntelliJ IDEA 8.1. In Maia it will be even easier — you will be able to do it directly from the auto-import popup:
And from completion list, too:
Smart Completion of Java Primitive Method Parameters
Tuesday, March 24th, 2009Many API include methods like setXxx(int) where int is one of the predefined values, typically declared in the same class. The fact that these are just legacy methods that have been created prior to enums invention, does not stop IntelliJ IDEA from helping you with such parameter values. For example, have a look at JList#getSelectionModel. Just invoke the Smart Completion (Ctrl+Shift+Space) inside the call parentheses:
Repetitive Type Parameters Folding
Monday, March 16th, 2009Aren’t you tired of verbose constructs like this, are you?
![]()
For years IntelliJ IDEA has been saving your time spent on writing code like this (Smart Type Completion after new keyword). Now it does so with your brain cycles while you’re reading it:
![]()
This new folding will be available in the first Maia EAP.
Determining Template Data Language by a File Extension
Thursday, March 12th, 2009When using FreeMarker or Velocity with IntelliJ IDEA, you sometimes need to change the underlying language for a template to enable coding assistance and syntax highlighting.
As with IntelliJ IDEA 8.1, you can open the Settings Dialog and select Template Data Languages to specify what language should be applied to a single template, or an entire folder containing template files. IntelliJ IDEA Velocity integration is also capable of determining the language by a double file extension (e.g. foo.java.vm or bar.css.ft).
In the upcoming EAP for IntelliJ IDEA 8.1.1 you will find another way of mapping files to various template languages: open the Settings dialog, select File Types, and click Add or Edit under Registered Patterns.



