Friday Jan 18, 2013

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. 


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.


« January 2013 »