Archive for June, 2006

TestNG plugin

Wednesday, June 28th, 2006

IntelliJ IDEA provides JUnit integration out of the box, but it does not mean that you cannot use other test frameworks. TestNG-J is a plugin that provides integration with the TestNG framework in a very similar way to the native IntelliJ IDEA integration with JUnit.
TestNG-J adds its own type of run/debug configuration that allows for running tests. It also displays testing results and highlights failed and passed tests. To learn more about plugin features and configuration, take a look at the plugin overivew.
The plugin is free and can be downloaded and installed using IntelliJ IDEA Plugin Manager. The plugin is available for both IntelliJ IDEA 5.x and EAP versions of IntelliJ IDEA 6.0.

Technorati tags: , , , ,

XML productivity tips

Monday, June 26th, 2006

IntelliJ IDEA is not “only Java” IDE. If you have a license, you don’t need a separate XML editor (as well as HTML/CSS or JavaScript ones). These editors come with IntelliJ IDEA “out-of-the-box”.

Here is a couple of links that may help you with being more productive with XML editing:



One more useful tip is that IntelliJ IDEA completes XML documents even if no schema is specified. All tag and attribute names and values are completed based on what you are typing. IntelliJ IDEA tracks your input and suggests new tag names and attributes for already used tags. It also filters out attributes that have already been specified for a tag, so you don’t have to worry about duplicates.

For example, you typed a tag like this:

<shopitem pricestandard=”200″ pricediscount=”180″ pricevip=”150″ group=”1″ qty=”1000″ id=”188839″/>



When you are about to create another shopitem tag and start typing “price” attributes, you will get the completion:



Start typing another attribute, and IntelliJ IDEA will help you avoid duplicates by removing what you already typed from completion list.



Edit XML with pleasure!

Technorati tags: , , ,

IntelliJ IDEA 6.0: GWT support

Friday, June 23rd, 2006

IntelliJ IDEA always strives for innovations. So, the innovative Google Web Toolkit is supported in forthcoming IntelliJ IDEA 6.0 release. Moreover, you can try it right now - the latest EAP version of IntelliJ IDEA comes bundled with GWT Studio plugin and provides general functionality. See the GWT demo to get the first impression and read the roadmap to see what’s coming next.

By the way, GWT Studio has quite an interesting story. The plugin was originally written by JetBrains marketing director, Alex Tkachman. Yes, we really eat our own dog food and even our marketing staff believes that IntelliJ IDEA is a great tool and tries to make it better in all possible ways.

Technorati tags: , , ,

“Go to Class by Name” tricks

Thursday, June 22nd, 2006

Two nice tricks for navigating to a class by name (Ctrl + N). Find out how to quickly find a class that ends with particular symbols.

Of course, these tricks can be used for other navigation features as well, for example when you navigate to a file (Ctrl + Shift + N) or symbol, i.e. method or variable (Ctrl + Alt + Shift + N).

Technorati tags: , ,

Something more about completion

Wednesday, June 21st, 2006

Along with basic code completion already described on this blog, IntelliJ IDEA provides so-called “smart completion” that can be considered as a separate feature. Sometimes users call it “super” or even “secret” completion. “Super” is because this feature is far more intelligent than simple completion. “Secret” comes from the fact that this completion is invoked not by the usual Ctrl + Space shortcut, but by Ctrl + Shift + Space.

Why have two different completions? Well, how often have you found yourself saying “This thing thinks that it’s smarter than me!” and try to make the product do what you want it to do? IntelliJ IDEA doesn’t want to be smarter than you are. But its intelligence is always at your disposal when you need it.

So, what is so special about smart completion? First of all, it filters the list of suggestions according to the expected expression type.

For example, it can suggest values at right-hand side of assignments, in the return statements, in method calls, and anywhere you need to.



In obvious cases where you don’t need to see a list of choices, smart completion will simply add the necessary value. For example, use Ctrl + Shift + Space after new when you create an instance of a class.



IntelliJ IDEA adds the constructor, brackets, and the semicolon. It also positions the caret right within the brackets. And all you need to do is press Ctrl + Shift + Space again to see the list of possible parameter values.



In case of abstract classes and interfaces, you can choose one of the inheritors.



Another example when you don’t need a list of choices is type casting. For example, you have typed something like str = (, where str is some variable of String type. To cast the right-hand side of assignment to String, just press Ctrl + Shift + Space. The result, of course, will be str = (String).

But, probably, the most impressive use case for the Smart completion is when you create an anonymous implementation of some interface. For example, you had the following code:



When you press Ctrl + Shift + Space and select the MouseListener interface, you get the following result:



Just think about the time the smart completion saves.

Note   This tip&trick was originally posted at www.javalobby.org.


Technorati tags: , ,

Numbered Bookmarks

Monday, June 19th, 2006

On top of anonymous bookmarks (F11 to toggle between activate/deactivate, Shift-F11 to manage), IntelliJ IDEA provides so called numbered bookmarks. What this mean is that on any line of any file managed by IntelliJ IDEA (Java, HTML, XML, JDK source files, etc.), you can define a bookmark that is identified by a number between 0 and 9. Simply put the caret on the desired line and press Ctrl-Shift-<Number> to toggle between activate/deactivate the numbered bookmark. You can then jump to such a numbered bookmark from anywhere within IntelliJ IDEA by triggering Ctrl-<Number>.

For example, place the caret at a point of interest in a Java method and press Ctrl-Shift-1. The gutter to the left will then show a tag labeled with the number 1. You can now jump to this bookmark from anywhere within IntelliJ IDEA by pressing Ctrl-1.



Personally, I find numbered boomarks very handy when working on a specific task where I have to jump back and forth between certain code locations repeatedly. It takes one keystroke to create the numbered bookmark and it takes one keystroke to jump to such a numbered bookmark. It couldn’t be any more efficient.

Technorati tags: , ,

IntelliJ IDEA 5.1.2 Released!

Friday, June 16th, 2006

JetBrains is glad to announce the release of IntelliJ IDEA 5.1.2
This release fixes several stability issues and bugs. See the complete list for more detailed information.
Release is free for licensed users of IntelliJ IDEA 5.x and available for download at http://www.jetbrains.com/idea/download/

The AJAX Experience & JavaOne 2006 Report

Thursday, June 15th, 2006

For those who missed our presentations at The AJAX Experience and JavaOne 2006 Conferences, we have published a short report on the JetBrains web site. There you can view some photos, check the Google video recordings of both presentations, as well as download a PDF copy of the AJAX with Pleasure brochure that we were giving away at the show.

Parentheses Inspections & Intentions

Monday, June 12th, 2006

You know the “Unnecessary Parentheses” inspection? IntelliJ IDEA has had it for quite some time. And if you were a user of the InspectionGadgets plugin since before it was bundled with IntelliJ IDEA, you know it even longer. The inspection reports any parentheses which do not alter the default evaluation order of an expression. For example:



It’s a nice inspection, but it may be a little greedy. I write code not only for the compiler, but also to be read by me and other people. Sometimes the parentheses highlighted by the inspection do have a use other than modifying the order of evaluation: they serve to clarify the expression.
Often while reading some new or old code, I encounter complex expressions which are quite hard to understand, especially so when they don’t have any parentheses to clarify the evaluation order. Take for example the following (still quite simple) code:



The new “Add Clarifying Parentheses” intention can help understand complex expressions, by adding a few well placed parentheses. This intention is available in Demetra since build #5218. While strictly unnecessary, with parentheses understanding the expression takes a little less brainpower.



I think there should be an option in the “Unnecessary Parentheses” inspection to ignore clarifying parentheses, don’t you agree?

Technorati tags: , , ,

TabSwitch Plugin

Friday, June 9th, 2006

Of course, tabs is a good way for organizing opened files within an application. However, when you have too many opened tabs it becomes difficult to navigate between them. IntelliJ IDEA helps you to navigate between recently opened files (CTRL + E), but sometimes you need to switch only between the tabs.
The TabSwitch plugin allows you to switch between IntelliJ IDEA tabs like you switch between opened applications in Windows. With the plugin installed, just press Alt + A, and you’ll get the list of the opened tabs. The most recently used tabs come first.



As it turned out, Alt + A is not an intuitive shortcut. So, many developers changed it to Ctrl + Tab. This shortcut is used in IntelliJ IDEA for switching within splitted windows. But it is rarely used, so you can easily override it.
To change the shortcut, open Settings - > Keymap. Then select Plugins->TabSwitch, and configure its shortcuts (remember that you cannot modify the default keymap and need to create your own).



The plugin has more features and shortucts that help you with tab navigation. Here you can find the full description: http://www.intellij.org/twiki/bin/view/Main/TabSwitchPlugin

The TabSwitch is free and can be downloaded via IntelliJ IDEA Plugin Manager.

Technorati tags: , ,