Archive for September, 2009

Super Completion

Tuesday, September 15th, 2009

Do you often find yourself calling a super method with a large number of parameters? Typing all those arguments one by one is soooooo boring, isn’t it?! Don’t be upset anymore — latest Maia EAP can rescue you. Just use Smart Completion (Ctrl+Shift+Space):

Debugger Evaluate Expression Enhancements

Monday, September 14th, 2009

Say, you hit a breakpoint in Java code:

And you cleanly see that component is a label:

You now want to investigate label internals via Evaluate Expression (Alt+F8), e.g. invoke its getText() method, but component declared type is Component and it does not have this method! The only way out is to use Surround with run-time type (Ctrl+Alt+T) first to cast it to JLabel and only then completion becomes available:

Not anymore it isn’t. IntelliJ IDEA tries to help with casting wherever possible, so you can now get the same results using Basic code completion (Ctrl+Space) only:

…press Enter and the cast is done for you:

Needless to say, it works with Smart completion (Ctrl+Shift+Space), too. It works even for complex expressions with method calls. Note, that method evaluation can take a lot of time, not to mention the possible side effects, so evaluating expressions every time you hit completion is not so nice. This is why you need to press the same shortcut twice to get the run-time type variants. That’s what you’re going to see at the bottom of completion list:

And you can play with all this now!

TFS Checkin Notes and Policies Support

Wednesday, September 9th, 2009

IntelliJ IDEA Team Foundation Server integration now supports checkin notes and policies. Checkin notes are the arbitrary text fields that you can associate with a checkin. You can mark them as mandatory, so that everyone will be required to type something before performing a checkin. This is handy, for example, when you need developers to provide a comment from manager who reviewed their code.

Checkin policies are the rules executed before every checkin to ensure that a selected changeset is OK to commit. For example, a policy may verify that a valid comment is specified for a changeset, or that required work items are associated with it, or that file names that it includes match corporate naming standatds, etc.

IntelliJ IDEA allows you to implement custom policies in the form of plugins and configure them on a server.

This functionality is available in both IntelliJ IDEA 8 and Maia. For more information refer to this Confluence page.

Groovy-related Configuration Changes

Tuesday, September 8th, 2009

The next Maia EAP brings you massive changes in Groovy, Grails, Griffon, Gant & Gradle support, mostly affecting framework configuration.

First, Grails/Griffon application options are available when you create a project or a module:

You may also choose to import an application from existing sources:

Earlier, you needed Gant & Gradle in module dependencies to run build scripts — quite awkward, because the way you are building your project should not affect its classpath. Now, we have per-project settings for Gant & Gradle:

Also, you can now write Groovy code and get full coding assistance with compilation as long as you have Groovy jars anywhere in a module classpath. Together with the new compiler Resource patterns path constraints feature (/ - path separator; /**/ - any number of directories) this made Groovy facet obsolete. So, there is no Groovy facet anymore.

You can still add any Gr8 libraries to a module via Add Framework Support context action:

Everything you’ve just read about will be available in the next EAP.

Maven Properties and Filters Support in Maia

Monday, September 7th, 2009

Next Maia EAP comes with full support of Maven Properties and Filtered Resources. New features include:

Go to declaration with Ctrl+B on a property from your pom.xml files, settings.xml and profiles.xml files, system and environment properties, and properties defined in custom Maven filters.

Find Usages

Rename properties defined in the section of you Maven project and custom filters files.

Android Logcat Support in Maia

Friday, September 4th, 2009

In Maia you can find a new Android Logcat window that lets you see all log messages and exceptions when you are debugging an Android application.

The Logging level list allows you to select what messages are displayed in console:

  • Verbose — lowest priority, all messages
  • Debug
  • Info
  • Warning
  • Error
  • Fatal
  • Assert — highest priority, assertions only.

Logcat supports stack trace navigation and messages highlighting (you can customize colors for various log levels in the IDE Settings dialog (Ctrl+Alt+S). Note that Logcat is available only in debug mode.

Android Resource Management Features

Friday, September 4th, 2009

Maia provides a number of smart features to make working with Android resources simpler.

  • Convenient navigation from XML resource descriptors to appropriate Java fields in an R.java class…

    … and from Java code to resource files.

  • Usage search for resources. That is, when you are searching for usages of res/drawable/android.png resource file you will find both XML (@drawable/android) and Java references (R.drawable.android). By the way, searching for usages of R.drawable.android Java field yields the same results.

    Note that you can find usages of value resources (represented by XML tags) by pressing Shift+F6 when caret is positioned just before a tag:

  • Rename refactoring. When you rename a resource file (i.e. res/drawable/android.png), all XML and Java references are updated automatically. Renaming of R.drawable.android Java field, as you may have guessed, has the same effect. Note that now renaming of a resource represented by an XML descriptor is possible only through renaming an appropriate Java field.

Listeners and Adapters

Thursday, September 3rd, 2009

Occasionally implementing a Listener leads to an explosion of ugly empty boiler-plate methods. In such cases it is usually better to extend a matching adapter class and only override the needed methods.

The next IntelliJ IDEA Maia EAP build will make switching between implementing a Listener or extending an Adapter easier — with newly added Listener implementation could be replaced with Adapter extension inspection (also announced on Twitter).

This new inspection quickly highlights any implementations of Listeners which contain empty methods and offers to replace them with an extension of the relevant Adapter class.

A quick Alt+Enter, Enter replaces the verbose listener code by a more compact use of an Adapter. If you ever need to return to an implementation of a Listener, there is a new complementary intention to make this journey back quick and painless — Replace Adapter Extension with Listener implementation.