Beefed Up Code Completion in NetBeans IDE 7.4

When I call up code completion in all versions of NetBeans IDE, the Java Editor gives typed suggestions for completing the current statement:

This is called code completion. No surprises there.

However, if I invoke code completion a second time (i.e., press Ctrl-Space twice), a deeper level of suggestions is returned in NetBeans IDE 7.3.1, as well as in recent releases before that:

However, in NetBeans IDE 7.4, instead of the above, the code completion includes suggestions applicable to attributes from the current scope of variables, in the form of parameters for methods:

This is also known as "chained completion". In other words, when in NetBeans IDE 7.4 you invoke code completion a second time, the Java Editor will scan variables, fields and methods, which are visible from the context, and then suggest a chain that conforms to the relevant type.

More info about this can be found here:

https://netbeans.org/bugzilla/show_bug.cgi?id=218604

https://netbeans.org/bugzilla/show_bug.cgi?id=229560

Next, another excellent enhancement, this time by external contributor Benno Markiewicz. In 7.3.1, I try to use code completion here, because I'm interested to see whether any methods relating to property listening can be attached to my object:

No luck, as you can see. In 7.4, however, there's a new checkbox in the Options window, disabled by default because the underlying functionality is potentially slower and you'll get more results so is potentially confusing, so that explicit enablement means you know what you're getting yourself into, named "Subword completion", as you can see below:

And now, I get some very interesting and, more importantly, useful results, applicable to properties on my object:

More info about subword completion can be found here: https://netbeans.org/bugzilla/show_bug.cgi?id=212412

Comments:

@Geertjan: Thanks for the kudos and thanks also to Dusan Balek (who fixed some issue regarding this new feature). Subword completion is inspired by Intellij IDEA and the "code recommenders" plugin for Eclipse. The regex for the matching was taken from one of the blogs linked within the issue.

Posted by markiewb on August 28, 2013 at 03:48 PM PDT #

Excellent news. I found subword completion very helpful in Visual Studio, great to see it coming to NetBeans.

Posted by Chris Nahr on August 29, 2013 at 02:31 AM PDT #

Welcome to the 21st century, NetBeans.

Posted by O RLY on October 21, 2013 at 05:23 AM PDT #

Unfortunately this version/fix lost the ability to suggest variable names for types which aren't imported and the ability to autoformat javadocs by inserting tabs and stars, both of which were more valuable to me.

Posted by guest on January 15, 2014 at 10:04 PM PST #

Not really sure what you're talking about, guest, would appreciate it if you'd drop me an e-mail at geertjan.wielenga@oracle.com so we can find out what it is you mean, because NetBeans doesn't just 'lose' features, sounds like bugs to me.

Posted by Geertjan on January 15, 2014 at 10:57 PM PST #

I really like the subword completion feature. Sometimes I just remember one part of a method but not necessarely the first, so subword completion saves me some time there.
However, it still has some problems. The biggest one is that it doesn't prefer exactly matching suggestions and just seems to sort the suggestions alphabetically. I put an example for that in this bug entry:
https://netbeans.org/bugzilla/show_bug.cgi?id=241749
As in most cases you know the exact method name, this behavior can be again time consuming (as you always have to select out of the list) and makes me turn subword completion off again.

Posted by Daniel Brüggemann on March 20, 2014 at 02:38 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today