Posts Tagged ‘Code Completion’

Complete static methods and fields with the new IntelliJ IDEA 12 EAP build 122.29

Thursday, August 9th, 2012

Did you know how to quickly complete a static method call or a constant reference without writing the class name first? Just type some prefix and invoke Basic Code Completion (Ctrl+Space) twice (or Ctrl+Alt+Space once):

There are two problems though:

  1. The entire project is searched and there might be just plain too many completely unrelated suggestions, and it’s hard to search among them what you need.
  2. You may not remember the name of the member you want while knowing what it type should be.
Now we have a solution for these problems. It’s the plain old second SmartType Completion (Ctrl+Shift+Space). It now also scans the entire project for static methods and fields, but suggests only those whose type is suitable in the context:
This may be very handy with collection libraries like Guava:
You can try this in the new EAP: build 122.29. Of course, it contains other improvements as well: code completion has become faster in Java, Groovy extensions are now recognized in more cases, Extract Style refactoring for Android, etc. Simply download the build or “Check for updates” in the IDE itself.

Better Code Completion in IntelliJ IDEA 12 Leda

Wednesday, July 11th, 2012

As you know code completion in IntelliJ IDEA constantly evolves. Here’s a few new features coming in IntelliJ IDEA 12:

  • Middle matching
  • Class Name Completion in Basic Completion
  • Completion statistics in Productivity Guide
  • Other minor improvements

(more…)

Smarter JavaScript completion in IntelliJ IDEA 11.1

Wednesday, April 4th, 2012

This is a cross-post from WebStorm & PhpStorm blog, originally posted by Konstantin Ulitin.

We are getting a lot of reports and ideas from you about the ordering of JavaScript completion options. So in IntelliJ IDEA we made small but important improvements. More relevant suggestions now appear at the top of the list in many cases.
(more…)

Groovy support improvements in IntelliJ IDEA 11.1

Tuesday, April 3rd, 2012

Here I would like to tell you about some of the Groovy language support improvements available in IntelliJ IDEA 11.1.

Unused Symbol Highlighting

If a class, method or property is unused even if it is in fact public, you may notice it immediately with new unused symbol highlighting feature.

(more…)

Want more from IntelliJ IDEA? Press the same shortcut again!

Wednesday, February 22nd, 2012

Sometimes you invoke an action and you don’t get what you wanted immediately. In such cases it may help to invoke the action again by pressing the same shortcut. In basic code completion (Ctrl+Space) this will list non-imported classes:

It works in similar way for smart-type and class name completions:

In File Structure popup (Ctrl+F12) you will show inherited members with it:

When introducing a variable (Ctrl+Alt+V), you may want to reassign an existing one instead:

I may have missed something, but all this is already available in IntelliJ IDEA 11. And there’s a couple more nice things you can try in IntelliJ IDEA 11.1 EAP. First, all Goto actions (Ctrl+N for classes, Ctrl+Shift+N for files etc.) now expand their search scope after you press their shortcut again. For example, Goto Action (Ctrl+Shift+A) suggests to search in non-menu actions:

Finally, Show Usages action (normally Ctrl+Alt+F7, remapped to Meta+Alt+F7 by me) will expand the search scope as well:

Try it and tell us how you like it.

Chained expression completion in IntelliJ IDEA 11.1

Monday, February 20th, 2012

If you use completion autopopup in IntelliJ IDEA 11, you may have seen “n variants…” suggestions:

This means there are two StringUtil classes available, neither of them is imported, and IDE can’t choose which of them to put to the first place. When you choose such variant no new import statements will be added. The good side is that you won’t get wrong imports after pressing space, dot or a bracket. The bad side is that you eventually have to face this choice: you may either explicitly invoke completion (Ctrl+Space) again or choose the correct qualified name from the auto-import hint which appears after choosing the item.

Here’s a good news though, now (since IntelliJ IDEA 11.1) you don’t ever have to choose the qualified name. In this particular case, you just type a dot, no import is inserted as before, but the next completion autopopup will list all the possible static members from both possible StringUtil classes:

Needless to say, after you choose the method you want all the necessary imports will be added.

In fact, this feature is even more powerful. It tries to enumerate all the completion variants matching the non-existent qualifier and suggest chained calls based on this. So you may spare some typing even if you don’t use autopopup (or have hit dot too early before it appeared):

Ah, yes, this works in Java and Groovy code.

Spring 3.1 c-namespace in IntelliJ IDEA 10.5 EAP build 106.561

Friday, April 22nd, 2011

Spring 3.1 “c-namespace” facility is now supported in IntelliJ IDEA 10.5 with code completion, error highlighting, quick fixes and code generation.

Grab the fresh IntelliJ IDEA 10.5 EAP build 106.561, check the release notes and send us your feedback.

Happy Easter Holidays!

Shiftless code completion and navigation in IntelliJ IDEA 10.5

Friday, April 15th, 2011

With IntelliJ IDEA 10.5, you may press up to twice as less keys every day as you do now. Seriously! Here’s how.

The reason IDEs exist in the first place is that they make your life easier. In particular, they are able to generate code for you. An ideal IDE would do all the boring typing by itself, leaving you more time for thinking about the great software engineering problems you face. Unfortunately, such an ideal is not there yet. Currently, if you want an IDE to help you, you first have to help it help you. Usually this means giving it some cues on a word you have in mind, and it then tries to guess the whole word. So you can just type  NPE and smart IntelliJ IDEA will suggest that you must have meant NullPointerException. Or StBui for StringBuilder. I’m sure you get the idea. This handy “camel case” matching feature saves quite a lot of typing.

Here it gets complicated. In the first place, you had to so something (coding) and the IDE was there to help you. Now you have to do something easier, namely giving the cues to the IDE. But since this requires some action from you, why couldn’t IDE help you with this as well? This means helping you help the IDE help you :). But how can such a simple task as giving the cues be made even simpler?

As it’s easy to see from the examples, the “camel case” matching requires you to enter LOTS of capital letters. And this means pressing Shift quite often. Very often. In fact, almost always. But is this really needed? Following our colleagues from ReSharper team, we asked ourselves this question and, like they, have found no adequate reason. After that we just removed this requirement to press Shift in IntelliJ IDEA. Well, you can still do it, and the capital letters will match “camel hump” starts as they did before. But why bother if you can get the same result without Shift? OK, chances are that you’ll see a bit more variants in this case, but this still pays off in the productivity.

Shiftless matching is now everywhere in IntelliJ IDEA.

When searching for a class (Ctrl+N / Cmd+N):

When typing in the editor with the autopopup enabled:

In the File Structure popup (Ctrl+F12 / Cmd+F12):

So, grab an IntelliJ IDEA 10.5 EAP build, rest to your little fingers and enjoy!

Faster XML coding with new completion features

Wednesday, October 27th, 2010

How often do you write XML configurations like that above? How many keystrokes does it take?

This one is written in just moments, with the help of the new completion features coming in IntelliJ IDEA 10. First of all, the IDE completes all required subtags for you, even nested ones. Second, you can use smart completion feature to ensure that the tags you write are in order described in your XML schema.

If you do not know where your new tag should be inserted, invoke the Generate / XML Tag action from context menu, choose the tag you want, and IntelliJ IDEA will generate a completely valid XML structure and insert it in the right place of the document.

Download the latest IntelliJ IDEA EAP build and try this in the next XML file you open.

Grails: completion of controller and action names

Wednesday, September 15th, 2010

We have added more Grails-specific completion in IntelliJ Idea X. In particular, IntelliJ IDEA now knows about action and controller names in most places where they can appear.

In the ‘controller’ and ‘action’ attributes of some GSP tags:

In some method calls (e.g. redirect(…), render(…), chain(…)):

In the URL mappings configuration:

Needless to say, find usages and rename work for such references as well.