Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Class.getMethods with JDT
Class.getMethods with JDT [message #556653] Thu, 02 September 2010 08:36 Go to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Hi all,

I am trying to get the JDT-equivalent method to Class.getMethods(). The IType.getMethodes() only returns the declared methods. How can I get the list of all public methods?
I think this is already implemented somewhere for the completion. I've searched into IType and SearchEngine, but could not find anything helpful.

Thanks in advance
--
Mickael Istria -- BonitaSoft S.A.
http://www.bonitasoft.com/products/BPM_download.php
Re: Class.getMethods with JDT [message #556909 is a reply to message #556653] Fri, 03 September 2010 06:48 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
They are two ways to get all the methods.
1. Get the super classes and get all their methods too. To get all the types of the super classes
ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
IType[] types = hierarchy.getAllSuperclasses(type);


2. Get all the method declarations using search from an hierarchy scope
IJavaSearchScope  scope = SearchEngine.createHierarchyScope(type);
SearchPattern pattern = SearchPattern.createPattern(
			*,
			IJavaSearchConstants.METHOD,
			IJavaSearchConstants.DECLARATIONS,
			SearchPattern.R_PATTERN_MATCH);
new SearchEngine().search(
			pattern,
			new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
			scope,
			requestor,
			null);
		
Re: Class.getMethods with JDT [message #556921 is a reply to message #556909] Fri, 03 September 2010 08:08 Go to previous message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Hi,

I used the SearchPattern you gave me, and it works like a charm.

Thank you!
--
Mickael Istria -- BonitaSoft S.A.
http://www.bonitasoft.com/products/BPM_download.php
Previous Topic:JavaBuilder rebuilds entire project when modifying one class
Next Topic:My Junit plug-in tests do not run when launched against a Product
Goto Forum:
  


Current Time: Fri Apr 26 00:01:14 GMT 2024

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

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

Back to the top