NetBeans IDE 7.3: Find Usages Filter

You're happily coding along and suddenly think to yourself: "Hmmm. I wonder where the 'pos' variable in my class is used throughout my application?" So you right-click your "pos" variable and choose "Find Usages":

Now, as always, you see the dialog below where you can set the scope of the search and whether comments should be included:

Then you click Find and get a massive amount of data back, in this case, 274 occurrences where the "pos" variable is used: 

That's a lot of data you got back. For the first time, in 7.3, you now have the second column of buttons on the left of the Usages window. This column is the "Find Usages Filter" and has six buttons, as shown below.

From top to bottom, the buttons above have the following tooltips:

  • Read filter
  • Write filter
  • Read/Write filter
  • Import filter
  • Comment filter
  • Test filter

From the data returned to the Usages window, you can remove all comments, for example, where "pos" was found, or all test classes, so that you're left with exactly the data you're interested in. Most useful is to use the "Write filter". Now everything is filtered out of the Usages window, except for the places in the code where the selected variable has write access:

Compare the above to what you get back when you use the "Read filter" instead, showing where the variable has read access:

And what does the "Read/Write filter" do? It will find occurrences where the variable has both read and write access, e.g., "pos += 3".

Thanks to Ralph for help in understanding this one. 



Posted by guest on January 18, 2013 at 07:37 PM PST #

Great, I love this feature!

Posted by Muhammad Ghazali on January 29, 2013 at 05:57 PM PST #

What about removing some nodes from filtering results? This could help to leave only interesting data that could be compared and create list. The customized elements would remind todo list of elements that the user is working with.

Posted by guest on January 30, 2013 at 01:41 PM PST #

A wonderful feature. I was just about to request it when I googled first to see if someone else reported it before me and found this post. But it seems more obvious for me if the filter was appearing in the Find Usages dialog.

Posted by Mina on May 22, 2013 at 12:17 PM PDT #

Hmmm... interesting feature. I don't have those filters in my IDE (also 7.3). Is there a way to enable these filters?

Also, I find the tool "Find Usages" works much faster than just clicking on the project itself and searching for the function name. Does "Find Usages" search the entire project or just uses a different algorithm which makes it so much faster?


Posted by guest on January 21, 2015 at 08:02 AM PST #

For a start, start using the latest version of NetBeans, i.e., NetBeans IDE 8.0.2. If you're still struggling with this after that, drop me a mail (geertjan dot wielenga at oracle dot com) and I'll help.

Posted by Geertjan on January 23, 2015 at 11:38 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

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.


« July 2016