Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Replies: 1 - Pages: 1  
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

IntelliJ IDEA: Smart completion

At 8:28 AM on Apr 14, 2006, Alexandra Rusina wrote:

Smart completion is not just another name for a completion in IntelliJ IDEA , but a separate feature. Some 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.
1 . At 1:24 PM on Apr 14, 2006, Romain Guy DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: IntelliJ IDEA: Smart completion

This feature works in many other cases. This is why I love it/hate it, because I never really know when it will do something really cool :) For instance, if you type new IAE and Ctrl+Shift+Space, you get new IllegalArgumentException(); whereas normal code completion gives the choice. I also like it when you write the following:

List aList = ...;
// ...
aList.toArray(new

Then Ctrl+Shift+Space and you get aList.toArray(new AnObject[|]); (with | being the caret.)
Romain Guy
Romain Guy's Java Weblog, #ProgX, Jext

thread.rss_message