Enhanced find usages support in NetBeans >= 7.1

Posted byChristian Moser Posted on28. March 2012 Comments1

In my opinion, Netbeans is one of the most intuitive Java IDE today, especially when it comes to maven development. There was just one missing feature I was always upset about. The IDE was not indexing classes and their dependencies in the local maven repository. So it was not possible to find referenced classes contained in maven projects that weren’t opened  in the IDE. This is quiet annoying if you need to gain an overview of the code, or you have to track down one specific misbehavior especially if you work with hundreds of maven projects.

So, together with Netbeans contributors (mainly Jesse Glick), we’ve worked out a solution for the problem.

The class dependencies were found by bytecode parsing and then indexed with Lucene for very fast search results. All classes from the JDK are excluded to reduce the overhead.

Find Usages in action

In the following example, I selected the class “org.apache.maven.artifact.ArtifactUtils” and searched with “Find Usages” for all referring classes. The class is used as an import in one of the classes in the only loaded maven project  “Maven Release Plugin”.

This gave me the following output:

Under the node “Maven Repository: local” are all hits listed found in the local maven repository. This enables the developer to quickly scan all interesting artifacts without the need to open any maven project in Netbeans.

For now, only the class name is highlighted and linked to the corresponding class located in the maven artifact. I plan to implemented the same behavior as seen as in the search results for already opened projects, in this case “Maven Release Plugin” which features enhanced line highlighting and more precisely jumps to the source code.

Conclusion

It took my some time to get used to a small part of the massive code base of Netbeans and it’s API’s but it felt good to give something back to the community.

Last but not least, I was able to improve my knowledge in programming across the board which was a lot of fun!  😎

 

Category