X

Geertjan's Blog

  • August 26, 2013

Fixing Similar Code All In One Go Throughout All Applications

Geertjan Wielenga
Product Manager

Recently I was showing someone how NetBeans IDE lets you fix missing @Override annotations:

Then the someone said: "Well, now that I have fixed this particular missing @Override annotation, it would be cool if I could immediately tell NetBeans to find all other instances of missing @Override annotations, throughout my application."

And, as luck would have it, all you need to do is click the right arrow key (as can be seen by the arrow in the hint above) and you'll see it expand to the following:

If you select the third or fourth items above, a dialog will open where you can set the scope (by default, the current file, but it could be all open projects, the current project, or the current package) for searching for instances of missing @Override annotations. In the third case, the missing @Override annotations will be found and listed, while in the fourth case you'll also be able to fix all those missing annotations simply by clicking a button and then everywhere within the selected scope the missing @Override annotation will be added: 

Pretty cool, since it makes sense that you'd want to find all other instances of the same problem once your attention has been caught by one of them.

Interested to know more generally what you, humble reader of this blog, think about the support for Java hints in NetBeans IDE? What do you like about it/them? (What's your favorite Java hint and why?) What could be improved? What's missing? 

Join the discussion

Comments ( 1 )
  • Michael Bishop Monday, August 26, 2013

    I think they're good. Back in the 4.X and 5.X NetBeans releases, people would always cite refactoring and hints when choosing Eclipse over NetBeans. Over the past few revisions, the hints just keep getting better and better.

    I like the ones that catch cases that are less obvious:

    object.doSomething();

    if (object == null) { // Flagged because an NPE would've already been thrown above.

    }

    I find myself using them more and more and thus my code gets better and better!


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.