Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » What is an efficient way of finding the classes in a project using Eclipse's JDT?
icon5.gif  What is an efficient way of finding the classes in a project using Eclipse's JDT? [message #706072] Sat, 30 July 2011 20:39 Go to next message
kcassell2001 is currently offline kcassell2001
Messages: 18
Registered: May 2010
Junior Member
Eclipse's SearchEngine class has many methods for searching, including various flavors of search, searchAllTypeNames, etc. searchAllTypeNames seems to be oriented around finding the classes in a package. What is a good strategy for finding the user-defined classes in a project?


  1. Use search with a custom IJavaSearchResultCollector.
  2. Obtain all of the packages in the project (using search?), then iterate through the packages, collecting the classes using searchAllTypeNames.
  3. Traverse the AST manually.
  4. Something else.


Note, I don't really need the "most efficient" way of collecting methods. I prefer something that is easy-to-code and reasonably efficient to something that requires large amounts of code to be more efficient.

I welcome any related, general guidance on using the SearchEngine methods. I find the many options baffling.
Re: What is an efficient way of finding the classes in a project using Eclipse's JDT? [message #706953 is a reply to message #706072] Mon, 01 August 2011 04:06 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam Kandula
Messages: 444
Registered: July 2009
Senior Member
searchAllTypeNames() does find all classes that match the given pattern. The package name doesn't need to be specified and this is supposed to be the easiest and the most efficient one.
Re: What is an efficient way of finding the classes in a project using Eclipse's JDT? [message #707965 is a reply to message #706953] Tue, 02 August 2011 09:21 Go to previous messageGo to next message
kcassell2001 is currently offline kcassell2001
Messages: 18
Registered: May 2010
Junior Member
Unfortunately, if you provide a null package argument, you get all top level classes, not just the ones defined in the project you care about. Therefore, you need some additional filtering, I think.
Re: What is an efficient way of finding the classes in a project using Eclipse's JDT? [message #708138 is a reply to message #707965] Tue, 02 August 2011 13:58 Go to previous message
Satyam Kandula is currently offline Satyam Kandula
Messages: 444
Registered: July 2009
Senior Member
There is one another flavor of searchAllTypeNames() which takes an argument to match the package name pattern. Use SearchPattern#R_PREFIX_MATCH there.
Previous Topic:Java 6 method not being recognised
Next Topic:Eclipse (with JSF) code assistance (auto code hinting) problem
Goto Forum:
  


Current Time: Thu Oct 23 15:23:03 GMT 2014

Powered by FUDForum. Page generated in 0.02139 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software