New Code Completion and Suggestions

Guest Author

Are you curious about the newest NetBeans editor improvements? Two hot topics are redesigned code completion and suggestions. I got a permission from the developers to post steps how to build NetBeans with these - so you can try them out! Checkout and build takes some time and effort, so be prepared for it. You have been warned.

1. Checkout CVS sources - CVSROOT=:pserver:anoncvs@cvs.netbeans.org:/cvs (more info here):
  • cvs checkout -P stable_nowww
  • cvs checkout -P -r completion editor/completion java/editor
  • cvs checkout -P -f -r completion nbbuild_nowww

The size of downloaded files is around 430 MB. No, we won't help you with paying your Internet connection bill.

2. Build NetBeans with ant using following command in nbbuild subdirectory (more info here):
  • ant build-nozip all-editor/errorstripe all-editor/errorstripe/annotations all-java/errorstripe all-tasklist/errorstripe all-editor/hints all-java/hints

That's it, once the IDE is built, you can czech the new features out. In case you have troubles with building, write me a comment and I'll help you.

Warning: these features are under development and the IDE built with them should not be used in production environment. Their functionality may change and no quality is guaranteed. There are several known bugs and the UI will be changed, too. Take them just as preview of new functionality.

New Code Completion:

Improved, faster, sexier.

  • The new Code Completion is faster. An existing Code Completion result list is simply narrowed down when typing additional characters instead of computing new result lists repeatedly.
  • The new Code Completion has modified layout of the result list items. An information being completed is at the beginning of an item's text (i.e. simple name followed by a package name in parentheses is displayed for classes, simple name followed by a type name is displayed for class members). Type names are aligned to the right side of the completion window.
  • The new Code Completion introduces a tooltip popup for displaying method parameters. Code Completion for methods changed its behavior. It uses tooltip popup to show method parameters instead of their incremental completion. The tooltip popup with method parameters can be invoked on demand using Alt-Space.
  • The new Code Completion popup size is not limited by the parent text component size.
  • The new Code Completion allows users to \*press
    ;', and 
    ,' next to Enter to complete the text and close the popup.
  • The new Code Completion supports anonymous inner classes. Try to invoke code completion after writing new Runn|, the text new Runnable() { public void run() {} } is completed. Use Ctrl+Enter to complete text without a body skeleton.
  • The new Code Completion supports overriding/implementing methods generation. Try to invoke code completion in a class body between members. Items to create skeletons of all methods that can be overridden/implemented are returned.
  • The new Code Completion supports getters/setters generation. Try to invoke code completion in a class body between members. Items to create getter and setter method stubs are returned.
  • The Code Completion support for Javadoc and keywords is being prepared.
  • The new Code Completion makes the Javadoc popup hidden by default. It can be invoked on demand using Ctrl+Shift+Space.

Suggestions (aka Editor Hints):

A lightbulb for Java editor, which provides several hints. When a light bulb appears, press Alt-Enter to get the list of possible hints. Most hints are available on lines with error annotations.

Better than your paperclip!

Currently, there are following hints available:
  • Add import
  • Implement all abstract methods. Works for both "normal" classes and annonymous inner classes
  • Add throws clause to the method header
  • Create method/field
  • Add cast (for example: List l; String s = l.get(0);)
  • Encapsulate field: works on non-private fields

Why am I posting this? We want to know your feedback. If you take your time to download and build NetBeans from CVS, please spare a minute or two and let us know what you think about the improvements.

Join the discussion

Comments ( 14 )
  • Dmitri Trembovetski! Wednesday, April 13, 2005
    This is awesome! I'll see if I have time to compile and try these cool features out!



    Java2D Team
  • Roman Strobl Wednesday, April 13, 2005
    You can do it on background... download takes time, but building is done in 10 minutes or so.
  • pprun Thursday, April 14, 2005
    It's great!

    According to the above steps, it builds SUCCESSFUL.

    I'm trying it:

    I think the developer would like to add an alternative to 'Add throws clause to the method header': Surrounding with 'try/catch'!


  • Roman Strobl Thursday, April 14, 2005
    Yes, I also think we seriously need to support surround with try/catch.
  • Navneet Karnani Thursday, April 14, 2005
    Can the developers make these available on the Update Center (Alpha/Beta) for non-humans like me who cannot download 480MB and then build it ?
    It will be highly appreciated.
  • Roman Strobl Friday, April 15, 2005
    Just chatted with my colleague who develops suggestions and it makes sense to put suggestions on update center. But they need to be stabilized first. I'll let you know.
  • Petr Zajac Friday, April 15, 2005
    It is not necessary to checkout all sources from netbeans cvs. You can use the 3rd version of the starter kit for creating modules on the netbeans 4.x platform. The kit was developed by richunger and it can be downloaded from http://contrib.netbeans.org/servlets/ProjectDocumentList
  • jtr Wednesday, May 18, 2005
    Great! How about editor templates?
    for (Iterator [i] = [col.iterator]; [i].hasNext();) {
    [Type] obj = [Type] [i].next();
  • Roman Strobl Wednesday, May 18, 2005
    Work on progress - stay tuned for 4.2.
  • Navneet Karnani Thursday, May 19, 2005
    I checked the May 17th build and the hints are still not in it. When will we get it ? I am eager !!!
  • Roman Strobl Thursday, May 19, 2005
    Please be patient, it will take time. Every such feature needs to go through API review and some other processes which ensure its quality. I'll definitely blog about it when it will go to the trunk.
  • guest Sunday, July 31, 2005
    [Trackback] In your free time, check out some relevant information about
  • guest Tuesday, August 2, 2005
    [Trackback] You are invited to check the pages on
  • guest Wednesday, August 3, 2005
    [Trackback] Take your time to check out some relevant pages on
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.